Abuild and Helpers: Difference between revisions

From Alpine Linux
mNo edit summary
(added wikilink and moved category to the bottom of the page)
 
(48 intermediate revisions by 11 users not shown)
Line 1: Line 1:
The abuild script and its friends are installed automatically along with the <tt>alpine-sdk</tt> package.  
The {{pkg|abuild}} package provides scripts necessary for [[Creating an Alpine package|creating packages]] for Alpine Linux. It also implements functionality for building packages as well as additional commands and options for package maintenance. For package development and maintenance, it is recommended to install the {{pkg|alpine-sdk}} meta package, which will install the {{pkg|abuild}} package in addition to other relevant tools.{{Cmd|apk add alpine-sdk}}


{{Cmd|apk add alpine-sdk}}
The [https://gitlab.alpinelinux.org/alpine/abuild git repository] always contains the latest version of the scripts, example-files, and makefiles.


The  [http://git.alpinelinux.org/cgit/abuild.git/tree/ git repository] contains always the lastest version of the scripts, example-files, and makefiles.
== Setting up the build environment ==
{{:Include:Abuild-configure}}
== Building packages ==
=== Basic usage ===


== Package build helpers ==
If you just want to build a package from an [[APKBUILD Reference|APKBUILD]] file, only  two command are needed. Both commands operate on an APKBUILD file in the current directory, so you should <code>cd</code> into the directory before running them.


=== abuild-keygen ===
* <code>abuild checksum</code>: updates the checksums for source files.
{{:Abuild-keygen}}
* <code>abuild -r</code>: builds the package.


=== abuild-sign ===
The [https://git.alpinelinux.org/abuild/tree/abuild.1.scd manual page] (available via <code>man abuild</code>) describes all options and commands for <code>abuild</code>.
{{:Abuild-sign}}
 
=== abuild-tar ===
=== Building in a chroot ===
{{:Abuild-tar}}
{{:Include:AbuildRootBld}}
== Bumping a package version ==
 
The tool <code>abump</code> is a utility to bump pkgver in APKBUILD files if the package gets an update to a newer upstream release. <code>abump</code> will update the package's <code>pkgver</code>, rebuild it and create a new commit with the resulting changes.
 
The [https://git.alpinelinux.org/abuild/tree/abump.1.scd manual page] (available via <code>man abump</code>) describes all options for <code>abump</code>.
 
== Updating a package release ==
<!-- Shouldn't this be apkrel? None of the other packaging tools use "apkg...". Or perhaps it should be unified with abump? -->
If you want to bump or reset the pkgrel value of your APKBUILD or test your APKBUILD files, <tt>apkgrel</tt> can assist you.


=== abump ===
{{Cmd|<nowiki>apkgrel -a|-h|-s NUM|-t|-z [-f] FILE...</nowiki>}}
{{:Abump}}


=== apkgrel ===
'''apkgrel options'''
{{:Apkgrel}}


=== abuild ===
* '''-a'''  Add 1 to current pkgrel
{{:Abuild}}
* '''-f'''  Force, even if given files are not in proper format
* '''-h'''  Show this help
* '''-s'''  Set pkgrel to NUM
* '''-t'''  Only verify that files are in proper format
* '''-z'''  Set pkgrel to 0


== APKBUILD generation ==
== Generating new APKBUILDs ==


=== newapkbuild ===
=== newapkbuild ===
To create the actual APKBUILD file <tt>newapkbuild</tt> can serve you a template to start with. It will create a directory with the given package name, place an example/template APKBUILD file to the given directory, and fill some variables if those are provided.
{{:Include:Newapkbuild}}
 
{{:Newapkbuild}}


=== apkbuild-cpan ===
=== apkbuild-cpan ===
{{:Apkbuild-cpan}}
{{:Include:apkbuild-cpan}}


=== apkbuild-pypi ===
=== apkbuild-pypi ===
{{:Apkbuild-pypi}}
{{:Include:apkbuild-pypi}}


== Signing packages and indexes ==


== Misc tools ==
=== abuild-sign ===
=== buildlab ===
{{:Include:Abuild-sign}}
More details can be found at the [[Buildlab|buildlab]] page.


=== abuild-tar ===
{{:Include:Abuild-tar}}


=== buildrepo ===
=== buildrepo ===
{{:Buildrepo}}


<code>buildrepo</code> build an entire package repository.


See [https://gitlab.alpinelinux.org/alpine/lua-aports/-/blob/master/buildrepo.1.scd the man page] for a complete description.
<!-- ToDo
<!-- ToDo
=== cmp-apks-iso ===
=== cmp-apks-iso ===
Line 53: Line 68:


=== initramfs-init ===
=== initramfs-init ===
-->
== See also ==


-->
* [[How to make a cross architecture chroot]]
[[Category:Package Manager]] [[Category:Development]]

Latest revision as of 09:13, 26 February 2025

The abuild package provides scripts necessary for creating packages for Alpine Linux. It also implements functionality for building packages as well as additional commands and options for package maintenance. For package development and maintenance, it is recommended to install the alpine-sdk meta package, which will install the abuild package in addition to other relevant tools.

apk add alpine-sdk

The git repository always contains the latest version of the scripts, example-files, and makefiles.

Setting up the build environment

Abuild needs to be configured for both the system and user.

Edit the file /etc/abuild.conf as per 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.

In order to use abuild command The user executing abuild must be a member of the abuild group:

# addgroup <yourusername> abuild

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

For abuild a public/private rsa key pair is needed. The abuild-keygen command from abuild package generates and configures the security keys.

$ doas abuild-keygen -a -i

abuild-keygen options

  • -a Set PACKAGER_PRIVKEY=<generated key> in abuild.conf
  • -i Install public key into /etc/apk/keys using sudo
  • -h Show this help
  • -n Non-interactive. Use defaults
  • -q Quiet mode

Building packages

Basic usage

If you just want to build a package from an APKBUILD file, only two command are needed. Both commands operate on an APKBUILD file in the current directory, so you should cd into the directory before running them.

  • abuild checksum: updates the checksums for source files.
  • abuild -r: builds the package.

The manual page (available via man abuild) describes all options and commands for abuild.

Building in a chroot

Install package abuild-rootbld:

apk add abuild-rootbld

You may now build your packages from source in an unprivileged sandbox based on bubblewrap with the command:

abuild rootbld

rootbld assumes your APKBUILD file is in a directory structure like aports or you need to set environment variable APORTSDIR to current directory.

If the build process needs network access there has to bet set the net option in APKBUILD.

Note that using rootbld inside a docker container requires additional configuration.

Bumping a package version

The tool abump is a utility to bump pkgver in APKBUILD files if the package gets an update to a newer upstream release. abump will update the package's pkgver, rebuild it and create a new commit with the resulting changes.

The manual page (available via man abump) describes all options for abump.

Updating a package release

If you want to bump or reset the pkgrel value of your APKBUILD or test your APKBUILD files, apkgrel can assist you.

apkgrel -a|-h|-s NUM|-t|-z [-f] FILE...

apkgrel options

  • -a Add 1 to current pkgrel
  • -f Force, even if given files are not in proper format
  • -h Show this help
  • -s Set pkgrel to NUM
  • -t Only verify that files are in proper format
  • -z Set pkgrel to 0

Generating new APKBUILDs

newapkbuild

The newapkbuild tool, which is installed as part of the abuild package, can generate a new APKBUILD template to use as a starting point. The manual page (available via man newapkbuild) describes all options for newapkbuild.

If you doubt to which repository your package belongs to you can safely use testing. Building package in your aports/testing directory is not mandatory but this way the package is already at the right place.

Tip: Follow the package naming conventions mentioned in package policies while choosing a packagename.

The following command will create a directory with the given package name, place an example/template APKBUILD file in the directory, and fill some variables if those are provided.

newapkbuild packagename

If you are creating a daemon package which needs initd scripts you can add the -c option as follows:

newapkbuild -c packagename

This will copy the sample initd and confd files to the build directory. A third file sample.install file will be copied as well (we will discuss this later on).

apkbuild-cpan

The Comprehensive Perl Archive Network (CPAN) provides a large collection of perl software and documentation. apkbuild-cpan helps with the creation of APKBUILD for perl modules from CPAN.

apkbuild-cpan [create <Module::Name> | check | recreate | update | upgrade]

This command is provided by the apkbuild-cpan package.

apkbuild-pypi

The Python Package Index (PyPi) is a repository of software and libraries for the Python programming language. The apkbuild-pypi command helps with the creation of APKBUILD for python package hosted at PyPI.

apkbuild-pypi [create <package> | check | recreate | update | upgrade

This command is provided by the apkbuild-pypi package.

Signing packages and indexes

abuild-sign

abuild-sign is for signing indexes.

abuild-sign [-hq] [-k PRIVKEY] [-p PUBKEY] INDEXFILE...

abuild-sign options

  • -h Show this help
  • -k The private key to use for signing
  • -p The name of public key. apk add will look for /etc/apk/keys/PUBKEY

abuild-tar

abuild-tar [--hash[=<algorithm>]] [--cut]

abuild-tar options

  • --hash[=sha1|md5] Read tar archive from stdin, precalculate hash for regular entries and output tar archive on stdout
  • --cut Remove the end of file tar record

buildrepo

buildrepo build an entire package repository.

See the man page for a complete description.

See also