Skip to content

session reversion: rewrite all version operators unconditionally (match bash) - #13

Merged
dkijania merged 1 commit into
mainfrom
fix/reversion-all-operators
Jul 22, 2026
Merged

dkijania merged 1 commit into
mainfrom
fix/reversion-all-operators

Conversation

@dkijania

Copy link
Copy Markdown
Member

Fixes #12.

Problem

deb-session-reversion.sh — which mina's callers (reversion.sh, manager.sh) invoke with no flag — rewrites the old version to the new one across every versioned dependency constraint on every reversion. deb-toolkit session reversion did this only under --update-deps, and even then only for exact = pins, leaving >=/<</etc. alone on the theory that a looser constraint is still satisfied by a higher version.

That theory breaks for mina: reversions are not monotonic. manager.sh reversions from $__source_version to an arbitrary $__target_version — e.g. a fork build 3.4.0-rc2-company-<hash> down to a clean 3.4.0-rc2. On a downward reversion a left-alone (>= old) is unsatisfiable and the package won't install.

Changes

  • replace_in_constraint rewrites all Debian relation operators (=, <<, <=, >=, >>), matching the operator as a prefix rather than splitting on whitespace — so both (<< X) (spaced) and (=X) (no space) are handled. mina emits both forms.
  • The dependency rewrite is now unconditional. The --update-deps CLI flag and the update_deps manifest field are kept, accepted, and ignored (deprecated), so existing callers and manifests keep parsing/working; the flag emits a deprecation warning. bash has no "version-only" reversion mode, so matching bash means always rewriting.
  • The rewrite stays constraint-scoped (only inside (...)), so a version-like substring in a package name is never mangled — an improvement over the bash bare-substring pass, and identical output on mina's real (parenthesized-constraint) inputs.

Verification

Against the bash scripts, realistic downward reversion 3.4.0-rc2-company-abc123 → 3.4.0-rc2, mixed (=X)/(<< X), no flag:

              bash                              deb-toolkit
Version:      3.4.0-rc2                         3.4.0-rc2
Depends:   mina-devnet-config (= 3.4.0-rc2)     mina-devnet-config (= 3.4.0-rc2)
Replaces:  mina-mainnet (<< 3.4.0-rc2)          mina-mainnet (<< 3.4.0-rc2)
Breaks:    mina-mainnet (<< 3.4.0-rc2)          mina-mainnet (<< 3.4.0-rc2)
Conflicts: mina-mainnet (<< 3.4.0-rc2)          mina-mainnet (<< 3.4.0-rc2)

Control fields identical. (Before this change, deb-toolkit left every one of those deps at the old version — even with --update-deps.)

  • New unit tests: all-operator rewrite; no-space operator ((=X)).
  • Updated session_roundtrip integration test, which previously asserted >= should be left alone — that assertion encoded the bug.
  • Full suite green: cargo test --all-targets (52 unit + integration), fmt, clippy -D warnings.

Not in scope

The secondary save divergence noted in #12 — deb-toolkit drops the leading ./ and root entry in data.tar vs dpkg-deb --build — is untouched here; that's a save concern, not reversion. #12 tracks it.

…ch bash)

Fixes #12.

deb-session-reversion.sh (whose mina callers invoke it with no flag)
rewrites the old version to the new one across every versioned
dependency constraint on every reversion. deb-toolkit did this only
under --update-deps, and even then only for exact `=` pins, leaving
`>=`/`<<`/etc. alone on the theory that a looser constraint is still
satisfied by a higher version.

That theory fails for mina: reversions are not monotonic (manager.sh
reversions to an arbitrary target, e.g. a fork build 3.4.0-rc2-company
-<hash> down to a clean 3.4.0-rc2). On a downward reversion a stale
`(>= old)` is unsatisfiable and the package will not install.

Changes:
- replace_in_constraint rewrites all Debian relation operators
  (=, <<, <=, >=, >>), matching the operator as a prefix so both
  `(<< X)` and `(=X)` — mina emits both — are handled.
- reversion performs the dependency rewrite unconditionally; the
  --update-deps CLI flag and update_deps manifest field are kept,
  accepted, and ignored (deprecated) so existing callers/manifests
  keep working. The flag now warns.
- rewrite stays constraint-scoped (inside `(...)`), so a version-like
  substring in a package name is never mangled — an improvement over
  the bash bare-substring pass.

Verified against the bash scripts on a realistic downward reversion
with mixed `(=X)`/`(<< X)` formats: control fields are now identical.
@dkijania
dkijania merged commit 52a5954 into main Jul 22, 2026
2 checks passed
@dkijania
dkijania deleted the fix/reversion-all-operators branch July 22, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session reversion diverges from mina bash: loose-constraint deps not rewritten (uninstallable on downward reversion)

1 participant