Repository navigation
tools/pkg-version: count package versions from main's history - #690
robotosaith wants to merge 22 commits into
Conversation
Every PR bumped its packages' version files, and open PRs kept taking the same number: two branches that write the same version line merge without a conflict, so the second shipped new contents under a published number unless a review caught it (review lessons L-12, L-404, L-426, L-477), and the fixes were renumber commits, "main merged" commits on contributors' branches, or a follow-up PR (derekross#683). tools/pkg-version works the version out instead. The version file gives the series (its first two numbers); on main's first-parent line every commit that touches packages/<name> is the next number. The count starts at the commit that adds this tool, from the version file as it stood then, so no published number comes back, and a third number in the file is read as a floor only, so an old-style bump changes nothing (an equal or lower one) or lifts the count (a higher one). A build off main is main's version at the merge base plus the branch's commits and the commit (0.2.130.1.g4f2a9c1), which pacman orders between main's 0.2.130 and 0.2.131; a package or series main doesn't have yet builds as 0.1.0pre1.g<commit>, below main's first 0.1.0. --commit maps a version back to the commit it was built from (derekross#689). The build container and the phone get no .git, so build-packages, repo-build and phone-install-package copy a package through tools/lib/pkg-tar.sh, which adds the version as .pkgver; without the history (a shallow clone, a copy) it refuses rather than guess. CI's test job checks out the full history for the count. tests/pkg-version covers the cases in a scratch repository (two PRs that both wrote one number land as two, a merge commit counts once, branch builds, the refusals; pacman's order with vercmp where pacman is) and replays this repository's history as if the count had started at its first commit: 30 packages over 382 commits, every commit a new number and none below its version file's. The same replay shows what the old scheme did: 61 times a package changed on main without a new number, 12 of them in files the package ships. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 30 packages whose PKGBUILD read pkgver from their version file read it from .pkgver when a build tool made a copy, and from tools/pkg-version otherwise. omamobile-keyring (a date the index names) and linux-omamobile (pkgrel only) keep their own schemes; the upstream builds keep their pinned versions. omamobile-remote printed a version written into its script, which had to match the version file by hand (L-640); install now writes the package's pkgver into it. omamobile-voice's test compares pkgver with tools/pkg-version instead of the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Subjects drop the version, the PR template asks for no bump, and CONTRIBUTING §6.3 says how versions come about now: the series in the version file, one number per commit on main, a branch build's suffix, and that a dependency on a change not yet on main names a version main has shipped or a provides name. AGENTS lists the tool; RELEASES §7 and the packages stage read the version from it; the reviewer agent checks for no bump. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The history skips a commit whose version file doesn't parse, so a HEAD with "0.2-beta" in it built under the number of the commit before: new contents under a published version, the collision the tool exists to end. The version path now checks the file at the commit it builds and refuses, as the branch path already did. tests/pkg-version covers it, and its --main case compares the output instead of piping it into grep -q (AGENTS, Userspace). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A version tools/pkg-version can't work out (a version file that doesn't parse) stopped the whole build through pkg_tar's alarm_die, and with it the nightly publish for every phone (review lesson L-420). It is now checked with the boot files before anything is built: that package is skipped and named, the rest is built and signed, and the run exits 3 with the package in .skipped, which repo-publish already treats as "publish the rest, then fail". The messages name both reasons. tests/stage-boot-files adds such a package to its skip run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 packages install their version file under /usr/share/omamobile, and runbooks read it on the phone (SUSPEND-PLAN cats device-cheetah's and the shell's); with versions counted, the file only gives the series and a stale third number. Each PKGBUILD now hands pkgver to install as OMAMOBILE_PKGVER, and install writes it over the copy (without it, as in the package tests, the file is copied as before). omamobile-remote takes its printed version the same way instead of a second argument. omamobile-voice's test compared pkgver with tools/pkg-version, which a build tool's copy doesn't have (makepkg's check() on the phone or in the container); it reads .pkgver there. Every package's test/all in a copy without the repository now gives the same results as main's. tests/pkg-version checks that every package shipping the file hands pkgver over, and runs the installs that need no build (10 of 23). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A build of edits not committed yet got the commit's version, so build-packages took the package as up to date and skipped it, and the phone got a build of different contents under a published number. Before this change, the hand-written bump avoided that only because the contributor bumped as they edited. Without --rev, the package's tree as it stands (tracked and new files, gitignored ones left out) is compared with HEAD's; when they differ, its tree id is added: 0.2.130.d5e0b7a2. pacman orders it above the commit's build and below the next commit's (checked with vercmp), each edit is a new version, and undoing the edits gives the commit's version back. A package not committed at all builds as 0.1.0pre0.d<tree>, below its first commit's 0.1.0pre1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With versions counted by tools/pkg-version, a build off main carries .g<commit> and a build of edits not committed yet carries .d<tree>. Both sort above the published build, so if the maintainer's out/repo held one from local testing and was published as it stood (--no-build development), every phone would take it over main's on the next update. stage() now refuses an index that lists one, before it copies anything, and names it; --from-main rebuilds main's version over it. The pattern matches only tools/pkg-version's 7-digit form, so the release kernel's 12-digit .g<commit> passes, and the test checks both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The images and packages stages stopped with "bump packages/<device package>/version" when the boot files were stale and out/repo already had the current version. With versions counted by tools/pkg-version, a hand-written bump is no longer how a package gets a new version: any commit under the package is, and boot files are gitignored, so staging them alone gives none. The stages now ask for a commit under the device package, and print the next number to write into its version file when there is nothing else to change (read as a floor, that commit gives exactly that number). tests/release checks both lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nted RELEASES §7.1 describes the change over: before the merge the version files are the published versions; the merge commit starts the count and moves every counted package one number up (published once by the next nightly); pull requests opened before it merge as they are, with a bump above the count taken as a floor; the third numbers stay as floors until the maintainer cuts the files to their series; and going back means writing the counted versions into the files first, since their stale numbers sit below what phones have. CONTRIBUTING and AGENTS now say a commit subject carries no version (it isn't known until the merge), a doc names a version only once main has shipped it, and which packages still carry hand-written versions (those built from another project's release, the kernel and the keyring). AGENTS' commit subject example lost its version, its pkg-version row gains .d<tree>, and the reviewer agent checks subjects and docs too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
To be clear, this is a change to how everyone contributes, so it's your call. If you'd rather keep hand-written versions, or want only parts of this (say, just the uncommitted-edits fix in |
…rsion
Both run tools/build-packages in a copy of the repository, which since
tools/pkg-version sources tools/lib/pkg-tar.sh. The copies lacked it, so
build-packages stopped at its source line ("No such file or directory")
and release-signing's first refusal check failed in CI. Both skip on a
machine without repo-add, which is how this was missed before the push.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @robotosaith. You have read the problem right: the same version number written by two pull requests has cost every round a check and still slipped through, and this is a complete answer to it, not a sketch: the replay of our own history, the floor for old-style bumps, the refusal to publish a branch build, the version a package prints. Thank you also for saying up front that it's my call. It is a change to how everyone contributes and to how I release, and my answer is: not as it stands, and yes with the first four points below settled. The first one decides it. Here is what I checked. I merged it onto today's main in a scratch tree.
Smaller things, for the discussion rather than the diff:
So: points 1 to 4, and I'll look at it again. If you'd rather land a part first, the two I'd take on their own are the refusal to publish a build that isn't main's, and uncommitted edits getting their own version. I'll note the same on #689. |
Review of derekross#690: the count started at the commit that added the tool, found by its path, so moving tools/pkg-version restarted every count from the stale version files (0.2.130 back to 0.2.126, a published number for other contents, with nothing failing). And OMAMOBILE_PKGVER_SINCE, meant for the history replay, moved every counted version when it was set in a build's environment. A commit now counts when its PKGBUILD, as that commit has it, reads .pkgver; before that the version file is the version. The start is the package's opt-in, which a move of the tool can't change: moving it touches the PKGBUILDs, one more number. A package that keeps a written version simply never counts. The replay takes --count-from on the command line, with --history only; the environment variable is gone. pkg_tar finds a counted PKGBUILD by the same .pkgver line. tests/pkg-version adds a package that keeps its written version, a move of the tool, the old variable ignored and --count-from refused outside --history. tests/all runs the suite and parses the tool on lines of their own at the end, not in the long for lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of derekross#690: this package carries the boot files release phones write to slot B, and its version is the maintainer's switch: changes to initramfs/init or src/ merge without one, and the version is written only after an image built from them has booted on the 7 Pro. Counted, any merge under the package (a README included) would have been a new version at the next nightly, and tools/release's hint brought the hand-written number back for exactly this case. Its PKGBUILD reads version again, so tools/pkg-version never counts it, like linux-omamobile and omamobile-keyring; tests/pkg-version fails if a package with OMAMOBILE_BOOT_FILES in its install reads .pkgver. tools/release and RELEASES' images stage are main's again (bump the version). RELEASES §7.1 says how the count starts (29 packages), and drops the sentence retiring review lessons, which is the maintainer's to change; CONTRIBUTING says how a fork counts against this repository's main (OMAMOBILE_MAIN_REF). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of derekross#690: the maintainer changes the reviewer's checklist himself if counted versions land. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/release went back to asking for a device-package version bump (the device package that ships boot files keeps a written version), so its test expects main's text again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the thorough look, and for trying it on a scratch tree. All five are in (merged with today's main):
From your smaller notes, CONTRIBUTING now tells forks to use |
|
Thank you, @robotosaith. All five points are in, and the two I cared most about are done better than I asked: the count starts at each package's own opt-in rather than at a recorded commit, and the test fails if a package that ships boot files is ever counted. I checked it merged onto today's main: Two things before I can merge it: 1. It conflicts with main again, in 2. A commit that a merge brought into main gets a plain number. So a build from inside a merged branch has a number main gives to other contents, without the - if git merge-base --is-ancestor "$rev" "$main"; then
+ # On main's own line (its first parents), not merely reachable from it: a
+ # commit a merge brought in is a branch build of the commit it left main at
+ local id later
+ id=$(git rev-parse "$rev^{commit}")
+ if git rev-list --first-parent "$main" | grep -c -x -F "$id" >/dev/null; then
v=$(walk "$rev" | tail -1 | cut -d' ' -f2)
[[ -n $v ]] || die "$path/version doesn't hold a version (0.2 or 0.2.5) at $rev"
echo "$v"
return 0
fi
base=$(git merge-base "$rev" "$main") || die "$rev shares no history with $main"
+ if [[ $base == "$id" ]]; then
+ later=$(git rev-list --first-parent "$main" "^$id" | tail -1)
+ base=$(git rev-parse "$later^1")
+ fiWith it c1 and c2 build as Smaller things, for this push if you can:
I went through the open pull requests: none depends on a version main hasn't shipped, so the dependency caveat in §7.1 has no case today, and only three version hunks would act as floors (omamobile-modem 0.1.24 and 0.1.25, omamobile-modem-sit 0.3.37). When it merges is mine to pick: the merge moves 29 packages one number up and the next nightly republishes them all once, so I'll place it at the end of a round's merges rather than in the middle. |
# Conflicts: # AGENTS.md # tests/all
committed() took a commit for main's when main could reach it, but the count runs on main's first-parent line, so a commit inside a branch that a merge commit brought in got a number main gives to other contents, with no .g<commit> for repo-publish to refuse. It now asks whether the commit is on that line, and otherwise builds it as a branch of the commit it left main at (the maintainer's fix on derekross#690). tests/pkg-version checks out both commits of the merged pr-c: 0.3.3.1.g… and 0.3.3.2.g…. It also fails when a PKGBUILD reads a written version and isn't on the short list that keeps one (device-cheetah, the keyring), so a new package copied from an older PKGBUILD can't stay on one unnoticed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pkg_version() sourced the PKGBUILD in place, which reads a .pkgver in the directory before asking the tool, while pkg_tar ships the fresh number. A .pkgver left there (the tool's own message suggests passing a version that way) would have kept a package "up to date" on the publish machine for good. For a PKGBUILD that reads .pkgver it now asks tools/pkg-version, as pkg_tar does; tests/build-packages-host-tools leaves a stale .pkgver and an old build in the repository and expects "to build". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shell's 0.2.126 to 0.2.127 was already off by one as main moved, so §7.1 says only that the 29 packages move one up. A respin built from a branch is a branch build that repo-publish refuses unless the build names that branch as its main line: the bundle row says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for trying the merge case, @derekross. All in on
Smaller things:
The affected suites pass in the Arch container, and |
|
Thank you, @robotosaith. Every point from my last comment is in: the first-parent fix with its own test (and with the fix taken out, your test fails at the merged branch's first commit, as it should), That list check earned its keep straight away. Main gained a new package after your push, 1. Main moved again, and the branch now conflicts in five files: 2. Convert --- a/packages/omamobile-install-link/PKGBUILD
-pkgver=$(cat "${startdir:-.}/version")
+pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}")
package() {
cd "omamobile-installer-$_commit"
- "$startdir/install" "$pkgdir" "$PWD" "$PWD/target/release"
+ OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$PWD" "$PWD/target/release"
--- a/packages/omamobile-install-link/install
install -Dm644 version "$d/usr/share/omamobile/install-link/version"
+# The package's own version (tools/pkg-version), which the file's
+# series doesn't give
+[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$d/usr/share/omamobile/install-link/version"With both, on the merge: When it lands is still mine to choose, as I said: the merge moves 30 packages one number up and the next nightly republishes them all, so I'll put it at the end of a round's merges. Thanks for the patience with a pull request that main keeps moving under. |
# Conflicts: # AGENTS.md # docs/RELEASES.md # packages/omamobile-device-cheetah/install # tests/all # tools/build-packages
Main gained the package (derekross#743) after the branch's conversion, and tests/pkg-version refuses a PKGBUILD that reads its written version without being on the list. pkgver now comes from .pkgver or tools/pkg-version, and install writes it over the shipped version file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, @derekross, and for checking the merge against #743 before I'd seen it. Both are in:
Landing it at the end of a round is fine with me. |
|
On when: this lands after the 2026.11.15 release. It moves 30 packages up a number and the next nightly republishes them all, and I don't want the release candidate's package set to shift under it. Please do the re-merge of main and the conversion of the package main added since. Once the release is published I'll merge it, and I'll say here when. |
|
Thank you, @robotosaith, and sorry for the crossed wires: my comment this afternoon asked again for the re-merge and the One small thing has come up since: main merged #814 after your push, and it rewrote the As I said, this lands after the 2026.11.15 release is published, and I'll say here when. If main moves again before then I'm happy to do that last merge myself as a commit on top of your branch, so you don't have to keep chasing it. |
What and why
Fixes #689. Package versions are no longer written in pull requests.
tools/pkg-versionkeeps the series from eachversionfile (its first two numbers, such as 0.2) and counts the commits onmainthat touched the package, starting from the number the file holds today, so no published version comes back and two merges can't ship one number. A branch builds as<main's version>.<n>.g<commit>and uncommitted edits as.d<tree>, which pacman orders betweenmain's builds;tools/repo-publishrefuses both. A third number inversionstill works as a floor, so contributors can keep their old habit for a while.The switch. Nothing is renumbered by hand. Until this merges, the
versionfiles are the published versions. A commit counts when the package's own PKGBUILD reads.pkgver, so the start is each package's opt-in, not the tool's path (moving the tool is one more number, never a restart). The merge commit makes 29 PKGBUILDs opt in, so each of those packages moves one number up and the next nightly republishes them once. Open pull requests that still bump merge as they are: a number at or below the count changes nothing, and one above it is taken as a floor (drop that hunk unless you want the jump). The old third numbers stay in the files while people adjust; cutting them to0.2later is your call. Going back would mean writing the counted versions into the files first. RELEASES §7.1 has the details; CONTRIBUTING §6.3 and AGENTS are updated, commit subjects no longer carry a version, and the packages built from another project's release, the kernel, the keyring andomamobile-device-cheetahkeep hand-written versions. device-cheetah ships the boot files release phones write to slot B, so its version stays yours to write after they have booted on the 7 Pro;tests/pkg-versionfails if a package withOMAMOBILE_BOOT_FILESis ever counted. The reviewer agent and the review lessons are left for you.Builds without git history (the container, the phone) get the version as
.pkgverfromtools/build-packages,repo-buildandphone-install-package. The installed/usr/share/omamobile/*/versionfiles hold the real version.Device and build
uname -r): n/aversionnow read the counted version (omamobile-device-cheetahkeeps readingversion); noversionfile changedChecks (no phone needed)
tools/pr-check origin/mainpassestests/allpasses;tests/pkg-versionreplays this repository's history from its first commit (29 packages, 420 commits: every commit a new number, none below its file's)tests/packages: every package'stest/allgives the same results in a standalone copy as onmainversionbumpedCo-Authored-By:trailerOn the phone
makepkgwas run from a copy in an Arch Linux container, and pacman's order was checked withvercmpuserdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)🤖 Generated with Claude Code