lib.version: Fix version range expansion #109

Merged
Jan Lindemann merged 5 commits from jan/fix/20260915-lib-version-fix-version-range-expansion into master 2026-09-15 21:53:19 +02:00 AGit

Debian packages that should satisfy a jw-pkg dependency specification "= 1.2.3" need that pin expanded to ">= 1.2.3, < 1.2.4", which doesn't work. The resulting pin remains = 1.2.3, which Debian requires as an exact match on installation, and which is unsatisfiable. The pin expansion machinery in lib.version is broken in several places, and this commit addresses that.

lib.version.Version.__resolved_id(): Resolve VERSION to core

__resolved_id() returns the full version if only VERSION was specified, fix that.

Also: raise Version.Error instead of a bare Exception.

Tests written by AI.

lib.version.Dependency.__version_boundaries(): Expand non-full specs

Full version dependency specs (= 1.2.3-4 or = VERSION-REVISION) don't need expansion, they pin the wanted version with an = fine exactly.

__version_boundary has that the wrong way around, fix that.

Also fix the is_full and version_boundaries() docstrings, which still describe the old behavior.

Tests written by AI.

lib.version.Dependency.constraint_str(): Delimit by comma

A multi-boundary constraint is rendered as foo >= 1.2.3-45 foo < 1.2.4, which is invalid: the RPM spec template writes the Requires: line from it verbatim, and RPM entries are comma-separated, so the second clause is swallowed into one bad entry. Debian's format_depends() normalizes runs of whitespace to commas, so it tolerates the space join, but the comma is the only delimiter that is correct for both.

Join the boundary clauses with , instead of a space.

Also:

  • Drop the stray trailing comma in the version_boundaries() call.
  • Fix the untemplated docstring, which describes the opposite of the code: untemplated = True (the default) resolves the macros, untemplated = False keeps them as written.

Tests written by AI.

lib.version.Version.next(): Step the last part

Range expansion needs a bound that steps the last existing part of a version, add that.

next() increments the last part, whatever it is: next of 1 is 2, of 1.0 is 1.1, of 1.2.3 is 1.2.4, of 1.2.3-45 is 1.2.3-46.

Tests written by AI.

lib.version.Dependency.__version_boundaries(): Use Version.next()

Use Version.next() in __version_boundaries(), which steps the last existing part, so = 1.0 spans >= 1.0, < 1.1.

Tests written by AI.

Debian packages that should satisfy a jw-pkg dependency specification `"= 1.2.3"` need that pin expanded to "`>= 1.2.3, < 1.2.4"`, which doesn't work. The resulting pin remains `= 1.2.3`, which Debian requires as an exact match on installation, and which is unsatisfiable. The pin expansion machinery in lib.version is broken in several places, and this commit addresses that. #### lib.version.Version.__resolved_id(): Resolve VERSION to core `__resolved_id()` returns the full version if only `VERSION` was specified, fix that. Also: raise `Version.Error` instead of a bare Exception. Tests written by AI. #### lib.version.Dependency.__version_boundaries(): Expand non-full specs Full version dependency specs (`= 1.2.3-4` or `= VERSION-REVISION`) don't need expansion, they pin the wanted version with an `=` fine exactly. __version_boundary has that the wrong way around, fix that. Also fix the `is_full` and `version_boundaries()` docstrings, which still describe the old behavior. Tests written by AI. #### lib.version.Dependency.constraint_str(): Delimit by comma A multi-boundary constraint is rendered as `foo >= 1.2.3-45 foo < 1.2.4`, which is invalid: the RPM spec template writes the Requires: line from it verbatim, and RPM entries are comma-separated, so the second clause is swallowed into one bad entry. Debian's `format_depends()` normalizes runs of whitespace to commas, so it tolerates the space join, but the comma is the only delimiter that is correct for both. Join the boundary clauses with `, ` instead of a space. Also: - Drop the stray trailing comma in the `version_boundaries()` call. - Fix the untemplated docstring, which describes the opposite of the code: untemplated = True (the default) resolves the macros, untemplated = False keeps them as written. Tests written by AI. #### lib.version.Version.next(): Step the last part Range expansion needs a bound that steps the last existing part of a version, add that. `next()` increments the last part, whatever it is: next of `1` is `2`, of `1.0` is `1.1`, of `1.2.3` is `1.2.4`, of `1.2.3-45` is `1.2.3-46`. Tests written by AI. #### lib.version.Dependency.__version_boundaries(): Use Version.next() Use `Version.next()` in `__version_boundaries()`, which steps the last existing part, so `= 1.0` spans `>= 1.0, < 1.1`. Tests written by AI.
__resolved_id() returns the full version if only VERSION was specified, fix
that.

Also: raise Version.Error instead of a bare Exception.

Tests written by AI.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1
Signed-off-by: Jan Lindemann <jan@janware.com>
Full version dependency specs ("= 1.2.3-4" or "= VERSION-REVISION") don't
need expansion, they pin the wanted version with an = fine exactly.

__version_boundary has that the wrong way around, fix that.

Also fix the is_full and version_boundaries() docstrings, which still
describe the old behavior.

Tests written by AI.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1
Signed-off-by: Jan Lindemann <jan@janware.com>
A multi-boundary constraint is rendered as 'foo >= 1.2.3-45 foo < 1.2.4',
which is invalid: the RPM spec template writes the Requires: line from it
verbatim, and RPM entries are comma-separated, so the second clause is
swallowed into one bad entry. Debian's format_depends() normalizes runs of
whitespace to commas, so it tolerates the space join, but the comma is the
only delimiter that is correct for both.

Join the boundary clauses with ', ' instead of a space.

Also:

- Drop the stray trailing comma in the version_boundaries() call.
- Fix the untemplated docstring, which describes the opposite of the code:
  untemplated = True (the default) resolves the macros, untemplated = False
  keeps them as written.

Tests written by AI.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1
Range expansion needs a bound that steps the last existing part of a
version, add that.

next() increments the last part, whatever it is: next of '1' is '2', of
'1.0' is '1.1', of '1.2.3' is '1.2.4', of '1.2.3-45' is '1.2.3-46'.

Tests written by AI.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1
lib.version.Dependency.__version_boundaries(): Use Version.next()
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m42s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m43s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m30s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m29s
CI / Packaging test (push) Successful in 0s
3f00f4a416
Use Version.next() in __version_boundaries, which steps the last existing
part, so '= 1.0' spans '>= 1.0, < 1.1'.

Tests written by AI.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.85.1
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-09-15 21:43:49 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!109
No description provided.