1
0
mirror of https://github.com/azlux/dpkg-deb synced 2024-11-23 06:46:18 +00:00
dpkg-deb/gitea/build-package
2020-02-03 21:18:09 +01:00

52 lines
1.7 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="go-gitea/gitea"
api=$(curl --silent "https://api.github.com/repos/$repo/releases/latest")
new=$(echo $api | grep -Po '"tag_name": "v\K.*?(?=")')
all_dist=('amd64' '386' 'arm-6' '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/gitea-$new-linux-$dist -O "$STARTDIR/gitea"
wget -q https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service -O "$STARTDIR/gitea.service"
# Install files
install -Dm 755 "$STARTDIR/gitea" "$DESTDIR/usr/local/bin/gitea"
install -Dm 755 "$STARTDIR/gitea.service" "$DESTDIR/etc/systemd/system/gitea.service"
install -dm 750 "$DESTDIR/var/lib/gitea/custom"
install -dm 750 "$DESTDIR/var/lib/gitea/data"
install -dm 750 "$DESTDIR/var/lib/gitea/indexers"
install -dm 750 "$DESTDIR/var/lib/gitea/public"
install -dm 750 "$DESTDIR/var/lib/gitea/log"
install -dm 770 "$DESTDIR/etc/gitea"
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-6" ] && dist="armhf"
[ "$dist" == "386" ] && dist="i386"
sed -i "s/ARCHI-TO-REPLACE/$dist/" "$DESTDIR/DEBIAN/control"
# Build .deb
dpkg-deb --build "$DESTDIR" "$OUTDIR"
done