portupgrade
Introduction
Portupgrade (also known as pkgtools) is a set of tools for working with ports and packages. It enhances system tools and adds many new abilities. It is easily and highly configurable, allowing you to create individual, variable environments for any port you like, and to define commands that will be executed before/after port upgrade stages.
pkgtools uses hash databases so access to information about available (in the ports tree) and installed ports and their dependencies is fast.
pkgtools consist of the utils:
portupgrade - upgrade a port using ports or packages.
portinstall - helps you install new ports in a handy way.
pkg_deinstall - wraps pkg_delete(1) and provides additional features.
pkg_fetch - fetches packages from a remote site.
pkg_which - checks which package a file came from quickly.
pkg_glob - displays packages matched by a glob and different other conditions.
portversion - a fast version of pkg_version(1).
portsclean - cleans ports workdirs, unreferenced distfiles, old and orphan shared libraries, and stale packages.
portcvsweb - instantly lets you browse change history via CVSweb.
pkgdb - manages and searches the package database.
portsdb - creates binary database from the ports INDEX.
portdu - displays installed packages disk usage.
and a few other.
Authors
Initially pkgtools was written by Akinori MUSHA <knu AT FreeBSD DOT org>
It is currently maintained by BryanDrewery <bdrewery AT FreeBSD DOT org>
Past Maintainers
These people have maintained the project over time.
KOMATSU Shinichiro <koma2 AT lovepeers DOT org>
Sergey Matveychuk <sem AT FreeBSD DOT org>
Stanislav Sedov <stas AT FreeBSD DOT org>
Development
Hints & Tips
Look at pkgtools.conf. You'll find many interesting examples there.
portupgrade can stop/start/restart services when you like. Add these lines in pkgtools.conf and you'll always have service started after an upgrade process:
AFTERINSTALL = { '*' => proc { |origin| cmd_start_rc(origin) }, }
You can fetch INDEX and rebuild portsdb with one command:
portsdb -Fu
Use portinstall(1) and pkg_deinstall(1).
You can see a port history in your browser with portcvsweb(1) easily.
portsclean -D will purge old distfiles. portsclean -C will clean all 'work' directories. portsclean -L will clean up unused libraries in /usr/local/lib/compat/pkg. portsclean -P will clean up outdated packages.
If you afraid that something will able going wrong after upgrade, you can preserve old packages with -b option.
- You can find useful to exclude some packages from upgrading. It's easy with -x option. This command updates all package except ruby* packages and portupgrade:
portupgrade -a -x ruby -x portupgrade
- Easily to see how much space is used by ruby and all depended port you can with this command:
pkgdu -tr ruby
Using -c/-C options for portupgrade helps when you plan to update many ports. poruptgrade will run make config for all ports you want upgrade before upgrading process. So you can configure all of them and go to rest while the ports updating.
You can get packages older or newer some date with pkg_glob '<2008-07-10' - it shows packages older the data. It can be very useful to update all packages older some date with the command:
portupgrade -fa -x '>=2008-07-10'
TODO
Add portsbackup and portsrestore utilites. They will save ports data (/etc/make.conf, /var/db/pkg, /var/db/ports, /usr/local/etc) and restore all ports on another computer by rebuilding them from the ports tree. (The idea belongs to AndrejZverev).
Send your wishes, bug reports to http://github.com/pkgtools/pkgtools or <bdrewery AT FreeBSD DOT org>
Desired features
From: MatthiasAndree
When unregistering a package installed that was installed twice or more often (for me, it happened recently with pkgconfig and pkg-config), pkgdb -F offers to unregister one package's metadata without removing its files. pkgdb -F might however compare the package lists of all packages and remove files that are unique to the package to be deinstalled (i. e. not installed by the package that remains). Example: assume package-1.1 with files a, b, c and package-1.1_4 with files a, c, e are installed. In this case, pkgdb -F could offer to remove "b" if package-1.1 is deinstalled.
When unregistering a package that was installed twice or more often, pkgdb -F might count the number of MD5 mismatches of the installed files to figure out which package data is more current or fits the existing installation better, and default to installing metadata with most mismatches.
From: Hannes Hauswedell <hannes.hauswedell at gmail.com>
- I would wish for portupgrade to automatically meet new requirements upon upgrading. both pkg_add and make install do this, portupgrade should too. Upgrading a port and not installing a new requirement is almost never desired and shouldnt be default. (i.e. -R should not be required for this, instead if at all it should be achieved by -N )
- When using portupgrade in -P mode it should check dependencies before(!) doing a make install, otherwise requirements will always be installed via source, even though a current package might exist. an example: port A has no package and requires B that does have package. if I portupgrade -P "A" both are installed from source although B could have - and following the manual for -P, should have - been installed via package.
From: RW <list-freebsd-2004 at morbius.sent.com>
Portupgrade uses pkg_add -f to install packages. pkg_add is supposed to install the missing dependencies itself, but sometimes they are missing in the repository. Because it uses the -f option pkg_add is able to proceed without the missing dependency. Personally, I think it might be cleaner to drop the -f option and allow the pkg_add to fail.
From: AndrewPantyukhin
- Deliver SIGSTOP to spawned processes.
From: AlexanderLeidinger
- option to keep the logs of failed builds/updates (this is not '-L', but similar)
- parse the output of the install phase and present a list of installed startup scripts before portupgrade exits (hidden behind an option or not)
- parse the output of the install phase and present a list of all the stuff in the security report before portupgrade exits (only as an option)
From: Chris Calvey <chris at securityforensics.co.uk>
- A suggestion might be that portupgrade could capture say the kill signal, write its current upgrade tree to disk and exit. On restarting portupgrade, it would re-load the saved tree and continue.