I'd like to have the following abilities in the ports infrastructure:

The idea is to support operations like these:

To be able to do this, I propose a new utility, a program, called pkg_trans, that will be used like this:

pkg_trans -b

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

pkg_trans -l

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:

Progress

Let's call this “alpha” release :)

Notes