portupgrade + FLAVORS

Matthew D. Fuller fullermd at over-yonder.net
Mon Apr 8 01:52:08 UTC 2019


For any portupgrade users still out there wishing for FLAVOR support,
I have patches to add it.  I've been running them here locally for a
few weeks without incident (apart from an extra upgrade or two
actually working without manual intervention/resort to portmaster,
that is).  Dropping the attached patch into
$PORTS/ports-mgmt/portupgrade/files/patch-flavors and rebuilding it is
a simple shortcut to getting it in place.

I haven't done any testing of using portupgrade with pre-built
packages (is there even any reason to post-pkg?), or using portinstall
(never saw the point), but it seems to handle the upgrading path just
fine.


Also sitting in a PR upstream at
https://github.com/freebsd/portupgrade/pull/72


-- 
Matthew Fuller     (MF4839)   |  fullermd at over-yonder.net
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.
-------------- next part --------------
--- bin/portupgrade.orig	2018-03-09 18:59:29 UTC
+++ bin/portupgrade
@@ -1147,6 +1147,11 @@ def get_make_args(origin, pkgname = nil)
   else
     args = $make_args.split(' ')
   end
+
+  if flavor = origin[/@(.+)$/, 1]
+    args << 'FLAVOR=' + flavor
+  end
+
   quoted = 0
   n = 0
   is_quoted = false
--- lib/pkgtools/pkgdb.rb.orig	2018-03-09 18:59:29 UTC
+++ lib/pkgtools/pkgdb.rb
@@ -425,10 +425,20 @@ class PkgDB
       @installed_pkgs = []
       @installed_ports = []
       @db = {}
+
+      flavors = {}
+      pkg_flavors = xbackquote(PkgDB::command(:pkg), 'annotate', '-Sa',
+                               'flavor').split("\n")
+      pkg_flavors.each do |line|
+        pkg, flavor = line.sub(/: Tag: flavor Value: /, ':').split(':')
+        flavors[pkg] = flavor
+      end
+
       pkg_origins = xbackquote(PkgDB::command(:pkg), 'query', '%n-%v %o').split("\n")
       pkg_origins.each do |line|
         pkg, origin = line.split(' ')
         @installed_pkgs << pkg
+        origin << '@' + flavors[pkg] if flavors[pkg]
         add_origin(pkg, origin)
       end
       @installed_pkgs.freeze
--- lib/pkgtools/portsdb.rb.orig	2018-03-09 18:59:29 UTC
+++ lib/pkgtools/portsdb.rb
@@ -325,6 +325,7 @@ class PortsDB
   end
 
   def portdir(port)
+    port = port.sub(/@.*$/, '')
     File.join(ports_dir, port)
   end
 


More information about the freebsd-ports mailing list