Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

fix(packaging): order Debian prereleases before the final version (#2096, from #2073)

xerj-org7fe811494bae
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e16b97fac..e0aaf8a3d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Playground saved views immediately restore the current dashboard, replace
stale URL filters when navigating, and preserve custom time-range endpoints.
+- Debian release-candidate package versions now sort before the corresponding
+ final release, preserving normal upgrade order without renaming release assets.
+
- `xerj search` and a plain-string `xerj_search` rank a file that contains
the query as an exact phrase (a pasted error message or log line) at the
top. The bag-of-words leg alone let a short `defs` list sharing two of the
diff --git a/docs/PACKAGING_DEBIAN.md b/docs/PACKAGING_DEBIAN.md
index 39061369c..a7fb1ef4a 100644
--- a/docs/PACKAGING_DEBIAN.md
+++ b/docs/PACKAGING_DEBIAN.md
@@ -20,6 +20,11 @@ xerj-<version>-x86_64-unknown-linux-gnu.deb (Architecture: amd64)
xerj-<version>-aarch64-unknown-linux-gnu.deb (Architecture: arm64)
```
+Debian control-file prereleases use `~`: Rust version `1.0.0-rc.76` becomes
+`1.0.0~rc.76`, so the final `1.0.0` sorts newer for upgrades. Asset filenames,
+the staged executable and its version banner keep the original Rust version.
+A hyphen occurring only in `+build` metadata is not rewritten.
+
Install with `sudo dpkg -i xerj-<version>-x86_64-unknown-linux-gnu.deb`; the
binary lands in `/usr/bin/xerj` with docs under `/usr/share/doc/xerj`
(README, LICENSE, machine-readable `copyright`). There is no systemd unit and
diff --git a/scripts/build-deb.sh b/scripts/build-deb.sh
index 658dd49f6..cc884da7b 100755
--- a/scripts/build-deb.sh
+++ b/scripts/build-deb.sh
@@ -101,8 +101,15 @@ case "$VERSION" in
[0-9]*) : ;;
*) die "version '$VERSION' is not a valid Debian version (must start with a digit; canary builds pass the workspace version, not the ref name)" ;;
esac
-dpkg --compare-versions "$VERSION" eq "$VERSION" 2>/dev/null \
- || die "version '$VERSION' rejected by dpkg --compare-versions"
+# SemVer prereleases must sort before the final release in Debian too.
+# A hyphen only inside +build metadata is not a prerelease separator.
+DEB_VERSION="$VERSION"
+if [[ "${VERSION%%+*}" == *-* ]]; then
+ # Not ${VERSION/-/~}: bash tilde-expands the replacement to $HOME.
+ DEB_VERSION="${VERSION%%-*}~${VERSION#*-}"
+fi
+dpkg --compare-versions "$DEB_VERSION" eq "$DEB_VERSION" 2>/dev/null \
+ || die "version '$DEB_VERSION' rejected by dpkg --compare-versions"
# ── runtime dependencies, measured off the ELF we are about to pack ──────────
# readelf/objdump parse ELF of any architecture, so this works unchanged on
@@ -170,7 +177,7 @@ INSTALLED_SIZE=$(du -sk "$PKG/usr" | cut -f1)
# REST surface included.
cat > "$PKG/DEBIAN/control" <<EOF
Package: xerj
-Version: $VERSION
+Version: $DEB_VERSION
Architecture: $DEB_ARCH
Maintainer: xerj Contributors <https://github.com/xerj-org/xerj>
Installed-Size: $INSTALLED_SIZE
diff --git a/scripts/test_build_deb_versions.py b/scripts/test_build_deb_versions.py
new file mode 100644
index 000000000..dd37ef03e
--- /dev/null
+++ b/scripts/test_build_deb_versions.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python3
+"""Exercise control-file generation; packaging executables are local test doubles."""
+import os
+from pathlib import Path
+import shutil
+import subprocess
+import tempfile
+import unittest
+
+
+class DebianVersionTests(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.root = Path(self.temp.name)
+ self.tools = self.root / "bin"
+ self.tools.mkdir()
+ for name, body in {
+ "dpkg": "exit 0",
+ "readelf": "printf 'Shared library: [libc.so.6]\\n'",
+ "objdump": "printf 'GLIBC_2.17\\n'",
+ "sha256sum": "printf 'fixture-checksum %s\\n' \"$1\"",
+ "dpkg-deb": '''case "$1" in
+--root-owner-group) cp "$3/DEBIAN/control" "$4"; cp "$3/usr/bin/xerj" "$4.payload";;
+--info) cat "$2";;
+*) exit 90;;
+esac''',
+ }.items():
+ path = self.tools / name
+ path.write_text("#!/bin/sh\n" + body + "\n")
+ path.chmod(0o755)
+ self.env = dict(os.environ, PATH=str(self.tools) + os.pathsep + os.environ.get("PATH", ""))
+ self.script = Path(__file__).with_name("build-deb.sh")
+
+ def package(self, version):
+ name = "xerj-" + version + "-x86_64-unknown-linux-gnu"
+ stage = self.root / name
+ stage.mkdir()
+ binary = stage / "xerj"
+ binary.write_bytes(b"staged executable fixture, never executed\n")
+ binary.chmod(0o755)
+ (stage / "README.md").write_text("fixture")
+ (stage / "LICENSE").write_text("fixture")
+ output = self.root / "dist"
+ result = subprocess.run(["bash", str(self.script), "--stage-dir", str(stage),
+ "--target", "x86_64-unknown-linux-gnu", "--version", version, "--out-dir", str(output)],
+ env=self.env, capture_output=True, text=True, timeout=10)
+ self.assertEqual(result.returncode, 0, result.stderr)
+ artifact = output / (name + ".deb")
+ self.assertTrue(artifact.exists())
+ self.assertEqual(Path(str(artifact) + ".payload").read_bytes(), binary.read_bytes())
+ fields = dict(line.split(": ", 1) for line in artifact.read_text().splitlines() if ": " in line and not line.startswith(" "))
+ return fields["Version"]
+
+ def test_release_candidate_sorts_before_final(self):
+ self.assertEqual(self.package("1.0.0-rc.76"), "1.0.0~rc.76")
+
+ def test_final_version_is_unchanged(self):
+ self.assertEqual(self.package("1.0.0"), "1.0.0")
+
+ def test_build_metadata_hyphen_is_not_a_prerelease(self):
+ self.assertEqual(self.package("1.0.0+build-2026"), "1.0.0+build-2026")
+
+ @unittest.skipUnless(shutil.which("dpkg"), "native dpkg unavailable; metadata generation still tested")
+ def test_native_debian_upgrade_order(self):
+ old, new = self.package("1.0.0-rc.76"), self.package("1.0.0")
+ result = subprocess.run([shutil.which("dpkg"), "--compare-versions", old, "lt", new], timeout=10)
+ self.assertEqual(result.returncode, 0)
+
+
+if __name__ == "__main__":
+ unittest.main()