2023-12-31 05:31:19 +00:00
---
obj: concept
source: https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package
---
# Alpine Package
2024-01-17 08:00:45 +00:00
Alpine Packages are packages for [Alpine Linux ](../../../linux/Alpine%20Linux.md ) and installable via [apk ](apk.md ).
2023-12-31 05:31:19 +00:00
## Setup
2024-01-17 08:00:45 +00:00
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 ](../../cli/system/doas.md ), and an editor, such as vi, nano, [micro ](../../cli/micro.md ).
2023-12-31 05:31:19 +00:00
```shell
apk add alpine-sdk
addgroup user abuild
```
Generate a key for package creation:
```shell
abuild-keygen -a -i
```
## Build
For you build you need a [APKBUILD ](APKBUILD.md ) file and `abuild` as a packaging tool.
Usage:
- `abuild checksum` : updates the checksums for source files.
- `abuild -r` : builds the package.
### Building in a chroot
2024-01-17 08:44:04 +00:00
Install package `abuild-rootbld` :
2023-12-31 05:31:19 +00:00
```shell
apk add abuild-rootbld
```
2024-01-17 08:44:04 +00:00
You may now build your packages from source in an unprivileged sandbox based on bubblewrap with the command:
2023-12-31 05:31:19 +00:00
```shell
abuild rootbld
```
2024-01-17 08:44:04 +00:00
If the build process needs network access there has to bet set the **net** option in [APKBUILD ](APKBUILD.md ).
2023-12-31 05:31:19 +00:00
## Bumping a package version
2024-01-17 08:44:04 +00:00
The tool `abump` is a utility to bump pkgver in [APKBUILD ](APKBUILD.md ) 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.
2023-12-31 05:31:19 +00:00
```shell
abump [-hR]
```
**abump options**
2024-01-17 08:44:04 +00:00
- **-h** Show this help
- **-R** Run abuild with -R for recursive building
- **-k** Keep existing packages
2023-12-31 05:31:19 +00:00
## Updating a package release
2024-01-17 08:44:04 +00:00
If you want to bump or reset the pkgrel value of your [APKBUILD ](APKBUILD.md ) or test your [APKBUILD ](APKBUILD.md ) files, apkgrel can assist you.
2023-12-31 05:31:19 +00:00
```shell
apkgrel -a|-h|-s NUM|-t|-z [-f] FILE...
```
**apkgrel options**
2024-01-17 08:44:04 +00:00
- **-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