Bug 246883

Summary: ports-mgmt/pkg: PKG REVISIONS limited with two characters not number
Product: Base System Reporter: Please <please>
Component: binAssignee: freebsd-pkg (Nobody) <pkg>
Status: Closed Unable to Reproduce    
Severity: Affects Only Me CC: pkg
Priority: --- Flags: linimon: maintainer-feedback? (pkg)
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Please 2020-05-30 21:50:55 UTC
I am producing packages in the format: ${PORTNAME}-${PORTVERSION}[_${PORTREVISION}][,${PORTEPOCH}]. 

When PORTREVISION is 99+ pkg manager does not respect packages. Maximum revision 99. 

'pkg upgrade' thinks it is 99 is the latest package revision in the repository even repository has a definition of higher numbers of 99. 

It might be in this part of the code: https://github.com/freebsd/pkg/blob/16207928cbdbd8e950071e6067f8bc5a0a621856/libpkg/pkg_version.c#L72  

Documentation does not state 99 limits:
PORTREVISION is a monotonically increasing value which is reset to 0 with every increase of DISTVERSION, typically every time there is a new official vendor release. If PORTREVISION is non-zero, the value is appended to the package name. [...]
https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/book.html#5.2.3.1
Comment 1 Please 2020-05-30 22:19:26 UTC
How to repeat.
Create a repository with packages that have higher numbers in revision.

#pkg search appstore
appstore-1.0.125         SSO authentication method for Redmine
appstore-1.0.15_100      SSO authentication method for Redmine
appstore-1.0.15_101      SSO authentication method for Redmine
..
appstore-1.0.15_122      SSO authentication method for Redmine
appstore-1.0.15_18       SSO authentication method for Redmine
appstore-1.0.15_19       SSO authentication method for Redmine
..
appstore-1.0.15_99       SSO authentication method for Redmine

#pkg upgrade appstore
Updating internal_repo repository catalogue...
internal_repo repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
Your packages are up to date.


The only solution to get the package installed is to install it again / update command does not work.

# pkg install appstore-1.0.125
Installed packages to be UPGRADED:
        appstore: 1.0.15_99 -> 1.0.125 [internal_repo]
Comment 2 Baptiste Daroussin freebsd_committer freebsd_triage 2021-08-18 11:56:40 UTC
$ pkg version -t 1_99 1_125
<

At least the version comparison code works so if there is a bug it is not there
Comment 3 Baptiste Daroussin freebsd_committer freebsd_triage 2021-08-18 12:07:21 UTC
I cannot reproduce, upgrade works fine with 3 digit packages, I added a unit test to make sure it is not broken in our test suite:
https://github.com/freebsd/pkg/commit/c0c3b2f472072a4f2fb02feff113bdccd70f7ffa