I'd like to have the following abilities in the ports infrastructure:
- To group package installs in "transactions" so that when a single "make install" (or portinstall) pulls other ports as dependencies, these are tracked as being pulled by this particular "make install".
- To be able to undo such package transactions, i.e. remove all packages installed by a single "make install" (or portinstall) in a straightforward way.
- To track removals of packages in a way similar to the one just described and (optionally) to undo these removals (read on).
The idea is to support operations like these:
- Install some large group of packages, like KDE or GNOME. Don't like it, want to delete all packages installed during the operation.
- Install a newer version of postgresql, have an OMG moment and remember you need to dump the database with the old version and reaload it with the new version. Revert the install by deleting the new packages and reinstalling the old ones (i.e. undo a removal).
To be able to do this, I propose a new utility, a program, called pkg_trans, that will be used like this:
Begins a transaction. Writes transaction id to stdout.
pkg_trans -a package_name -z trans_id
Records that a package is being installed, as a part of a transaction.
pkg_trans -d package_name -z trans_id
Records that a package is being removed, as a part of a transaction. Optionally, at this point, if pkg_trans_save_deleted_packages="YES" is present in /etc/rc.conf, a binary package backup is created by pkg_create -b to enable undoing the delete. When the transaction is logically over, the following is used:
pkg_trans -e -z trans_id
This ends the transaction, cleans up, whatever is needed. The command
pkg_trans -u -z trans_id
Undos a transaction, while
Shows a list of all recorded transactions, chronologically ordered.
pkg_trans -i -z trans_id
Shows details of a transaction.
I've chosen -z for transaction ID because -t and -x are both used by various pkg_* utilities for other purposes and -z is free in all utilities.
For this to be effective, I think these utilities will have to be modified:
pkg_add - to start a transaction, record added packages, end the transaction
pkg_delete - to start a transaction, record the deleted packages, end the transaction
the make install infrastructure, I believe this involves pkg_create to register the package, to the same effects as pkg_add. There are several problems here I don't know how to solve currently: 1) the transaction ID has to be kept somehow and passed around and b) make install can be exited by Ctrl-C and I still want the packages registered upto the point of interruption to remain recorded in the transaction and that the transaction ends cleanly.
- portupgrade - all of the above.
I have implemented pkg_trans and modified pkg_* utilities. The whole thing currently works in the general case. See http://people.freebsd.org/~ivoras/big/pkg_install.tgz for a working build tree.
See this post for usage examples: http://lists.freebsd.org/pipermail/freebsd-ports/2008-October/051033.html
Let's call this "alpha" release
- For this to become really usable, portinstall and the "make install" infrastructure need to be modified. I cannot do those - help is most welcome!