Skip to content

Commit

Permalink
feat: Build, install, and use static libnl3
Browse files Browse the repository at this point in the history
Signed-off-by: txtsd <[email protected]>
  • Loading branch information
txtsd committed Sep 6, 2023
1 parent 3bab921 commit d89950b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 37 deletions.
34 changes: 34 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/ash
set -x

# General updates
apk update
apk add cmake openssl openssl-dev openssl-libs-static linux-headers ninja-is-really-ninja alpine-sdk runuser sudo sed

# Setup build environment
addgroup $(whoami) abuild
mkdir -p /var/cache/distfiles
chmod a+w /var/cache/distfiles
chgrp abuild /var/cache/distfiles
chmod g+w /var/cache/distfiles
cwd=$(pwd)

# Create user to run abuild
adduser -G abuild -g "Alpine Package Builder" -s /bin/ash -D abuilder
echo "abuilder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Build static libnl3
runuser -u abuilder -- /usr/bin/abuild-keygen -n -a -i -b 4096
cd /home/abuilder
runuser -u abuilder -- git clone https://gitlab.alpinelinux.org/alpine/aports.git --depth 1
cd /home/abuilder/aports/main/libnl3
# runuser -u abuilder -- /bin/sed -i "s/subpackages=\"/subpackages=\"\$pkgname-static /" APKBUILD
runuser -u abuilder -- /bin/sed -i "s/--disable-static/--enable-static/" APKBUILD
runuser -u abuilder -- /usr/bin/abuild -r
apk add /home/abuilder/packages/main/$(abuild -A)/libnl3*

# Build static DPITunnel-cli
cd ${cwd}
cmake -B build -DCMAKE_BUILD_TYPE=RELEASE -DSTATIC_BINARY=true -G Ninja .
cmake --build build

10 changes: 6 additions & 4 deletions .github/workflows/cd.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: CD
name: Build

on:
release:
types: [created]
push:
pull_request:
types: [opened, edited]

jobs:
build:
Expand All @@ -25,11 +27,11 @@ jobs:

- name: Setup Docker
run: |
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run --rm --privileged multiarch/qemu-user-static:register --reset --credential yes
- name: Build
- name: Build in Docker
run: |
docker run --workdir /github/workspace --rm --entrypoint "./build_static_alpine.sh" -v "$(pwd)":"/github/workspace" multiarch/alpine:${{ matrix.arch }}-edge
docker run --workdir /github/workspace --rm --entrypoint "./.github/scripts/build.sh" -v "$(pwd)":"/github/workspace" multiarch/alpine:${{ matrix.arch }}-edge
- name: Upload Binary
if: github.event_name != 'release'
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/ci.yml

This file was deleted.

6 changes: 0 additions & 6 deletions build_static_alpine.sh

This file was deleted.

0 comments on commit d89950b

Please sign in to comment.