Skip to content

Commit 555c8d9

Browse files
committed
Offline vendored build for Debian packaging
Add GOPROXY=off, GONOSUMCHECK=*, GOTOOLCHAIN=local to debian/rules to block all network access from Go during build. Remove go mod vendor from configure and vendor cleanup from clean since vendor/ is now shipped in the orig tarball. Add debian/make-orig-tarball.sh to create the vendored orig tarball from git archive + autotools + go mod vendor.
1 parent 41cf43d commit 555c8d9

2 files changed

Lines changed: 53 additions & 3 deletions

File tree

debian/make-orig-tarball.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# Build a vendored orig tarball for Debian packaging.
3+
#
4+
# Launchpad and other Debian build hosts have no network access, so the
5+
# orig tarball must ship everything needed to build offline:
6+
# - autotools generated files (configure, Makefile.in, ...)
7+
# - Go vendor/ directory (all Go module dependencies)
8+
#
9+
# The tarball is created from the current git HEAD, not from a GitHub
10+
# release download (which lacks both autotools files and vendor/).
11+
#
12+
# Output: ../libcoraza_<version>.orig.tar.gz
13+
#
14+
# Prerequisites: git, dpkg-parsechangelog, autoconf, automake, libtool, go
15+
#
16+
# Usage: debian/make-orig-tarball.sh
17+
# Run from the top-level source directory (must be a git repo).
18+
19+
set -euo pipefail
20+
21+
VERSION=$(dpkg-parsechangelog -S Version | sed 's/-.*//')
22+
TARBALL="libcoraza_${VERSION}.orig.tar.gz"
23+
DISTNAME="libcoraza-${VERSION}"
24+
WORKDIR=$(mktemp -d)
25+
26+
trap 'rm -rf "$WORKDIR"' EXIT
27+
28+
echo "==> Exporting git tree..."
29+
git archive --prefix="${DISTNAME}/" HEAD | tar xf - -C "$WORKDIR"
30+
31+
echo "==> Generating autotools files..."
32+
(
33+
cd "$WORKDIR/${DISTNAME}"
34+
echo "$VERSION" > .tarball-version
35+
./build.sh
36+
)
37+
38+
echo "==> Running go mod vendor..."
39+
(
40+
cd "$WORKDIR/${DISTNAME}"
41+
go mod vendor
42+
)
43+
44+
echo "==> Creating tarball..."
45+
tar czf "../${TARBALL}" -C "$WORKDIR" "${DISTNAME}"
46+
47+
echo "==> Created ../${TARBALL}"
48+
echo " $(tar tzf "../${TARBALL}" | grep -c vendor/) vendor entries included"

debian/rules

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
77
export GOPATH = $(CURDIR)/.gopath
88
export GOCACHE = $(CURDIR)/.gocache
99
export GOFLAGS = -mod=vendor
10+
export GOPROXY = off
11+
export GONOSUMCHECK = *
12+
export GOTOOLCHAIN = local
1013

1114
SOMAJOR = 1
1215
SOVER = $(DEB_VERSION_UPSTREAM)
@@ -19,7 +22,6 @@ override_dh_autoreconf:
1922
./build.sh
2023

2124
override_dh_auto_configure:
22-
go mod vendor
2325
dh_auto_configure -- --libdir=/usr/lib/$(DEB_HOST_MULTIARCH)
2426

2527
override_dh_auto_build:
@@ -53,5 +55,5 @@ override_dh_strip:
5355

5456
override_dh_auto_clean:
5557
[ ! -f Makefile ] || $(MAKE) distclean
56-
chmod -Rf u+w .gopath .gocache vendor 2>/dev/null || true
57-
rm -rf .gopath .gocache vendor
58+
chmod -Rf u+w .gopath .gocache 2>/dev/null || true
59+
rm -rf .gopath .gocache

0 commit comments

Comments
 (0)