Bug 224023

Summary: ports-mgmt/pkg: upgrading to pkg-1.10.2_1 makes "pkg version" do weird things
Product: Ports & Packages Reporter: Trond.Endrestol
Component: Individual Port(s)Assignee: freebsd-pkg (Nobody) <pkg>
Status: Closed FIXED    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (pkg)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Trond.Endrestol 2017-12-01 17:29:58 UTC
After upgrading to pkg-1.10.2_1, pkg version -ovIL= prints mindblowing results:

# pkg version -ovIL=
print/auctex                       ?   orphaned: print/auctex
lang/cython                        ?   orphaned: lang/cython
lang/perl5.26                      >   succeeds index (index has 5.24.3)

Look carefully at the last line. It does not make any sense. Neither print/auctex nor lang/cython has been removed from the ports tree.

pkg version -ovPL= has some other issue:

# pkg version -ovPL=
Child process pid=93545 terminated abnormally: Segmentation fault

Restoring /usr/local/sbin/{pkg,pkg-static,pkg2ng} from pkg-1.10.2 gives me the wanted behaviour.
Comment 1 Trond.Endrestol 2017-12-05 11:06:50 UTC
(In reply to Trond.Endrestol from comment #0)
Upgraded ports-mgmt/pkg to pkg-1.10.3.

Forcefully updated the origins of print/auctex and lang/cython by running:

portupgrade -fpvo print/auctex print/auctex
portupgrade -fpvo lang/cython lang/cython

Upgraded the other outdated ports with no observed side effects.

pkg version -ov{I,P}L= now displays:

# pkg version -ovIL=
print/auctex                       ?   orphaned: print/auctex
lang/perl5.26                      >   succeeds index (index has 5.24.3)

# pkg version -ovPL=
[no output, as expected]

It's a mystery why print/auctex is listed as orphaned when consulting the index. The index is up-to-date. The ports tree is the true source of facts.

lang/perl5.26 is installed and /etc/make.conf specify DEFAULT_VERSIONS+=perl5=5.26.
Why isn't DEFAULT_VERSIONS+=perl5=5.26 being respected?

This is on amd64 stable/11 r326394, with the source tree at r326565, and the ports tree at r455569.
Comment 2 Baptiste Daroussin freebsd_committer 2017-12-05 12:30:04 UTC
This is because we are not matching anymore on origin. Because origin is not unique anymore (flavors). We are now matching on the package name. in case of lang/perl5.26 we are looping in the index for a package named "perl5-<version>" in your case you decided to have the latest perl5 as the default perl version but on FreeBSD, so in the INDEX the default is 5.24.3.

So pkg will lookup for lang/perl5.26, get the package name: perl5-5.26, extract the package name "perl5" lookup for it in the INDEX and find perl5-5.24.3 and tells you you have a newer version.

Concerning the segmentation fault it is being tracked down right now, will fix asap.
Comment 3 Trond.Endrestol 2017-12-05 12:32:59 UTC
(In reply to Baptiste Daroussin from comment #2)
Thank you for clarifying.

The segfault is gone in my system(s). That may not be true of systems elsewhere.
Comment 4 commit-hook freebsd_committer 2017-12-05 16:22:17 UTC
A commit references this bug:

Author: bapt
Date: Tue Dec  5 16:22:02 UTC 2017
New revision: 455589
URL: https://svnweb.freebsd.org/changeset/ports/455589

Log:
  Fix segfault in pkg version against the ports tree

  PR:		224023
  Reported by:	jrm, kib, Trond.Endrestol@ximalas.info
  Tested by:	jrm (an early version of the patch)

Changes:
  head/ports-mgmt/pkg/Makefile
  head/ports-mgmt/pkg/files/patch-src_version.c
Comment 5 Trond.Endrestol 2017-12-06 13:06:20 UTC
(In reply to Trond.Endrestol from comment #1)
The missing print/auctex is due to EMACS_PORT_NAME=emacs-nox11 in /etc/make.conf. In which case I can only blame myself.

If nobody objects, I'd like to close this case.
Comment 6 Trond.Endrestol 2017-12-07 09:37:01 UTC
Some problems were caused by me and some by pkg. We're still friends.