Include:Setup your system and account for building packages

From Alpine Linux
Revision as of 06:58, 14 October 2024 by Antiz (talk | contribs) (Remove outdated / debatable instructions to setup the cache dir: /var/cache/distfiles is created by the "abuild" package and it already belongs to root:abuild with a 775 mode. Ensuring it exists with `mkdir -p` is not so useful and setting `chmod a+w` permissions to it (basically turning it into 777) is, at the very least, highly debatable security wise. The second approach implies changing the group to "abuild" and giving it write permissions, which is useless as it's already the default.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The alpine-sdk is a metapackage that pulls in the most essential packages used to build new packages. Also install and configure a way to elevate privileges, such as sudo or doas, and an editor, such as vi, nano, micro.

# apk add alpine-sdk

This would be a good time to create a normal user account for you to work in. To make life easier later, it's a good idea to add this user to the wheel group; operations that require superuser privileges can now be done with sudo or doas.

The aports tree is in git so before we clone it, let's configure git.

$ git config --global user.name "Your Full Name" $ git config --global user.email "your@email.address"

Read carefully Development using git to grasp basic Git operations and how to configure for sending email patches.

Now we can clone the aports tree.

$ git clone https://gitlab.alpinelinux.org/alpine/aports

Before we start creating or modifying APKBUILD files, we need to setup abuild for our system and user. Edit the file /etc/abuild.conf to your requirements.

Most of the defaults can be left alone, unless you are developing for a custom platform, in which case the comments in the file should guide you. The one field to edit is PACKAGER, so that you can get credit (or blame) for packages you create.

To use 'abuild -r' command to install dependency packages automatically (and other 'abuild' commands that require it).

# addgroup <yourusername> abuild

Note: Remember to logout and login again for the group change to have effect.

The last step is to configure the security keys with the abuild-keygen script for abuild with the command:

# abuild-keygen -a -i

If you want to share the generated keys between multiple computers (~/.abuild), you will have to manually copy the generated public key into /etc/apk/keys for the signing process of generated packages to work, example:

# cp /home/user/.abuild/user@domain.tld-12345abc.rsa.pub /etc/apk/keys