Thursday, March 25, 2010

Mixing binary backage and source ports install sources with portupgrade in FreeBSD

Ok so a few weeks ago I made this post about automating update checks and downloads.  While as it turns out there was another issue I ran into.  The problem is simply this:

When using portupgrade -Pa to to FreeBSD updates from packages all updated packages will be installed even if you compile one of the updated packages was compiled locally from the ports tree with custom options or libraries.  This causes any customizations to be lost and possibly version mismatches with system libraries.

The only ways around this problem was to either only upgrade some subset of the ports or to set HOLD_PKGS and manually update problem ports after a package update.  Neither of these solutions is optimal so I took the time to make a patch for portupgrade.

The patch adds a USE_PORTS configuration option that specifies a lit of packages to always build from the ports tree even when portupgrade -P is called.  (The -PP option still works the same as before.)  Thus any custom packages can be added to this list and then an automatic update can be done that will favor binary version when available and when not overridden.  This also means that if one package is built from source its parents and children will still come from binary packages if available.

Build the pached version
Patch, build, and install.
cd /usr/ports/ports-mgmt/portupgrade
sudo make extract
cd work
sudo wget http://pynej.dnsalias.com/Shared/pkgtools-2.4.6-1.patch
sudo patch -p0 < pkgtools-2.4.6-1.patch
cd pkgtools-2.4.6
sudo make isntall clean
You may also want to add portupgrade to your HOLD_PKGS list in /usr/local/etc/pkgtools.conf so it doesn't get replaced in the future.

Configuration
To configure the list of overrides you will need to edit the following section:
sudo vim /usr/local/etc/pkgtools.conf
USE_PORTS = [
    
  ]
Here is a sample of some common overrides.
  •  php5 to enable the apache module
  •  php5-mysql to get the binding to the correct version of mysql-server
  •  mod_perl2 to enable apache module
  •  phpmyadmin as it depends ont he wrong php5-mysql paskage)
sudo vim /usr/local/etc/pkgtools.conf
USE_PORTS = [
    'lang/php5',
    'databases/php5-mysql',
    'databases/phpmyadmin',
    'www/mod_perl2',
  ]

3 comments:

Adam B said...

Oh, this is exactly the situation we're in and the patch we need, in our case to ensure openssl-dependant ports are built against our locally updated openssl port rather than the older system version of openssl. But I'm wondering why such a useful and sensible mod wouldn't make it back into the stock portupgrade -- did you submit and they rejected? It'd sure be nice to solve this problem without maintaining a local patch.

In any case, thanks much for the improvement!

Jeremy Pyne said...

It was submited lat year, still in pr at http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/144769

mahakk01 said...

I am sorry to say but I have no clue about this topic. I need to read basics of this topic before deciding whether your post is good or not. I followed other topics of your blog. On that basis I expect it to be good one.
digital signature