fix(ppa): bundle Rust toolchain for noble Cargo.lock v4 builds

Document install channels (PPA/GitHub/CDN); release skill supports
full/cli/ext modes with R2+GitHub ext uploads and manual PPA commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-17 10:18:50 +08:00
1 parent f068b4ab75
commit e31585842d
16 files changed
+347 -213

No files matched your search

+65 -13
View File
@@ -2,6 +2,12 @@
# Build a signed Ubuntu *source* package for Launchpad PPA.
# Usage: ./scripts/ppa-build-source.sh [series]
# Example: ./scripts/ppa-build-source.sh noble
#
# Launchpad builders have no network and noble's cargo (1.75) cannot read
# Cargo.lock v4. This script therefore:
# 1) cargo vendor → vendor/
# 2) installs a modern Rust toolchain into third_party/rust (cached)
# 3) packs both into the .orig.tar.xz for offline debuild on Launchpad
set -euo pipefail
SERIES="${1:-noble}"
@@ -12,16 +18,39 @@ need() { command -v "$1" >/dev/null || { echo "missing tool: $1 (sudo apt instal
need cargo cargo
need debuild devscripts
need dpkg-parsechangelog dpkg-dev
need curl curl
need tar tar
need xz xz-utils
VER="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
DEB_VER="${VER}-1ppa1~${SERIES}"
# Debian revision comes from debian/changelog (e.g. 1.0.2-1ppa2); we append ~series.
CHG_VER="$(dpkg-parsechangelog -l debian/changelog -S Version)"
# Strip any previous ~series suffix from changelog version
BASE_DEB_VER="${CHG_VER%%~*}"
# If changelog still has old upstream, prefer Cargo VER for the upstream part
if [[ "$BASE_DEB_VER" != "$VER"-* ]]; then
# keep debian revision suffix after first '-' following VER if possible
REV="${BASE_DEB_VER#*-}"
if [[ "$BASE_DEB_VER" == *"-"* ]]; then
BASE_DEB_VER="${VER}-${REV}"
else
BASE_DEB_VER="${VER}-1ppa1"
fi
fi
DEB_VER="${BASE_DEB_VER}~${SERIES}"
PKG_ROOT="${TMPDIR:-/tmp}/marqdo-ppa/${VER}"
BUILD_AREA="${ROOT}/../build-area"
GPG_KEY="${MARQDO_PPA_GPG_KEY:-505943294D04C803}"
RUST_VER="${MARQDO_PPA_RUST_VERSION:-1.85.0}"
RUST_TRIPLE="${MARQDO_PPA_RUST_TRIPLE:-x86_64-unknown-linux-gnu}"
RUST_NAME="rust-${RUST_VER}-${RUST_TRIPLE}"
RUST_CACHE="${MARQDO_PPA_RUST_CACHE:-${HOME}/.cache/marqdo-ppa}"
RUST_TARBALL="${RUST_CACHE}/${RUST_NAME}.tar.gz"
RUST_URL="${MARQDO_PPA_RUST_URL:-https://static.rust-lang.org/dist/${RUST_NAME}.tar.gz}"
echo "==> upstream ${VER} → debian ${DEB_VER} (${SERIES})"
rm -rf "$PKG_ROOT"
mkdir -p "$PKG_ROOT" "$BUILD_AREA"
mkdir -p "$PKG_ROOT" "$BUILD_AREA" "$RUST_CACHE"
# Clean export of sources (no target/, .git)
if command -v git >/dev/null && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
@@ -33,9 +62,7 @@ fi
# Ensure debian/ from working tree (may be newer than last commit)
rsync -a "$ROOT/debian/" "$PKG_ROOT/debian/"
# Series-specific changelog entry (rewrite top distribution)
cd "$PKG_ROOT"
# Update changelog top line distribution / version if needed
python3 - <<PY
from pathlib import Path
import re
@@ -55,7 +82,6 @@ PY
echo "==> cargo vendor (Launchpad offline)"
mkdir -p .cargo
cargo vendor --locked vendor >/tmp/marqdo-cargo-vendor.conf
# cargo vendor prints config to stdout; also write known-good offline config
cat > .cargo/config.toml <<'EOF'
[source.crates-io]
replace-with = "vendored-sources"
@@ -64,16 +90,43 @@ replace-with = "vendored-sources"
directory = "vendor"
EOF
# Orig tarball: upstream version without debian/
echo "==> bundle Rust ${RUST_VER} (${RUST_TRIPLE}) for Launchpad"
if [ ! -f "$RUST_TARBALL" ]; then
echo " downloading ${RUST_URL}"
curl -fL --retry 3 --retry-delay 2 -o "${RUST_TARBALL}.partial" "$RUST_URL"
mv "${RUST_TARBALL}.partial" "$RUST_TARBALL"
else
echo " cache hit ${RUST_TARBALL}"
fi
rm -rf third_party/rust
mkdir -p third_party
RUST_EXTRACT="$(mktemp -d "${TMPDIR:-/tmp}/marqdo-rust.XXXXXX")"
tar -xzf "$RUST_TARBALL" -C "$RUST_EXTRACT"
# Official dist tarball contains install.sh
INSTALL_SH="$(find "$RUST_EXTRACT" -maxdepth 2 -name install.sh | head -1)"
if [ -z "$INSTALL_SH" ]; then
echo "error: install.sh not found in ${RUST_TARBALL}" >&2
exit 1
fi
# --disable-ldconfig avoids needing root; strip docs to save space
bash "$INSTALL_SH" \
--prefix="$PKG_ROOT/third_party/rust" \
--without=rust-docs \
--disable-ldconfig
rm -rf "$RUST_EXTRACT"
"$PKG_ROOT/third_party/rust/bin/rustc" --version
"$PKG_ROOT/third_party/rust/bin/cargo" --version
# Always rebuild orig (vendor + rust toolchain change every run)
cd "$(dirname "$PKG_ROOT")"
ORIG="marqdo_${VER}.orig.tar.xz"
if [ ! -f "$BUILD_AREA/$ORIG" ]; then
tar -cJf "$BUILD_AREA/$ORIG" \
--exclude=debian \
-C "$(dirname "$PKG_ROOT")" "$(basename "$PKG_ROOT")"
fi
# debuild expects ../marqdo_VER.orig.tar.xz relative to package dir parent
echo "==> packing ${ORIG} (vendor + third_party/rust)"
rm -f "$BUILD_AREA/$ORIG" "marqdo_${VER}.orig.tar.xz"
tar -cJf "$BUILD_AREA/$ORIG" \
--exclude=debian \
-C "$(dirname "$PKG_ROOT")" "$(basename "$PKG_ROOT")"
ln -sfn "$BUILD_AREA/$ORIG" "marqdo_${VER}.orig.tar.xz"
ls -lh "$BUILD_AREA/$ORIG"
cd "$PKG_ROOT"
echo "==> debuild -S (key ${GPG_KEY})"
@@ -84,7 +137,6 @@ mkdir -p "$BUILD_AREA"
shopt -s nullglob
for f in ../marqdo_"${DEB_VER}"* ../marqdo_"${VER}".orig.tar.*; do
[ -e "$f" ] || continue
# orig may already be a symlink into BUILD_AREA — skip same inode
if [ "$(realpath -m "$f")" = "$(realpath -m "$BUILD_AREA/$(basename "$f")")" ]; then
continue
fi
+9 -13
View File
@@ -73,20 +73,16 @@ 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
# Prefer changes matching this series; fall back to newest source.changes
CHANGES="$(ls -1t "$BUILD_AREA"/marqdo_*"~${SERIES}"_source.changes 2>/dev/null | head -1 || true)"
if [ -z "${CHANGES:-}" ]; then
CHANGES="$(ls -1t "$BUILD_AREA"/marqdo_*_source.changes 2>/dev/null | head -1 || true)"
fi
if [ -z "${CHANGES:-}" ] || [ ! -f "$CHANGES" ]; then
echo "error: no *_source.changes under $BUILD_AREA" >&2
ls -la "$BUILD_AREA" 2>/dev/null || true
exit 1
fi
echo "==> artifact: $CHANGES"