diff --git a/packaging/main.sh b/packaging/main.sh index f4e3fb8..558ce8a 100755 --- a/packaging/main.sh +++ b/packaging/main.sh @@ -26,7 +26,11 @@ case "$1" in . ./resources/pkgbuild-git-stable-optimized.sh create_pkgbuild_git_stable_optimized ;; + apkbuild-source-stable-optimized) + . ./resources/apkbuild-source-stable-optimized.sh + create_apkbuild_source_stable_optimized + ;; *) - printf '\nusage: package.sh [target] \n\ntargets: release-binaries pkgbuild-git-stable-optimized\n\n' + printf '\nusage: package.sh [target] \n\ntargets: release-binaries pkgbuild-git-stable-optimized apkbuild-source-stable-optimized\n\n' ;; esac diff --git a/packaging/resources/apkbuild-source-stable-optimized.sh b/packaging/resources/apkbuild-source-stable-optimized.sh new file mode 100644 index 0000000..330d033 --- /dev/null +++ b/packaging/resources/apkbuild-source-stable-optimized.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +create_apkbuild_source_stable_optimized() { + printf '\nGenerating APKBUILD...\n' + local source="https://github.com/rwinkhart/MUTN/archive/refs/tags/v"$version".tar.gz" + local checksum=$(curl -sL "$source" | sha512sum | cut -d ' ' -f1) + printf "# Maintainer: Randall Winkhart +pkgname=mutn +pkgver="$version" +pkgrel="$((revision-1))" +pkgdesc='A simple, self-hosted, SSH-synchronized password/note manager for the CLI (based on libmutton)' +arch='all' +url='https://github.com/rwinkhart/MUTN' +license='MIT' +depends='gnupg' +makedepends='busybox go' +options='!check net' +source=\"\$pkgname-\$pkgver.tar.gz::"$source"\" + +build() { + cd \${srcdir}/MUTN-\$pkgver + + # compress man page + gzip -kf ./docs/man + + # determine microarchitecture feature level + case \$CARCH in + 'x86_64') + cpuFlags=\$(grep -E 'flags\s+:\s' /proc/cpuinfo) + if [ ! -z \"\$(echo \"\$cpuFlags\" | grep 'avx512f')\" ]; then + export GOAMD64=v4 + elif [ ! -z \"\$(echo \"\$cpuFlags\" | grep 'avx2')\" ]; then + export GOAMD64=v3 + elif [ ! -z \"\$(echo \"\$cpuFlags\" | grep 'sse4_2')\" ]; then + export GOAMD64=v2 + else + export GOAMD64=v1 + fi + ;; + # TODO check aarch64 feature level + esac + + # compile binary + CGO_ENABLED=1 go build -ldflags=\"-s -w\" -trimpath ./mutn.go +} + +package() { + cd \${srcdir}/MUTN-\$pkgver + install -Dm755 ./mutn \${pkgdir}/usr/bin/mutn + install -Dm644 ./LICENSE \${pkgdir}/usr/share/licenses/mutn/LICENSE + install -Dm644 ./completions/zsh/_mutn \${pkgdir}/usr/share/zsh/site-functions/_mutn + install -Dm644 ./completions/bash/mutn \${pkgdir}/usr/share/bash-completion/completions/mutn + install -Dm644 ./docs/man.gz \${pkgdir}/usr/share/man/man1/mutn.1.gz +} + +sha512sums=\" +$checksum \$pkgname-\$pkgver.tar.gz +\" +" > 1output/APKBUILD + printf '\nAPKBUILD generated\n\n' +}