Skip to content
Merged
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
94 changes: 47 additions & 47 deletions init/archlinux/PKGBUILD.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,60 @@ pkgdesc='{{Desc}}'
arch=('x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64' 'i686' 'pentium4')
url='https://golift.io/unpackerr'
license=('MIT')
makedepends=('go' 'make')
source=("unpackerr-${pkgver}.tar.gz::{{SOURCE_PATH}}")
sha256sums=('{{SHA256}}')
configfile='unpackerr.conf'
backup=("etc/${pkgname}/${configfile}")
install="${pkgname}.aur.install"
makedepends=('go' 'gzip')

build() {
cd "$pkgname-$pkgver"
export EXTRA_LDFLAGS=-linkmode=external
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
make man VERSION="${pkgver}" ITERATION="${pkgrel}"
make "${pkgname}.service" VERSION="${pkgver}" ITERATION="${pkgrel}"
source=("${pkgname}-${pkgver}.tar.gz::{{SOURCE_PATH}}")
sha512sums=('{{SHA}}')

if [ "$CARCH" == "x86_64" ]; then
make linux VERSION="${pkgver}" ITERATION="${pkgrel}"
mv "$pkgname.amd64.linux" "$pkgname"
elif [ "$CARCH" == "arm" ] || [ "$CARCH" == "armv6h" ] || [ "$CARCH" == "armv7h" ]; then
make armhf VERSION="${pkgver}" ITERATION="${pkgrel}"
mv "$pkgname.armhf.linux" "$pkgname"
elif [ "$CARCH" == "aarch64" ]; then
make arm64 VERSION="${pkgver}" ITERATION="${pkgrel}"
mv "$pkgname.arm64.linux" "$pkgname"
elif [ "$CARCH" == "i686" ] || [ "$CARCH" == "pentium4" ]; then
make linux386 VERSION="${pkgver}" ITERATION="${pkgrel}"
mv "$pkgname.i386.linux" "$pkgname"
fi
backup=("etc/${pkgname}/${pkgname}.conf")

prepare(){
cd "$pkgname-$pkgver"
mkdir -p build/
}

check() {
build() {
cd "$pkgname-$pkgver"
go test ./...

export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -modcacherw"
export VLDFLAGS="-w -s -X 'golift.io/version.Branch=main (${sha512sums[0]:0:11})' \
-X golift.io/version.BuildDate=$(date -u +%Y-%m-%dT%H:%M:00Z) \
-X golift.io/version.BuildUser=$(whoami) \
-X golift.io/version.Revision=${pkgrel} \
-X golift.io/version.Version=${pkgver}"

go build -o unpackerr -ldflags "$VLDFLAGS" .
go run github.com/davidnewhall/[email protected] --manual unpackerr --version ${pkgver} --date "${DATE}" README.md
go run github.com/davidnewhall/[email protected] --manual unpackerr --version ${pkgver} --date "${DATE}" examples/MANUAL.md
gzip -9 examples/MANUAL
mv examples/MANUAL.gz ${pkgname}.1.gz
}

package() {
cd "$pkgname-$pkgver"
# Binary.
install -Dm755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
cd "${srcdir}/${pkgname}-${pkgver}"

# Directories.
install -dm0755 "${pkgdir}/share/doc/${pkgname}" \
"${pkgdir}/usr/share/licenses/${pkgname}" "${pkgdir}/etc/${pkgname}"
# Man file.
install -Dm644 "${pkgname}.1.gz" "${pkgdir}/share/man/man1/${pkgname}.1.gz"
# Config file, and example config file.
install -m644 "examples/${configfile}.example" "${pkgdir}/etc/$pkgname/${configfile}.example"
install -m644 "examples/${configfile}.example" "${pkgdir}/etc/${pkgname}/${configfile}"
# Extra documentation.
install -m644 *.html examples/* "${pkgdir}/share/doc/${pkgname}/"
# License.
install -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# User and group.
echo 'u unpackerr - "unpackerr file extracter" -' > sysusers.conf
install -Dm0644 "sysusers.conf" "${pkgdir}/usr/lib/sysusers.d/unpackerr.conf"
rm sysusers.conf
# Systemd Service Unit.
install -Dm644 "${pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
install -d -m 755 "${pkgdir}/usr/share/"{licenses,doc}"/${pkgname}" "${pkgdir}/etc/${pkgname}"

# Install the binary
install -D -m 755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}"

# Install configuration file(s).
install -D -m 644 "examples/${pkgname}.conf.example" "${pkgdir}/etc/${pkgname}/${pkgname}.conf"
install -D -m 644 "examples/${pkgname}.conf.example" "${pkgdir}/etc/${pkgname}/${pkgname}.conf.example"

# License, documentation, manual.
install -D -m 644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
install -D -m 644 *.html examples/* "${pkgdir}/usr/share/doc/${pkgname}/"
install -D -m 644 "${pkgname}.1.gz" "${pkgdir}/usr/share/man/man1/${pkgname}.1.gz"

# Install the systemd service unit and system user account.
install -D -m 644 "init/systemd/${pkgname}.service" "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
echo "u ${pkgname} - \"${pkgname} daemon\"" > "${pkgname}.sysusers"
install -D -m 644 "${pkgname}.sysusers" "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
rm "${pkgname}.sysusers"
}
3 changes: 2 additions & 1 deletion init/archlinux/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
This template file is built by GitHub Actions and uploaded to a [different github repo](https://github.com/golift/aur).
This template file is built by GitHub Actions and uploaded to the
[AUR repo](https://aur.archlinux.org/packages/unpackerr).
5 changes: 2 additions & 3 deletions init/archlinux/SRCINFO.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pkgbase = unpackerr
pkgver = {{VERSION}}
pkgrel = {{Iter}}
url = https:/golift.io/unpackerr
install = unpackerr.aur.install
arch = x86_64
arch = arm
arch = armv6h
Expand All @@ -13,9 +12,9 @@ pkgbase = unpackerr
arch = pentium4
license = MIT
makedepends = go
makedepends = make
makedepends = gzip
backup = etc/unpackerr/unpackerr.conf
source = unpackerr-{{VERSION}}.tar.gz::{{SOURCE_PATH}}
sha256sums = {{SHA256}}
sha512sums = {{SHA}}

pkgname = unpackerr
38 changes: 13 additions & 25 deletions init/archlinux/aur-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash -x

# Deploys a new aur PKGBUILD file to am arch linux aur github repo.
# Deploys a new aur PKGBUILD file to an arch linux aur github repo.
# Run by GitHub Actions when a new release is created on GitHub.

source settings.sh

SOURCE_PATH=https://github.com/Unpackerr/unpackerr/archive/v${VERSION}.tar.gz
echo "==> Using URL: $SOURCE_PATH"
SHA256=$(curl -sL $SOURCE_PATH | openssl dgst -r -sha256 | awk '{print $1}')
SHA=$(curl -sL $SOURCE_PATH | sha512sum | awk '{print $1}')

push_it() {
pushd release_repo
Expand All @@ -21,13 +21,13 @@ push_it() {
# Make an id_rsa file with our secret.
mkdir -p $HOME/.ssh
KEY_FILE="$(mktemp -u $HOME/.ssh/XXXXX)"
echo "${DEPLOY_KEY}" > "${KEY_FILE}"
chmod 600 "${KEY_FILE}"
# Configure ssh to use this secret on a custom github hostname.
GITHUB_HOST="github.$(basename $KEY_FILE)"
echo "${DEPLOY_KEY}" > "${KEY_FILE}"
# Configure ssh to use this secret on a custom hostname.
AUR_HOST="arch.$(basename $KEY_FILE)"
printf "%s\n" \
"Host $GITHUB_HOST" \
" HostName github.com" \
"Host $AUR_HOST" \
" HostName aur.archlinux.org" \
" IdentityFile ${KEY_FILE}" \
" StrictHostKeyChecking no" \
" LogLevel ERROR" | tee -a $HOME/.ssh/config
Expand All @@ -36,32 +36,20 @@ git config --global user.email "[email protected]"
git config --global user.name "unpackerr-auto-releaser"

rm -rf release_repo
git clone git@${GITHUB_HOST}:golift/aur.git release_repo
mkdir -p release_repo/unpackerr
git clone aur@${AUR_HOST}:unpackerr.git release_repo

sed -e "s/{{VERSION}}/${VERSION}/g" \
-e "s/{{Iter}}/${ITERATION}/g" \
-e "s/{{SHA256}}/${SHA256}/g" \
-e "s/{{SHA}}/${SHA}/g" \
-e "s/{{Desc}}/${DESC}/g" \
-e "s%{{SOURCE_PATH}}%${SOURCE_PATH}%g" \
init/archlinux/PKGBUILD.template | tee release_repo/unpackerr/PKGBUILD
init/archlinux/PKGBUILD.template | tee release_repo/PKGBUILD

sed -e "s/{{VERSION}}/${VERSION}/g" \
-e "s/{{Iter}}/${ITERATION}/g" \
-e "s/{{SHA256}}/${SHA256}/g" \
-e "s/{{SHA}}/${SHA}/g" \
-e "s/{{Desc}}/${DESC}/g" \
-e "s%{{SOURCE_PATH}}%${SOURCE_PATH}%g" \
init/archlinux/SRCINFO.template | tee release_repo/unpackerr/.SRCINFO

tee release_repo/unpackerr/unpackerr.aur.install << EOF
post_upgrade() {
/bin/systemctl restart unpackerr
}

pre_remove() {
/bin/systemctl stop unpackerr
/bin/systemctl disable unpackerr
}
EOF
init/archlinux/SRCINFO.template | tee release_repo/.SRCINFO

push_it
[ "$1" != "" ] || push_it
7 changes: 5 additions & 2 deletions init/systemd/unpackerr.service
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Systemd service unit for unpackerr.
# Be sure to use `systemctl edit unpackerr` to modify this service with an override.conf because
# direct changes will be overwritten by package updates.
# Read more here: https://unpackerr.zip/docs/install/linux#change-the-uidgid

[Unit]
Description=unpackerr - archive extraction daemon
After=network.target
Requires=network.target
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/unpackerr $DAEMON_OPTS
Expand Down