Sabtu, 31 Januari 2009

Upgrading FreeBSD Packages

In my last post I discussed upgrading from FreeBSD 7.0 to 7.1. In this post I'll mention packages that needed to be updated.

In the last post I showed two installed packages using the native pkg_info command.


neely# pkg_info
cdrtools-2.01_6 CD/CD-R[W] and ISO-9660 image creation and extraction tools
dvd+rw-tools-7.0 DVD burning software

At this point I could have used pkg_delete to remove them, and added the newest packages via pkg_add. Because that is easy, I decided to show an alternative that might be better for systems with many packages.

I decided to use Portupgrade to update packages installed on the system. Portupgrade was not on the box so I added it via pkg_add. I used the -n switch to do a "dry run" to see what version would be added.

neely# pkg_add -vrn portupgrade
scheme: [ftp]
user: []
password: []
host: [ftp.freebsd.org]
port: [0]
document: [/pub/FreeBSD/ports/i386/packages-7.1-release/Latest/portupgrade.tbz]
---> ftp.freebsd.org:21
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
<<< 220 Welcome to freebsd.isc.org.
>>> USER anonymous
<<< 331 Please specify the password.
>>> PASS richard@neely.taosecurity.com
<<< 230 Login successful.
>>> PWD
<<< 257 "/"
>>> CWD pub/FreeBSD/ports/i386/packages-7.1-release/Latest
<<< 250 Directory successfully changed.
>>> MODE S
<<< 200 Mode set to S.
>>> TYPE I
<<< 200 Switching to Binary mode.
setting passive mode
>>> PASV
<<< 227 Entering Passive Mode (204,152,184,73,191,203)
opening data connection
initiating transfer
>>> RETR portupgrade.tbz
<<< 150 Opening BINARY mode data connection for portupgrade.tbz (132387 bytes).
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.1-release/Latest
/portupgrade.tbz...Waiting for final status
x +CONTENTS
x +COMMENT
x +DESC
x +DISPLAY
x +MTREE_DIRS
x man/man1/pkg_deinstall.1.gz
x man/man1/pkg_fetch.1.gz
x man/man1/pkg_glob.1.gz
x man/man1/pkg_sort.1.gz
x man/man1/pkgdb.1.gz
x man/man1/pkgdu.1.gz
x man/man1/portcvsweb.1.gz
x man/man1/portsclean.1.gz
x man/man1/portsdb.1.gz
x man/man1/portupgrade.1.gz
x man/man1/portversion.1.gz
x man/man5/pkgtools.conf.5.gz
x man/man1/pkg_which.1.gz
x man/man1/portinstall.1.gz
x man/man1/ports_glob.1.gz
x sbin/pkg_deinstall
x sbin/pkg_fetch
x sbin/pkg_glob
x sbin/pkg_sort
x sbin/pkg_which
x sbin/pkgdb
x sbin/pkgdu
x sbin/portcvsweb
x sbin/portinstall
x sbin/ports_glob
x sbin/portsclean
x sbin/portsdb
x sbin/portupgrade
x sbin/portversion
x lib/ruby/site_ruby/1.8/pkg.rb
x lib/ruby/site_ruby/1.8/pkgdb.rb
x lib/ruby/site_ruby/1.8/pkgdbtools.rb
x lib/ruby/site_ruby/1.8/pkginfo.rb
x lib/ruby/site_ruby/1.8/pkgmisc.rb
x lib/ruby/site_ruby/1.8/pkgtools.rb
x lib/ruby/site_ruby/1.8/pkgtsort.rb
x lib/ruby/site_ruby/1.8/pkgversion.rb
x lib/ruby/site_ruby/1.8/portinfo.rb
x lib/ruby/site_ruby/1.8/ports.rb
x lib/ruby/site_ruby/1.8/portsdb.rb
x etc/pkgtools.conf.sample
x etc/pkgtools.status-pkg.sh
x share/zsh/site-functions/_pkgtools
x share/examples/pkgtools/bash/complete.sample
x share/examples/pkgtools/tcsh/complete.sample
x share/doc/pkgtools/ChangeLog
x share/doc/pkgtools/NEWS
x share/doc/pkgtools/README
x libdata/ldconfig/portupgrade
<<< 226 File send OK.
tar command returns 0 status
Done.
Package 'portupgrade-2.4.6,2' depends on 'ruby-1.8.6.287,1' with 'lang/ruby18' origin.
and was not found.
Package 'portupgrade-2.4.6,2' depends on 'db41-4.1.25_4' with 'databases/db41' origin.
and was not found.
Package 'portupgrade-2.4.6,2' depends on 'ruby18-bdb-0.6.4' with 'databases/ruby-bdb' origin.
and was not found.
pkg_add: 1 package addition(s) failed

Notice pkg_add used ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.1-release/Latest as its installation location. I could have altered this behavior by setting an environment variable thus:

setenv PACKAGESITE ftp://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-7-stable/Latest/

I didn't do that here, however, so I'm installing the version as released with 7.1.

neely# pkg_add -vr portupgrade
...edited...
Trying to record dependency on package 'ruby-1.8.6.287,1' with 'lang/ruby18' origin.
Trying to record dependency on package 'db41-4.1.25_4' with 'databases/db41' origin.
Trying to record dependency on package 'ruby18-bdb-0.6.4' with 'databases/ruby-bdb' origin.
Package portupgrade-2.4.6,2 registered in /var/db/pkg/portupgrade-2.4.6,2

------------------------------------------------------------------------------
Fill ALT_PKGDEP section in pkgtools.conf file for portupgrade
be aware of alternative dependencies you use.
E.g.
ALT_PKGDEP = {
'www/apache13' => 'www/apache13-modssl',
'print/ghostscript-gnu' => 'print/ghostscript-gpl',
}

Note also, portupgrade knows nothing how to handle ports with different
suffixes (E.g. -nox11). So you should explicitly define variables
(E.g. WITHOUT_X11=yes) for the ports in /etc/make.conf or pkgtools.conf
(MAKE_ARGS section) files.
------------------------------------------------------------------------------

Great, now let's see what needs to be updated.

neely# pkg_version -v
cdrtools-2.01_6 ? orphaned: sysutils/cdrtools
db41-4.1.25_4 ? orphaned: databases/db41
dvd+rw-tools-7.0 ? orphaned: sysutils/dvd+rw-tools
portupgrade-2.4.6,2 ? orphaned: ports-mgmt/portupgrade
ruby-1.8.6.287,1 ? orphaned: lang/ruby18
ruby18-bdb-0.6.4 ? orphaned: databases/ruby-bdb

Ah, I don't have a ports tree on this system. Even though I'm not building anything using the ports tree (I'm installing packages), I still need a local copy of the ports tree to know what is current. I install it using Portsnap.

neely# portsnap fetch
Looking up portsnap.FreeBSD.org mirrors... 2 mirrors found.
Fetching public key from portsnap2.FreeBSD.org... done.
Fetching snapshot tag from portsnap2.FreeBSD.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Sat Jan 31 19:15:45 EST 2009:
922e444be604245dd2c5567a0394f2ec588a710724529c100% of 55 MB 94 kBps 00m00s
Extracting snapshot... done.
Verifying snapshot integrity... done.
Fetching snapshot tag from portsnap2.FreeBSD.org... done.
Fetching snapshot metadata... done.
Updating from Sat Jan 31 19:15:45 EST 2009 to Sat Jan 31 20:26:31 EST 2009.
Fetching 3 metadata patches.. done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 8 patches..... done.
Applying patches... done.
Fetching 0 new ports or files... done.

neely# portsnap extract
...edited...
Building new INDEX files... done.

In the future to update I would change extract to update.

Now I can see what needs updating.

neely# pkg_version -v
cdrtools-2.01_6 < needs updating (port has 2.01_7)
db41-4.1.25_4 = up-to-date with port
dvd+rw-tools-7.0 < needs updating (port has 7.1)
portupgrade-2.4.6,2 = up-to-date with port
ruby-1.8.6.287,1 = up-to-date with port
ruby18-bdb-0.6.4 = up-to-date with port

I decided to run Portupgrade and tell it to only use packages (PP):

neely# portupgrade -varRPP
---> Session started at: Sat, 31 Jan 2009 22:37:43 -0500
[Rebuilding the pkgdb in /var/db/pkg ... - 6 packages found (-0 +6) ...... done]
[Updating the portsdb in /usr/ports ... - 19698 port entries found
.........1000.........2000.........3000.........4000.........5000.........
6000.........7000.........8000.........9000.........10000.........11000.........
12000.........13000.........14000.........15000.........16000.........17000.....
....18000.........19000...... ..... done]
---> Checking for the latest package of 'sysutils/cdrtools'
** No such file or directory - /usr/ports/packages/All
---> Fetching the package(s) for 'cdrtools-2.01_7' (sysutils/cdrtools)
---> Fetching cdrtools-2.01_7
++ Will try the following sites in the order named:
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.1-release/
---> Invoking a command: /usr/bin/fetch -o '/var/tmp/portupgradepS4h9CcR/cdrtools-
2.01_7.tbz' 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.1-release/All/cdrtools-2.01_7.tbz'
/var/tmp/portupgradepS4h9CcR/cdrtools-2.01_7.t100% of 767 kB 86 kBps
---> Downloaded as cdrtools-2.01_7.tbz
---> Identifying the package /var/tmp/portupgradepS4h9CcR/cdrtools-2.01_7.tbz
---> Saved as /usr/ports/packages/All/cdrtools-2.01_7.tbz
---> Listing the results (+:done / -:ignored / *:skipped / !:failed)
+ cdrtools-2.01_7
---> Packages processed: 1 done, 0 ignored, 0 skipped and 0 failed
---> Found a package of 'sysutils/cdrtools': /usr/ports/packages/All/cdrtools-
2.01_7.tbz (cdrtools-2.01_7)
---> Located a package version 2.01_7 (/usr/ports/packages/All/cdrtools-2.01_7.tbz)
---> Upgrade of sysutils/cdrtools started at: Sat, 31 Jan 2009 22:38:08 -0500
---> Upgrading 'cdrtools-2.01_6' to 'cdrtools-2.01_7' (sysutils/cdrtools) using a package
---> Updating dependency info
---> Modifying /var/db/pkg/dvd+rw-tools-7.0/+CONTENTS
---> Uninstallation of cdrtools-2.01_6 started at: Sat, 31 Jan 2009 22:38:08 -0500
---> Fixing up dependencies before creating a package
---> Backing up the old version
---> Uninstalling the old version
---> Deinstalling 'cdrtools-2.01_6'
pkg_delete: package 'cdrtools-2.01_6' is required by these other packages
and may not be deinstalled (but I'll delete it anyway):
dvd+rw-tools-7.0
[Updating the pkgdb in /var/db/pkg ... - 5 packages found (-1 +0)
(...) done]
---> Uninstallation of cdrtools-2.01_6 ended at: Sat, 31 Jan 2009 22:38:12 -0500
(consumed 00:00:03)
---> Installation of cdrtools-2.01_7 started at: Sat, 31 Jan 2009 22:38:12 -0500
---> Installing the new version via the package

===========================================================================

Note: The location of the cdrtools `defaults' files has been set to

/usr/local/etc

This is the FreeBSD ports standard config file location, NOT the cdrtools
standard location, which is /etc/default.

The reason for this is that FreeBSD ports and packages should not use
configuration files outside of /usr/local.

===========================================================================

---> Removing temporary files and directories
---> Removing old package'
---> Installation of cdrtools-2.01_7 ended at: Sat, 31 Jan 2009 22:38:14 -0500 (consumed 00:00:01)
---> Cleaning out obsolete shared libraries
[Updating the pkgdb in /var/db/pkg ... - 6 packages found (-0 +1) . done]
---> Upgrade of sysutils/cdrtools ended at: Sat, 31 Jan 2009 22:38:16 -0500
(consumed 00:00:07)
---> ** Upgrade tasks 2: 1 done, 0 ignored, 0 skipped and 0 failed
---> Checking for the latest package of 'sysutils/dvd+rw-tools'
---> Fetching the package(s) for 'dvd+rw-tools-7.1' (sysutils/dvd+rw-tools)
---> Fetching dvd+rw-tools-7.1
++ Will try the following sites in the order named:
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.1-release/
---> Invoking a command: /usr/bin/fetch -o '/var/tmp/portupgradeFKkYF29e/dvd+rw-
tools-7.1.tbz' 'ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7.1-release
/All/dvd+rw-tools-7.1.tbz'
/var/tmp/portupgradeFKkYF29e/dvd+rw-tools-7.1.100% of 101 kB 52 kBps
---> Downloaded as dvd+rw-tools-7.1.tbz
---> Identifying the package /var/tmp/portupgradeFKkYF29e/dvd+rw-tools-7.1.tbz
---> Saved as /usr/ports/packages/All/dvd+rw-tools-7.1.tbz
---> Skipping cdrtools-2.01_7 (already installed)
---> Listing the results (+:done / -:ignored / *:skipped / !:failed)
+ dvd+rw-tools-7.1
- cdrtools-2.01_7
---> Packages processed: 1 done, 1 ignored, 0 skipped and 0 failed
---> Found a package of 'sysutils/dvd+rw-tools': /usr/ports/packages/All/dvd+rw-
tools-7.1.tbz (dvd+rw-tools-7.1)
---> Located a package version 7.1 (/usr/ports/packages/All/dvd+rw-tools-7.1.tbz)
---> Upgrade of sysutils/dvd+rw-tools started at: Sat, 31 Jan 2009 22:38:22 -0500
---> Upgrading 'dvd+rw-tools-7.0' to 'dvd+rw-tools-7.1' (sysutils/dvd+rw-tools) using a package
---> Updating dependency info
---> Uninstallation of dvd+rw-tools-7.0 started at: Sat, 31 Jan 2009 22:38:22 -0500
---> Fixing up dependencies before creating a package
---> Backing up the old version
---> Uninstalling the old version
---> Deinstalling 'dvd+rw-tools-7.0'
[Updating the pkgdb in /var/db/pkg ... - 5 packages found (-1 +0)
(...) done]
---> Uninstallation of dvd+rw-tools-7.0 ended at: Sat, 31 Jan 2009 22:38:26 -0500 (consumed 00:00:04)
---> Installation of dvd+rw-tools-7.1 started at: Sat, 31 Jan 2009 22:38:26 -0500
---> Installing the new version via the package
---> Removing temporary files and directories
---> Removing old package'
---> Installation of dvd+rw-tools-7.1 ended at: Sat, 31 Jan 2009 22:38:27 -0500 (consumed 00:00:01)
---> Cleaning out obsolete shared libraries
[Updating the pkgdb in /var/db/pkg ... - 6 packages found (-0 +1)
. done]
---> Upgrade of sysutils/dvd+rw-tools ended at: Sat, 31 Jan 2009 22:38:29 -0500
(consumed 00:00:07)
---> ** Upgrade tasks 2: 2 done, 0 ignored, 0 skipped and 0 failed
---> Listing the results (+:done / -:ignored / *:skipped / !:failed)
+ sysutils/cdrtools (cdrtools-2.01_6)
+ sysutils/dvd+rw-tools (dvd+rw-tools-7.0)
---> Packages processed: 2 done, 0 ignored, 0 skipped and 0 failed
---> Session ended at: Sat, 31 Jan 2009 22:38:31 -0500 (consumed 00:00:48)

When done I check the results:

neely# pkg_version -v
cdrtools-2.01_7 = up-to-date with port
db41-4.1.25_4 = up-to-date with port
dvd+rw-tools-7.1 = up-to-date with port
portupgrade-2.4.6,2 = up-to-date with port
ruby-1.8.6.287,1 = up-to-date with port
ruby18-bdb-0.6.4 = up-to-date with port

That's it!


Richard Bejtlich is teaching new classes in DC and Europe in 2009. Register before free seats are taken!

0 komentar:

Posting Komentar