The arrow of time

Ivan Voras' blog

Addition to FreeBSD's package infrastructure: pkg_trans

Some time ago I've described a feature I wished for the ports & package infrastructure, and now I have a working prototype, at least for some of it. The main idea is to enable grouping of package operations into "transactions" that can be undoed as a whole. My own examples when this would be needed are

  • 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 transaction (by deleting the new packages and reinstalling the old ones) i.e. undo the upgrade.

With pkg_trans (or at least with what pkg_trans will develop into), these operations are possible!

This is also a call for testers. The source is available here: http://wiki.freebsd.org/IvanVoras/PkgTransProposal. I'd like to hear any feedback about the pkg_trans implementation and/or the idea.

Update: Will talk about pkg_trans at AsiaBSDCon 2009, which will hopefully rally more interest for it.

To use it:

  • Extract it somewhere
  • Run make in the created directory
  • su to root
  • Run make install

Now you have a new utility, pkg_trans, and additions to existing pkg_add and pkg_delete utilities. It's highly recommended you also add pkg_trans_save_deleted_packages="YES" to /etc/rc.conf (suggestions for better placement of this configurable is welcome). To undo this, run make install from the normal build tree (at /usr/src/usr.sbin/pkg_install) and manually remove the pkg_trans utility.

The additional pkg_trans utility is called by patched pkg_add and pkg_delete, to isolate transaction functionality and minimize changes to pkg_add and pkg_delete. It also serves to query transactions and undo them. In all other aspects, pkg_add and pkg_delete behave like they did before.

The man pages are not yet updated, but the wiki page above has simple descriptions of new options. Here's what currently works:

  • Recording pkg_add and pkg_delete transactions (one invocation of pkg_add/pkg_delete is one transaction, no matter how many packages it touches).
  • Backing up of packages in pkg_delete transactions
  • Undoing those transactions
  • Querying transaction records.

The transaction records are installed in /var/db/pkgtrans and /usr/ports/pkgtrans.

To use the new facilities, run pkg_add and pkg_delete as usual and note how transactions are generated with "pkg_trans -l". You can undo the transactions with "pkg_trans -u ###", given the appropriate transaction ID.

A sample console session with the new utilities is available at the announcement. I'd be happy to hear reports of its usage!

#1 great idea

Added on 2008-10-23T19:59 by fan

Excellent idea. Does pkg_trans play well with the "pkg_improved" changes that were made to pkg tools? pkg_improved uses a small .db (sqlite?) to speed up various pkg operations. I guess the patches are simple enough it would make little difference?

cheers,

encrypted isci howto is great too ... soon I will pxeboot and mount things via iscsi and leave nfs turned off ;-)

#2 pkg_trans and pkg_improved

Added on 2008-10-25T14:42 by Ivan Voras

I don't really agree with how "pkg_improved" was envisioned. I would be very happy if it used sqlite but instead it uses the ancient BDB databases. Much complexity could be avoided by using sqlite.

The pkg_trans work is orthogonal to the pkg_improved, but the patches are conflicting (though not much - I've avoided changes to existing pkg_* utilities and added the new functionality as an additional utility).

#3 Great

Added on 2008-10-30T18:56 by Jan

Hi Ivan

 

I like your idea about transactions support within pkg_* subsystem... keep going. O hope it will become in base freebsd ASAP.

 

Best regards, Jan

#4 Re: Great

Added on 2009-06-25T01:22 by Ivan Voras

Status update: the patch has been rejected.

Post your comment here!

Your name:
Comment title:
Text:
Type "xxx" here:

Comments are subject to moderation and will be deleted if deemed inappropriate. All content is © Ivan Voras. Comments are owned by their authors... who agree to basically surrender all rights by publishing them here :)