feat(packaging): add ppa-ship.sh one-shot build and dput
Installs apt deps with sudo, then builds/signs/uploads as the real user. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
8ab55e2193
commit
4923129d10
3 files changed
+139
-12
No files matched your search
@@ -51,22 +51,29 @@ Debian packaging lives under repo-root `debian/` (this tree).
|
||||
- Debian revision: `X.Y.Z-1ppa1~SERIES` (SERIES = `noble`, `jammy`, …)
|
||||
- **Ext pack** SemVer (`ext/VERSION`) is **not** the deb version; bump deb only when CLI/stdlib packaging changes.
|
||||
|
||||
## Build source package (local)
|
||||
## One-shot (recommended)
|
||||
|
||||
In a normal terminal (sudo password + GPG passphrase when prompted):
|
||||
|
||||
```bash
|
||||
# from repo root, clean tree preferred
|
||||
./scripts/ppa-build-source.sh noble # or jammy
|
||||
# → ../build-area/marqdo_X.Y.Z-1ppa1~noble_source.changes
|
||||
cd ~/work/marqdo
|
||||
./scripts/ppa-ship.sh noble # install tools → debuild -S → dput
|
||||
# ./scripts/ppa-ship.sh resolute # if PPA enabled that series
|
||||
# ./scripts/ppa-ship.sh noble -n # build only, no upload
|
||||
```
|
||||
|
||||
The script vendors Cargo crates into `vendor/` (Launchpad builders have **no network**).
|
||||
`sudo ./scripts/ppa-ship.sh …` is OK: apt runs as root; build/sign/upload drop to `$SUDO_USER` so GPG still works.
|
||||
|
||||
## Upload
|
||||
## Build source package only
|
||||
|
||||
```bash
|
||||
./scripts/ppa-build-source.sh noble
|
||||
# → ../build-area/marqdo_X.Y.Z-1ppa1~noble_source.changes
|
||||
dput ppa:cflmy/marqdo ../build-area/marqdo_*_source.changes
|
||||
```
|
||||
|
||||
The build script vendors Cargo crates into `vendor/` (Launchpad builders have **no network**).
|
||||
|
||||
Wait for https://launchpad.net/~cflmy/+archive/ubuntu/marqdo/+builds
|
||||
|
||||
## Series strategy
|
||||
|
||||
@@ -79,12 +79,21 @@ cd "$PKG_ROOT"
|
||||
echo "==> debuild -S (key ${GPG_KEY})"
|
||||
debuild -S -sa -k"${GPG_KEY}" -d
|
||||
|
||||
echo "==> artifacts:"
|
||||
ls -la "$BUILD_AREA"/marqdo_"${DEB_VER}"* 2>/dev/null || ls -la ../marqdo_"${DEB_VER}"*
|
||||
CHANGES="$(ls -1 ../marqdo_${DEB_VER}_source.changes 2>/dev/null | head -1)"
|
||||
if [ -n "${CHANGES:-}" ]; then
|
||||
cp -f ../marqdo_"${DEB_VER}"* "$BUILD_AREA/" 2>/dev/null || true
|
||||
# debuild writes next to package parent (/tmp/marqdo-ppa/); collect into build-area
|
||||
mkdir -p "$BUILD_AREA"
|
||||
shopt -s nullglob
|
||||
for f in ../marqdo_"${DEB_VER}"* ../marqdo_"${VER}".orig.tar.*; do
|
||||
[ -e "$f" ] || continue
|
||||
cp -f "$f" "$BUILD_AREA/"
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
echo "==> artifacts in $BUILD_AREA:"
|
||||
ls -la "$BUILD_AREA"/marqdo_"${DEB_VER}"* "$BUILD_AREA"/marqdo_"${VER}".orig.tar.* 2>/dev/null || true
|
||||
CHANGES="$BUILD_AREA/marqdo_${DEB_VER}_source.changes"
|
||||
if [ -f "$CHANGES" ]; then
|
||||
echo
|
||||
echo "Upload with:"
|
||||
echo " dput ppa:cflmy/marqdo $BUILD_AREA/$(basename "$CHANGES")"
|
||||
echo " dput ppa:cflmy/marqdo $CHANGES"
|
||||
echo " # or: ./scripts/ppa-ship.sh ${SERIES}"
|
||||
fi
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/env bash
|
||||
# One-shot: install packaging tools → build signed source package → dput to Launchpad PPA.
|
||||
#
|
||||
# Run in YOUR terminal (needs sudo for apt + GPG passphrase for signing):
|
||||
# ./scripts/ppa-ship.sh # default series: noble
|
||||
# ./scripts/ppa-ship.sh resolute # match host /etc/os-release
|
||||
# ./scripts/ppa-ship.sh noble --no-upload
|
||||
# sudo ./scripts/ppa-ship.sh noble # also OK — build/sign/upload drop back to $SUDO_USER
|
||||
#
|
||||
# PPA: ppa:cflmy/marqdo | key: 505943294D04C803
|
||||
set -euo pipefail
|
||||
|
||||
SERIES="${1:-noble}"
|
||||
NO_UPLOAD=0
|
||||
for arg in "${@:2}"; do
|
||||
case "$arg" in
|
||||
--no-upload|-n) NO_UPLOAD=1 ;;
|
||||
*) echo "unknown arg: $arg" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
# Never cargo/debuild/dput as root — GPG lives in the human user's ~/.gnupg
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
if [ -z "${SUDO_USER:-}" ] || [ "$SUDO_USER" = root ]; then
|
||||
echo "error: run as a normal user, or: sudo -u \$USER ./scripts/ppa-ship.sh" >&2
|
||||
exit 1
|
||||
fi
|
||||
REAL_USER="$SUDO_USER"
|
||||
REAL_HOME="$(getent passwd "$REAL_USER" | cut -d: -f6)"
|
||||
echo "==> root detected; apt as root, build/upload as ${REAL_USER}"
|
||||
run_user() {
|
||||
local upath="${REAL_HOME}/.cargo/bin:/usr/local/bin:/usr/bin:/bin"
|
||||
sudo -u "$REAL_USER" -H --preserve-env=MARQDO_PPA_GPG_KEY \
|
||||
env HOME="$REAL_HOME" PATH="$upath" "$@"
|
||||
}
|
||||
APT=(apt-get)
|
||||
else
|
||||
REAL_USER="$(id -un)"
|
||||
REAL_HOME="$HOME"
|
||||
run_user() { "$@"; }
|
||||
APT=(sudo apt-get)
|
||||
fi
|
||||
|
||||
PPA_TARGET="${MARQDO_PPA:-ppa:cflmy/marqdo}"
|
||||
PKGS=(build-essential debhelper devscripts dput lintian
|
||||
dpkg-dev quilt cargo rustc pkg-config libssl-dev ca-certificates
|
||||
python3 xz-utils)
|
||||
|
||||
need_apt=0
|
||||
for bin in debuild dput dpkg-parsechangelog cargo gpg; do
|
||||
if ! command -v "$bin" >/dev/null 2>&1; then
|
||||
need_apt=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
# dh_auto_* comes from debhelper even if debuild exists from a partial install
|
||||
if ! dpkg -s debhelper >/dev/null 2>&1; then
|
||||
need_apt=1
|
||||
fi
|
||||
|
||||
if [ "$need_apt" -eq 1 ]; then
|
||||
echo "==> installing packaging toolchain (sudo)…"
|
||||
"${APT[@]}" update -qq
|
||||
DEBIAN_FRONTEND=noninteractive "${APT[@]}" install -y "${PKGS[@]}"
|
||||
else
|
||||
echo "==> packaging tools already present"
|
||||
fi
|
||||
|
||||
echo "==> building source package for series=${SERIES}"
|
||||
run_user "$ROOT/scripts/ppa-build-source.sh" "$SERIES"
|
||||
|
||||
VER="$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)"
|
||||
DEB_VER="${VER}-1ppa1~${SERIES}"
|
||||
BUILD_AREA="$(cd "$ROOT/.." && pwd)/build-area"
|
||||
CHANGES="${BUILD_AREA}/marqdo_${DEB_VER}_source.changes"
|
||||
|
||||
# ppa-build may leave artifacts next to /tmp/marqdo-ppa — copy already done; also scan
|
||||
if [ ! -f "$CHANGES" ]; then
|
||||
alt="$(ls -1 "$BUILD_AREA"/marqdo_*_source.changes 2>/dev/null | tail -1 || true)"
|
||||
if [ -n "${alt:-}" ]; then
|
||||
CHANGES="$alt"
|
||||
else
|
||||
echo "error: no *_source.changes under $BUILD_AREA" >&2
|
||||
ls -la "$BUILD_AREA" 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "==> artifact: $CHANGES"
|
||||
if command -v lintian >/dev/null 2>&1; then
|
||||
echo "==> lintian (non-fatal)"
|
||||
run_user lintian -i "$CHANGES" || true
|
||||
fi
|
||||
|
||||
if [ "$NO_UPLOAD" -eq 1 ]; then
|
||||
echo
|
||||
echo "Skip upload (--no-upload). When ready:"
|
||||
echo " dput ${PPA_TARGET} ${CHANGES}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "==> dput ${PPA_TARGET}"
|
||||
run_user dput --unchecked "${PPA_TARGET}" "$CHANGES"
|
||||
|
||||
echo
|
||||
echo "Done. Watch builds:"
|
||||
echo " https://launchpad.net/~cflmy/+archive/ubuntu/marqdo/+builds"
|
||||
echo "Enable the Ubuntu series (${SERIES}) in PPA → Change details if Launchpad rejects the upload."
|
||||
Reference in new issue
Block a user