Skip to content
This repository was archived by the owner on Oct 31, 2026. It is now read-only.

Commit 088b219

Browse files
committed
Wire VERSION_SUFFIX through to the packages so rebuilds upgrade
The build-weekly version_suffix input only reached the in-app version string; package.sh hardcoded the -1 revision, so a rebuilt .deb carried the same version and pkg upgrade (rightly) offered nothing. package.sh now takes VERSION_SUFFIX (validated positive integer), the workflow passes it, and make package accepts SUFFIX=.
1 parent a789785 commit 088b219

6 files changed

Lines changed: 49 additions & 13 deletions

File tree

‎.github/workflows/build-weekly.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ jobs:
307307
- name: Package (zip, deb, pacman)
308308
env:
309309
UPSTREAM_TAG: ${{ needs.resolve.outputs.upstream_tag }}
310+
VERSION_SUFFIX: ${{ needs.resolve.outputs.version_suffix }}
310311
run: bash scripts/package.sh
311312

312313
- name: Upload artifacts

‎Makefile‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# make lint
1111
# make check-vendor
1212
# make vendors [VENDORS=all|libopentui|pty] [FORCE=0|1]
13-
# make package UPSTREAM_TAG=v2.0.24 [WORKSPACE=...] [WORK=...] [OUT=...]
13+
# make package UPSTREAM_TAG=v2.0.24 [WORKSPACE=...] [WORK=...] [OUT=...] [SUFFIX=2]
1414
# make apt-repo [REPO_DIR=apt-repo] [OUT=out] [SIGN=1] [KEEP=4]
1515
# make clean
1616

@@ -21,6 +21,7 @@ FORCE ?= 0
2121
WORKSPACE ?= $(CURDIR)
2222
WORK ?= $(CURDIR)/work
2323
OUT ?= $(CURDIR)/out
24+
SUFFIX ?= 1
2425
APT_REPO_DIR ?= $(CURDIR)/apt-repo
2526
SIGN ?= 1
2627
KEEP ?= 4
@@ -52,7 +53,7 @@ vendors:
5253

5354
package:
5455
@if [ -z "$(UPSTREAM_TAG)" ]; then echo "usage: make package UPSTREAM_TAG=v2.0.24" >&2; exit 1; fi
55-
UPSTREAM_TAG="$(UPSTREAM_TAG)" WORKSPACE="$(WORKSPACE)" WORK="$(WORK)" OUT="$(OUT)" bash scripts/package.sh
56+
UPSTREAM_TAG="$(UPSTREAM_TAG)" VERSION_SUFFIX="$(SUFFIX)" WORKSPACE="$(WORKSPACE)" WORK="$(WORK)" OUT="$(OUT)" bash scripts/package.sh
5657

5758
apt-repo:
5859
bash scripts/apt-repo.sh --repo "$(APT_REPO_DIR)" --keep "$(KEEP)" \

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ make test # bats suite (TEST=install for one suite)
224224
make lint # shellcheck (+ actionlint if installed)
225225
make check-vendor # golden checksum + ELF gates for vendor/
226226
make vendors # verify vendor cache, stage natives into out/
227-
make package UPSTREAM_TAG=v2.0.24 # zip/deb/pacman from a prebuilt CLI
227+
make package UPSTREAM_TAG=v2.0.24 # zip/deb/pacman from a prebuilt CLI (SUFFIX=2 for a packaging-only rebuild)
228228
make apt-repo # signed APT repo from out/*.deb (SIGN=0 skips gpg)
229229
make clean # remove work/, out/, upstream/, dist/
230230
```

‎scripts/package.sh‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# (The Termux paths inside are install *targets*, not the build host.)
44
# Runs on Linux x86_64 CI and anywhere with zip/dpkg-deb/xz (incl. Termux);
55
# `make package UPSTREAM_TAG=...` is the local entry point.
6-
# Env: REPO_ROOT, UPSTREAM_TAG (e.g. v2.0.24).
6+
# Env: REPO_ROOT, UPSTREAM_TAG (e.g. v2.0.24), VERSION_SUFFIX (e.g. 2).
77
# Inputs: $WORKSPACE/dist/cli/cli-linux-arm64-android/bin/opencode (from build).
88
# The renderer is embedded in the binary (bionic lib swapped into the npm musl
99
# slot pre-build), so packages carry no sidecar .so.
@@ -15,6 +15,13 @@ WORK="${WORK:-$REPO_ROOT/work}"
1515
OUT="${OUT:-$REPO_ROOT/out}"
1616
UPSTREAM_TAG="${UPSTREAM_TAG:?set UPSTREAM_TAG, e.g. v2.0.24}"
1717
VER="${UPSTREAM_TAG#v}"
18+
# Debian/pacman revision: rebuilding the same upstream tag with new patches
19+
# bumps this (2.0.24-1 -> 2.0.24-2) so apt/pacman see a newer version.
20+
# CI passes the build-weekly `version_suffix` input here; without it the
21+
# rebuilt .deb would carry the same version and `pkg upgrade` would (rightly)
22+
# offer nothing.
23+
VERSION_SUFFIX="${VERSION_SUFFIX:-1}"
24+
case "$VERSION_SUFFIX" in ''|*[!0-9]*|0) echo "VERSION_SUFFIX must be a positive integer" >&2; exit 1 ;; esac
1825

1926
CLI_BIN="$WORKSPACE/dist/cli/cli-linux-arm64-android/bin/opencode"
2027
test -x "$CLI_BIN" || { echo "missing CLI binary: $CLI_BIN" >&2; exit 1; }
@@ -82,9 +89,10 @@ ln -sf opencode2 "$PKGROOT/data/data/com.termux/files/usr/bin/opencode"
8289
mkdir -p "$PKGROOT/data/data/com.termux/files/usr/share/doc/opencode2"
8390
cp -f "$STAGE/LICENSE" "$PKGROOT/data/data/com.termux/files/usr/share/doc/opencode2/"
8491

85-
# `-1` Debian revision: packaging-only fixes bump it (2.0.24 -> 2.0.24-2) so
86-
# dpkg/apt see a newer version instead of "same version, nothing to do".
87-
DEB="$OUT/opencode2_${VER}-1_aarch64.deb"
92+
# The Debian revision comes from $VERSION_SUFFIX: packaging-only fixes bump
93+
# it (2.0.24-1 -> 2.0.24-2) so dpkg/apt see a newer version instead of
94+
# "same version, nothing to do".
95+
DEB="$OUT/opencode2_${VER}-${VERSION_SUFFIX}_aarch64.deb"
8896
DEBDIR="$WORK/deb"
8997
rm -rf "$DEBDIR"
9098
mkdir -p "$DEBDIR/DEBIAN"
@@ -103,7 +111,7 @@ fi
103111
INSTALLED_SIZE=$(du -sk "$DEBDIR/data" | cut -f1)
104112
cat > "$DEBDIR/DEBIAN/control" <<DEOF
105113
Package: opencode2
106-
Version: ${VER}-1
114+
Version: ${VER}-${VERSION_SUFFIX}
107115
Architecture: aarch64
108116
Maintainer: opencode-android <noreply@example.com>
109117
Installed-Size: ${INSTALLED_SIZE}
@@ -191,10 +199,10 @@ chmod 755 "$DEBDIR/DEBIAN/postinst" "$DEBDIR/DEBIAN/prerm" "$DEBDIR/DEBIAN/postr
191199
dpkg-deb -b "$DEBDIR" "$DEB" >/dev/null
192200
ls -lh "$DEB"
193201

194-
PACMAN="$OUT/opencode2-${VER}-1-aarch64.pkg.tar.xz"
202+
PACMAN="$OUT/opencode2-${VER}-${VERSION_SUFFIX}-aarch64.pkg.tar.xz"
195203
cat > "$PKGROOT/.PKGINFO" <<PEOF
196204
pkgname = opencode2
197-
pkgver = ${VER}-1
205+
pkgver = ${VER}-${VERSION_SUFFIX}
198206
pkgdesc = OpenCode AI coding assistant for Android/Termux
199207
url = https://github.com/anomalyco/opencode
200208
builddate = $(date +%s)

‎tests/helpers.bash‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,14 @@ make_foreign_opencode() {
211211

212212
# ── package.sh driver ──────────────────────────────────────────────────
213213
# Build the real artifacts once per bats file. $1 = scratch dir (use
214-
# $BATS_FILE_TMPDIR); the output lands in "$1/out".
214+
# $BATS_FILE_TMPDIR); the output lands in "$1/out". $2 = package revision
215+
# (VERSION_SUFFIX, default 1).
215216
build_artifacts() {
216-
local base="$1"
217+
local base="$1" suffix="${2:-1}"
217218
write_stub_cli "$base/ws/dist/cli/cli-linux-arm64-android/bin/opencode" "9.9.9-test"
218219
if ! env WORK="$base/work" OUT="$base/out" WORKSPACE="$base/ws" \
219-
UPSTREAM_TAG=v9.9.9 bash "$REPO_ROOT/scripts/package.sh" \
220+
UPSTREAM_TAG=v9.9.9 VERSION_SUFFIX="$suffix" \
221+
bash "$REPO_ROOT/scripts/package.sh" \
220222
> "$base/package.log" 2>&1; then
221223
echo "package.sh failed:" >&2
222224
cat "$base/package.log" >&2

‎tests/package.bats‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,30 @@ PKG="$OUT/opencode2-9.9.9-1-aarch64.pkg.tar.xz"
8989
assert_contains "$(cat "$ctl/postrm")" 'rm -rf "$PREFIX/libexec/opencode2"'
9090
}
9191

92+
@test "VERSION_SUFFIX=2 produces -2 revisions in deb and pacman names" {
93+
# A packaging-only rebuild of the same upstream tag must yield a higher
94+
# version, or apt/pacman (rightly) offer no upgrade.
95+
build_artifacts "$BATS_FILE_TMPDIR/suf2" 2
96+
local deb="$BATS_FILE_TMPDIR/suf2/out/opencode2_9.9.9-2_aarch64.deb"
97+
local pkg="$BATS_FILE_TMPDIR/suf2/out/opencode2-9.9.9-2-aarch64.pkg.tar.xz"
98+
assert_file_exists "$deb"
99+
assert_file_exists "$pkg"
100+
101+
run dpkg-deb -f "$deb" Version
102+
assert_success
103+
assert_contains "$output" "9.9.9-2"
104+
105+
run tar -xOf "$pkg" .PKGINFO
106+
assert_success
107+
assert_contains "$output" "pkgver = 9.9.9-2"
108+
}
109+
110+
@test "package.sh rejects a non-positive VERSION_SUFFIX" {
111+
run env UPSTREAM_TAG=v9.9.9 VERSION_SUFFIX=0 bash "$REPO_ROOT/scripts/package.sh"
112+
assert_failure
113+
assert_contains "$output" "VERSION_SUFFIX must be a positive integer"
114+
}
115+
92116
@test "pacman archive ships .PKGINFO, the install script and the Termux layout" {
93117
run tar -tf "$PKG"
94118
assert_success

0 commit comments

Comments
 (0)