1
0
mirror of https://github.com/azlux/dpkg-deb synced 2024-11-23 06:46:18 +00:00
dpkg-deb/webhookd/build-package
2020-03-25 18:30:35 +01:00

48 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Exit the script if any of the commands fail
set -e
set -u
set -o pipefail
# Set working directory to the location of this script
cd "$(dirname "${BASH_SOURCE[0]}")"
STARTDIR="$(pwd)"
DESTDIR="$STARTDIR/pkg"
OUTDIR="$STARTDIR/deb"
mkdir "$OUTDIR"
# get version
repo="ncarlier/webhookd"
api=$(curl --silent "https://api.github.com/repos/$repo/releases/latest")
new=$(echo $api | grep -Po '"tag_name": "v\K.*?(?=")')
all_dist=('amd64' 'arm' 'arm64')
for dist in "${all_dist[@]}"; do
# Remove potential leftovers from a previous build
rm -rf "$DESTDIR"
wget -q https://github.com/$repo/releases/download/v$new/webhookd-linux-$dist.tgz -O "$STARTDIR/tar.tgz"
tar xzf "$STARTDIR/tar.tgz" -C "$STARTDIR/"
wget -q https://raw.githubusercontent.com/ncarlier/webhookd/master/etc/default/webhookd.env -O "$STARTDIR/webhookd.env"
install -Dm 755 "$STARTDIR/webhookd" "$DESTDIR/usr/local/bin/webhookd"
install -Dm 755 "$STARTDIR/webhookd.env" "$DESTDIR/etc/default/webhookd.env"
install -Dm 644 "$STARTDIR/webhookd.service" "$DESTDIR/etc/systemd/system/webhookd.service"
mkdir -p "$DESTDIR/DEBIAN"
cp "$STARTDIR/DEBIAN/"* "$DESTDIR/DEBIAN/"
# Modify control file for build
sed -i "s/VERSION-TO-REPLACE/$new/" "$DESTDIR/DEBIAN/control"
[ "$dist" == "arm" ] && dist="armhf"
[ "$dist" == "386" ] && dist="i386"
sed -i "s/ARCHI-TO-REPLACE/$dist/" "$DESTDIR/DEBIAN/control"
# Build .deb
dpkg-deb --build "$DESTDIR" "$OUTDIR"
done