Skip to content

Instantly share code, notes, and snippets.

@XtendedGreg
Created February 18, 2024 12:31
Show Gist options
  • Save XtendedGreg/ebd54547a28178b443aa521fed571397 to your computer and use it in GitHub Desktop.
Save XtendedGreg/ebd54547a28178b443aa521fed571397 to your computer and use it in GitHub Desktop.
Creating Alpine Linux Packages

Creating Alpine Linux Packages

  • This Gist covers the commands and methods needed to create APK files and a local repository on Alpine Linux for your own software packages.
  • The focus of this guide is toward interpereted language software packages that do not require compiling, and is a simplified overview of what is needed to build a package.
  • Written by: XtendedGreg and featured on the live stream https://youtube.com/live/Q0XAnXgCxIw

Setup Development Environment and Build Package

Step 1: Install Dependancies

apk add alpine-sdk sudo abuild-rootbld doas

Step 2: Setup User

adduser [username]
addgroup [username] abuild
addgroup [username] wheel
lbu add /home/[username]

Step 3: Create Repository Directory and Assign Permissions

mkdir -p /var/cache/distfiles
chgrp abuild /var/cache/distfiles
chmod g+w /var/cache/distfiles
lbu add /var/cache/distfiles

Step 4: Change to User Account and Generate Keys

su [username]
git config --global user.name "Your Full Name"
git config --global user.email "your@email.address"
abuild-keygen -a -i
cp /home/[username]/.abuild/*.rsa.pub /etc/apk/keys

Step 5: Create Working Directory and Initialize

This will create the directory and copy the example conf, init and install file to the directory.

mkdir -p ~/dev/testing/[package name]
cd ~/dev/testing/[package name]
newapkbuild -c [package name]

Step 6: Edit APKBUILD File

Update the file to definitely include pkgname, pkgver, pkgdesc, url, license, depends and source.

Step 7: Edit Application Scripts

  • Add and edit whatever files you need to complete your program and then add them to the source entry in APKBUILD.
  • You may want to create a directory called root inside the package folder that contains the files that you need in the correct relative locations to their final installed locations and then include that path in the source entry in APKBUILD.

Step 8: Create Checksum for All Included Files

cd ~/dev/testing/[package name]
abuild checksum

Step 9: Build Package

abuild -r

Step 10: Add Local Repository to APK Repositories List

echo /home/[username]/packages/testing/ >> /etc/apk/repositories
echo /home/[username]/packages/main/ >> /etc/apk/repositories
echo /home/[username]/packages/community/ >> /etc/apk/repositories
apk update

Install Finished Package

apk add [package name]

SAVE YOUR WORK

lbu commit -d

Additional Resources

Notes

  • This gist has not yet been tested from scratch to confirm viability and this note will be removed once it has.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment