Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apkbuild #87

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 87_apk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.apk
*.gz
27 changes: 27 additions & 0 deletions 87_apk/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM alpine:3.20.0 AS build

RUN apk update && apk add --no-cache mandoc man-pages abuild curl doas alpine-sdk

ENV USERNAME="builder"
ENV GROUP="builder"

# Create a non-admin user and group
RUN addgroup -S $USERNAME && adduser -S $USERNAME -G $GROUP
RUN echo "$USERNAME:$USERNAME" | chpasswd
RUN echo "$USERNAME ALL=(ALL) ALL" > /etc/sudoers
RUN echo 'GROUP="$GROUP"' > /etc/abuild.conf

WORKDIR /package

# Copy files from the local machine to the container
COPY ./hello-world /package

# Change the ownership of the working directory to the non-admin user
RUN chown -R builder:builder /package

# Switch to the non-admin user
USER builder

WORKDIR /package

#abuild-keygen -a -i
27 changes: 27 additions & 0 deletions 87_apk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# APK

TODO:

- Create packages
- Host packages in a repository (s3)

## Build

Build and run the container

```sh
# Build
docker build -t apkbuilder -f Dockerfile.build .

# run
docker run -it --entrypoint /bin/sh apkbuilder
```

## Resources

- Alpine linux create a apk-package [here](https://stackoverflow.com/questions/59684341/alpine-linux-create-a-apk-package)
- https://github.com/alpinelinux
- https://github.com/alpinelinux/apk-tools/blob/master/doc/apk.8.scd
- https://github.com/gr0und-s3ct0r/apkbuild
https://codeberg.org/chimo/apkbuilds
- https://wiki.alpinelinux.org/wiki/Abuild_and_Helpers
35 changes: 35 additions & 0 deletions 87_apk/hello-world/APKBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contributor:
# Maintainer:
pkgname=hello-world
pkgver=1.0
pkgrel=0
pkgdesc="Hello World! program"
url="http://alpinelinux.org"
arch="noarch"
license="GPL"
depends=
makedepends=
install=
subpackages=
source=""
builddir="$srcdir/$pkgname-$pkgver"

# append extra dependencies to -dev subpackage
# remove if not used.
# depends_dev="somepackage-dev"

prepare() {
mkdir -p "$builddir"
}

build() {
cd "$builddir"
cp ../hello-world.sh .
}

package() {
cd "$builddir"
install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname
}

sha512sums="" #generate with 'abuild checksum'
24 changes: 24 additions & 0 deletions 87_apk/hello-world/hello-world.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euf -o pipefail

readonly SCRIPT_NAME=$(basename "$0")
readonly SCRIPT_PATH=${0}
readonly SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
readonly HOME_DIR=~
if [[ $(command -v greadlink) ]]; then
# mac requires 'brew install coreutils'
readonly SCRIPT_FULL_PATH="$(dirname "$(greadlink -f "$0")")"
else
readonly SCRIPT_FULL_PATH="$(dirname "$(readlink -f "$0")")"
fi

echo "************************************************"
echo "* hello-world from debian package"
echo "************************************************"
echo "SCRIPT_NAME=${SCRIPT_NAME}"
echo "SCRIPT_PATH=${SCRIPT_PATH}"
echo "SCRIPT_DIR=${SCRIPT_DIR}"
echo "HOME_DIR=${HOME_DIR}"
echo "SCRIPT_FULL_PATH=${SCRIPT_FULL_PATH}"
echo "************************************************"

Loading