Abuild and Helpers: Difference between revisions

From Alpine Linux
(Restructure titles (remove some needless ones))
(Deduplicate wording)
Line 1: Line 1:
The abuild package provides scripts you need when creating packages for Alpine Linux. The abuild package and its friends are installed automatically along with the <tt>alpine-sdk</tt> package.
The <code>abuild</code> package provides scripts necessary for creating packages for Alpine Linux. It implements functionality for building packages as well as additional commands and options for package maintenance. The <code>abuild</code> package and related tools can be installed automatically by installing the <code>alpine-sdk</code> package.


{{Cmd|apk add alpine-sdk}}
{{Cmd|apk add alpine-sdk}}


The [https://git.alpinelinux.org/abuild/tree/ git repository] always contains the latest version of the scripts, example-files, and makefiles.
The [https://git.alpinelinux.org/abuild/tree/ git repository] always contains the latest version of the scripts, example-files, and makefiles.


== Building packages ==
== Building packages ==
To build a package the <code>abuild</code> program is used. It implements functionality for building packages as well as additional commands and options for package maintenance.


=== Prerequisites ===
=== Prerequisites ===

Revision as of 14:54, 19 November 2023

The abuild package provides scripts necessary for creating packages for Alpine Linux. It implements functionality for building packages as well as additional commands and options for package maintenance. The abuild package and related tools can be installed automatically by installing the alpine-sdk package.

apk add alpine-sdk

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

Building packages

Prerequisites

In order to use abuild:

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 abuild package provides scripts necessary for creating packages for Alpine Linux. It implements functionality for building packages as well as additional commands and options for package maintenance. The abuild package and related tools can be installed automatically by installing the alpine-sdk package.

apk add alpine-sdk

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

Building packages

Prerequisites

In order to use abuild:

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

Template loop detected: Include:Abump

apkgrel

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

To create the actual APKBUILD file newapkbuild can serve you a template to start with. It will create a directory with the given package name, place an example/template APKBUILD file in the given directory, and fill some variables if those are provided.


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]

apkbuild-pypi

Template loop detected: Include:Apkbuild-pypi


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

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

apkbuild-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

Template loop detected: Include:Buildrepo


Setting up the build environment

abuild-keygen

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



apkgrel

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

To create the actual APKBUILD file newapkbuild can serve you a template to start with. It will create a directory with the given package name, place an example/template APKBUILD file in the given directory, and fill some variables if those are provided.


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]

apkbuild-pypi

The abuild package provides scripts necessary for creating packages for Alpine Linux. It implements functionality for building packages as well as additional commands and options for package maintenance. The abuild package and related tools can be installed automatically by installing the alpine-sdk package.

apk add alpine-sdk

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

Building packages

Prerequisites

In order to use abuild:

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

Template loop detected: Include:Abump

apkgrel

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

To create the actual APKBUILD file newapkbuild can serve you a template to start with. It will create a directory with the given package name, place an example/template APKBUILD file in the given directory, and fill some variables if those are provided.


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]

apkbuild-pypi

Template loop detected: Include:Apkbuild-pypi


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

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

apkbuild-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

Template loop detected: Include:Buildrepo


Setting up the build environment

abuild-keygen

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




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

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

apkbuild-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

The abuild package provides scripts necessary for creating packages for Alpine Linux. It implements functionality for building packages as well as additional commands and options for package maintenance. The abuild package and related tools can be installed automatically by installing the alpine-sdk package.

apk add alpine-sdk

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

Building packages

Prerequisites

In order to use abuild:

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

Template loop detected: Include:Abump

apkgrel

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

To create the actual APKBUILD file newapkbuild can serve you a template to start with. It will create a directory with the given package name, place an example/template APKBUILD file in the given directory, and fill some variables if those are provided.


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]

apkbuild-pypi

Template loop detected: Include:Apkbuild-pypi


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

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

apkbuild-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

Template loop detected: Include:Buildrepo


Setting up the build environment

abuild-keygen

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



Setting up the build environment

abuild-keygen

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