diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 2ca376343..07b845261 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -21,7 +21,7 @@ partition contents: use placeholders such as . - [ ] `tools/pr-check origin/main` passes - [ ] `tests/all` passes - [ ] `tests/packages` passes (or the packages I touched: ...) -- [ ] Each changed package has its `version` bumped, and the new version is in the commit subject +- [ ] No package `version` bumped: the version is counted at merge (`tools/pkg-version`, CONTRIBUTING §6.3) - [ ] Commits have area prefixes and bodies that say why; any AI help is a `Co-Authored-By:` or `Assisted-by:` trailer, never a `Signed-off-by:` ## On the phone diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0b4a48e6f..30e4217b7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -59,6 +59,10 @@ jobs: node --version fi - uses: actions/checkout@v5 + with: + # The packages' versions are counted from main's history + # (tools/pkg-version), and origin/main is the line they count on + fetch-depth: 0 - name: A normal user (some tests check what a user may not do) run: | useradd -m ci diff --git a/.gitignore b/.gitignore index 14b43f718..ebc8a802e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ logs/ # Python bytecode from running package code in place __pycache__/ *.pyc + +# A package version worked out for a build without git (tools/lib/pkg-tar.sh) +packages/*/.pkgver diff --git a/AGENTS.md b/AGENTS.md index 25acda816..81b67d3f1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -43,7 +43,7 @@ Omarchy Mobile runs native Omarchy (Arch Linux ARM, Hyprland, Omarchy's packages - **Kernel branches:** one subsystem per branch (`omamobile-`). `omamobile` on GitHub is the one source of the release kernel: community pull requests land there as rebase merges, the maintainer's curated, signed-off commits land as a fast-forward of a local release branch built on the current `github/omamobile` (`tools/publish-kernel`), and releases are tags on it (`kernel-`, [RELEASES](docs/RELEASES.md) §8). It is never rewritten or force-pushed. `omamobile-int` is a local integration branch for test kernels only, no longer published and no release source. Don't rebase or force-push branches someone else is merging from. - **Commit messages:** - Kernel commits are upstream-style: the subsystem prefix from `git log --oneline `, the why, and the evidence. AI agents never add `Signed-off-by:` (`Documentation/process/coding-assistants.rst`): the human signs off. - - This repository uses an area prefix (`omamobile-gnss: …`, `device-cheetah 0.1.15: …`, `DISPLAY-PLAN: …`), a body that explains why, and the attribution trailer the session asks for. + - This repository uses an area prefix (`omamobile-gnss: …`, `omamobile-device-cheetah: …`, `DISPLAY-PLAN: …`; no package version, which is counted at merge), a body that explains why, and the attribution trailer the session asks for. - **Reviewing pull requests:** use the `omamobile-reviewer` agent (`.claude/agents/omamobile-reviewer.md`), one PR (or a few related ones) per run. It reads the review lessons ([docs/review/LESSONS.md](docs/review/LESSONS.md) is their index, the entries are in `docs/review/lessons/`), runs `tools/pr-check` or `tools/kernel-pr-check`, and returns a verdict, a draft comment and candidate lessons. Nothing is posted until the maintainer says so; confirmed lessons (and corrections, when a review was wrong) are added to the lesson files in a `docs/review: …` commit, so the next review knows them. - **Commit only your own files when others have uncommitted work**, with a temporary index: @@ -57,7 +57,8 @@ Omarchy Mobile runs native Omarchy (Arch Linux ARM, Hyprland, Omarchy's packages ``` This leaves other people's staged and unstaged changes alone. -- **Moving a feature from bring-up into a package:** bump the package `version`, enable nothing that isn't hang-safe, and delete the bring-up files from `/etc/modprobe.d` on the phone (`omamobile-*-bringup.conf`, and any hand-copied package file). A file in `/etc/modprobe.d` replaces the package's `/usr/lib/modprobe.d` file of the same name, so a stale `omamobile-aoc.conf` there hid the package's new blacklist. +- **Package versions are counted, never written** ([CONTRIBUTING](CONTRIBUTING.md) §6.3): don't change a package's `version` file except to start a new series, and don't put a version in a commit subject. A doc or plan written in a pull request can't know the number its change will ship as: name the pull request or the commit, and add the number (`tools/pkg-version --history `) once `main` has it. Versions already in the docs (`omamobile-modem` 0.1.15+) are published ones and stay right. The packages built from another project's release (Mesa, Hyprland, libcamera and the others whose PKGBUILD sets `pkgver` itself), `linux-omamobile`, `omamobile-keyring` and `omamobile-device-cheetah` (its boot files get a version only after they have booted on the 7 Pro) still carry hand-written versions. +- **Moving a feature from bring-up into a package:** enable nothing that isn't hang-safe, and delete the bring-up files from `/etc/modprobe.d` on the phone (`omamobile-*-bringup.conf`, and any hand-copied package file). A file in `/etc/modprobe.d` replaces the package's `/usr/lib/modprobe.d` file of the same name, so a stale `omamobile-aoc.conf` there hid the package's new blacklist. - **Kernel releases change with every push** (`7.3.0-rc6-omamobile-push1-NNNNN-g`). `bin/omamobile push` runs `modules-push` when the tarball's checksum differs. Without its modules a new kernel boots without its drivers, the GPU among them. `modules-push` replaces `/usr/lib/modules/` as a whole; on the 9a that once took a hand-installed panel driver with it, and the display stayed on the boot logo. It now refuses when the folder holds modules added or swapped by hand since the last push (it records what each push installed in `.omamobile-modules.sha256`), and `OMAMOBILE_MODULES_REPLACE=1` overrides that, wiping them. Pin a daily release whose folder carries hand-installed modules (`/usr/lib/modules/.omamobile-pinned`), and keep a copy before overriding (`tar -C /usr/lib/modules -cf … `). - **Stop the modem before a `push` or a `reboot-to`.** `push` ends in `reboot-to`, a raw reboot syscall that stops no unit, so `omamobile-modem.service` never runs its clean stop and its `modem-up` marker stays. On the 7 Pro, where the modem starts at boot (device-cheetah 0.1.43+), the next boot counts that as an unclean end ("ended without a clean stop: a hang or a reset"); from `omamobile-modem` 0.1.19 it starts the modem all the same (before, it skipped the modem once), and a second such end before a clean stop holds it off until `omamobile-modem-start --retry`. So a skipped stop no longer costs a boot's modem, but it uses up the one unclean end the guard allows. This happened on 2026-11-08 after a `reboot-to bootloader` taken to charge a flat battery. So run `systemctl stop omamobile-modem` first, as part of the reboot the human said yes to; a reboot that needs no reason can be `systemctl reboot` instead, which stops it. The stop powers the CP off (one recovered UFS error-handler pass, as any reboot with the modem up costs) and, with the NV overlay on, captures its writes. For now it takes about 40 s and ends as "failed", with the CP's power-off logged as a crash; the marker is still removed ([#532](https://github.com/derekross/omarchy-mobile/issues/532)). This is not the restart the modem notes below forbid: nothing starts the modem again before the reboot. From `omamobile-modem` 0.1.21, with a device package whose `reboot-to` notes the boot it ends ([#403](https://github.com/derekross/omarchy-mobile/pull/403)), the next boot doesn't count a marker from that boot, so a `reboot-to` no longer uses up the unclean end (one already counted stays counted); the CP's ordered power-off and the NV capture still come only from the unit's stop, so the rule stands. [MODEM-PLAN](device/cheetah/MODEM-PLAN.md) M4.6b @@ -105,6 +106,7 @@ tools/phone-ssh CMD -> run anything; stream files with ssh 'cat > f' < f | `packages/linux-omamobile/stage KERNEL_OUT`, `tools/stage-boot-files` | Stage a kernel build for the kernel package, and a device's dtbo, overlays and release initramfs for its device package (gitignored `prebuilt/`, `boot-files/`); laptop only, no phone | | `omamobile-omarchy-patches status\|verify\|apply` (on the phone) | The Omarchy patch series: what is applied, already upstream or failed; `apply` re-applies it all or nothing (the pacman hook does this after every Omarchy upgrade). Log: `/var/log/omamobile/omarchy-patches.log` | | `tools/build-packages`, `tools/build-rootfs` | aarch64 packages (signed, `out/repo`) and the root image, built on the laptop in an Arch Linux ARM container (qemu-user); no phone | +| `tools/pkg-version PACKAGE`, `--commit PACKAGE VERSION` | A package's version, counted from `main`'s history (the series in `version`, then one per commit touching the package; off `main`, `..g` on top; edits not committed yet, `.d`), and the commit a version was built from. Read-only. The build tools put it in their copies as `.pkgver`; it refuses a shallow clone | | `tools/install-guided`, `tools/factory-index` | The guided install ([INSTALL-GUIDED](docs/INSTALL-GUIDED.md)), run twice on the 7 Pro as reinstalls; release bundles ship it with `phone-smoke`, `factory-index` and `camera-requirements.txt` under their signed checksums, as `bash install --guided` in the bundle's folder (the bundle's `install` hands `--guided` on to it), which needs no option there: it reads the bundle's own images, root image, descriptor and tools. It runs `install-phone`, the USB connection (`nmcli`, with consent: a plain link, no sharing), `nv-backup`, `phone-provision` and `phone-smoke` in order, resuming from its record in `~/.local/state/omamobile-install/` (which holds a digest of the phone's serial: never commit or share it). It sends `adb reboot bootloader` and a restart, adds a NetworkManager profile, downloads Google's factory image from `https://dl.google.com/` once the owner has accepted Google's terms in it (several GB into `~/.cache/omamobile-install/factory/`; the project hosts none of Google's files) and ends in the installer's writes, so never run it without the human's go, and never answer its terms question, its "already running Omarchy Mobile?" question or its "Install again from the start?" question for the owner; `--dry-run` reads the phone in fastboot and writes nothing, `--status` reads only the record. After the write it asks the phone that answers over SSH which one it is and stops for any other. `factory-index` keeps `device//factory-builds.json` (metadata of Google's factory builds, never their files) and needs no phone | | `tools/install-phone` | The installer: fastboot checks, the owner's answers into a local image copy, then only slot B's images and `userdata`. Asks the human to type the codename; `--dry-run` first. Never run it without the human's go | | `tools/nv-backup DIR`, `--check DIR` | The read-only backup of the radio and calibration partitions (the descriptor's `NV_PARTS` and `NV_BACKUP_EXTRA`) over USB SSH, found by `PARTNAME`, refused unless all are read-only and unmounted, each copy verified against a second read on the phone; `--check` is the checksum check of section 1 against such a backup. The output holds the IMEI: never commit or share it | @@ -220,7 +222,7 @@ Each entry gives the gotcha, then the reason or the fix. Details are in the link - pointer handlers declared directly on a window get no events, so put them on an Item inside it; - Qt 6.12's `QtQuick/Color` shadows Omarchy's `Commons.Color`, so import `qs.Commons as Commons`. - **pacman.conf order on aarch64:** `[omamobile]`, then `[omarchy]`, then Arch Linux ARM's repositories, so our Mesa and Omarchy's builds win. Use `omarchy update`, not `pacman -Syu`: on the phone it hands over to `omamobile-update` (patch 0012), which refuses a wrong order, low battery, another kernel or a bootloader package (`linux-omamobile` passes only when `omamobile-boot-update preflight` does), skips Snapper, the AUR and gum prompts, and holds boot-related migrations ([RELEASES](docs/RELEASES.md) §5.4). -- **Omarchy upgrades overwrite our Omarchy patches;** `omamobile-omarchy`'s pacman hook puts them back (all or nothing, from Omarchy's own files). Two families are selected by the installed Omarchy version: 4.5, which `[omamobile]` holds phones at since 2026-11-11 (`rootfs/packages.pinned`), uses `packages/omamobile-omarchy/patches/` (`patches/omarchy` links only to that family); a phone still on 4.0.6 uses `packages/omamobile-omarchy/legacy-4.0.6/` until its next `omarchy update`. Fixes go in `patches/`; `legacy-4.0.6/` takes only what a phone needs to get through that update. Bump the package version and make the selected family apply with `--fuzz=0` on the Omarchy the phone runs: `packages/omamobile-omarchy/test/all` applies it to the real aarch64 package. A patch Omarchy has absorbed is reported as upstream: drop it. +- **Omarchy upgrades overwrite our Omarchy patches;** `omamobile-omarchy`'s pacman hook puts them back (all or nothing, from Omarchy's own files). Two families are selected by the installed Omarchy version: 4.5, which `[omamobile]` holds phones at since 2026-11-11 (`rootfs/packages.pinned`), uses `packages/omamobile-omarchy/patches/` (`patches/omarchy` links only to that family); a phone still on 4.0.6 uses `packages/omamobile-omarchy/legacy-4.0.6/` until its next `omarchy update`. Fixes go in `patches/`; `legacy-4.0.6/` takes only what a phone needs to get through that update. Make the selected family apply with `--fuzz=0` on the Omarchy the phone runs: `packages/omamobile-omarchy/test/all` applies it to the real aarch64 package. A patch Omarchy has absorbed is reported as upstream: drop it. - **`environment.d` can't unset a variable:** `VAR=` with an empty value is a syntax error, and the generator skips the line silently, so the old value stays. Set an explicit value instead (`omamobile-shell` uses `none`). - **GeoClue answers no client until an authorization agent is registered for the caller's user,** and queues the call with no timeout, so every client just times out. `omamobile-gnss` runs GeoClue's demo agent as a user unit; app allow-list entries skip only the agent's question, not the agent. - **Firewall changes** (ufw is on): arm `systemd-run --on-active=90 /usr/bin/ufw disable` first, then check with a fresh SSH connection (`tools/phone-ssh --fresh`). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a48ae28c..abea57754 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -306,7 +306,8 @@ Findings that matter beyond one subsystem go into `device//NOTES.md`, ### 6.3 This repository -- **Commit subjects** name the area, then say what changed: `omamobile-gnss: package GNSS with location on demand`, `device-cheetah 0.1.15: reconnect USB after a replug`, `shell 0.1.17: …`, `DISPLAY-PLAN: D3b-1b result, …`, `NOTES: …`. When a commit changes a package, bump its `version` file and put the new version in the subject. +- **Commit subjects** name the area, then say what changed: `omamobile-gnss: package GNSS with location on demand`, `omamobile-device-cheetah: reconnect USB after a replug`, `DISPLAY-PLAN: D3b-1b result, …`, `NOTES: …`. No package version: it is counted when the change lands on `main`. +- **Package versions are counted, not written.** Leave `version` alone: [`tools/pkg-version`](tools/pkg-version) gives every commit on `main` that touches a package the next number of its series (the first two numbers in `version`), so two merges can't ship one number. A build off `main` gets `..g`, which `pacman` orders between `main`'s builds, and edits not committed yet add `.d`, a new version for each edit, so `tools/build-packages` rebuilds them without `--force`. Change `version` only to start a new series (`0.2` to `0.3`); a third number there is read as a floor and nothing else, so an old-style bump does no harm. A dependency on a change that isn't on `main` yet can't name its number: depend on a version `main` has already shipped, or on a name the other package `provides`. The same goes for docs: name a version only once `main` has shipped it (`tools/pkg-version --history ` lists them), and the pull request until then. Packages built from another project's release (Mesa, Hyprland, libcamera and the others whose PKGBUILD sets `pkgver` itself), `linux-omamobile`, `omamobile-keyring` and device packages that ship boot files (`OMAMOBILE_BOOT_FILES` in `install`: `omamobile-device-cheetah`, whose version the maintainer writes after the boot files have booted on the 7 Pro) keep hand-written versions: raise `pkgrel` (or the kernel package's `version`, which is its `pkgrel`) for a packaging change. On a fork whose own `main` is behind, count against this repository's: `git fetch upstream`, then `OMAMOBILE_MAIN_REF=upstream/main`, or a test build sorts below the published package. How the project moved from written to counted versions, and what happens to pull requests opened before, is in [RELEASES](docs/RELEASES.md) §7.1. - **Bodies** explain the why and what was tested. Wrap at 72 columns. If an AI assistant co-wrote the commit, end with a `Co-Authored-By:` trailer, as the history does. - **Every file has an SPDX header** (§7). - **Describe what something is built from, not which other project it's based on.** Docs, the README, device notes and the website don't name or compare other mobile Linux projects or distributions: say "Arch Linux ARM with the `linux-megi` kernel", not "based on X". Citing a properly licensed source for a fact (upstream Linux, Google's GPL kernel, postmarketOS, Mesa, Omarchy) is fine, and expected. diff --git a/docs/KEYBOARD-LAYOUTS.md b/docs/KEYBOARD-LAYOUTS.md index c6cf33690..dd8b75994 100644 --- a/docs/KEYBOARD-LAYOUTS.md +++ b/docs/KEYBOARD-LAYOUTS.md @@ -66,6 +66,6 @@ Do not edit a generated file. Every file but the two hand-made terminal ones is 3. Run `squeekboard/generate --check`. It strips the generator's additions from each file, regenerates and compares (lines 170-189, 201-211). 4. Run the tests from `packages/omamobile-shell/`: `test/all` runs `python3 -B test/keyboard-layouts.py` (every layout as squeekboard 1.43.1 parses it, the action row in every view, the globe keysym, known keysyms when libxkbcommon is installed; it exits 77, a skip, without PyYAML) and, only when that passes, `squeekboard/generate --check`; then `bash test/keyboard-languages.sh` (`omamobile-keyboard-languages` against a fake `gsettings`) (`test/all` lines 428-436, 463). Each can also be run on its own. 5. From the repository root, run `tools/pr-check` and `tests/packages` before pushing (see the tools table in `AGENTS.md`). -6. Bump `version` and note the change in the package `README.md` and this page. +6. Note the change in the package `README.md` and this page. A new language is selectable once the package is installed with its portrait file in `squeekboard/keyboards/`: `omamobile-keyboard-languages list` then offers every top-level portrait file in the installed directory, and `omamobile-setup-user` links it at the next login. To try one before packaging, set `OMAMOBILE_KEYBOARDS_DIR` to the source directory for the list. diff --git a/docs/RELEASES.md b/docs/RELEASES.md index f09e0f3ad..d7c4eb83b 100644 --- a/docs/RELEASES.md +++ b/docs/RELEASES.md @@ -217,7 +217,7 @@ One package for every device, in `[omamobile]`. - **`stage KERNEL_OUT [PREBUILT]`**, on the build machine, after `bin/omamobile kernel` and `modules` (or anything that leaves the same files): copies `include/config/kernel.release`, `arch/arm64/boot/Image`, every DTB under `arch/arm64/boot/dts/exynos/google` (`DTB_DIRS` adds others) and `modules-.tar.zst` into the package's gitignored `prebuilt/`, with `SHA256SUMS`. `KERNEL_DIR` must be the clean checkout of a published release: its HEAD the release's commit and carrying a `kernel-[.N]` tag, the tag on the published repository (`LINUX_OMAMOBILE_REMOTE`, default GitHub's `linux-omarchy-mobile`) pointing at that commit, and the commit on its `omamobile` branch. `git rev-list --count HEAD` is the commit count for pkgver; the commit, the count and the tag go in `SOURCE`, which `install` requires. `stage --verify` checks a staged `prebuilt/` again (checksums, `SOURCE`, the tag on the published repository). - **Refusals:** a development release (`-omamobile-push1-…`, or any release not of the form `[-rcN]-omamobile[-]-g`), a `-dirty` tree, no `KERNEL_DIR`, a `KERNEL_DIR` at another commit or with uncommitted changes, a commit without a release tag (a test build or an `omamobile-int` snapshot), a tag the published repository doesn't have or that isn't on its `omamobile`, an `Image` without arm64's header magic, a modules tarball of another release or without `modules.order`, no DTBs, and at packing time a `prebuilt/` that fails its checksums. -- **pkgver** from the staged release (`lib/pkgver`, as §4 and §7 say), **pkgrel** from the package's `version` file (packaging changes only). With nothing staged pkgver is `0` and `package()` refuses. `tools/build-packages` builds it only when named, never by default or with `--all` (so a `prebuilt/` staged for a test never reaches the daily publish, which carries `prebuilt/` directories along), and runs `stage --verify` first. +- **pkgver** from the staged release (`lib/pkgver`, as §4 and §7 say), **pkgrel** from the package's `version` file (packaging changes only; written by hand, as `tools/pkg-version` doesn't count this package). With nothing staged pkgver is `0` and `package()` refuses. `tools/build-packages` builds it only when named, never by default or with `--all` (so a `prebuilt/` staged for a test never reaches the daily publish, which carries `prebuilt/` directories along), and runs `stage --verify` first. - **`/usr/share/omamobile/linux/kernel.release`** names the release the package installed, for the boot hook (§5.3), and `SOURCE` beside it the tag and commit. - **Layout** as above. depmod's own files (`modules.dep`, `.alias`, `.symbols` …) are left out, as Arch's kernels leave them out: kmod's `60-depmod.hook` makes them on the phone, and the boot hook refuses a release without them. `options=(!strip !debug)`: makepkg must not touch the `Image` or the stripped modules. `depends=(kmod omamobile-boot-update)`. @@ -428,12 +428,23 @@ automatic boot-update policy. | Thing | Version | Where it is recorded | | --- | --- | --- | | Kernel | `uname -r`: `7.3.0-rc6-omamobile-g`; pkgver `7.3.0rc6.r.g` (§4) | annotated tag `kernel-` (`.1`, `.2` for a respin) on `omamobile` in linux-omarchy-mobile; the scheme is a proposal for the maintainer to confirm | -| Packages | each package's `version` file, bumped in the commit that changes it (CONTRIBUTING §6.3) | the package | -| Descriptor | none of its own; a change to it is a device-package change and bumps that package | `omamobile-device-` | -| Bundle | calendar version ``, with `.1`, `.2` for a respin the same day | tag `release-` in this repository, covering every device released that day; `MANIFEST` pins the kernel tag, every package version and both commits | +| Packages | the series in each package's `version` file, then the count of commits on `main` that touched the package (`tools/pkg-version`, CONTRIBUTING §6.3) | `main`'s history: `tools/pkg-version --commit ` | +| Descriptor | none of its own; a change to it is a device-package change and gives that package a new version | `omamobile-device-` | +| Bundle | calendar version ``, with `.1`, `.2` for a respin the same day; a respin's packages built from a branch rather than `main` are branch builds (`.g`, §7.1) that `tools/repo-publish` refuses, unless the build names that branch as its main line (`OMAMOBILE_MAIN_REF`) | tag `release-` in this repository, covering every device released that day; `MANIFEST` pins the kernel tag, every package version and both commits | A release never contains a kernel or package that isn't in `[omamobile]` at the same moment, so a bundle install and `omarchy update` meet at the same versions. The first release is `2026.MM.DD`, labelled "developer preview", for the Pixel 7 Pro only (§12.12). +### 7.1 From written to counted package versions + +Until the pull request that added `tools/pkg-version` (issue #689), each pull request wrote its package's next version into `version` by hand. Two open pull requests could write the same number and both merge, and a stacked or rebased one had to be renumbered at every merge. The count replaces that for every package whose PKGBUILD reads it; the others keep hand-written versions (CONTRIBUTING §6.3), `omamobile-device-cheetah` among them: its boot files reach release phones' slot B, and the maintainer gives them a version only after an image built from them has booted on the 7 Pro. + +1. **Before the merge,** each `version` file holds the last number written by hand, which is the version `[omamobile]` publishes. +2. **The merge commit starts the count.** A commit counts when the package's PKGBUILD, as that commit has it, reads `.pkgver` (the version `tools/pkg-version` hands a build); before that, the `version` file is the version. The merge commit makes 29 PKGBUILDs read it, so each of those packages moves one number up from the version `main` held just before, and the first development publish after it rebuilds the 29 once. Nothing is written by hand, and no version that was published comes back. The start is the package's own opt-in, not the tool's: moving or renaming `tools/pkg-version` touches the PKGBUILDs, which is one more number, never a restart (`tests/pkg-version` moves it). +3. **From then on,** a merge needs no version change. Squash merges, merge commits and direct pushes count once each, in the order they land; a commit that changes only tests or docs under a package counts too. `tools/pkg-version --commit ` finds the commit a published version was built from, and `--history ` lists them all. +4. **Pull requests opened before the change** merge as they are. A `version` hunk at or below the count changes nothing; a number above it is taken as a floor, so the package jumps to it: drop such a hunk at review unless the jump is wanted. A conflict on `version` resolves to `main`'s file. A versioned dependency on another open pull request's number (`depends=('omamobile-shell>=0.2.130')`) may name a number the count gives to something else: check it against `tools/pkg-version` at merge, or depend on a shipped version. +5. **The `version` files keep their old third numbers** for now, so contributors who still bump do no harm while they adjust. They go stale; once the pull requests from before the change have drained, one commit can cut every file to its series (`0.2`). That commit touches every package, so each moves one number up again and is republished once; it is the maintainer's call when. +6. **Going back** to hand-written versions means first writing each package's current version (`tools/pkg-version `) into its `version` file: the files' stale numbers are below what phones have installed, and `pacman` would not upgrade from them. + ## 8. The kernel branches - **`omamobile` on GitHub is the one source of the release kernel.** It starts from a squashed commit holding the upstream tag's tree (v7.3-rc6), with every commit after it unchanged, and it only moves forward: pull requests and release tags point at its commit ids, so nothing rewrites or force-pushes it. @@ -496,7 +507,7 @@ Per release, in order. Stop at any failed step. `tools/release` runs the checkli 2. **Publish and tag** [`kernel`]: `tools/publish-kernel --dry-run --tag kernel- `, read what it would push, then run it without `--dry-run`. If it stops because `omamobile` moved, rebase, test what changed, and repeat. The stage checks that the annotated tag is on GitHub's `omamobile` and that the release worktree (`$KERNEL_BASE/wt-release`) is exactly that commit and clean. 3. **Build** [`build`] the kernel from the tag in the pinned container with the pinned clang (the stage checks `toolchain.txt`), release `LOCALVERSION` (`bin/omamobile kernel --release`), into the fixed `$KERNEL_BASE/out-kernel-release` (byte-identical builds need the same paths; the stage refuses that directory when it holds anything but a release build); stage `linux-omamobile` from it (`packages/linux-omamobile/stage`, §4). 4. **Images** [`images`] for every device: `DEVICE= bin/omamobile initramfs --release`, then `DEVICE= bin/omamobile images`, twice, checksums equal; then the device package's boot files (§5), for a device package whose `install` ships them (`OMAMOBILE_BOOT_FILES`): kept when `tools/stage-boot-files --check` finds them current, since the device package in `out/repo` was built from them, and then the boot images are built from their initramfs, so the bundle boots the bytes every phone's hook writes later; when they are stale, staged again only for a new device-package version (the stage asks for the bump when `out/repo` already has the current one), then `tools/build-packages packages/`. -5. **Packages** [`packages`]: every changed package has a bumped `version`, its `test/all` passes, `tools/build-packages` builds and signs them and the database on the laptop (`tools/repo-build` on a phone only as an opt-in shortcut). The stage checks that `out/repo` is signed by the release key, holds every package the image installs at this checkout's version, and that development publishes exactly it (`tools/repo-publish --no-build development`); it pins that index. `linux-omamobile` and `omamobile-boot-update` are among the image's packages (decision 10); `tools/build-packages` builds `linux-omamobile` only when named (`tools/build-packages packages/linux-omamobile`), and the stage checks the device package carries the staged boot files' initramfs. When the packages are built and published on a build host (the machine the daily publish runs on) and the release is cut on another, `tools/build-host-sync` carries the files between them instead of hand copies (host from `BUILD_HOST` in `omamobile.local.conf`, `--dry-run` prints every command): `push` after the `images` stage sends the staged `linux-omamobile` prebuilt and the device packages' boot files, checked on both sides (`packages/linux-omamobile/stage --verify`, `tools/stage-boot-files --check`) and refused unless the build host's checkout is the same clean commit; `command` prints the one build-and-publish command for it, with the `DOCKER_HOST` its publish service runs with resolved (a unit's `%t` means nothing to a shell); `pull` before this stage brings its `out/repo` and `out/publish` back and puts them in place only when their indexes are the ones `pkgs.omamobile.org` serves, `out/repo` is development's index, and every listed package matches. Then [`rootfs`] the root image on the stable channel from the pinned index, carrying both, and [`bundle`] the signed bundle. +5. **Packages** [`packages`]: every changed package has a new version (counted by `tools/pkg-version`; `tools/repo-publish` refuses a branch build, `.g`, or one of uncommitted edits, `.d`), its `test/all` passes, `tools/build-packages` builds and signs them and the database on the laptop (`tools/repo-build` on a phone only as an opt-in shortcut). The stage checks that `out/repo` is signed by the release key, holds every package the image installs at this checkout's version, and that development publishes exactly it (`tools/repo-publish --no-build development`); it pins that index. `linux-omamobile` and `omamobile-boot-update` are among the image's packages (decision 10); `tools/build-packages` builds `linux-omamobile` only when named (`tools/build-packages packages/linux-omamobile`), and the stage checks the device package carries the staged boot files' initramfs. When the packages are built and published on a build host (the machine the daily publish runs on) and the release is cut on another, `tools/build-host-sync` carries the files between them instead of hand copies (host from `BUILD_HOST` in `omamobile.local.conf`, `--dry-run` prints every command): `push` after the `images` stage sends the staged `linux-omamobile` prebuilt and the device packages' boot files, checked on both sides (`packages/linux-omamobile/stage --verify`, `tools/stage-boot-files --check`) and refused unless the build host's checkout is the same clean commit; `command` prints the one build-and-publish command for it, with the `DOCKER_HOST` its publish service runs with resolved (a unit's `%t` means nothing to a shell); `pull` before this stage brings its `out/repo` and `out/publish` back and puts them in place only when their indexes are the ones `pkgs.omamobile.org` serves, `out/repo` is development's index, and every listed package matches. Then [`rootfs`] the root image on the stable channel from the pinned index, carrying both, and [`bundle`] the signed bundle. 6. **Test install** [`test-install`] on each released device, attended (this gates the release, §12.10): the signed bundle's `install` on a phone whose stock slot A and backups are known good; first boot, device package installed, `omarchy update` clean (the installed phone follows stable, and `promote` comes after this step: the stage first asks the server whether stable has an index, and with none, which can only be before the first release to a server, prints the one-time promotion of the pinned index and stops; later releases find the previous release there), then a package-hook kernel update and a reboot into it; on the Pixel 7 Pro with a SIM, after `tools/phone-provision` and the carrier settings, the modem stack comes up at boot on its own ([MODEM-PLAN](../device/cheetah/MODEM-PLAN.md) M4.6b) and the phone registers. The bundle is signed before this step, so the bytes tested are the bytes released; `test-install --passed ""` records it. 7. **Identifiers** [`identifiers`]: grep the bundle, the root image's file list, `MANIFEST` and the release notes for MAC addresses (`[0-9a-f]{2}(:[0-9a-f]{2}){5}`), serial numbers, SSIDs and account names; confirm no file from a factory image is in any artifact. The stage also reads the root image's `/etc`, `/root` and our own directories and the release initramfs; serials, SSIDs and account names come from a private list outside the repository (`~/.config/omamobile/release-identifiers`, one per line). `tools/release scan FILE...` checks any file the same way. 8. **Verify** [`verify`] the release's signature from a clean keyring: the bundle's `SHA256SUMS.sig` by the release key, every file against `SHA256SUMS`, and the root image against the SHA-256 the signed `MANIFEST` names (the bundle stage signed it; the root image needs no signature of its own, since the installer and `manifest.json` authorise it only through that signed record); upload [`upload`] them to `pkgs.omamobile.org/releases/` (§6) with `tools/release-upload --dry-run out/bundle/omamobile--`, then `tools/release-upload --full --latest out/bundle/omamobile--`, files before the index (`upload --done` reads them back with `--verify-only`); promote [`promote`] the release's packages to `stable`: `tools/repo-publish stable --expect-index ` promotes development's index and files unchanged, signatures included, and only if development's index is still the one the release was built and tested from. diff --git a/docs/REMOTE-TESTING.md b/docs/REMOTE-TESTING.md index 03153019a..dc4a32e67 100644 --- a/docs/REMOTE-TESTING.md +++ b/docs/REMOTE-TESTING.md @@ -14,7 +14,7 @@ It is opt-in. `omamobile-remote` and the patched `wlrctl` are in `packages/`, no On the phone, from the repository built by `tools/build-packages`: ``` -pacman -U wlrctl-0.2.2-1-aarch64.pkg.tar.* omamobile-remote-0.1.2-1-any.pkg.tar.* +pacman -U wlrctl-0.2.2-1-aarch64.pkg.tar.* omamobile-remote-*-any.pkg.tar.* ``` From your computer, an ssh key to the phone's user (USB networking is the easy way: `ssh user@172.16.42.1` on the images that have it). Every command below is run as that user: diff --git a/packages/omamobile-apps/PKGBUILD b/packages/omamobile-apps/PKGBUILD index c8148f158..6e7548bb8 100644 --- a/packages/omamobile-apps/PKGBUILD +++ b/packages/omamobile-apps/PKGBUILD @@ -8,7 +8,7 @@ # in `optdepends` with the reason. Device-specific stacks (the modem's RIL # and bridge) never go in `depends`: they belong to the device's image. pkgname=omamobile-apps -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile's default mobile apps (camera, phone, messages, contacts, images, maps and location, NFC tags)" arch=(any) diff --git a/packages/omamobile-audio/PKGBUILD b/packages/omamobile-audio/PKGBUILD index 74266ee6a..60d3c0354 100644 --- a/packages/omamobile-audio/PKGBUILD +++ b/packages/omamobile-audio/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-audio -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile audio for the Pixel 7 Pro, Pixel 6 Pro and Pixel 9a: UCM profiles and PipeWire rules for the AoC sound card, Pixel 7 Pro speaker protection with the factory calibration" arch=(any) diff --git a/packages/omamobile-boot-update/PKGBUILD b/packages/omamobile-boot-update/PKGBUILD index 6d8d297eb..5c9899c6b 100644 --- a/packages/omamobile-boot-update/PKGBUILD +++ b/packages/omamobile-boot-update/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-boot-update -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile: rebuild a phone's slot-B boot images from linux-omamobile and write them, guarded and verified (pacman hook, opt-in)" arch=(any) @@ -16,5 +16,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-boot-update/install b/packages/omamobile-boot-update/install index a6d090061..5a3d574fd 100755 --- a/packages/omamobile-boot-update/install +++ b/packages/omamobile-boot-update/install @@ -21,3 +21,6 @@ install -Dm644 avb/testkey_rsa4096.pem "$d/usr/share/omamobile-boot-update/avb/t install -Dm644 avb/SOURCE "$d/usr/share/omamobile-boot-update/avb/SOURCE" install -Dm644 avb/LICENSE "$d/usr/share/licenses/omamobile-boot-update/LICENSE.avb" install -Dm644 version "$d/usr/share/omamobile/boot-update/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/boot-update/version" diff --git a/packages/omamobile-device-akita/PKGBUILD b/packages/omamobile-device-akita/PKGBUILD index f39c2682c..7a5841f12 100644 --- a/packages/omamobile-device-akita/PKGBUILD +++ b/packages/omamobile-device-akita/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-device-akita -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel 8a (akita): storage guard, USB networking and the USB replug rescue" arch=(aarch64) @@ -23,5 +23,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-akita/install b/packages/omamobile-device-akita/install index e5e368303..d9aaa9dda 100755 --- a/packages/omamobile-device-akita/install +++ b/packages/omamobile-device-akita/install @@ -33,3 +33,6 @@ install -Dm644 etc/omamobile-mirrorlist \ "$destination/etc/pacman.d/omamobile-mirrorlist" install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-akita/LICENSE" install -Dm644 version "$destination/usr/share/omamobile/device-akita/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-akita/version" diff --git a/packages/omamobile-device-cheetah/PKGBUILD b/packages/omamobile-device-cheetah/PKGBUILD index 9be29bd7c..3ed67f719 100644 --- a/packages/omamobile-device-cheetah/PKGBUILD +++ b/packages/omamobile-device-cheetah/PKGBUILD @@ -1,6 +1,9 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-device-cheetah +# Written by hand, not counted (tools/pkg-version): the boot files this +# package ships go out under a new version only after they have booted on +# the Pixel 7 Pro, and the maintainer writes that version then pkgver=$(cat "${startdir:-.}/version") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel 7 Pro (cheetah): boot-slot success, storage guard, USB networking" @@ -25,5 +28,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-cheetah/install b/packages/omamobile-device-cheetah/install index a73f86069..813353b97 100755 --- a/packages/omamobile-device-cheetah/install +++ b/packages/omamobile-device-cheetah/install @@ -25,6 +25,9 @@ install -Dm644 etc/upower-critical.conf "$destination/etc/UPower/UPower.conf.d/5 install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-cheetah/LICENSE" install -Dm644 LICENSE.Apache-2.0 "$destination/usr/share/licenses/omamobile-device-cheetah/LICENSE.Apache-2.0" install -Dm644 version "$destination/usr/share/omamobile/device-cheetah/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-cheetah/version" # Suspend is verified on this phone (device/cheetah/SUSPEND-PLAN.md): the # shell's user setup turns auto-sleep on once where this file exists. install -Dm644 /dev/null "$destination/usr/share/omamobile/auto-sleep-default" diff --git a/packages/omamobile-device-dodge/PKGBUILD b/packages/omamobile-device-dodge/PKGBUILD index ffd7c803d..ae604cbbb 100644 --- a/packages/omamobile-device-dodge/PKGBUILD +++ b/packages/omamobile-device-dodge/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Martin Lund pkgname=omamobile-device-dodge -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the OnePlus 13 (dodge): reboot-to-fastboot and USB networking" arch=(aarch64) diff --git a/packages/omamobile-device-felix/PKGBUILD b/packages/omamobile-device-felix/PKGBUILD index 0de7dd309..9c53110e4 100644 --- a/packages/omamobile-device-felix/PKGBUILD +++ b/packages/omamobile-device-felix/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-device-felix -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel Fold (felix): storage guard and USB networking" arch=(aarch64) @@ -23,5 +23,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-felix/install b/packages/omamobile-device-felix/install index 4c8428eaa..07760a049 100755 --- a/packages/omamobile-device-felix/install +++ b/packages/omamobile-device-felix/install @@ -27,3 +27,6 @@ install -Dm644 etc/omamobile-mirrorlist \ "$destination/etc/pacman.d/omamobile-mirrorlist" install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-felix/LICENSE" install -Dm644 version "$destination/usr/share/omamobile/device-felix/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-felix/version" diff --git a/packages/omamobile-device-husky/PKGBUILD b/packages/omamobile-device-husky/PKGBUILD index c6dfb1f7e..0c2e9eaa3 100644 --- a/packages/omamobile-device-husky/PKGBUILD +++ b/packages/omamobile-device-husky/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-device-husky -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel 8 Pro (husky): storage guard, USB networking and the USB replug rescue" arch=(aarch64) @@ -23,5 +23,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-husky/install b/packages/omamobile-device-husky/install index f2a8c7ed0..964eab115 100755 --- a/packages/omamobile-device-husky/install +++ b/packages/omamobile-device-husky/install @@ -59,3 +59,6 @@ install -Dm644 etc/omamobile-mirrorlist \ "$destination/etc/pacman.d/omamobile-mirrorlist" install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-husky/LICENSE" install -Dm644 version "$destination/usr/share/omamobile/device-husky/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-husky/version" diff --git a/packages/omamobile-device-lynx/PKGBUILD b/packages/omamobile-device-lynx/PKGBUILD index 4442fb3be..ebb353042 100644 --- a/packages/omamobile-device-lynx/PKGBUILD +++ b/packages/omamobile-device-lynx/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-device-lynx -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel 7a (lynx): storage guard, USB networking, and boot-success marker" arch=(aarch64) @@ -23,5 +23,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-lynx/install b/packages/omamobile-device-lynx/install index 1f63549dc..2d909a9f7 100755 --- a/packages/omamobile-device-lynx/install +++ b/packages/omamobile-device-lynx/install @@ -33,3 +33,6 @@ install -Dm644 etc/omamobile-mirrorlist \ install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-lynx/LICENSE" install -Dm644 LICENSE.Apache-2.0 "$destination/usr/share/licenses/omamobile-device-lynx/LICENSE.Apache-2.0" install -Dm644 version "$destination/usr/share/omamobile/device-lynx/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-lynx/version" diff --git a/packages/omamobile-device-oriole/PKGBUILD b/packages/omamobile-device-oriole/PKGBUILD index 3befe18d6..736490f4f 100644 --- a/packages/omamobile-device-oriole/PKGBUILD +++ b/packages/omamobile-device-oriole/PKGBUILD @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT pkgname=omamobile-device-oriole -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Pixel 6 first-light support: storage policy, USB networking and boot helpers" arch=(aarch64) @@ -16,4 +16,4 @@ backup=(etc/UPower/UPower.conf.d/20-omamobile-critical-power.conf etc/pacman.d/o build() { "$startdir/build" "$srcdir/build"; } check() { "$startdir/test/all"; } -package() { "$startdir/install" "$pkgdir" "$srcdir/build"; } +package() { OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build"; } diff --git a/packages/omamobile-device-oriole/install b/packages/omamobile-device-oriole/install index 4cf89033f..59d6ddb17 100755 --- a/packages/omamobile-device-oriole/install +++ b/packages/omamobile-device-oriole/install @@ -23,3 +23,6 @@ for file in LICENSE; do install -Dm644 "$file" "$destination/usr/share/licenses/omamobile-device-oriole/$file" done install -Dm644 version "$destination/usr/share/omamobile/device-oriole/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-oriole/version" diff --git a/packages/omamobile-device-panther/PKGBUILD b/packages/omamobile-device-panther/PKGBUILD index f01769587..57a0141ae 100644 --- a/packages/omamobile-device-panther/PKGBUILD +++ b/packages/omamobile-device-panther/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-device-panther -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel 7 (panther): storage guard, USB networking, GPU, haptics, suspend-to-idle, USB after a replug, display brightness, Wi-Fi" arch=(aarch64) @@ -23,5 +23,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-panther/install b/packages/omamobile-device-panther/install index fa535d334..381cc8f5d 100755 --- a/packages/omamobile-device-panther/install +++ b/packages/omamobile-device-panther/install @@ -67,3 +67,6 @@ install -Dm644 etc/omamobile-mirrorlist \ "$destination/etc/pacman.d/omamobile-mirrorlist" install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-panther/LICENSE" install -Dm644 version "$destination/usr/share/omamobile/device-panther/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-panther/version" diff --git a/packages/omamobile-device-raven/PKGBUILD b/packages/omamobile-device-raven/PKGBUILD index 0153bf58d..a2ff65646 100644 --- a/packages/omamobile-device-raven/PKGBUILD +++ b/packages/omamobile-device-raven/PKGBUILD @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT pkgname=omamobile-device-raven -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel 6 Pro (raven): boot-slot success, USB rescue, display, power and module policy" arch=(aarch64) @@ -20,5 +20,5 @@ build() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-raven/install b/packages/omamobile-device-raven/install index f32025f73..1b6db9489 100755 --- a/packages/omamobile-device-raven/install +++ b/packages/omamobile-device-raven/install @@ -21,3 +21,6 @@ install -Dm644 etc/omamobile-mirrorlist "$destination/etc/pacman.d/omamobile-mir install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-raven/LICENSE" install -Dm644 LICENSE.Apache-2.0 "$destination/usr/share/licenses/omamobile-device-raven/LICENSE.Apache-2.0" install -Dm644 version "$destination/usr/share/omamobile/device-raven/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-raven/version" diff --git a/packages/omamobile-device-tegu/PKGBUILD b/packages/omamobile-device-tegu/PKGBUILD index 2732b538d..487b1519d 100644 --- a/packages/omamobile-device-tegu/PKGBUILD +++ b/packages/omamobile-device-tegu/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-device-tegu -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile support for the Google Pixel 9a (tegu): storage guard, USB networking, hang-safe graphics start" arch=(aarch64) @@ -25,5 +25,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/build" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/build" } diff --git a/packages/omamobile-device-tegu/install b/packages/omamobile-device-tegu/install index 049fa4c1d..534a139b7 100755 --- a/packages/omamobile-device-tegu/install +++ b/packages/omamobile-device-tegu/install @@ -27,3 +27,6 @@ install -Dm644 device.conf "$destination/usr/share/omamobile/device.conf" install -Dm644 etc/omamobile-mirrorlist "$destination/etc/pacman.d/omamobile-mirrorlist" install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-device-tegu/LICENSE" install -Dm644 version "$destination/usr/share/omamobile/device-tegu/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/device-tegu/version" diff --git a/packages/omamobile-fingerprint/PKGBUILD b/packages/omamobile-fingerprint/PKGBUILD index 525dfe6e4..c1c06b1d8 100644 --- a/packages/omamobile-fingerprint/PKGBUILD +++ b/packages/omamobile-fingerprint/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-fingerprint -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile fingerprint for the Pixel 7 Pro: Google's HAL in a chroot, bridged to fprintd" arch=(aarch64) @@ -18,5 +18,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-fingerprint/install b/packages/omamobile-fingerprint/install index 58c8aec76..3f54d962a 100755 --- a/packages/omamobile-fingerprint/install +++ b/packages/omamobile-fingerprint/install @@ -34,3 +34,6 @@ install -Dm755 vendor/systemd/system-sleep/omamobile-fprintd-resume "$d/usr/lib/ install -Dm644 vendor/modprobe.d/omamobile-fingerprint-lhbm.conf "$d/usr/lib/modprobe.d/omamobile-fingerprint-lhbm.conf" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-fingerprint/LICENSE" install -Dm644 version "$d/usr/share/omamobile/fingerprint/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/fingerprint/version" diff --git a/packages/omamobile-firstboot/PKGBUILD b/packages/omamobile-firstboot/PKGBUILD index a9a5c281c..b41dba4fb 100644 --- a/packages/omamobile-firstboot/PKGBUILD +++ b/packages/omamobile-firstboot/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-firstboot -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile first boot: the user, SSH key, firewall and Omarchy's setup from the installer's answers" arch=(any) @@ -17,5 +17,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-firstboot/install b/packages/omamobile-firstboot/install index 8ceaf7fdc..155cac898 100755 --- a/packages/omamobile-firstboot/install +++ b/packages/omamobile-firstboot/install @@ -14,3 +14,6 @@ ln -sfn ../omamobile-firstboot.service "$d/usr/lib/systemd/system/multi-user.tar install -Dm644 ssh/10-omamobile.conf "$d/etc/ssh/sshd_config.d/10-omamobile.conf" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-firstboot/LICENSE" install -Dm644 version "$d/usr/share/omamobile/firstboot/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/firstboot/version" diff --git a/packages/omamobile-gnss/PKGBUILD b/packages/omamobile-gnss/PKGBUILD index e5964331a..2987364ac 100644 --- a/packages/omamobile-gnss/PKGBUILD +++ b/packages/omamobile-gnss/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-gnss -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile GNSS for the Pixel 7 Pro: Broadcom's lhd/gpsd in a vendor chroot, NMEA to GeoClue on demand" arch=(aarch64) @@ -17,5 +17,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-gnss/install b/packages/omamobile-gnss/install index 96b042414..bef8da550 100755 --- a/packages/omamobile-gnss/install +++ b/packages/omamobile-gnss/install @@ -38,3 +38,6 @@ install -Dm644 etc/geoclue/conf.d/90-omamobile-gnss.conf "$d/etc/geoclue/conf.d/ install -Dm644 etc/omamobile/gnss.conf "$d/etc/omamobile/gnss.conf" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-gnss/LICENSE" install -Dm644 version "$d/usr/share/omamobile/gnss/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/gnss/version" diff --git a/packages/omamobile-install-link/PKGBUILD b/packages/omamobile-install-link/PKGBUILD index 0312d078e..ccb8524d2 100644 --- a/packages/omamobile-install-link/PKGBUILD +++ b/packages/omamobile-install-link/PKGBUILD @@ -13,7 +13,7 @@ # the installer has them. cargo fetches the crates (Cargo.lock pinned) in # prepare() and builds offline. Everything else is this directory's. pkgname=omamobile-install-link -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile install link: the phone finishes its setup with the installer, over USB" arch=(aarch64) @@ -82,5 +82,5 @@ PY package() { cd "omamobile-installer-$_commit" - "$startdir/install" "$pkgdir" "$PWD" "$PWD/target/release" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$PWD" "$PWD/target/release" } diff --git a/packages/omamobile-install-link/install b/packages/omamobile-install-link/install index a7d3287e6..d7675ed3e 100755 --- a/packages/omamobile-install-link/install +++ b/packages/omamobile-install-link/install @@ -59,6 +59,9 @@ ln -sfn ../omamobile-install-link-agent.service "$user/graphical-session.target. install -Dm644 tmpfiles.d/omamobile-install-link.conf "$d/usr/lib/tmpfiles.d/omamobile-install-link.conf" 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" { echo "# The install link's daemon and gadget script: derekross/omamobile-installer" echo "protocol: $protocol" diff --git a/packages/omamobile-mirror/PKGBUILD b/packages/omamobile-mirror/PKGBUILD index 8550eca11..d2a1d6822 100644 --- a/packages/omamobile-mirror/PKGBUILD +++ b/packages/omamobile-mirror/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-mirror -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile screen mirroring: the phone's screen and input on a computer over the USB cable (wayvnc)" arch=(any) @@ -17,5 +17,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-mirror/install b/packages/omamobile-mirror/install index e4b69682e..b1ccfba59 100755 --- a/packages/omamobile-mirror/install +++ b/packages/omamobile-mirror/install @@ -16,3 +16,6 @@ install -Dm644 share/mirror.conf.example "$d/usr/share/omamobile/mirror/mirror.c install -Dm644 README.md "$d/usr/share/doc/omamobile-mirror/README.md" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-mirror/LICENSE" install -Dm644 version "$d/usr/share/omamobile/mirror/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/mirror/version" diff --git a/packages/omamobile-mmd/PKGBUILD b/packages/omamobile-mmd/PKGBUILD index faba84561..998c1be14 100644 --- a/packages/omamobile-mmd/PKGBUILD +++ b/packages/omamobile-mmd/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-mmd -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile ModemManager-compatible bridge: org.freedesktop.ModemManager1 served from omamobile-sitd" arch=(aarch64) @@ -21,5 +21,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-mmd/install b/packages/omamobile-mmd/install index 1e622c944..0a11f0f14 100755 --- a/packages/omamobile-mmd/install +++ b/packages/omamobile-mmd/install @@ -13,3 +13,6 @@ install -Dm644 dbus/org.freedesktop.ModemManager1.conf "$d/usr/share/dbus-1/syst install -Dm644 polkit/org.freedesktop.ModemManager1.policy "$d/usr/share/polkit-1/actions/org.freedesktop.ModemManager1.policy" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-mmd/LICENSE" install -Dm644 version "$d/usr/share/omamobile/mmd/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/mmd/version" diff --git a/packages/omamobile-modem-sit/PKGBUILD b/packages/omamobile-modem-sit/PKGBUILD index dbf3a6726..7e14b2d48 100644 --- a/packages/omamobile-modem-sit/PKGBUILD +++ b/packages/omamobile-modem-sit/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-modem-sit -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile SIT RIL for the Pixel 7 Pro's S5300: LTE registration, IMS calls and SMS, cellular data on rmnet0" arch=(aarch64) @@ -20,5 +20,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-modem-sit/install b/packages/omamobile-modem-sit/install index 8d749425a..83378c534 100755 --- a/packages/omamobile-modem-sit/install +++ b/packages/omamobile-modem-sit/install @@ -19,3 +19,6 @@ install -Dm644 networkmanager/90-omamobile-rmnet.conf "$d/usr/lib/NetworkManager install -Dm644 etc/omamobile/modem-sit.conf "$d/etc/omamobile/modem-sit.conf" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-modem-sit/LICENSE" install -Dm644 version "$d/usr/share/omamobile/modem-sit/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/modem-sit/version" diff --git a/packages/omamobile-modem/PKGBUILD b/packages/omamobile-modem/PKGBUILD index f010fc4bc..261353da4 100644 --- a/packages/omamobile-modem/PKGBUILD +++ b/packages/omamobile-modem/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-modem -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile modem runtime for the Pixel 7 Pro: stock rfsd and cbd in a vendor chroot on RAM copies of NV, with a per-phone overlay for the modem's own NV writes" arch=(aarch64) @@ -15,5 +15,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-modem/install b/packages/omamobile-modem/install index 618da1e11..d38dc2d8b 100755 --- a/packages/omamobile-modem/install +++ b/packages/omamobile-modem/install @@ -35,3 +35,6 @@ install -Dm644 udev/61-omamobile-vendor-udisks-ignore.rules "$d/usr/lib/udev/rul install -Dm644 README.md "$d/usr/share/doc/omamobile-modem/README.md" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-modem/LICENSE" install -Dm644 version "$d/usr/share/omamobile/modem/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/modem/version" diff --git a/packages/omamobile-omarchy/PKGBUILD b/packages/omamobile-omarchy/PKGBUILD index 4d2f19378..cbbcd46ea 100644 --- a/packages/omamobile-omarchy/PKGBUILD +++ b/packages/omamobile-omarchy/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-omarchy -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile's Omarchy patches, re-applied after every Omarchy upgrade, omamobile-update, Omarchy's update for a phone, and a kernel module cleanup that keeps the next boot's modules" arch=(any) @@ -17,5 +17,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-omarchy/install b/packages/omamobile-omarchy/install index 783e2296f..136dc4aec 100755 --- a/packages/omamobile-omarchy/install +++ b/packages/omamobile-omarchy/install @@ -33,6 +33,9 @@ install -Dm644 libalpm/95-omamobile-omarchy-patches.hook "$d/usr/share/libalpm/h install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-omarchy/LICENSE" install -Dm644 LICENSE.omarchy "$d/usr/share/licenses/omamobile-omarchy/omarchy-MIT" install -Dm644 version "$d/usr/share/omamobile/omarchy/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/omarchy/version" for f in legacy-4.0.6/*.patch; do install -Dm644 "$f" "$d/usr/share/omamobile/omarchy/legacy-4.0.6/${f##*/}" done diff --git a/packages/omamobile-owl-widgets/PKGBUILD b/packages/omamobile-owl-widgets/PKGBUILD index 2331c4ae1..d0e20af10 100644 --- a/packages/omamobile-owl-widgets/PKGBUILD +++ b/packages/omamobile-owl-widgets/PKGBUILD @@ -5,7 +5,7 @@ # conformance suite (status.json), and an index built with our compiler. # No previews (docs/WIDGET-INTEROP-PLAN.md Q10). pkgname=omamobile-owl-widgets -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 _commit=b63886b pkgdesc="Omarchy Mobile: OWL home-screen widgets from the omarchy-widgets store (the built-ins and the Store tab), checked against our runtime" @@ -24,5 +24,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" "$srcdir/omarchy-widgets" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" "$srcdir/omarchy-widgets" } diff --git a/packages/omamobile-owl-widgets/install b/packages/omamobile-owl-widgets/install index 77c975581..a86aebd53 100755 --- a/packages/omamobile-owl-widgets/install +++ b/packages/omamobile-owl-widgets/install @@ -33,3 +33,6 @@ install -Dm644 "$index" "$share/index.json" [[ -f $store/order.txt ]] && install -Dm644 "$store/order.txt" "$share/order.txt" install -Dm644 "$store/LICENSE" "$destination/usr/share/licenses/omamobile-owl-widgets/LICENSE" install -Dm644 "$here/version" "$share/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$share/version" diff --git a/packages/omamobile-remote/PKGBUILD b/packages/omamobile-remote/PKGBUILD index 5c15e6056..1292f40c4 100644 --- a/packages/omamobile-remote/PKGBUILD +++ b/packages/omamobile-remote/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-remote -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Use an Omarchy Mobile phone over ssh like a person would: screenshots, keys, taps, scrolling, locking, unlocking, apps, keeping it awake during a test. Opt-in, enables nothing" arch=(any) @@ -15,5 +15,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-remote/bin/omamobile-remote b/packages/omamobile-remote/bin/omamobile-remote index c0e11867d..7f56c9a4c 100755 --- a/packages/omamobile-remote/bin/omamobile-remote +++ b/packages/omamobile-remote/bin/omamobile-remote @@ -136,7 +136,7 @@ cmd=${1:-help} shift || true case $cmd in help|-h|--help) sed -n '3,30p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; - version) echo "omamobile-remote 0.1.2"; exit 0 ;; + version) echo "omamobile-remote @VERSION@"; exit 0 ;; # the package's version, set by install esac find_session diff --git a/packages/omamobile-remote/install b/packages/omamobile-remote/install index 11eed7a38..86bcbece4 100755 --- a/packages/omamobile-remote/install +++ b/packages/omamobile-remote/install @@ -1,6 +1,8 @@ #!/bin/bash # SPDX-License-Identifier: MIT -# Stage the package into DESTDIR (./install DESTDIR, an absolute path). It +# Stage the package into DESTDIR (./install DESTDIR, an absolute path; +# OMAMOBILE_PKGVER, the PKGBUILD's pkgver, is what `omamobile-remote +# version` prints). It # installs scripts only: no unit, no udev rule, no group, no network listener. # Nothing here runs until somebody logs in over ssh and runs it. set -euo pipefail @@ -9,5 +11,6 @@ d=${1:?usage: install DESTDIR} cd "$(dirname "$(readlink -f "$0")")" install -Dm755 bin/omamobile-remote "$d/usr/bin/omamobile-remote" +sed -i "s/@VERSION@/${OMAMOBILE_PKGVER:-unknown}/" "$d/usr/bin/omamobile-remote" install -Dm644 README.md "$d/usr/share/doc/omamobile-remote/README.md" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-remote/LICENSE" diff --git a/packages/omamobile-remote/test/all b/packages/omamobile-remote/test/all index be1f849f4..7f97aa783 100755 --- a/packages/omamobile-remote/test/all +++ b/packages/omamobile-remote/test/all @@ -17,9 +17,11 @@ trap 'rm -rf "$tmp"' EXIT mkdir -p "$tmp/noproc" export OMAMOBILE_REMOTE_PROC=$tmp/noproc -# --- the printed version matches the version file -check "omamobile-remote version prints the version file" \ - test "$(bin/omamobile-remote version)" = "omamobile-remote $(cat version)" +# --- the printed version is the package's: install puts pkgver in +mkdir -p "$tmp/dest" +OMAMOBILE_PKGVER=0.1.7.2.gabc1234 ./install "$tmp/dest" >/dev/null +check "omamobile-remote version prints the version install was given" \ + test "$("$tmp/dest/usr/bin/omamobile-remote" version)" = "omamobile-remote 0.1.7.2.gabc1234" # --- the scripts parse for f in bin/* install test/all test/fake/*; do diff --git a/packages/omamobile-sensors/PKGBUILD b/packages/omamobile-sensors/PKGBUILD index 6bf774034..36397788e 100644 --- a/packages/omamobile-sensors/PKGBUILD +++ b/packages/omamobile-sensors/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-sensors -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile sensors for the Pixel 7 Pro: iio-sensor-proxy's D-Bus API from the AoC, auto-rotate for Hyprland" arch=(any) diff --git a/packages/omamobile-settings/PKGBUILD b/packages/omamobile-settings/PKGBUILD index 28ab9ed7f..f8b7c44a8 100644 --- a/packages/omamobile-settings/PKGBUILD +++ b/packages/omamobile-settings/PKGBUILD @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT pkgname=omamobile-settings -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Native mobile Settings framework and device information" arch=(aarch64 x86_64) diff --git a/packages/omamobile-shell/PKGBUILD b/packages/omamobile-shell/PKGBUILD index b662b4da6..ddf800c18 100644 --- a/packages/omamobile-shell/PKGBUILD +++ b/packages/omamobile-shell/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-shell -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile's phone profile for the Omarchy shell: status bar, quick settings, launcher" arch=(any) @@ -26,7 +26,7 @@ backup=(etc/xdg/xdg-desktop-portal/hyprland-portals.conf) install=omamobile-shell.install package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } check() { diff --git a/packages/omamobile-shell/README.md b/packages/omamobile-shell/README.md index 71f4ac874..f811a1453 100644 --- a/packages/omamobile-shell/README.md +++ b/packages/omamobile-shell/README.md @@ -100,6 +100,6 @@ Open, save and choose-a-folder requests through the portal (Qt, GTK, Electron an `hypr/phone.lua` maximizes every app between the bar and the dock, with no gaps, no border and full opacity (Omarchy's 0.96-0.985 let the home widgets show through). When the maximized window closes, the next one takes the screen (`misc:exit_window_retains_fullscreen`). Modal dialogs float centred at their own size, never bigger than the screen; picture-in-picture is 300x169 in the top-right corner. `omamobile-setup-user` sets the monitor scale to 3 with `GDK_SCALE` to match, gives foot 6 px padding, a scrollback multiplier of 3 and a 300 ms long press, and adds Chromium's Wayland input-method flags, each once and only over Omarchy's own values. -The package contract follows omarchy-mac's: `./install DESTDIR` stages files and enables nothing, `test/all` runs the package's own tests, and `version` holds the version. +The package contract follows omarchy-mac's: `./install DESTDIR` stages files and enables nothing, `test/all` runs the package's own tests, and `version` holds the version series (`tools/pkg-version` counts the rest from `main`'s history). Develop on a desktop with `phone/dev/run-desktop` from the repo root. diff --git a/packages/omamobile-shell/install b/packages/omamobile-shell/install index f886a7c8d..a83482f36 100755 --- a/packages/omamobile-shell/install +++ b/packages/omamobile-shell/install @@ -74,3 +74,6 @@ install -Dm644 LICENSE "$destination/usr/share/licenses/omamobile-shell/LICENSE" # come from omamobile-owl-widgets, which ships the store's licence. install -Dm644 widgets/LICENSE-owl-guide "$destination/usr/share/licenses/omamobile-shell/LICENSE-owl-guide" install -Dm644 version "$destination/usr/share/omamobile/shell/version" +# The package's own version (tools/pkg-version), which the file's +# series doesn't give +[[ -z ${OMAMOBILE_PKGVER:-} ]] || echo "$OMAMOBILE_PKGVER" > "$destination/usr/share/omamobile/shell/version" diff --git a/packages/omamobile-speaker-tuning/PKGBUILD b/packages/omamobile-speaker-tuning/PKGBUILD index 118629594..17a328a56 100644 --- a/packages/omamobile-speaker-tuning/PKGBUILD +++ b/packages/omamobile-speaker-tuning/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-speaker-tuning -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile speaker tuning for the Pixel 7 Pro: Waves on the AoC, configured from the user's own vendor files" arch=(aarch64) @@ -15,5 +15,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-speaker-tuning/install b/packages/omamobile-speaker-tuning/install index 0c57a3eaf..0f8d5fc15 100755 --- a/packages/omamobile-speaker-tuning/install +++ b/packages/omamobile-speaker-tuning/install @@ -21,3 +21,6 @@ install -Dm644 systemd/omamobile-speaker-tuning.service "$d/usr/lib/systemd/syst install -Dm644 etc/omamobile/speaker-tuning.conf "$d/etc/omamobile/speaker-tuning.conf" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-speaker-tuning/LICENSE" install -Dm644 version "$d/usr/share/omamobile/speaker-tuning/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/speaker-tuning/version" diff --git a/packages/omamobile-telephony-tegu/PKGBUILD b/packages/omamobile-telephony-tegu/PKGBUILD index 0da8e53cb..a0e8fe600 100644 --- a/packages/omamobile-telephony-tegu/PKGBUILD +++ b/packages/omamobile-telephony-tegu/PKGBUILD @@ -1,6 +1,6 @@ # SPDX-License-Identifier: MIT pkgname=omamobile-telephony-tegu -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Opt-in Pixel 9a Phone/Messages bridge attachment to an already running sitd" arch=(any) @@ -15,5 +15,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-telephony-tegu/install b/packages/omamobile-telephony-tegu/install index df5c69d86..1d26b7544 100755 --- a/packages/omamobile-telephony-tegu/install +++ b/packages/omamobile-telephony-tegu/install @@ -10,3 +10,6 @@ install -Dm644 systemd/10-tegu-attach.conf "$d/usr/lib/systemd/system/omamobile- install -Dm644 README.md "$d/usr/share/doc/omamobile-telephony-tegu/README.md" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-telephony-tegu/LICENSE" install -Dm644 version "$d/usr/share/omamobile/telephony-tegu/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/telephony-tegu/version" diff --git a/packages/omamobile-voice/PKGBUILD b/packages/omamobile-voice/PKGBUILD index 88870f2a6..b966a49fd 100644 --- a/packages/omamobile-voice/PKGBUILD +++ b/packages/omamobile-voice/PKGBUILD @@ -17,7 +17,7 @@ # makepkg has no fallback for one source; a copy on our own server would # replace this URL (same file name, same sha256). pkgname=omamobile-voice -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 _commit=5359861c739e955e79d9a303bcbc70fb988958b1 _model=ggml-base.en.bin diff --git a/packages/omamobile-voice/test/all b/packages/omamobile-voice/test/all index 7467fe3df..67e4dddfb 100755 --- a/packages/omamobile-voice/test/all +++ b/packages/omamobile-voice/test/all @@ -18,8 +18,11 @@ bash -n "$here/PKGBUILD" || fail "PKGBUILD parses" eval "$(startdir=$here bash -c 'source "$startdir/PKGBUILD" printf "pkgname=%q pkgver=%q commit=%q model=%q url0=%q sum0=%q\n" "$pkgname" "$pkgver" "$_commit" "$_model" "${source[0]}" "${sha256sums[0]}" printf "deps=%q\n" "${depends[*]:-}"')" -[[ $pkgname == omamobile-voice && $pkgver == "$(cat "$here/version")" ]] || fail "name and version" -ok "PKGBUILD parses, version from ./version" +# The version: a build tool's copy carries it as .pkgver (no git there), +# the repository works it out with tools/pkg-version +if [[ -f $here/.pkgver ]]; then want=$(cat "$here/.pkgver"); else want=$("$repo/tools/pkg-version" "$here"); fi +[[ $pkgname == omamobile-voice && -n $pkgver && $pkgver == "$want" ]] || fail "name and version" +ok "PKGBUILD parses, version from .pkgver or tools/pkg-version" [[ $commit =~ ^[0-9a-f]{40}$ ]] || fail "the source is pinned to a full commit, not a branch: $commit" [[ $url0 == "$model-$commit::https://huggingface.co/ggerganov/whisper.cpp/resolve/$commit/$model" ]] || fail "the model's URL names the pinned commit: $url0" diff --git a/packages/omamobile-waydroid/PKGBUILD b/packages/omamobile-waydroid/PKGBUILD index f3962f705..175a98ec9 100644 --- a/packages/omamobile-waydroid/PKGBUILD +++ b/packages/omamobile-waydroid/PKGBUILD @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Maintainer: Derek Ross pkgname=omamobile-waydroid -pkgver=$(cat "${startdir:-.}/version") +pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}") pkgrel=1 pkgdesc="Omarchy Mobile Waydroid integration: kernel checks, container hardening, Mali-G710 Mesa overlay, ufw rules" arch=(any) @@ -17,5 +17,5 @@ check() { } package() { - "$startdir/install" "$pkgdir" + OMAMOBILE_PKGVER=$pkgver "$startdir/install" "$pkgdir" } diff --git a/packages/omamobile-waydroid/install b/packages/omamobile-waydroid/install index f549dfc22..d40148578 100755 --- a/packages/omamobile-waydroid/install +++ b/packages/omamobile-waydroid/install @@ -20,3 +20,6 @@ install -Dm644 libalpm/90-omamobile-waydroid.hook "$d/usr/share/libalpm/hooks/90 install -Dm644 etc/omamobile/waydroid.conf "$d/etc/omamobile/waydroid.conf" install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-waydroid/LICENSE" install -Dm644 version "$d/usr/share/omamobile/waydroid/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/waydroid/version" diff --git a/tests/all b/tests/all index e10e54b42..5d94d467a 100755 --- a/tests/all +++ b/tests/all @@ -93,6 +93,10 @@ echo "# tests/install-guided" # the guided install, against stand-ins for the tests/install-guided echo "# tests/chroot-extractors" tests/chroot-extractors +echo "# tests/pkg-version" # the counted package versions, and the tool and its library parse +bash -n tools/pkg-version +bash -n tools/lib/pkg-tar.sh +tests/pkg-version echo "# tests/rootfs-smoke-link" # the smoke test's install-link checks, on small made-up images tests/rootfs-smoke-link echo "# tests/build-packages-deps" # a package's dependencies into the build container, behind a library change too diff --git a/tests/build-packages-host-tools b/tests/build-packages-host-tools index 8d7f88560..f30af3fc9 100755 --- a/tests/build-packages-host-tools +++ b/tests/build-packages-host-tools @@ -18,7 +18,7 @@ R=$t/repo trap 'gpgconf --homedir "$R/keys/testdev/gnupg" --kill gpg-agent 2>/dev/null || true; rm -rf "$t"' EXIT mkdir -p "$R/tools/lib" "$R/device/testdev" "$R/packages" "$t/bin" "$t/tmp" -cp tools/build-packages tools/stage-boot-files "$R/tools/" && cp omamobile.conf "$R/" +cp tools/build-packages tools/stage-boot-files tools/pkg-version "$R/tools/" && cp tools/lib/pkg-tar.sh "$R/tools/lib/" && cp omamobile.conf "$R/" mkdir -p "$R/packages/omamobile-boot-update/lib" && cp packages/omamobile-boot-update/lib/descriptor.sh "$R/packages/omamobile-boot-update/lib/" printf 'CODENAME=testdev\n' > "$R/device/testdev/device.conf" cat > "$R/tools/lib/alarm.sh" <<'A' @@ -115,3 +115,17 @@ for tool in $(grep -v '^#' packages/omamobile-settings/test/host-tools); do done grep -c '^qmake6$' packages/omamobile-settings/test/host-tools >/dev/null || fail "omamobile-settings names qmake6" pass "omamobile-settings names qmake6 and the other commands its test calls" + +# A counted package's version is tools/pkg-version's, as pkg_tar ships it: a +# .pkgver left in its directory doesn't make an old build "up to date" +mkdir -p "$R/packages/counted" +echo 0.1 > "$R/packages/counted/version" && echo .pkgver > "$R/packages/.gitignore" # as this repository has it +printf 'pkgname=counted\npkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}")\npkgrel=1\narch=(any)\n' > "$R/packages/counted/PKGBUILD" +(cd "$R" && git add -A && git -c user.name=t -c user.email=t@invalid -c commit.gpgsign=false commit -q -m fixture) +echo 0.0.9 > "$R/packages/counted/.pkgver" +mkdir -p "$R/out/testdev/repo/aarch64" && : > "$R/out/testdev/repo/aarch64/counted-0.0.9-1-any.pkg.tar.zst" +# (the slow packages --list also reports aren't in this copy, so it ends non-zero) +list=$(cd "$R" && PATH=$t/bin:$PATH ALARM_TEST_CACHE=$t/cache tools/build-packages --local testdev --list packages/counted 2>&1 || true) +grep -c -x 'to build packages/counted 0.1.0-1' <<<"$list" >/dev/null \ + || { echo "$list"; fail "a stale .pkgver doesn't make a counted package up to date"; } +pass "a counted package's version comes from tools/pkg-version, not a .pkgver left in its directory" diff --git a/tests/local-builds b/tests/local-builds index 179d7410c..3de03df0e 100755 --- a/tests/local-builds +++ b/tests/local-builds @@ -18,8 +18,8 @@ trap 'gpgconf --homedir "$t/signer" --kill gpg-agent 2>/dev/null || true; gpgcon R=$t/repo mkdir -p "$R/tools/lib" "$R/device/panther" "$R/packages" -cp tools/local-key-init tools/fetch-published tools/build-packages tools/build-rootfs "$R/tools/" -cp tools/lib/alarm.sh tools/lib/alarm-setup "$R/tools/lib/" +cp tools/local-key-init tools/fetch-published tools/build-packages tools/build-rootfs tools/pkg-version "$R/tools/" +cp tools/lib/alarm.sh tools/lib/alarm-setup tools/lib/pkg-tar.sh "$R/tools/lib/" cp device/panther/device.conf "$R/device/panther/" cp -a packages/omamobile-device-panther "$R/packages/" run() { (cd "$R" && "$@") > "$t/log" 2>&1; } diff --git a/tests/pinned-packages b/tests/pinned-packages index edf58de52..d7aa5d577 100755 --- a/tests/pinned-packages +++ b/tests/pinned-packages @@ -29,8 +29,8 @@ cleanup() { trap cleanup EXIT mkdir -p "$R/tools/lib" "$R/rootfs" "$R/packages/omamobile-keyring" "$R/keys" "$t/up" "$t/imp" -cp tools/build-packages "$R/tools/" -cp tools/lib/alarm.sh tools/lib/signing.sh "$R/tools/lib/" +cp tools/build-packages tools/pkg-version "$R/tools/" +cp tools/lib/alarm.sh tools/lib/signing.sh tools/lib/pkg-tar.sh "$R/tools/lib/" run() { (cd "$R" && "$@") > "$t/log" 2>&1; } # The release key as tools/release-key-init makes it, trusted by the keyring diff --git a/tests/pkg-version b/tests/pkg-version new file mode 100755 index 000000000..643cdcf76 --- /dev/null +++ b/tests/pkg-version @@ -0,0 +1,274 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# tools/pkg-version (and tools/lib/pkg-tar.sh) against a throwaway repository: +# the count from the commit whose PKGBUILD opts in, a third number as a floor +# only, two PRs that wrote the same number, a new series, branch builds, a +# package that keeps a written version, a moved tool, and the refusals +# without history. Then this repository's own rules (boot-file packages keep +# written versions) and a replay of its history as if the count had started +# at its first commit: no package may keep or lower its version across a +# commit that touched it, or fall below the number its version file gave. +set -euo pipefail +here=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd) +t=$(mktemp -d) +trap 'rm -rf "$t"' EXIT +n=0 +ok() { n=$((n + 1)); echo "ok $n - $1"; } +fail() { echo "not ok - $*" >&2; exit 1; } +is() { [[ $1 == "$2" ]] || fail "$3: got '$1', expected '$2'"; ok "$3"; } + +r=$t/repo +mkdir -p "$r/packages/demo" "$r/tools/lib" +cd "$r" +git init -q -b main +git config user.name Tester +git config user.email tester@example.org +pv() { tools/pkg-version "$@" 2>&1; } +change() { mkdir -p "$(dirname "packages/${2:-demo}/$1")" && echo "$RANDOM $*" >> "packages/${2:-demo}/$1"; } +commit() { git add -A && git commit -q -m "$1"; } + +# Before the tool: the version file is the version, as it was published. +echo 0.2.5 > packages/demo/version; change code; commit "demo 0.2.5" +change code; commit "demo: a change that forgot its bump" +cp "$here/tools/lib/pkg-tar.sh" tools/lib/ +echo "pkgname=demo" > packages/demo/PKGBUILD +cat >> packages/demo/PKGBUILD <<'EOF' +pkgver=$(cat "${startdir:-.}/version") +pkgrel=1 +EOF +commit "demo: a PKGBUILD" +is "$(git show HEAD~1:packages/demo/version)" 0.2.5 "fixture" +cp -r packages/demo packages/kept; commit "kept: a package that keeps its written version" + +# The tool lands; nothing counts until a PKGBUILD reads .pkgver. +cp "$here/tools/pkg-version" tools/; commit "tools/pkg-version" +is "$(pv demo)" 0.2.5 "the commit that adds the tool doesn't change a package's version" +sed -i 's|^pkgver=.*|pkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null \|\| "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}")|' packages/demo/PKGBUILD +commit "demo: read the counted version" +is "$(pv demo)" 0.2.6 "the commit that opts in is the next number after the published one" +change code; commit "demo: a change, no bump" +is "$(pv demo)" 0.2.7 "a commit touching the package is the next number" +echo 0.2.6 > packages/demo/version; change code; commit "demo 0.2.6: an old-style bump to a taken number" +is "$(pv demo)" 0.2.8 "a third number at or below the count changes nothing" +echo 0.2.20 > packages/demo/version; commit "demo 0.2.20: a jump" +is "$(pv demo)" 0.2.20 "a higher third number is a floor" +c20=$(git rev-parse HEAD) +change test/all; commit "demo: tests only" +is "$(pv demo)" 0.2.21 "every commit under the package counts" +echo 0.3 > packages/demo/version; commit "demo: a new series" +is "$(pv demo)" 0.3.0 "a new series starts at 0" +change code; commit "demo: a change" +is "$(pv demo)" 0.3.1 "and counts on" +is "$(pv --commit demo 0.2.20)" "$c20" "--commit finds the commit a version was built from" +is "$(pv --commit demo 0.2.5)" "$(git rev-list --max-parents=0 HEAD)" "--commit finds a version from before the tool" +is "$(pv --history demo | wc -l)" 10 "--history lists every commit that touched the package" +pv --commit demo 0.9.9 >/dev/null && fail "an unknown version is refused" +ok "an unknown version is refused" +change code kept; commit "kept: a change, no bump" +is "$(pv kept)" 0.2.5 "a package whose PKGBUILD doesn't read .pkgver keeps its written version" +echo 0.2.6 > packages/kept/version; commit "kept 0.2.6" +is "$(pv kept)" 0.2.6 "and takes the next one when it is written" +is "$(OMAMOBILE_PKGVER_SINCE=$(git rev-list --max-parents=0 HEAD) pv demo)" 0.3.1 "the old start override in the environment changes nothing" +pv --count-from HEAD demo >/dev/null && fail "--count-from is refused without --history" +ok "--count-from is refused without --history" + +# Two PRs both write 0.3.2, squash-merged one after the other: the merge +# shows no conflict, and each lands with its own number. +git checkout -q -b pr-a; echo 0.3.2 > packages/demo/version; change a; commit "demo 0.3.2: A" +a=$(pv demo) +git checkout -q main; git checkout -q -b pr-b; echo 0.3.2 > packages/demo/version; change b; commit "demo 0.3.2: B" +git checkout -q main; git merge -q --squash pr-a >/dev/null; commit "demo 0.3.2: A (#1)" +is "$(pv demo)" 0.3.2 "the first PR lands as 0.3.2" +git merge -q --squash pr-b >/dev/null 2>&1 +commit "demo 0.3.2: B (#2)" +is "$(pv demo)" 0.3.3 "the second PR, with the same number in its file, lands as 0.3.3" +[[ $a =~ ^0\.3\.1\.1\.g[0-9a-f]{7}$ ]] || fail "a branch build: got $a" +ok "a branch build is main's version at the base, its own commits and the commit ($a)" + +# A merge commit on main (not squashed) is one commit on main's line. +git checkout -q -b pr-c; change c; commit "c1"; change c; commit "c2" +git checkout -q main; git merge -q --no-ff -m "Merge pr-c" pr-c +is "$(pv demo)" 0.3.4 "a merge commit counts once, not per commit it brings" +# The commits it brought are on main's history but not its line: branch +# builds of the commit they left main at, never one of main's numbers. +v=$(pv --rev pr-c~1 demo) +[[ $v == 0.3.3.1.g$(git rev-parse --short=7 pr-c~1) ]] || fail "a merged branch's first commit: got $v" +ok "a commit a merge brought in is a branch build ($v)" +v=$(pv --rev pr-c demo) +[[ $v == 0.3.3.2.g$(git rev-parse --short=7 pr-c) ]] || fail "a merged branch's second commit: got $v" +ok "and so is the next one ($v)" + +# The tool moves (and its PKGBUILD line with it): one more number, never a +# restart from the stale version file. +git checkout -q -b moved +mkdir -p tools/bin && git mv tools/pkg-version tools/bin/pkg-version +sed -i 's|tools/pkg-version|tools/bin/pkg-version|' packages/demo/PKGBUILD; commit "tools: move pkg-version" +is "$(tools/bin/pkg-version --main moved demo)" 0.3.5 "moving the tool is one more number" +change code; commit "demo: after the move" +is "$(tools/bin/pkg-version --main moved demo)" 0.3.6 "and the count goes on" +git checkout -q main + +# Branch builds against main. +git checkout -q -b other; echo x > README.md; commit "elsewhere" +is "$(pv demo)" 0.3.4 "a branch that doesn't touch the package builds main's version" +change code; commit "demo on a branch"; change code; commit "again" +v=$(pv demo) +[[ $v == 0.3.4.2.g$(git rev-parse --short=7 HEAD) ]] || fail "two branch commits: got $v" +ok "two branch commits: $v" +mkdir -p packages/fresh; echo 0.1 > packages/fresh/version; commit "fresh" +v=$(pv fresh) +[[ $v =~ ^0\.1\.0pre1\.g[0-9a-f]{7}$ ]] || fail "a new package on a branch: got $v" +ok "a new package on a branch builds below main's first ($v)" +echo 0.4 > packages/demo/version; commit "demo 0.4 on a branch" +v=$(pv demo) +[[ $v =~ ^0\.4\.0pre3\.g[0-9a-f]{7}$ ]] || fail "a new series on a branch: got $v" +ok "a new series on a branch builds below main's first of it ($v)" +[[ $(pv --main other demo) == 0.4.0 ]] || fail "--main names the line to count on" +ok "--main names the line to count on" +git checkout -q main + +# Edits not committed yet: their own version, one per edit, between the +# commit's and the next. +change code; v1=$(pv demo) +[[ $v1 =~ ^0\.3\.4\.d[0-9a-f]{7}$ ]] || fail "an uncommitted edit: got $v1" +ok "an uncommitted edit builds above the commit ($v1)" +change code; v2=$(pv demo) +[[ $v2 =~ ^0\.3\.4\.d[0-9a-f]{7}$ && $v2 != "$v1" ]] || fail "a second edit: got $v2 after $v1" +ok "each edit is a new version ($v2)" +is "$(pv --rev HEAD demo)" 0.3.4 "--rev names the commit alone" +git checkout -q -- packages/demo +is "$(pv demo)" 0.3.4 "undone edits build the commit's version" +change new-file; v1=$(pv demo) +[[ $v1 =~ \.d[0-9a-f]{7}$ ]] || fail "a new file not added yet: got $v1" +ok "a new file counts before git add ($v1)" +rm packages/demo/new-file +mkdir -p packages/demo/src && echo x > packages/demo/src/ignored && printf '%s\n' src/ .pkgver > packages/.gitignore +git add packages/.gitignore && commit "ignore makepkg's src and .pkgver, as this repository does" +is "$(pv demo)" 0.3.4 "a gitignored file (makepkg's src/) doesn't" +mkdir -p packages/newpkg && echo 0.1 > packages/newpkg/version +v=$(pv newpkg) +[[ $v =~ ^0\.1\.0pre0\.d[0-9a-f]{7}$ ]] || fail "an uncommitted package: got $v" +ok "a package not committed yet builds below its first commit ($v)" +rm -rf packages/newpkg packages/demo/src + +# The copy a build container or the phone gets: .pkgver, and the PKGBUILD +# reads it there without git. +( + source tools/lib/pkg-tar.sh + mkdir "$t/copy" + pkg_tar packages/demo | tar xf - -C "$t/copy" +) +is "$(cat "$t/copy/demo/.pkgver")" 0.3.4 "pkg_tar puts the version in the copy" +is "$(cd "$t/copy/demo" && startdir=$PWD bash -c 'source ./PKGBUILD; echo $pkgver')" 0.3.4 "the PKGBUILD reads it there" +echo 9.9.9 > packages/demo/.pkgver +rm -rf "$t/copy2" && mkdir "$t/copy2" +(source tools/lib/pkg-tar.sh; pkg_tar packages/demo | tar xf - -C "$t/copy2") +is "$(cat "$t/copy2/demo/.pkgver")" 0.3.4 "a stale .pkgver in the directory loses to the fresh one" +rm packages/demo/.pkgver + +# A version file that doesn't parse is refused, not built under the +# number before it. +git checkout -q -b badfile; echo 0.3-beta > packages/demo/version; commit "demo: a bad version file" +pv --main badfile demo >/dev/null && fail "a version file that doesn't parse is refused" +ok "a version file that doesn't parse is refused" +git checkout -q main + +# Without the history: refuse, never guess. +git clone -q --depth 1 "file://$r" "$t/shallow" +(cd "$t/shallow" && tools/pkg-version demo) >/dev/null 2>&1 && fail "a shallow clone is refused" +ok "a shallow clone is refused" +mkdir -p "$t/nogit-tree/packages" "$t/nogit-tree/tools" && cp -r packages/demo "$t/nogit-tree/packages/" && cp tools/pkg-version "$t/nogit-tree/tools/" +(cd "$t/nogit-tree/packages/demo" && startdir=$PWD bash -c 'source ./PKGBUILD; [[ -z $pkgver ]]') 2>/dev/null || + fail "a copy without .git gets no version" +ok "a copy without .git gets no version (makepkg stops on an empty pkgver)" +(source tools/lib/pkg-tar.sh; cd "$t/nogit-tree" && pkg_tar packages/demo >/dev/null 2>&1) && fail "pkg_tar refuses without a version" +ok "pkg_tar refuses without a version" + +# pacman's order, where pacman is (CI's Arch container). +if command -v vercmp >/dev/null; then + lt() { [[ $(vercmp "$1" "$2") == -1 ]] || fail "vercmp $1 < $2"; } + lt 0.3.4 0.3.4.1.gabc1234; lt 0.3.4.1.gfffffff 0.3.4.2.g0000000; lt 0.3.4.2.g0000000 0.3.5 + lt 0.1.0pre1.gabc1234 0.1.0; lt 0.1.0pre9.gabc1234 0.1.0pre10.gabc1234; lt 0.4.0pre3.gabc1234 0.4.0 + lt 0.3.4 0.3.4.dabc1234; lt 0.3.4.dfff1234 0.3.5; lt 0.3.4.dfff1234 0.3.4.1.g0000000 + lt 0.3.4.1.gabc1234 0.3.4.1.gabc1234.d0000000; lt 0.3.4.1.gfff1234.dfff1234 0.3.4.2.g0000000 + lt 0.1.0pre0.dfff1234 0.1.0pre1.g0000000 + ok "pacman orders branch builds between main's builds" +else + ok "# skip: no vercmp for pacman's order" +fi + +# Every package that puts its version file on the phone writes the +# package's version there, not the file's series: its PKGBUILD hands pkgver +# to install, and install writes it (run here for the packages whose install +# needs no build). +cd "$here" +shipped=0 ran=0 +for i in packages/*/install; do + p=$(basename "$(dirname "$i")") + [[ $p != linux-omamobile ]] || continue # pkgrel only, its pkgver is the kernel's + grep -c -E 'install -Dm644 (version|"\$here/version") ' "$i" >/dev/null || continue + grep -c 'OMAMOBILE_PKGVER=$pkgver "$startdir/install"' "packages/$p/PKGBUILD" >/dev/null || + fail "$p: its PKGBUILD doesn't hand pkgver to install" + rm -rf "$t/inst" + # Some installs need a build first (prebuilt/, a source tree): those that + # run here are checked, and enough of them must run + if OMAMOBILE_PKGVER=9.8.7.6.gabc1234 "$i" "$t/inst" >/dev/null 2>&1; then + [[ -n $(grep -rlx 9.8.7.6.gabc1234 "$t/inst/usr/share/omamobile" 2>/dev/null) ]] || + fail "$p: install writes the version it is given" + ran=$((ran + 1)) + fi + shipped=$((shipped + 1)) +done +((shipped >= 20)) || fail "only $shipped packages ship a version file: the pattern no longer matches" +((ran >= 5)) || fail "only $ran of $shipped installs ran here" +ok "the $shipped packages that ship a version file hand it pkgver, and the $ran installs that run here write it" + +# A package that ships boot files keeps a written version (they reach +# release phones' slot B only after the maintainer has booted them). +boot=0 +for i in packages/*/install; do + grep -c OMAMOBILE_BOOT_FILES "$i" >/dev/null || continue + p=$(basename "$(dirname "$i")") + grep -c -F '/.pkgver"' "packages/$p/PKGBUILD" >/dev/null && fail "$p ships boot files and counts its version" + boot=$((boot + 1)) +done +((boot >= 1)) || fail "no package ships boot files: the pattern no longer matches" +ok "the $boot package(s) that ship boot files keep a written version" + +# Only these keep a written version: a new package copied from an older +# PKGBUILD would otherwise stay on one without anyone noticing +written=(omamobile-device-cheetah omamobile-keyring) +for f in packages/*/PKGBUILD; do + p=$(basename "$(dirname "$f")") + grep -c -F '/.pkgver"' "$f" >/dev/null && continue + grep -c -E '^pkgver=.*/version"' "$f" >/dev/null || continue + [[ " ${written[*]} " == *" $p "* ]] || + fail "$p reads a written version: read .pkgver as the other packages do, or name it in tests/pkg-version" +done +ok "only ${written[*]} keep a written version" + +# This repository's own history, replayed from its first commit. +if [[ $(git rev-parse --is-shallow-repository) == true ]]; then + ok "# skip: a shallow clone has no history to replay" + exit 0 +fi +first=$(git rev-list --max-parents=0 HEAD | tail -1) +checked=0 commits=0 +for f in packages/*/PKGBUILD; do + grep -c -F '/.pkgver"' "$f" >/dev/null || continue + p=$(basename "$(dirname "$f")") + prev= + while read -r c v; do + file=$(git show "$c:packages/$p/version" | tr -d '[:space:]') + if [[ -n $prev && ${prev%.*} == "${v%.*}" ]]; then + [[ $(printf '%s\n' "$prev" "$v" | sort -V | tail -1) == "$v" && $prev != "$v" ]] || + fail "$p: $v at $c does not follow $prev" + fi + if [[ $file =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + [[ $(printf '%s\n' "$file" "$v" | sort -V | tail -1) == "$v" ]] || fail "$p: $v at $c is below its file's $file" + fi + prev=$v commits=$((commits + 1)) + done < <(tools/pkg-version --main HEAD --history --count-from "$first" "$p") + checked=$((checked + 1)) +done +ok "replayed $checked packages over $commits commits from the first one: every commit a new number, none below its file's" diff --git a/tests/release-signing b/tests/release-signing index c2252c1c0..8e4b6dca8 100755 --- a/tests/release-signing +++ b/tests/release-signing @@ -27,8 +27,8 @@ cleanup() { trap cleanup EXIT mkdir -p "$R/tools/lib" "$R/packages/omamobile-keyring" "$R/keys" "$R/out/repo/aarch64" "$t/bin" -cp tools/build-packages tools/repo-publish "$R/tools/" -cp tools/lib/alarm.sh tools/lib/signing.sh "$R/tools/lib/" +cp tools/build-packages tools/repo-publish tools/pkg-version "$R/tools/" +cp tools/lib/alarm.sh tools/lib/signing.sh tools/lib/pkg-tar.sh "$R/tools/lib/" run() { (cd "$R" && PATH="$t/bin:$PATH" "$@") > "$t/log" 2>&1; } # The original key: one signing key. The release key as tools/release-key-init diff --git a/tests/repo-publish-stage b/tests/repo-publish-stage index 8bef0715b..b35f5d47b 100755 --- a/tests/repo-publish-stage +++ b/tests/repo-publish-stage @@ -220,3 +220,17 @@ expect_index v2 expect "without a record, a no-op keeps v1 and drops what the failed v3 copied" base-1-1 app-1-1 app-2-1 stages v3 "stages v3 after that" expect "and the next change keeps only the set it replaces" base-1-1 app-2-1 app-3-1 + +# A branch build or a build of uncommitted edits is never published, and +# the channel is left as it was. +before=$(have) +make_repo vg base-1-1 app-0.2.1.1.gabc1234-1 +if run_stage vg; then fail "refuses a branch build"; fi +grep -c 'test builds' "$t/log" >/dev/null || fail "says why a branch build is refused" +make_repo vd base-1-1 app-0.2.1.dabc1234-1 +if run_stage vd; then fail "refuses a build of uncommitted edits"; fi +[[ $(have) == "$before" ]] || fail "a refused test build changes nothing in the channel" +pass "test builds (.g, .d) are refused and change nothing" +make_repo vk base-1-1 linux-omamobile-7.3.0rc6.r4521.g0123456789ab-1 +stages vk "a release kernel's 12-digit commit is not a test build" +pass "a release kernel's 12-digit commit is not a test build" diff --git a/tests/stage-boot-files b/tests/stage-boot-files index 9cdb848b4..5ac85afeb 100755 --- a/tests/stage-boot-files +++ b/tests/stage-boot-files @@ -55,7 +55,7 @@ pass "repo-publish carries boot-files/; build-packages checks them, verifies the # a throwaway local key. if command -v gpg >/dev/null && command -v zstd >/dev/null; then R=$t/repo && mkdir -p "$R/tools/lib" "$R/device/testdev" "$R/packages" "$t/bin" "$t/tmp" - cp tools/build-packages tools/stage-boot-files "$R/tools/" && cp omamobile.conf "$R/" + cp tools/build-packages tools/stage-boot-files tools/pkg-version "$R/tools/" && cp tools/lib/pkg-tar.sh "$R/tools/lib/" && cp omamobile.conf "$R/" mkdir -p "$R/packages/omamobile-boot-update/lib" && cp packages/omamobile-boot-update/lib/descriptor.sh "$R/packages/omamobile-boot-update/lib/" printf 'CODENAME=testdev\n' > "$R/device/testdev/device.conf" cat > "$R/tools/lib/alarm.sh" <<'A' @@ -72,6 +72,10 @@ A printf 'pkgname=%s\npkgver=$(cat "${startdir:-.}/version")\npkgrel=1\narch=(any)\n' "$p" > "$R/packages/$p/PKGBUILD" done printf '#!/bin/bash\nboot=${OMAMOBILE_BOOT_FILES:-boot-files}\n' > "$R/packages/omamobile-device-testdev/install" + # A package whose version tools/pkg-version can't work out (a version file + # that holds none): skipped like stale boot files, not the whole run + mkdir -p "$R/packages/nover" && echo none > "$R/packages/nover/version" + printf 'pkgname=nover\npkgver=$(cat "${startdir:-.}/.pkgver" 2>/dev/null || "${startdir:-.}/../../tools/pkg-version" "${startdir:-.}")\npkgrel=1\narch=(any)\n' > "$R/packages/nover/PKGBUILD" # The container: makepkg's result, a package with its .PKGINFO cat > "$t/bin/docker" <<'D' #!/bin/bash @@ -95,14 +99,16 @@ D ( cd "$R" && git init -q && git add -A ) rc=0 (cd "$R" && PATH=$t/bin:$PATH TMPDIR=$t/tmp ALARM_TEST_CACHE=$t/cache BUILT_LOG=$t/built tools/build-packages --nocheck --local testdev \ - packages/plain packages/omamobile-device-testdev) > "$t/bp.log" 2>&1 || rc=$? + packages/plain packages/omamobile-device-testdev packages/nover) > "$t/bp.log" 2>&1 || rc=$? gpgconf --homedir "$kd/gnupg" --kill gpg-agent 2>/dev/null || true [[ $rc == 3 ]] || { cat "$t/bp.log"; fail "build-packages exits 3 when a device package's boot files are missing (got $rc)"; } [[ $(cat "$t/built") == plain ]] || { cat "$t/bp.log"; fail "the other package is built, the device package is not"; } [[ -f $R/out/testdev/repo/aarch64/plain-1-1-any.pkg.tar.zst.sig ]] || { cat "$t/bp.log"; fail "and the other package is signed into the repository"; } grep -c 'SKIPPED: omamobile-device-testdev' "$t/bp.log" >/dev/null && grep -c 'not built, boot files missing or stale: omamobile-device-testdev' "$t/bp.log" >/dev/null \ || { cat "$t/bp.log"; fail "the skip is named, before the build and at the end"; } - [[ $(cat "$R/out/testdev/repo/.skipped") == omamobile-device-testdev ]] || fail "the skip list is in repo/.skipped" + grep -c 'SKIPPED: nover: no version' "$t/bp.log" >/dev/null && grep -c 'not built, no version: nover' "$t/bp.log" >/dev/null \ + || { cat "$t/bp.log"; fail "a package with no version is skipped and named, the rest built"; } + [[ $(cat "$R/out/testdev/repo/.skipped") == $'omamobile-device-testdev\nnover' ]] || fail "the skip list is in repo/.skipped" # Exit 3 from anything else is 1: a repo-add that returns 3 printf '#!/bin/bash\nexit 3\n' > "$t/bin/repo-add" rm -rf "$R/out/testdev/repo/aarch64"/* diff --git a/tools/build-packages b/tools/build-packages index 6f87fd474..65a8a270d 100755 --- a/tools/build-packages +++ b/tools/build-packages @@ -62,12 +62,13 @@ set -euo pipefail cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." ROOT=$PWD source tools/lib/alarm.sh +source tools/lib/pkg-tar.sh SLOW=(mesa hyprland libcamera) # Packed from a staged kernel build: built only when named (see above) NAMED_ONLY=(linux-omamobile) repo=out/repo/aarch64 -# Exit 3 means exactly "built and signed everything but the skipped device +# Exit 3 means exactly "built and signed everything but the skipped # packages", which /../.skipped then lists: any other exit with 3 (a # gpg, tar or repo-add that happened to return it) becomes 1. Set before # anything can fail; the old list goes once the repository is known @@ -147,6 +148,11 @@ pkg_version() { startdir=$PWD # shellcheck disable=SC1091 source ./PKGBUILD >/dev/null 2>&1 + # A counted version comes from tools/pkg-version, as pkg_tar ships it: a + # .pkgver left in the directory would keep a package "up to date" for good + if grep -c -F '/.pkgver"' PKGBUILD >/dev/null; then + pkgver=$("$ROOT/tools/pkg-version" "$PWD" 2>/dev/null) || pkgver= + fi echo "${epoch:+$epoch:}$pkgver-$pkgrel" ) } @@ -284,10 +290,15 @@ done # Staged inputs, checked before anything is built: a release kernel from a # published tag (named only, so a refusal stops the run), and boot files # that match this tree (a refusal skips that package and fails the run at -# the end) -skipped=() kept=() warned=() +# the end), and a version tools/pkg-version can work out (the same) +skipped=() noversion=() kept=() warned=() for d in "${build[@]}"; do name=$(basename "$d") + if [[ $(pkg_version "$d") == -* ]]; then + echo "SKIPPED: $name: no version (run tools/pkg-version $d for why); building the rest" >&2 + noversion+=("$name") + continue + fi # Only the kernel package packs a staged build; a named-only package # without a stage script compiles its own if [[ " ${NAMED_ONLY[*]} " == *" $name "* && -x $d/stage ]]; then @@ -366,10 +377,9 @@ for dir in "${build[@]}"; do name=$(basename "$dir") alarm_say "$name $(pkg_version "$dir")" work=$(mktemp -d) - # The package directory as it is (including gitignored prebuilt files the - # PKGBUILDs install), minus makepkg's work directories and old packages. - tar cf - --exclude="./$name/pkg" --exclude="./$name/src/build" --exclude='*.pkg.tar.*' \ - -C "$(dirname "$dir")" "./$name" | tar xf - -C "$work" + # The package directory as it is, with its version worked out here + # (tools/lib/pkg-tar.sh): the container has no git history. + pkg_tar "$dir" | tar xf - -C "$work" || { rm -rf "$work"; alarm_die "$name: no version (tools/pkg-version)"; } out=$work/out && mkdir -p "$out" incheck=0 if ((nocheck == 0)); then @@ -460,9 +470,12 @@ ls -1 "$repo" | grep -E '\.pkg\.tar\.zst$' for w in "${warned[@]}"; do printf '\e[33mwarning:\e[0m %s\n' "$w" >&2; done # Exit 3: everything else is built and signed (tools/repo-publish publishes # it, then fails too); any other failure exits 1 earlier -if ((${#skipped[@]})); then - printf '\e[31merror:\e[0m %s\n' "not built, boot files missing or stale: ${skipped[*]} (the rest is built and signed; stage them with tools/stage-boot-files)" >&2 +if ((${#skipped[@]} + ${#noversion[@]})); then + ((${#skipped[@]} == 0)) || + printf '\e[31merror:\e[0m %s\n' "not built, boot files missing or stale: ${skipped[*]} (the rest is built and signed; stage them with tools/stage-boot-files)" >&2 + ((${#noversion[@]} == 0)) || + printf '\e[31merror:\e[0m %s\n' "not built, no version: ${noversion[*]} (the rest is built and signed; tools/pkg-version says why)" >&2 mkdir -p "$(dirname "$skipfile")" - printf '%s\n' "${skipped[@]}" > "$skipfile" + printf '%s\n' "${skipped[@]}" "${noversion[@]}" | sed '/^$/d' > "$skipfile" exit 3 fi diff --git a/tools/lib/pkg-tar.sh b/tools/lib/pkg-tar.sh new file mode 100644 index 000000000..274d241e1 --- /dev/null +++ b/tools/lib/pkg-tar.sh @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: MIT +# shellcheck shell=bash +# A package directory as a tar stream for building somewhere without the git +# history (the build container, the phone): the directory as it is +# (including gitignored prebuilt files the PKGBUILDs install), minus +# makepkg's work directories and old packages, plus .pkgver with the version +# tools/pkg-version works out here, for PKGBUILDs that read it. +# +# source tools/lib/pkg-tar.sh +# pkg_tar packages/ | tar xf - -C DEST +# +# Returns non-zero, writing nothing, when the version can't be worked out +# (a shallow clone, no .git): a build must not guess it. +pkg_tar() { + local dir=${1%/} name tmp v='' extra=() + name=$(basename "$dir") + if grep -c -F '/.pkgver"' "$dir/PKGBUILD" >/dev/null; then + v=$("$(dirname -- "${BASH_SOURCE[0]}")/../pkg-version" "$dir") || return 1 + fi + tmp=$(mktemp -d) + mkdir "$tmp/$name" + if [[ -n $v ]]; then + echo "$v" > "$tmp/$name/.pkgver" + extra=(-C "$tmp" "./$name/.pkgver") + fi + # Appended last, so it wins over a stale .pkgver in the directory. + tar cf - --exclude="./$name/pkg" --exclude="./$name/src/build" --exclude='*.pkg.tar.*' \ + -C "$(dirname "$dir")" "./$name" "${extra[@]}" + local rc=$? + rm -rf "$tmp" + return $rc +} diff --git a/tools/phone-install-package b/tools/phone-install-package index 8e9776f84..f772a7c82 100755 --- a/tools/phone-install-package +++ b/tools/phone-install-package @@ -22,9 +22,10 @@ phone_home=$("$ssh" "getent passwd '$phone_user' | cut -d: -f6") build=$phone_home/build/pkgs "$ssh" "rm -rf $build/$name && mkdir -p $build && chown '$phone_user': $build" -# makepkg's own work dirs (pkg/, src/ at the top) and old packages stay home. -tar cf - --exclude="./$name/pkg" --exclude="./$name/src/build" --exclude="*.pkg.tar.*" \ - -C "$(dirname "$dir")" "./$name" | "$ssh" "tar xf - -C $build --no-same-owner && chown -R '$phone_user': $build/$name" +# makepkg's own work dirs (pkg/, src/ at the top) and old packages stay home; +# the version is worked out here, since the phone gets no git history. +source tools/lib/pkg-tar.sh +pkg_tar "$dir" | "$ssh" "tar xf - -C $build --no-same-owner && chown -R '$phone_user': $build/$name" # Build-only dependencies (makedepends, checkdepends) that aren't installed # yet go in for the build and out again afterwards, like makepkg -s -r # (makepkg runs as the user, so pacman runs here as root). Runtime diff --git a/tools/pkg-version b/tools/pkg-version new file mode 100755 index 000000000..047f72607 --- /dev/null +++ b/tools/pkg-version @@ -0,0 +1,216 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# A package's version, worked out from git: nobody writes the last number. +# +# tools/pkg-version [--main REF] PACKAGE the version to build HEAD at +# tools/pkg-version [--main REF] --rev REV PACKAGE the version to build REV at +# tools/pkg-version --history PACKAGE " " for every +# commit on main's line that +# touched the package +# tools/pkg-version --history --count-from C PACKAGE the same, as if every +# commit from C counted (tests +# replay history with it) +# tools/pkg-version --commit PACKAGE VERSION the commit that version was built from +# +# PACKAGE is a name (omamobile-shell) or its directory (packages/omamobile-shell). +# +# packages//version gives the series: its first two numbers (0.2). A +# third number, which PRs used to bump by hand, is read only as a floor: a +# version never goes below it, and a lower or equal one changes nothing. On +# main (the first-parent line of REF, default origin/main) every commit that +# touches packages/ is the next number in the series, so two merges can +# never ship one number with different contents, and a merge needs no version +# change at all. Writing a new series (0.3) starts it at 0 (or at its third +# number, if given). +# +# A commit counts only when its PKGBUILD reads .pkgver, the version this tool +# hands a build: the package opts in, not the tool. Before that the version +# file is the version, as it was published, and the first commit that opts in +# is the next number after it, so no published number comes back. Where this +# tool lives doesn't matter (moving it can't restart a count), and a package +# that keeps a written version (the kernel, the keyring, a device package that +# ships boot files) never counts. +# +# Off main, a build is main's version at the merge base, then the branch's +# own commits that touch the package and the commit: 0.2.130.1.g4f2a9c1. +# pacman orders that above 0.2.130 and below main's next 0.2.131, so a phone +# with a test build upgrades to the next published one. A branch that doesn't +# touch the package builds main's version. A package (or a series) that main +# doesn't have yet builds as 0.1.0pre1.g4f2a9c1, below main's first 0.1.0. +# +# Edits not committed yet (without --rev) add the package's tree as it +# stands: 0.2.130.d5e0b7a2, a new version for each edit, above the commit's +# and below the next one, so build-packages builds them and pacman takes +# them over the commit's build. A package not committed at all builds as +# 0.1.0pre0.d5e0b7a2. +# +# It needs the history: in a shallow clone or a copy without .git it refuses +# rather than guess. Tools that build from a copy (build-packages, +# repo-build, phone-install-package) run it here first and put the result in +# the copy as .pkgver, which the PKGBUILDs read before asking git. +# +# OMAMOBILE_MAIN_REF sets REF like --main. On a fork, point it at this +# repository's main (git fetch upstream; OMAMOBILE_MAIN_REF=upstream/main): +# a fork's own main that is behind gives branch builds that sort below the +# published packages. +set -euo pipefail +die() { echo "pkg-version: $*" >&2; exit 1; } + +main=${OMAMOBILE_MAIN_REF:-} rev=HEAD explicit_rev='' mode=version want= count_from= +while (($#)); do + case $1 in + --main) main=${2:?--main needs a ref}; shift 2 ;; + --rev) rev=${2:?--rev needs a commit} explicit_rev=1; shift 2 ;; + --history) mode=history; shift ;; + --count-from) count_from=${2:?--count-from needs a commit}; shift 2 ;; + --commit) mode=commit; shift ;; + -h|--help) source "$(dirname -- "${BASH_SOURCE[0]}")/lib/usage.sh"; usage_from_header "$0"; exit 0 ;; + -*) die "unknown option $1" ;; + *) break ;; + esac +done +(($# >= 1)) || die "usage: tools/pkg-version [--main REF] [--rev REV] PACKAGE" +pkg=${1%/}; pkg=${pkg##*/} +[[ $mode != commit ]] || want=${2:?--commit needs PACKAGE VERSION} +# Only for a listing: a build's version never depends on it +[[ -z $count_from || $mode == history ]] || die "--count-from goes with --history only" +[[ $pkg =~ ^[a-z0-9][a-z0-9.+_-]*$ ]] || die "not a package name: $1" + +# The repository: the package directory's, else this tool's. +if [[ -d $1 ]]; then dir=$1; else dir=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}")"); fi +top=$(git -C "$dir" rev-parse --show-toplevel 2>/dev/null) || + die "$1 is not in a git checkout: build from a clone, or pass the version as .pkgver" +cd -- "$top" +[[ $(git rev-parse --is-shallow-repository) == false ]] || + die "a shallow clone can't count versions: git fetch --unshallow" +path=packages/$pkg + +if [[ -z $main ]]; then + for main in origin/main main ''; do + [[ -z $main ]] || git rev-parse -q --verify "$main^{commit}" >/dev/null && break + done + [[ -n $main ]] || main=$rev +fi +git rev-parse -q --verify "$rev^{commit}" >/dev/null || die "no such commit $rev" +git rev-parse -q --verify "$main^{commit}" >/dev/null || die "no such ref $main" + +# "S Z" from a version file's text (Z empty when it gives only a series). +parse() { + local v + v=$(tr -d '[:space:]' <<<"$1") + [[ $v =~ ^([0-9]+\.[0-9]+)(\.([0-9]+))?$ ]] || return 1 + echo "${BASH_REMATCH[1]} ${BASH_REMATCH[3]}" +} +file_at() { git show "$1:$path/version" 2>/dev/null; } + +# Does commit F's PKGBUILD read .pkgver (its version counted)? With +# --count-from, every commit in FROM (filled by walk) counts instead. +counts() { + if [[ -n $count_from ]]; then + [[ -n ${from[$1]:-} ]] + return + fi + git show "$1:$path/PKGBUILD" 2>/dev/null | grep -c -F '/.pkgver"' >/dev/null +} + +# " " for each commit on C's first-parent line touching the +# package, oldest first. A commit that doesn't count has its version file's +# number, as it was published. +walk() { + local c=$1 f s z S="" v=-1 + local -A from=() + if [[ -n $count_from ]]; then + local k + k=$(git rev-parse --verify "$count_from^{commit}") || die "no such commit $count_from" + if git merge-base --is-ancestor "$k" "$c"; then + while read -r f; do + from[$f]=1 + [[ $f != "$k" ]] || break + done < <(git rev-list --first-parent "$c") + fi + fi + while read -r f; do + read -r s z < <(parse "$(file_at "$f")") || continue + if [[ $s == "$S" ]] && counts "$f"; then + v=$((v + 1)) + [[ -z $z ]] || ((z <= v)) || v=$z + else + S=$s v=${z:-0} + fi + echo "$f $S.$v" + done < <(git rev-list --first-parent --reverse "$c" -- "$path") +} + +case $mode in + history) walk "$main"; exit 0 ;; + commit) + # The whole walk first: leaving its pipe early would SIGPIPE it. + mapfile -t lines < <(walk "$main") + for l in "${lines[@]}"; do + [[ ${l#* } != "$want" ]] || { echo "${l%% *}"; exit 0; } + done + die "$pkg $want was never built on $main" ;; +esac + +# The package as it stands in the working tree, when that isn't HEAD's: a +# tree id over its tracked and new files (gitignored ones left out, as git +# leaves them), so each edit is its own version and a build of it is never +# taken for the commit's +worktree() { + local idx t + idx=$(mktemp -u) + if ! { GIT_INDEX_FILE=$idx git read-tree HEAD && GIT_INDEX_FILE=$idx git add -A -- "$path" && + t=$(GIT_INDEX_FILE=$idx git write-tree); }; then + rm -f "$idx" + die "can't read the working tree of $path" + fi + rm -f "$idx" + t=$(git rev-parse -q --verify "$t:$path") || return 0 + [[ $t == "$(git rev-parse -q --verify "HEAD:$path" || true)" ]] || echo "${t:0:7}" +} +local_edits= +[[ -n $explicit_rev ]] || local_edits=$(worktree) + +# The version REV builds at, from the history alone +committed() { + [[ -n $(git ls-tree "$rev" -- "$path/version") ]] || die "$path/version doesn't exist at $rev" + # The history skips a version file that doesn't parse, so without this its + # commit would build under the number before it + parse "$(file_at "$rev")" >/dev/null || die "$path/version doesn't hold a version (0.2 or 0.2.5) at $rev" + # 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") + fi + n=$(git rev-list --count --first-parent "$base..$rev" -- "$path") + v=$(walk "$base" | tail -1 | cut -d' ' -f2) + if ((n == 0)) && [[ -n $v ]]; then echo "$v"; return 0; fi + read -r s z < <(parse "$(file_at "$rev")") || die "$path/version doesn't hold a version (0.2 or 0.2.5) at $rev" + sha=$(git rev-parse --short=7 "$rev") + # A new package, or a branch that starts a new series: main's first build + # of it will be S.Z, and pacman orders 0.1.0pre1 below 0.1.0. + if [[ -z $v || ${v%.*} != "$s" ]]; then echo "$s.${z:-0}pre$n.g$sha"; return 0; fi + echo "$v.$n.g$sha" +} + +if [[ -n $local_edits && -z $(git ls-tree HEAD -- "$path/version") ]]; then + # A package not committed yet: below its first commit's 0.1.0pre1 + read -r s z < <(parse "$(cat "$path/version" 2>/dev/null)") || + die "$path/version doesn't hold a version (0.2 or 0.2.5)" + echo "$s.${z:-0}pre0.d$local_edits" + exit 0 +fi +v=$(committed) +# Edits not committed yet: above the commit's version, below the next commit's +echo "$v${local_edits:+.d$local_edits}" diff --git a/tools/repo-build b/tools/repo-build index 387768cc0..da5a0d8f8 100755 --- a/tools/repo-build +++ b/tools/repo-build @@ -13,6 +13,7 @@ cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." # The release key (docs/RELEASES.md §10), with a clear error without it source tools/lib/signing.sh +source tools/lib/pkg-tar.sh signing_key_load "$PWD" || exit 1 key=$SIGNING_KEY repo=out/repo/aarch64 @@ -36,8 +37,7 @@ for dir in "${dirs[@]}"; do name=$(basename "$dir") echo "==> $name" "$ssh" "rm -rf $build/$name && mkdir -p $build && chown '$phone_user': $build" - tar cf - --exclude="./$name/pkg" --exclude="./$name/src/build" --exclude="*.pkg.tar.*" \ - -C "$(dirname "$dir")" "./$name" | "$ssh" "tar xf - -C $build --no-same-owner && chown -R '$phone_user': $build/$name" + pkg_tar "$dir" | "$ssh" "tar xf - -C $build --no-same-owner && chown -R '$phone_user': $build/$name" # --nodeps: runtime dependencies (e.g. omamobile-keyring) come from this # very repository, so they needn't be installed on the builder. "$ssh" "su - '$phone_user' -c 'cd $build/$name && makepkg -f --nodeps --noconfirm' 2>&1 | tail -1" diff --git a/tools/repo-publish b/tools/repo-publish index 89b3646bf..f4d2da2a5 100755 --- a/tools/repo-publish +++ b/tools/repo-publish @@ -195,6 +195,15 @@ stage() { mkdir -p "$to" local new current="" previous new=$(db_files "$from") + # A branch build (.g) or a build of edits not committed yet + # (.d) is a test build, never published: tools/pkg-version gives + # main's commits plain numbers + local test_builds + test_builds=$(grep -E '\.[gd][0-9a-f]{7}-[^-]+-[^-]+\.pkg\.tar\.' <<<"$new" || true) + if [[ -n $test_builds ]]; then + echo "$from holds test builds, not built from main (tools/repo-publish --from-main builds main's): $(tr '\n' ' ' <<<"$test_builds")" >&2 + return 1 + fi if [[ -f $to.sets ]]; then current=$(sed -n 's/^current //p' "$to.sets") previous=$(sed -n 's/^previous //p' "$to.sets") @@ -281,7 +290,8 @@ upload() { if [[ $channel == development ]]; then if ((build)); then say "Building what changed" - # 3: a device package was skipped (its boot files are missing or stale) + # 3: a package was skipped (a device package's boot files are missing + # or stale, or tools/pkg-version gave no version) # and everything else built: publish that, then fail the run rc=0; tools/build-packages --all || rc=$? # 3 with its list in out/repo/.skipped, and nothing else, is a skip @@ -330,4 +340,4 @@ else [[ $code == 200 ]] || die "$URL/$channel/$ARCH/omamobile.db answers $code" fi say "Done: $URL/$channel/$ARCH" -((skipped_build == 0)) || die "published without the device package(s) tools/build-packages skipped (boot files missing or stale): stage them and publish again" +((skipped_build == 0)) || die "published without the package(s) tools/build-packages skipped (boot files missing or stale, or no version): see its error lines, then publish again"