User:Encode/XDG package building: Difference between revisions

From Alpine Linux
(Package building without polluting $HOME)
 
m (The next version of abuild will allow you to use with bubblewrap: https://gitlab.alpinelinux.org/alpine/abuild/-/commit/b2244078217c79ad690be2c14efd929d2d0adcf5)
 
Line 2: Line 2:


{{Todo|Use a dedicated user.<br>
{{Todo|Use a dedicated user.<br>
Make {{Pkg|abuild-rootbld}} work with XDG (bubblewrap).}}
<code>abuild-keygen</code> should put the key in ${XDG_DATA_HOME}/abuild.}}


{{TOC right}}
{{TOC right}}
Line 8: Line 8:
= Prerequisites =
= Prerequisites =


Install the {{Pkg|alpine-sdk}} package, which is a metapackage that
Install the {{Pkg|alpine-sdk}} and {{Pkg|abuild-rootbld}} packages; the
pulls in most essential packages:
first is a metapackage that pulls in most essential packages, the
{{Cmd|# apk add alpine-sdk}}
second is for building in a clean chroot:
{{Cmd|# apk add alpine-sdk abuild-rootbld}}


Add the package building user to the '''abuild''' group to use <code>$
Add the package building user to the '''abuild''' group to use
abuild -r</code>:
<code>$ abuild rootbld</code>:
{{Cmd|# addgroup USER abuild}}
{{Cmd|# addgroup USER abuild}}
In <code>~/.profile</code> you will need:
In <code>~/.profile</code> you will need:
{{Cat|~/.profile|<nowiki>export ABUILD_USERDIR="${XDG_CONFIG_HOME}"/abuild</nowiki>}}
{{Cat|~/.profile|...
<nowiki>export ABUILD_USERDIR="${XDG_CONFIG_HOME:=$HOME/.config}"/abuild</nowiki>
...}}
{{Note|You will need to log out/in for these to take effect.}}
{{Note|You will need to log out/in for these to take effect.}}


Line 29: Line 32:


Change where built packages go:
Change where built packages go:
{{Cat|/etc/abuild.conf|<nowiki>REPODEST=/home/USER/src/.alpine-packages/</nowiki>}}
{{Cat|/etc/abuild.conf|...
<nowiki>REPODEST="${XDG_DATA_HOME:=$HOME/.local/share}/abuild/"</nowiki>
...}}


= Fetch latest APKBUILD files =
= Fetch latest APKBUILD files =
Line 46: Line 51:


Build the package & install the [[Creating_an_Alpine_package#Testing_the_package_locally|local]] package:
Build the package & install the [[Creating_an_Alpine_package#Testing_the_package_locally|local]] package:
{{Cmd|$ abuild -r
{{Cmd|$ abuild rootbld
<nowiki># apk add -uX ~/src/.alpine-package/community/ PACKAGE</nowiki>}}
<nowiki># apk add -uX "${XDG_DATA_HOME}"/abuild/community/ PACKAGE</nowiki>}}


= See also =
= See also =

Latest revision as of 05:45, 11 January 2023

This material is work-in-progress ...

I customize some packages locally, if you plan to develop you will probably need to also do a few more things (for example: "PACKAGER" in /etc/abuild.conf).
(Last edited by Encode on 11 Jan 2023.)

Todo: Use a dedicated user.
abuild-keygen should put the key in ${XDG_DATA_HOME}/abuild.


Prerequisites

Install the alpine-sdk and abuild-rootbld packages; the first is a metapackage that pulls in most essential packages, the second is for building in a clean chroot:

# apk add alpine-sdk abuild-rootbld

Add the package building user to the abuild group to use $ abuild rootbld:

# addgroup USER abuild

In ~/.profile you will need:

Contents of ~/.profile

... export ABUILD_USERDIR="${XDG_CONFIG_HOME:=$HOME/.config}"/abuild ...
Note: You will need to log out/in for these to take effect.

Make the directory to hold sources and configure the security keys:

$ mkdir ~/src $ abuild-keygen -a -i

When it says "Enter file in which to save the key:..." you should see:

 [/home/USER/$XDG_CONFIG_HOME/abuild/....rsa]

hit Enter. Enter your pass to install into /etc/apk/keys/.

Change where built packages go:

Contents of /etc/abuild.conf

... REPODEST="${XDG_DATA_HOME:=$HOME/.local/share}/abuild/" ...

Fetch latest APKBUILD files

This will clone them into ~/src/aports:

$ cd ~/src/ $ git clone 'https://git.alpinelinux.org/aports'

Build the package

Change into the directory for the package:

$ cd ~/src/aports/REPO/PACKAGE

Edit the APKBUILD as needed and update the checksum:

$ abuild checksum

Build the package & install the local package:

$ abuild rootbld # apk add -uX "${XDG_DATA_HOME}"/abuild/community/ PACKAGE

See also