Skip to content

Commit 1a4670a

Browse files
committed
Added script to publish to ppa launchpad
1 parent 294ca5b commit 1a4670a

2 files changed

Lines changed: 48 additions & 12 deletions

File tree

.github/workflows/publish-apt.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,34 @@ jobs:
4646
mkdir -p binary/aarch64
4747
tar -xzf crip-linux-aarch64.tar.gz -C binary/aarch64
4848
49-
- name: Create orig tarball
49+
- name: Obtain orig tarball
5050
env:
5151
VERSION: ${{ steps.version.outputs.tag }}
5252
run: |
53-
SOURCE_DIR="crip-${VERSION}"
54-
mkdir -p "${SOURCE_DIR}/binaries"
55-
cp binary/amd64/crip "${SOURCE_DIR}/binaries/crip-amd64"
56-
cp binary/aarch64/crip "${SOURCE_DIR}/binaries/crip-arm64"
57-
tar -czf "crip_${VERSION}.orig.tar.gz" "${SOURCE_DIR}"
53+
ORIG_TARBALL="crip_${VERSION}.orig.tar.gz"
54+
55+
# Try to download the orig tarball already on Launchpad (from a previous distro upload).
56+
# This ensures we use the exact same bytes, avoiding "different contents" rejections.
57+
PPA_URL="https://ppa.launchpadcontent.net/hakky554/apps/ubuntu/pool/main/c/crip/${ORIG_TARBALL}"
58+
echo "==> Trying to download existing orig tarball from PPA: ${PPA_URL}"
59+
if curl -fsSL "${PPA_URL}" -o "${ORIG_TARBALL}"; then
60+
echo "==> Downloaded existing orig tarball from PPA"
61+
else
62+
echo "==> No existing tarball on PPA, creating a new reproducible one"
63+
SOURCE_DIR="crip-${VERSION}"
64+
mkdir -p "${SOURCE_DIR}/binaries"
65+
cp binary/amd64/crip "${SOURCE_DIR}/binaries/crip-amd64"
66+
cp binary/aarch64/crip "${SOURCE_DIR}/binaries/crip-arm64"
67+
# Reproducible tarball: fixed timestamps, sorted entries, gzip -n
68+
REPRODUCIBLE_TIMESTAMP="2024-01-01 00:00:00"
69+
find "${SOURCE_DIR}" -exec touch -d "${REPRODUCIBLE_TIMESTAMP}" {} +
70+
tar --sort=name \
71+
--mtime="${REPRODUCIBLE_TIMESTAMP}" \
72+
--owner=root --group=root --numeric-owner \
73+
-cf - "${SOURCE_DIR}" | gzip -n > "${ORIG_TARBALL}"
74+
fi
75+
76+
echo "==> Orig tarball SHA256: $(sha256sum "${ORIG_TARBALL}")"
5877
5978
- name: Upload orig tarball and binaries
6079
uses: actions/upload-artifact@v4

scripts/build-source-package.sh

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
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"
2528
SOURCE_DIR="${PACKAGE_NAME}-${VERSION}"
2629
ORIG_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+
2834
echo "==> Building source package for ${PACKAGE_NAME} ${VERSION} (${DISTRO})"
2935

3036
# Create source directory with pre-built binaries
3137
mkdir -p "${SOURCE_DIR}/binaries"
3238
cp binary/amd64/crip "${SOURCE_DIR}/binaries/crip-amd64"
3339
cp 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
3642
if [ ! -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}")"
3956
fi
4057

4158
# Create debian packaging directory

0 commit comments

Comments
 (0)