Tuesday September 07 , 2010
Text Size
   



Updating and Maintaining Ports and Sources

Updating your ports

Keeping up to date on your ports and sources is important. Updating sources helps your system keep up with the latest updates when you run you next make buildkernel. This is also helpful when you are upgrading from 6.0 to 6.1 and so forth. Upgrades don’t happen quite that often but it is a good idea to update them from time to time.Updating your ports is most important! If you don’t update ports, you are or could be installing an outdated port. I put this is a daily script in my ~user/bin folder called daily.sh. The command you use to update ports is

# cd /usr/ports

# make update

Now if you wanted to update both sources and ports, you would do this:

# cd /usr/src
# make update

Now you can also automate this as well. Lets start with a small shell script. One thing to note about shell scripts is they are not hard and also when you run commands, you have to give the command the exact path name. For instance in a shell script, you just can’t put in cvsup :

cvsup -g -L 2 ~root/ports-supfile

you have to put

/usr/local/bin/cvsup -g -L 2 ~root/ports-supfile

so if you wanted to create a script that will update your sources and ports everyday, here is how we would do it:

#!/bin/sh
/usr/local/bin/cvsup -g -L 2 ~root/ports-supfile
/usr/local/bin/cvsup -g -L 2 ~root/stable-supfile

I always put my ports-supfile and stable-supfile in the ~root dir. You don’t have to. You can copy the examples at

/usr/share/examples/cvsup/stable-supfile
/usr/share/examples/cvsup/ports-supfile

and then put them anywhere you want.

One good thing to start with is when you’re running scripts, give them good names so you don’t forget what they have in them. So if you run a script hourly, you can call it hourly.sh and so on. I have a daily script that runs twice a day that runs a ton of different things:

#!/bin/sh
# Update the time to the MIT Time Server
/usr/sbin/ntpdate time.mit.edu
# updates your headers when you upgrade ClamAV or SpamAssassin
/usr/local/bin/setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -z
# Update sources
/usr/local/bin/cvsup -g -L 2 /root/stable-supfile
# Update Ports
/usr/local/bin/cvsup -g -L 2 /root/ports-supfile
# Backup /usr/local/etc
/bin/rm /home/wolson/archives/etc.tgz
/usr/bin/tar cvzf /home/wolson/archives/etc.tgz /usr/local/etc

Just read the notes and you should be able to figure out what that script does. That’s my daily.sh script

I would definitely recommend running a backup of vpopmail if you have a test or a backup box running. Here is the URL for it:

http://www.goodcleanemail.com/index.php?option=com_content&view=article&id=53:how-to-backup-vpopmail-with-rsyncssh&catid=35:vpopmail&Itemid=41

Maintaining your Ports

It is a good idea to keep your ports system up to date. There really isn’t an easy way to do this via a script so I would recommend you do this kind of thing once a week or so. If you wait a month or two or even more, you’ll have a lot of fun doing a bunch of portupgrades. If you run the following command, it will tell you what needs updating:

# pkg_version -v |grep -v up-to-date |less

Here is my output:

linux_base-8-8.0_14                 <   needs updating (port has 8.0_16)
portaudit-0.5.10                    <   needs updating (port has 0.5.11)

Generally the way we want top do this is via portupgrade. If you haven’t installed it yet, just do:

# cd /usr/ports/ports-mgmt/portupgrade
# make install clean

If I  want to upgrade linux_base-8-8.0_14 and all it's upward-recursive and downward recursive dependencies, this is what I would do:

# portupgrade -rR linux_base-8-8.0_14

Warning: I would not run the command below unless it’s on a test box. I WOULD NOT RECOMMEND THIS FOR A PRODUCTION MACHINE!!!

Here's how to upgrade all packages, downwards-recursive AND upwards-recursive, and clean up obsolete shared libraries:

# portupgrade -urRa

That’s basically it to updating and managing ports!