KrUsTy!
January 2nd, 2003, 14:52
Well, after a dressing down from MiNiOn, I figure I had better get this done. :D

Thanks for the motivation! :oops:

Keeping up with new version of ports/packages can be almost impossible. Doing this manually can mean ending up with a pretty messy installs of various ports and even different versions of the same thing!

portupgrade makes updating your installed ports a breeze! I have put this into 2 sections, first make sure your ports tree is updated, and then the portupgrade program for updating installed ports. If you already track the ports tree via CVS, skip this first part.

1. CVS - keeping your ports tree up-to-date

You will need to keep your ports tree updated to the latest versions of all the ports. Using CVS is an easy way to do this. For those of who have not had much or any experince with CVS, there is an great port to get you started. Its called "cvsupit". This will installed all the things you need for CVS and will setup up your CVS

You need to have a ports tree. If you don't, download the lastest ports tree, and install it.

ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/
get ports.tar.gz
tar xzf ports.tar.gz in /usr

Now that you have a ports tree, you need to keep it up-to date, which is where CVS comes in. So to install the "cvsupit" por which gets this all setup for you;

cd /usr/ports/net/cvsupit
make install clean

This will load everything you need, and when done, will go into a menu which will walk you through the setup of CVS. The first page asks about tracking the main OS source. You can it you want to, but for this you don't need that.

Skip the FreeBSD Source updating choose "none - Skip the updating of /usr/src/"

The next menu asks "Would you like to track the FreeBSD ports collection?". Answer "YES".

The next menu asks "Would you like to track the FreeBSD doc sources? You can answer "NO" to skip this.

Then it asks "Base directory for src, ports and docs subdirs?" You should leave it as /usr.

Then it will ask you to choose a CVS server. Choose which one is good for you.

Once your sever is chosen, it will ask "Do you wish to run the CVSup update now?" Hey, might as well, no time like the present!

If you choose "yes" then it will ask about compression, choose whatever suits you. You will then get a verbose panel of the CVS updating your ports collection. Once done it will give you the command to use to update the ports whenever you like. You can put this in a CRON or the Daily script, or you can just make it into a small shell script to run whenever you want to.

So now your ports tree is updated. Now onto the really cool stuff!

2. Portupgrade - updating your installed ports and packages.

You will need to install the portupgrade program.

cd /usr/ports/sysutils/portupgrade
make install clean

Then to take a look a what needs updating you can run;

pkg_version -v

which gives you a pkg_info with a comparison of your ports tree and installed packages and tell you which ones need to be updated. To upgrade a port, say for example an "unzip-5.50" installed port,

portupgrade -r unzip-5.50

It will then use the ports to build and reinstall that port, and any of its depencies (-R). Even better is just having portupgrade bring your entire installed packages and ports up to date;

portupgrade -ra

This will go through all ports/packages that need updating and update them! Cool! Although you may want to make sure you have the time, cause some building of ports, say KDE, can take quite a long time. To avoid getting too far behind I usually take a look about once a week and make sure that my installed ports are current, and if not I bring them up to date via portupgrade.

Sometimes portupgrade will have trouble with a dependecy in a particualr port. It will ask you to fix this by running pkgdb -F, which basically rebuilds your installed ports/packages database. It is interactive and you should just answer its questions as best you can.

For a much more in depth discussion of portupgrade and its various parts, take a look at this article, from which much of my little how to is based;

http://www.onlamp.com/pub/a/bsd/2001/11/29/Big_Scary_Daemons.html

A very good article. Take its warning about backing up your /usr/db/pkg database before playing around with portupgrade seriously. I have never had any trouble, nor heard about anyone who did, but always wise to have a backup copy of this database incase things get ugly.

Comments, questions and fixes are welcomed of course!

Happy upgrading!

{K}

soup4you2
January 23rd, 2003, 16:35
Here's a little knoledge for the guys running freebsd.. when you run pkg_version -L = you get a nice list that says what needs to be updated.. (provided you updated your ports nightly with cvsup) well a good example of this trick say you see mysql.. you dont want to run the portupgrade -ra because by default mysql overwrites the database tables so you would normally upgrade it by it's self with a dont overwrite database switch but if you can remember what switches goto what package you wish to update then Edit /usr/local/etc/pkgtools.conf and add this to the MAKE_ARGS variable: then add in a comment like 'databases/mysql323-server' => 'SKIP_INSTALL_DB=yes'
pretty simple and a nice way to ensure your updates go smoothly

And here's a simple portupgrade script i made.. i was feeling a little saucy... i dont really ever use it.. but it does make some things easy..

[code:1:aa5acf678d]#!/usr/local/bin/bash
# Simple port upgrade script

pu=
while [ x$pu = x ]; do
echo
echo -n "Do you wish to run portupgrade? [yes or no]: "
read yesnoanswer
case $yesnoanswer in
y* | Y*)
pu=1
;;
n* | n*)
echo "Ok perhaps later on then";
echo
exit 1
;;
esac
done

echo "Rebuilding Package Database"
/usr/local/sbin/pkgdb -F
echo
echo

echo "Listing Packages Needed to be upgraded"
pkg_version -L =

pu2=
while [ x$pu2 = x ]; do
echo
echo "Be sure to read over the list before you continue"
echo
echo -n "Are you sure you want to upgrade those packages? [ YES ] or [ NO ]: "
read yesnoanswer
case $yesnoanswer in
yes | YES)
pu2=1
;;
no | NO)
echo "Ok perhaps later on then";
echo
exit 1
;;
esac
done
/usr/local/sbin/portupgrade -ra
echo "Finished portupgrade"
[/code:1:aa5acf678d]

guy
July 4th, 2003, 00:03
Any tips for how to clean up after this or does portupgrade take care of that as well?

KrUsTy!
July 4th, 2003, 00:22
Any tips for how to clean up after this or does portupgrade take care of that as well?

Portupgrade cleans as it goes. After each new port that it builds and installs it runs a "make clean". You don't need to do anything but enjoy your updated installed ports.

{K}

guy
July 5th, 2003, 01:20
Nice! :D

hoserian
July 24th, 2003, 12:14
ok, so, i'm a retard.

in the howto you mention that it will give you the command to update the source tree whenever you like. i forgot to write it down or do anything with it. :oops:

can anyone refresh my memory as to what that command would be?

soup4you2
July 24th, 2003, 13:01
i'm not completely sure about cvsupit never used that port always just used cvsup.. but you most likely have a cvs-supfile or something and thats where you would define where the sources go..

example:

[code:1:d111c89200]
*default host=cvsup11.freebsd.org
*default base=/usr
*default prefix=/usr
*default release=cvs tag=RELENG_5_1
*default delete use-rel-suffix
*default compress
*default umask=002
src-all
[/code:1:d111c89200]

the /usr you see there is where it determins where to place the src directory. so by saying /usr it's going to make /usr/src perhaps somebody can enlighten us where cvsupit places this file and what it is called..

KrUsTy!
July 24th, 2003, 22:20
ok, so, i'm a retard.

in the howto you mention that it will give you the command to update the source tree whenever you like. i forgot to write it down or do anything with it. :oops:

can anyone refresh my memory as to what that command would be?

Once you have cvsupit loaded which makes and configures your cvsupfile for you, all you need to do is,

/usr/local/bin/cvsup -g -L 2 -z /etc/cvsupfile

I have it in a shell script on my laptop, so I can just run the shell scritpt when I want to get the ports updated on my laptop, and I have that same shell script in cron on my home server, runs every 6 hours, keeps my ports updated on the server without even having to think!

{K}

ealwen
July 25th, 2003, 19:18
What is the "*default umask=002" do?

As for the rest, it is a great howto

soup4you2
July 25th, 2003, 19:34
What is the "*default umask=002" do?

As for the rest, it is a great howto

have a look at this
http://screamingelectron.org/phpBB2/viewtopic.php?t=317

umask is a way of permissions.. we talk about what it is briefly in that document..

hugh nicks
August 26th, 2003, 21:48
odd.

when i built my last box a few days ago, i had no problems following krusty's how to for cvsup. worked great. now i'm re-doing everything on a 40GB drive, and the very first thing i did after getting into kde was to follow the cvs install. after make install clean, no menu, no gui, no nothing.

as i said, i worked perfectly the first time, but now i only get a message saying:
sheppy# /usr/local/bin/cvsup -g -L 2 -z /etc/cvsupfile
Parsing supfile "/etc/cvsupfile"
Cannot open "/etc/cvsupfile": No such file or directory

which makes sense because there was never a cvsupfile created! how can i get it to envoke again?

hn

* never mind *

stupidity got the better of me (as did extreme anger).
in my haste to get my new drive up and running by the end of the night, i didn't realize that i was building /usr/ports/net/cvsup, not cvsupit.

let that be a lesson to me... :oops:

molotov
September 4th, 2003, 23:53
ezunix.org has 2 excellent howto's on this subject aswell, including mounting /usr/obj/ as a ramdisk, using mergemaster, and otherways of updating the source/ports tree (cd /usr/src/; make update).

v902
October 6th, 2003, 20:27
FYI, ports.tar.gz are now in /pub/FreeBSD/ports/ports (port-current and ports-stable are symlinks)