45 lines
1.8 KiB
Bash
Executable File
45 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
# Build a standalone EasyDNS UI Debian package; never packages the DNS server.
|
|
set -eu
|
|
ROOT=$(CDPATH='' cd -- "$(dirname -- "$0")/.." && pwd)
|
|
ARCH=${GOARCH:-amd64}
|
|
VERSION=${VERSION:-0.1.0}
|
|
case "$ARCH" in
|
|
amd64|arm64) ;;
|
|
*) echo "Unsupported architecture: $ARCH (use amd64 or arm64)" >&2; exit 1 ;;
|
|
esac
|
|
case "$VERSION" in
|
|
*[!a-zA-Z0-9.+~:-]*|'') echo 'Invalid version' >&2; exit 1 ;;
|
|
esac
|
|
STAGING=$(mktemp -d)
|
|
trap 'rm -rf "$STAGING"' EXIT HUP INT TERM
|
|
chmod 0755 "$STAGING"
|
|
mkdir -p "$STAGING/DEBIAN" "$STAGING/usr/bin" "$STAGING/lib/systemd/system" "$STAGING/etc/default" "$ROOT/dist"
|
|
cd "$ROOT"
|
|
GOOS=linux GOARCH="$ARCH" CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$VERSION" -o "$STAGING/usr/bin/easydns-ui" ./cmd/easydns-ui
|
|
chmod 0755 "$STAGING/usr/bin/easydns-ui"
|
|
cp packaging/easydns-ui.service "$STAGING/lib/systemd/system/easydns-ui.service"
|
|
cp packaging/easydns-ui.default "$STAGING/etc/default/easydns-ui"
|
|
chmod 0644 "$STAGING/etc/default/easydns-ui"
|
|
cp packaging/debian/postinst packaging/debian/prerm packaging/debian/postrm "$STAGING/DEBIAN/"
|
|
cat > "$STAGING/DEBIAN/control" <<CONTROL
|
|
Package: easydns-ui
|
|
Version: $VERSION
|
|
Section: admin
|
|
Priority: optional
|
|
Architecture: $ARCH
|
|
Depends: adduser, coreutils, passwd
|
|
Maintainer: EasyDNS UI maintainers
|
|
Description: EasyDNS standalone OLED administration panel
|
|
A Go web UI for an existing EasyDNS server. Uses the server's
|
|
autogenerated control.token or local Unix control socket.
|
|
It does not install or replace the Rust DNS service.
|
|
CONTROL
|
|
cat > "$STAGING/DEBIAN/conffiles" <<CONF
|
|
/etc/default/easydns-ui
|
|
CONF
|
|
# The parent may be non-root while dpkg-deb is available.
|
|
OUT="$ROOT/dist/easydns-ui_${VERSION}_${ARCH}.deb"
|
|
dpkg-deb --build --root-owner-group "$STAGING" "$OUT" >/dev/null
|
|
printf '%s\n' "$OUT"
|