77#
88# The optional include_orig flag (true/false, default true) controls whether the
99# orig tarball is included in the upload (-sa) or omitted (-sd). Launchpad requires
10- # the orig tarball to be identical across all uploads for the same upstream version,
11- # so only the first distro upload should include it; subsequent distros should set
12- # this to "false" so Launchpad reuses the tarball already on file.
10+ # the orig tarball to be byte-identical across all uploads for the same upstream
11+ # version, so the first distro upload should use "true" and subsequent distros "false".
12+ #
13+ # When the orig tarball does not yet exist locally, the script first attempts to
14+ # download the exact copy already stored on Launchpad. If that fails (i.e. this is
15+ # the very first upload for this upstream version), a reproducible tarball is created.
1316#
1417# Example: ./scripts/build-source-package.sh 2.7.1 noble ABC123DEF456 true
1518# ./scripts/build-source-package.sh 2.7.1 jammy ABC123DEF456 false
@@ -25,17 +28,31 @@ PACKAGE_NAME="crip"
2528SOURCE_DIR=" ${PACKAGE_NAME} -${VERSION} "
2629ORIG_TARBALL=" ${PACKAGE_NAME} _${VERSION} .orig.tar.gz"
2730
31+ # Launchpad PPA base URL for downloading existing orig tarballs
32+ PPA_POOL_URL=" https://ppa.launchpadcontent.net/hakky554/apps/ubuntu/pool/main/c/crip"
33+
2834echo " ==> Building source package for ${PACKAGE_NAME} ${VERSION} (${DISTRO} )"
2935
3036# Create source directory with pre-built binaries
3137mkdir -p " ${SOURCE_DIR} /binaries"
3238cp binary/amd64/crip " ${SOURCE_DIR} /binaries/crip-amd64"
3339cp binary/aarch64/crip " ${SOURCE_DIR} /binaries/crip-arm64"
3440
35- # Reuse existing orig tarball if present (all distros must share the same one for Launchpad)
41+ # Obtain the orig tarball — must be byte-identical to what Launchpad already has
3642if [ ! -f " ${ORIG_TARBALL} " ]; then
37- echo " ==> Creating orig tarball ${ORIG_TARBALL} "
38- tar -czf " ${ORIG_TARBALL} " " ${SOURCE_DIR} "
43+ echo " ==> Trying to download existing orig tarball from PPA"
44+ if curl -fsSL " ${PPA_POOL_URL} /${ORIG_TARBALL} " -o " ${ORIG_TARBALL} " ; then
45+ echo " ==> Downloaded existing orig tarball from PPA"
46+ else
47+ echo " ==> No existing tarball on PPA, creating a new reproducible one"
48+ REPRODUCIBLE_TIMESTAMP=" 2024-01-01 00:00:00"
49+ find " ${SOURCE_DIR} " -exec touch -d " ${REPRODUCIBLE_TIMESTAMP} " {} +
50+ tar --sort=name \
51+ --mtime=" ${REPRODUCIBLE_TIMESTAMP} " \
52+ --owner=root --group=root --numeric-owner \
53+ -cf - " ${SOURCE_DIR} " | gzip -n > " ${ORIG_TARBALL} "
54+ fi
55+ echo " ==> Orig tarball SHA256: $( sha256sum " ${ORIG_TARBALL} " ) "
3956fi
4057
4158# Create debian packaging directory
0 commit comments