Updating pkgsrc
The pkgsrc packaging system uses quarterly release scheme, where only the latest release is being maintained in terms of updates and security patches. There is also a current branch available over CVS. Accelerators are built using quarterly releases:
- pkgsrc-2007Q4, released Jan 8, 2008, on Accelerators deployed March 20 until today
- pkgsrc-2008Q1, released Apr 13, 2008, we are skipping this version …
- pkgsrc-2008Q2, released July 26, 2008, adapted for Accelerators
- 2008Q3, to be released end of September
There are typically major difference between the releases. E.g. with 2008Q1, OpenSSL 0.9.8 was made current, which changes dependencies in most major packages, ultimately resulting in a rebuild of all. It is a good idea to update your Accelerator to the most recent release available, so stay on top of software updates and security patches.
Getting the tools ready
This procedure is intended to run as root. First, make sure you switch to 'root' by using your preferred way. Both using 'su -' (providing root's password), or 'sudo -i' (providing your sudo user's password) would work.
/opt/local/bin/sudo -i
Now change your profile to talk to the new release repository.
/opt/local/bin/gsed -i'' '/PKG_PATH/s/2007Q4/2008Q2/' /root/.profile
Now raise the PKG_PATH variable in your existing shell too:
export PKG_PATH=http://pkgsrc.joyent.com/2008Q2/All
If haven't updated to 2008Q2 or newer yet (which means that you're on 2007Q4), grab the updated PKGSRC config file (mk.conf):
mv /opt/local/etc/mk.conf /opt/local/etc/mk.conf.old /opt/local/bin/curl -o /opt/local/etc/mk.conf http://pkgsrc.joyent.com/2008Q2/mk.conf
Install the pkg_chk tool (it's patched to work properly, so make sure to get the one from our 2008Q2 repository - should be version 1.95):
/opt/local/sbin/pkg_add -u pkg_chk
Updating
Run pkg_chk in 'test' mode to see all the packages that will be updated:
/opt/local/sbin/pkg_chk -ubn
The test run end with an error messages claiming a pkg_chk_update.conf file cannot be accessed, but that's actually OK (since no files are being created in a test run). If you see a stream of packages for which a newer version exists, things are good.
Now, before you actually push the red button, it makes sense to plan. The update typically takes a few minutes, and software may become unavailable during the process, so it's a good measure to think of it as 'server maintenance' or 'downtime' even, and plan accordingly. Can you claim a maintenance and shut off all service? Good. If not letting your users/visitors know would work. Just in case.
When you're ready to go on:
/opt/local/sbin/pkg_chk -ubk
What happens is that pkg_chk first makes a map of all that will be updated. Then it deletes all packages to be processed. And finally re-adds them from the Joyent binary package repository. The '-k' flag makes it continue onto other packages if any package update fails, so feel free to omit 'k' if you want stop immediately when something like that happens. Note however that pkg_chk will be able to resume work any time, and any failed updates will be remembered, until reconciled eventually.
After the first run, inspect the output. You can re-run to get rid of all that succeeded in the first run, and only see the failures.
pkgsrc system packages
There are some system packages used by pkgsrc itself, that deserve an update (pax, tnftp, pkg_install, bmake and bootstrap-mk-files). A workaround is needed though, because these tools are involved in the very process of updating packages. The Catch XXII. Let's use a temporary location for these to overcome:
mkdir -p /tmp/pkgsrc.safe cp -p `pkg_info -L tnftp pax pkg_install bmake|grep bin` /tmp/pkgsrc.safe/ cp -p `pkg_info -L bootstrap-mk-files|grep share` /tmp/pkgsrc.safe/ /opt/local/sbin/pkg_delete -ff tnftp pax pkg_install bmake bootstrap-mk-files ln -s /tmp/pkgsrc.safe/ftp /usr/local/bin/ftp ln -s /tmp/pkgsrc.safe/pax /usr/local/bin/pax ln -s /tmp/pkgsrc.safe/tar /usr/local/bin/tar /tmp/pkgsrc.safe/pkg_add pkg_install /opt/local/sbin/pkg_add tnftp pax bmake
Use these steps if you get the following error when trying to run /tmp/pkgsrc.safe/pkg_add pkg_install
$ /tmp/pkgsrc.safe/pkg_add pkg_install ftp: illegal option -- V usage: ftp [-adfginpstvx] [-m mech] [-T timeout] [hostname [port]] ftp: illegal option -- V usage: ftp [-adfginpstvx] [-m mech] [-T timeout] [hostname [port]] ftp: illegal option -- V usage: ftp [-adfginpstvx] [-m mech] [-T timeout] [hostname [port]] ftp: illegal option -- V usage: ftp [-adfginpstvx] [-m mech] [-T timeout] [hostname [port]] pkg_add: no pkg found for 'pkg_install', sorry. pkg_add: 1 package addition failed
Make sure our PKG_PATH is set properly.
export PKG_PATH=http://pkgsrc.joyent.com/2008Q2/All
We need to link ftp, pax, and tar to /opt/local instead of /usr/local (don't worry about the links overwriting ftp, pax, and tar as we will finish off by installing the new versions)
ln -s /tmp/pkgsrc.safe/ftp /opt/local/bin/ftp ln -s /tmp/pkgsrc.safe/pax /opt/local/bin/pax ln -s /tmp/pkgsrc.safe/tar /opt/local/bin/tar
Install tnftp first, then pkg_install
/tmp/pkgsrc.safe/pkg_add tnftp /tmp/pkgsrc.safe/pkg_add pkg_install
Finally finish it off with:
/opt/local/sbin/pkg_add pax bmake
Other packages
See particular release's page on packages that need special handling: