-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unpackerr-auto-releaser
committed
Jul 31, 2024
1 parent
060ab29
commit 53bcff9
Showing
5 changed files
with
69 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters