Do it with pkgsrc

Hello, I'm a humble netBSD user, and I like to discover new packages to do more and more things with my computer. Here I'll post how I do things with pkgsrc. Feel free to make suggestions and comments about it.

2006-06-09

Manage your packages with ...

wip/pkgmanager: Package manager for pkgsrc
devel/cpuflags: Determine compiler flags to best target current cpu

pkgmanager is the greatest tool I know to manage my package collection from pkgsrc. It would never leave your system in inconsistent state as pkg_chk could. Check the website to understand how it works, and give it a try. Here’s my method to handle package installation, removal and update :

Of course you first need a pkgsrc tree. If you don't already have one, you can grab it and extract it with :

wget -c -P /tmp ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz
tar xfz /tmp/pkgsrc.tar.gz -C /usr

You may also grab the last wip tree :

wget -c -P /tmp http://pkgsrc-wip.sourceforge.net/snapshots/pkgsrc-wip-\

$(date+%Y%m%d)-snapshot.tar.gz
tar xfz /tmp/pkgsrc-wip-$(date +%Y%m%d)-snapshot.tar.gz -C /usr/pkgsrc


Now, the first thing you have to do is to install pkgmanager

cd /usr/pkgsrc/wip/pkgmanager
make install clean clean-depends

Let's see how to handle the main tasks :

a) Build and Install a new package

Let's say you want to install pkgfind

pkgmanager install pkgtools/pkgfind

pkgtools/pkgfind is then written in your want-list, compiled and installed, with all dependencies needed of course

b) Remove a package

If you want to remove pkgfind, just type

pkgmanager uninstall pkgtools/pkgfind

pkgtools/pkgfind will be removed from your want-list, and uninstalled, as well as every unneeded packages (former dependencies) its uninstallation may produce.

c) Update your packages

You first need to update your pkgsrc tree.

cd /usr/pksrc/
cvs update
cd /usr/pkgsrc/wip
cvs update

If you don't like cvs and don't care about netBSD servers bandwidth, which is bad, then you may use this crappy script :

#!/usr/pkg/bin/bash

echo "Fetching the trees"

echo -n "--Fetching pkgsrc-wip-"
echo -n $(date +%Y%m%d)
echo -n "-snapshot.tar.gz : "
wget --quiet -c -P /tmp http://pkgsrc-wip.sourceforge.net/snapshots/pkgsrc-wip-$(date +%Y%m%d)-snapshot.tar.gz
if [ "$?" -ne 0 ]
then
echo "Can't fetch it, trying archive from yesterday"
echo -n "--Fetching pkgsrc-wip-"
echo -n $(date -r $(expr `date +%s` - 86400) +%Y%m%d)
echo -n "-snapshot.tar.gz : "
wget --quiet -c -P /tmp http://pkgsrc-wip.sourceforge.net/snapshots/pkgsrc-wip-$(date -r $(expr `date +%s` - 86400) +%Y%m%d)-snapshot.tar.gz
if [ "$?" -ne 0 ]
then
echo "Can't fetch it, exiting"
exit 1
fi
fi
echo "OK"

echo -n "--Fetching pkgsrc.tar.gz : "
wget --quiet -c -P /tmp ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz
if [ "$?" -ne 0 ]
then
echo "Can't fetch it, exiting"
exit 1
fi
wget --quiet -c -P /tmp ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz.MD5
wget --quiet -c -P /tmp ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz.SHA1
echo "OK"

echo -n "Removing the old tree : "
rm -rf /usr/pkgsrc/
echo "OK"

echo -n "Extracting the trees : "
tar xfz /tmp/pkgsrc.tar.gz -C /usr
if [ "$?" -ne 0 ]
then
echo "NOK"
echo "Problems during extraction, check your pkgsrc tree"
exit 1
fi
tar xfz /tmp/pkgsrc-wip-$(date +%Y%m%d)-snapshot.tar.gz -C /usr/pkgsrc
if [ "$?" -ne 0 ]
then
echo "NOK"
echo "Problems during extraction, check your wip tree"
exit 1
fi
echo " OK"

echo -n "Fetching vulnerability list : "
/usr/pkg/sbin/download-vulnerability-list >> /dev/null
if [ "$?" -ne 0 ]
then
echo "NOK"
else
echo "OK"
fi

echo
echo "All done"
echo
exit 0


Once your trees are up to date, just type

pkgmanager sync

That's it !

Now if you wish to compile your packages with the appropriate flags, I suggest you to use devel/cpuflags. You just have to install it and to add those lines at the beginning of your /etc/mk.conf

.ifdef BSD_PKG_MK
.sinclude "/usr/pkg/share/mk/cpuflags.mk"
.endif


2 Comments:

At 9:34 PM, Anonymous Karsten Kruse said...

Nice entry, i didn't know pkgmanager.

Maybe you want to use blog.onetbsd.org to post your stuff? You could reach more people with it.

Anyways, thanks for that one :).

 
At 10:09 PM, Blogger wilouf said...

Thanks for your encouragement, i truly appreciate :)

I wish to keep it on this blog for consistency, and actually I'm not too sure to be able to publish good enough articles yet.

Let's see how I can make this blog interesting first :)

See you !

 

Post a Comment

<< Home