v0.1.0
This commit is contained in:
commit
fa432bebda
189 files changed
+26219
No files matched your search
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build EasyDNS .deb packages in Docker; results land in ./dist.
|
||||
#
|
||||
# scripts/build-deb.sh # host architecture
|
||||
# scripts/build-deb.sh --arch amd64,arm64 # several (needs buildx + QEMU/binfmt for foreign arches)
|
||||
# scripts/build-deb.sh --debian bookworm --revision 2
|
||||
# scripts/build-deb.sh --test # also install each .deb in a clean container and smoke-test it
|
||||
#
|
||||
# Requirements: Docker with BuildKit/buildx. Nothing is built on the host.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
ARCHES=""
|
||||
DEBIAN_RELEASE="bookworm"
|
||||
REVISION="1"
|
||||
TEST=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--arch) ARCHES="$2"; shift 2 ;;
|
||||
--debian) DEBIAN_RELEASE="$2"; shift 2 ;;
|
||||
--revision) REVISION="$2"; shift 2 ;;
|
||||
--test) TEST=1; shift ;;
|
||||
-h|--help) sed -n '2,10p' "$0"; exit 0 ;;
|
||||
*) echo "unknown option: $1" >&2; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
command -v docker >/dev/null || { echo "docker is required" >&2; exit 1; }
|
||||
docker buildx version >/dev/null 2>&1 || { echo "docker buildx is required (Docker >= 23 or the buildx plugin)" >&2; exit 1; }
|
||||
|
||||
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
|
||||
if [ -z "$ARCHES" ]; then
|
||||
case "$(uname -m)" in x86_64) ARCHES=amd64 ;; aarch64|arm64) ARCHES=arm64 ;; *) echo "unsupported host arch" >&2; exit 1 ;; esac
|
||||
fi
|
||||
mkdir -p dist
|
||||
|
||||
for arch in ${ARCHES//,/ }; do
|
||||
echo ">> building easydns ${VERSION}-${REVISION} for ${arch} (debian ${DEBIAN_RELEASE})"
|
||||
docker buildx build \
|
||||
-f deploy/docker/Dockerfile.deb \
|
||||
--platform "linux/${arch}" \
|
||||
--build-arg VERSION="$VERSION" \
|
||||
--build-arg REVISION="$REVISION" \
|
||||
--build-arg DEBIAN_RELEASE="$DEBIAN_RELEASE" \
|
||||
--target export \
|
||||
--output "type=local,dest=dist" \
|
||||
.
|
||||
deb="dist/easydns_${VERSION}-${REVISION}_${arch}.deb"
|
||||
[ -f "$deb" ] || { echo "expected $deb was not produced" >&2; exit 1; }
|
||||
echo ">> $deb"
|
||||
if [ "$TEST" = 1 ]; then
|
||||
echo ">> smoke test of $deb in a clean debian:${DEBIAN_RELEASE} container"
|
||||
docker run --rm --platform "linux/${arch}" -v "$PWD/dist:/dist:ro" "debian:${DEBIAN_RELEASE}-slim" sh -euc "
|
||||
apt-get update -qq >/dev/null && apt-get install -y -qq /dist/$(basename "$deb") >/dev/null
|
||||
easydns --version
|
||||
easydig -v
|
||||
easydns check-config --config /etc/easydns/config.yaml >/dev/null 2>&1 || true
|
||||
printf 'server: { listen: [\"127.0.0.1:5353\"], data_dir: /tmp/d }\napi: { enabled: false }\nmetrics: { enabled: false }\nzones: [ { name: example.com, type: primary, file: /usr/share/doc/easydns/zones/example.com.zone } ]\n' > /tmp/c.yaml
|
||||
easydns run --config /tmp/c.yaml >/tmp/log 2>&1 & sleep 1
|
||||
easydig @127.0.0.1 -p 5353 www.example.com +short | grep -q 192.0.2.10
|
||||
echo 'smoke test OK'
|
||||
"
|
||||
fi
|
||||
done
|
||||
(cd dist && sha256sum easydns_*.deb > SHA256SUMS)
|
||||
echo ">> done:"; ls -l dist/
|
||||
Reference in new issue
Block a user