Where to get pkgsrc and how to keep it up-to-date
Before you download and extract the files, you need to decide
where you want to extract them. When using pkgsrc as root user, pkgsrc
is usually installed in /usr/pkgsrc. You are though
free to install the sources and binary packages wherever you want in
your filesystem, provided that the pathname does not contain white-space
or other characters that are interpreted specially by the shell and some
other programs. A safe bet is to use only letters, digits, underscores
and dashes.
Getting pkgsrc for the first time
Before you download any pkgsrc files, you should decide
whether you want the current branch or the
stable branch. The latter is forked on a
quarterly basis from the current branch and only gets modified
for security updates. The names of the stable branches are built
from the year and the quarter, for example
2009Q1.
The second step is to decide how you
want to download pkgsrc. You can get it as a tar file, via SUP,
or via CVS. All three ways are described here.
As tar file
The primary download location for all pkgsrc files is
. There are a
number of subdirectories for different purposes, which are
described in detail in .
The tar file for the current branch is in the directory
current and is called pkgsrc.tar.gz.
It is autogenerated daily.
The tar file for the stable branch 2009Q1 is in the
directory pkgsrc-2009Q1 and is also called pkgsrc-2009Q1.tar.gz.
To download a pkgsrc stable tarball, run:
&uprompt; ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-20xxQy/pkgsrc-20xxQy.tar.gz
Where pkgsrc-20xxQy is the
stable branch to be downloaded, for example,
pkgsrc-2009Q1
.
Then, extract it with:
&uprompt; tar -xzf pkgsrc-20xxQy.tar.gz -C /usr
This will create the directory pkgsrc/
in /usr/ and all the package source will be
stored under /usr/pkgsrc/.
To download pkgsrc-current, run:
&uprompt; ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
Via SUP
As an alternative to the tar file, you can get pkgsrc via
the Software Update Protocol, SUP. To do so, make sure your
supfile has a line
release=pkgsrc
in it, see the examples in
/usr/share/examples/supfiles, and that the
/usr/pkgsrc directory exists. Then, simply
run:
&uprompt; sup -v /path/to/your/supfile.
Via anonymous CVS
To do an initial (full) checkout of pkgsrc, you first
have to set some environment variables. For the C-Shell,
type:
&cprompt; setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot
&cprompt; setenv CVS_RSH ssh
Or, the same for the bourne shell:
&uprompt; export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
&uprompt; export CVS_RSH="ssh"
By default, CVS doesn't do things like most people would
expect it to do. But there is a
way to convince CVS, by creating a file called
.cvsrc in your home directory and saving
the following lines to it. This file will save you lots of
headache and some bug reports, so we strongly recommend it. You
can find an explanation of this file in the CVS
documentation.
# recommended CVS configuration file from the pkgsrc guide
checkout -P
update -dP
release -d
diff -upN
cvs -q -z3
rdiff -u
To fetch a specific pkgsrc stable branch from scratch, run:
&uprompt; cd /usr
&uprompt; cvs checkout -r pkgsrc-20xxQy -P pkgsrc
Where pkgsrc-20xxQy is the stable
branch to be checked out, for example, pkgsrc-2009Q1
This will create the directory pkgsrc/
in your /usr/ directory and all the package source
will be stored under /usr/pkgsrc/.
To fetch the pkgsrc current branch, run:
&uprompt; cd /usr
&uprompt; cvs checkout -P pkgsrc
Keeping pkgsrc up-to-date
The preferred way to keep pkgsrc up-to-date is via CVS
(which also works if you have first installed it via a tar
file). It saves bandwidth and hard disk activity, compared to
downloading the tar file again.
Via tar files
When updating from a tar file, you first need to
completely remove the old pkgsrc directory. Otherwise those
files that have been removed from pkgsrc in the mean time will
not be removed on your local disk, resulting in inconsistencies.
When removing the old files, any changes that you have done to
the pkgsrc files will be lost after updating. Therefore updating
via CVS is strongly recommended.
Note that by default the distfiles and the binary packages
are saved in the pkgsrc tree, so don't forget to rescue them
before updating. You can also configure pkgsrc to use other than
the default directories by setting the
DISTDIR and PACKAGES
variables. See for the details.
To update pkgsrc from a tar file, download the tar file as
explained above. Then, make sure that you have not made any
changes to the files in the pkgsrc directory. Remove the pkgsrc
directory and extract the new tar file. Done.
Via CVS
To update pkgsrc via CVS, make sure the environment
variable CVS_RSH is set as above. Then,
change to the pkgsrc directory and run cvs:
&uprompt; cd /usr/pkgsrc
&uprompt; cvs update -dP
Switching between different pkgsrc branches
When updating pkgsrc, the CVS program keeps track of the
branch you selected. But if you, for whatever reason, want to
switch from the stable branch to the current one, you can do it
by adding the option -A
after the
update
keyword. To switch from the current branch
back to the stable branch, add the
-rpkgsrc-2009Q3
option.
What happens to my changes when updating?
When you update pkgsrc, the CVS program will only touch
those files that are registered in the CVS repository. That
means that any packages that you created on your own will stay
unmodified. If you change files that are managed by CVS, later
updates will try to merge your changes with those that have been
done by others. See the CVS manual, chapter
update
for details.