Bug 193527 - [patch] bsd.port.mk: check-already-installed hitting conflicts with ports that have same PKGBASE
Summary: [patch] bsd.port.mk: check-already-installed hitting conflicts with ports tha...
Status: Closed Works As Intended
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Ports Framework (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-10 16:15 UTC by John Hein
Modified: 2019-09-05 08:28 UTC (History)
2 users (show)

See Also:


Attachments
use PKGORIGIN to decide if a package is already installed (1.44 KB, text/plain)
2014-09-10 16:15 UTC, John Hein
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2014-09-10 16:15:30 UTC
Created attachment 147175 [details]
use PKGORIGIN to decide if a package is already installed

check-already-installed was changed after support for the old pkg_* tools was removed recently.  It was changed to look at PKGBASE instead of PKGORIGIN (despite passing -O to pkg info [1]).

This causes issues like the following when you have two ports that can legitimately have the same PKGBASE installed:

=======================
===>  Installing for glib-2.36.3_4
===>  Checking if glib already installed
===>   An older version of glib is already installed (glib-1.2.10_13)
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of glib
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop in /usr/ports/devel/glib20.
=======================

I could not determine why this change was made.  Is there a reason to use PKGBASE rather than PKGORIGIN?  Origin seems like the more correct thing to check.

I have attached a patch to go back to PKGORIGIN and done some test builds 

[1] This is a second bug - when passing something that is not an origin to pkg info -q -O, it still returns a result (e.g., pkg info -q -O pkg-1.3.7 gives pkg-1.3.7).  This deviates from the old pkg_info which returns nothing (since pkg-1.3.7 is not an origin).  Unless the definition of origin has changed, pkg_info seems more correct in this regard.  Should I open a separate bug for this, or is this intended behavior?
Comment 1 John Hein 2014-09-10 16:16:46 UTC
Ask portmgr to review this possible change to bsd.port.mk
Comment 2 Antoine Brodin freebsd_committer 2014-09-10 16:21:40 UTC
There is a problem with your installation,  devel/glib12 installs a package named glib12-1.2.10_14
Comment 3 John Hein 2014-09-10 16:43:07 UTC
Could be, but what's the breakage?

sh -xc 'cd /usr/ports/devel/glib12; make -V PKGBASE -V PKGORIGIN ; cd ../glib20 ; make -V PKGBASE -V PKGORIGIN; pkg info -q -O glib12 ; pkg info -q -O glib; pkg info -q -O devel/glib12 ; pkg info -q -O devel/glib20'
+ cd /usr/ports/devel/glib12
+ make -V PKGBASE -V PKGORIGIN
glib12
devel/glib12
+ cd ../glib20
+ make -V PKGBASE -V PKGORIGIN
glib
devel/glib20
+ pkg info -q -O glib12
+ pkg info -q -O glib
glib-1.2.10_13
glib-2.36.3_4
+ pkg info -q -O devel/glib12
glib-1.2.10_13
+ pkg info -q -O devel/glib20
glib-2.36.3_4



Notice that 'pkg info -q -O glib' returns two results.  I still think that's a bug with -O (since it's not getting an origin specification and still returning something).  But that's the command that check-already-installed is using, and that's why I hit the glib error.

glib12 was installed from a fresh ports tree yesterday.  The full info is:

================
pkg info -f -x glib-1.2.10_13
glib-1.2.10_13
Name           : glib
Version        : 1.2.10_13
Installed on   : Tue Sep  9 13:50:16 MDT 2014
Origin         : devel/glib12
Architecture   : freebsd:8:x86:32
Prefix         : /usr/local
Maintainer     : unknown
WWW            : http://www.gtk.org/
Comment        : Some useful routines of C programming (previous stable version)
Shared Libs provided:
        libgthread-12.so.3
        libgmodule-12.so.3
        libglib-12.so.3
Flat size      : 554KiB
Description    :
This is GLib version 1.2.  GLib, is a library which includes support
routines for C such as lists, trees, hashes, memory allocation, and
many other things.

WWW: http://www.gtk.org/
ftp://ftp.gtk.org/pub/gtk

A mailing list is located at gtk-list@redhat.com for discussion.
==================
Comment 4 Antoine Brodin freebsd_committer 2014-09-10 16:46:37 UTC
Here is what you should have:

# pkg info -f -x glib12-1.2.10_13
glib12-1.2.10_13
Name           : glib12
Version        : 1.2.10_13
Installed on   : Wed Sep 10 16:44:58 UTC 2014
Origin         : devel/glib12
Architecture   : freebsd:10:x86:64
Prefix         : /usr/local
Categories     : devel
Maintainer     : gnome@FreeBSD.org
WWW            : http://www.gtk.org/
Comment        : Some useful routines of C programming (previous stable version)
Shared Libs provided:
        libgthread-12.so.3
        libgmodule-12.so.3
        libglib-12.so.3
Annotations    :
        repo_type      : binary
        repository     : FreeBSD
Flat size      : 711KiB
Description    :
This is GLib version 1.2.  GLib, is a library which includes support
routines for C such as lists, trees, hashes, memory allocation, and
many other things.

WWW: http://www.gtk.org/
ftp://ftp.gtk.org/pub/gtk

A mailing list is located at gtk-list@redhat.com for discussion.
Comment 5 John Hein 2014-09-10 16:53:22 UTC
Ok.  I see I had _13 and the portrev bump to _14.
I see that change was made 9/5.  I guess my tree wasn't quite fresh.

I still think that using PKGORIGIN is more correct, isn't it?
Comment 6 Antoine Brodin freebsd_committer 2014-09-10 16:56:13 UTC
No, we switched away from PKGORIGIN for package unicity
See announce at https://lists.freebsd.org/pipermail/freebsd-ports-announce/2014-July/000084.html
Comment 7 John Hein 2014-09-10 17:01:16 UTC
Okay.
I guess there is at least a documentation bug for pkg-info(1) then?
Comment 8 Baptiste Daroussin freebsd_committer 2014-09-12 06:45:37 UTC
Using origin is wrong we are aiming at adding sub packages, which will make us having multiple packages from the same origin installed at the same time (and not conflicting)

In pkg we first used origin for unicity, to allow situation likes glib to be able to migrate, then we switched to something internal which basically is now 'origin~name" that allows sub packages, but this is temporary to allow people with an installation with multiple packages with the same name to migrate.

In final version it will be probably still something internal based on the name.
Comment 9 John Hein 2014-09-15 16:13:50 UTC
Understood that origin is no longer a good uniqueness test for the future.  I can't mark the patch obsolete here or I would.

I'll try to come up with a patch for pkg-info(8) that clarifies what one can specify for "pkg-name" and more clearly describes the situation with -O.  Unless someone else who understands pkg(8) innards better beats me to it.


Here's another failure case, by the way:  math/eigen2 & math/eigen3


===>  Installing for eigen-3.2.2
===>  Checking if eigen already installed
===>   eigen-3.2.2 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of eigen
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop in /usr/ports/math/eigen3.


eigen-2.0.17,1 was installed when this error popped up.

patch to force existing installs of eigen2 to be rebuilt with PKGNAMESUFFIX:

--- Makefile    (revision 368259)
+++ Makefile    (working copy)
@@ -3,6 +3,7 @@
 
 PORTNAME=      eigen
 PORTVERSION=   2.0.17
+PORTREVISION=  1
 PORTEPOCH=     1
 CATEGORIES=    math
 MASTER_SITES=  https://bitbucket.org/eigen/eigen/get/