]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add builder
authorBastian Dehn <hhaalo@arcor.de>
Sat, 26 Sep 2026 16:10:42 +0000 (18:10 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sat, 26 Sep 2026 16:10:42 +0000 (18:10 +0200)
Makefile
builder/Containerfile.template [new file with mode: 0644]
builder/builder [new file with mode: 0755]
builder/run [new file with mode: 0644]

index 44794f83d75975db36e537a8a70a017859274f9d..11795c522c080b47b5ebd79eff9fc4023e90a3eb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ SRCDIR=src
 BINDIR=usr/bin
 LIBDIR=usr/lib/$(NAME)
 SHAREDIR=usr/share/doc/$(NAME)
-PACKAGE=$(NAME)_$(VERSION)-$(REVISION)_x86_64
+PACKAGE=$(NAME)_$(VERSION)-$(REVISION)$(EXTRA_VERSION)_x86_64
 
 .PHONY: all build test clean package
 
diff --git a/builder/Containerfile.template b/builder/Containerfile.template
new file mode 100644 (file)
index 0000000..77d28fe
--- /dev/null
@@ -0,0 +1,30 @@
+FROM $distro
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update \
+       && apt-get install --assume-yes --no-install-recommends \
+       build-essential \
+       cmake \
+       file \
+       git \
+       cppcheck \
+       lcov \
+       lintian \
+       && apt-get clean \
+       && rm --recursive --force /var/lib/apt/lists/*
+RUN apt-get update \
+       && apt-get install --assume-yes --no-install-recommends \
+       rsync \
+       bats \
+       bats-support \
+       bats-assert \
+       shellcheck \
+       flac \
+       lame \
+       eyed3 \
+       opus-tools \
+       vorbis-tools \
+       parallel \
+       && apt-get clean \
+       && rm --recursive --force /var/lib/apt/lists/*
+COPY run /app/run
+ENTRYPOINT /app/run
diff --git a/builder/builder b/builder/builder
new file mode 100755 (executable)
index 0000000..f14642c
--- /dev/null
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+create_containerfile()
+{
+       local distro="$1"
+       local distro_postfix="$2"
+
+       sed "s/\$distro/$distro/" builder/Containerfile.template \
+               > "build/Containerfile-$distro_postfix" \
+               || return $?
+}
+
+build_container_image()
+{
+       local distro_postfix="$1"
+
+       podman build \
+               --tag "albentohandy-builder:$distro_postfix" \
+               --file "build/Containerfile-$distro_postfix" \
+               || return $?
+}
+
+run_builder_container()
+{
+       local distro_postfix="$1"
+
+       podman run \
+               --tty \
+               --rm \
+               --volume .:/src \
+               "albentohandy-builder:$distro_postfix" \
+               || return $?
+}
+
+main()
+{
+       local distros=${DISTROS:="debian:oldstable-slim
+               debian:stable-slim
+               debian:testing-slim
+               ubuntu:latest
+               ubuntu:rolling"}
+       mkdir --parents build || return $?
+       cp builder/run build/run || return $?
+       chmod 755 build/run || return $?
+
+       for distro in $distros; do
+               local distro_postfix=${distro/:/-}
+               create_containerfile "$distro" "$distro_postfix" || return $?
+               build_container_image "$distro_postfix" || return $?
+               run_builder_container "$distro_postfix" || return $?
+       done
+}
+
+main
diff --git a/builder/run b/builder/run
new file mode 100644 (file)
index 0000000..b4b61eb
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+get_source_date()
+{
+       export SOURCE_DATE_EPOCH=
+       umask 0022 || return $?
+       cd /src || return $?
+       SOURCE_DATE_EPOCH=$(git log --max-count=1 --pretty="%ct")
+       export EXTRA_VERSION="-$ID-$VERSION_CODENAME"
+}
+
+create_package_checksum()
+{
+       local package=
+       cd /app/build/build || return $?
+       package=$(find . -maxdepth 1 -name '*.deb')
+       lintian --fail-on error,warning,pedantic "$package" || return $?
+       sha256sum ./*.deb > "$package.sha256" || return $?
+       cat "$package.sha256" || return $?
+}
+
+reproducible_package_checksum_check()
+{
+       local package=
+       cd /app/reproducible-build/build || return $?
+       package=$(find . -maxdepth 1 -name '*.deb')
+       cp "/src/build/$package.sha256" . || return $?
+       cat "$package.sha256" || return $?
+       sha256sum -c "$package.sha256" || return $?
+}
+
+run_tests()
+{
+       cd /app || return $?
+       rsync --recursive --exclude=build* /src/ /app/tests/ || return $?
+       cd /app/tests || return $?
+       make --jobs="$(nproc)" test || return $?
+}
+
+build_package()
+{
+       cd /app || return $?
+       rsync --recursive --exclude=build* /src/ /app/build || return $?
+       cd /app/build || return $?
+       make --jobs="$(nproc)" package || return $?
+}
+
+copy_package()
+{
+       mkdir --parents /src/build || return $?
+       cp /app/build/build/*.deb /src/build/ || return $?
+       cp /app/build/build/*.sha256 /src/build/ || return $?
+}
+
+build_reproducible_package()
+{
+       cd /app || return $?
+       rsync --recursive --exclude=build* /src/ /app/reproducible-build \
+               || return $?
+       cd /app/reproducible-build || return $?
+       make --jobs="$(nproc)" package || return $?
+}
+
+main()
+{
+       source /etc/os-release || return $?
+       get_source_date || return $?
+
+       run_tests || return $?
+       build_package || return $?
+       create_package_checksum || return $?
+       copy_package || return $?
+
+       build_reproducible_package || return $?
+       reproducible_package_checksum_check || return $?
+}
+
+main
\ No newline at end of file