Subject: Re: transition of pkgsrc to a new machine
To: None <>
From: Tero Kivinen <>
List: tech-pkg
Date: 10/07/2002 04:03:09 (Frank Knappe) writes:
> I would prefer the installation from source, because I have all the
> sources in pkgsrc_distfiles and this machine has only a dialup 
> connection.
> I will look into the suggestion with pkgchk.

The script included at the end of this email might be useful. I used
to have almost all packages installed on my system (I usually do
pkg_delete -r '*'; pkg_chk -C pkgchk.conf -a -k where the pkgchk.conf
have names of all packages with no conflicts). The good thing about
that is that when someone says about have you tried the tool xxx, I
usuall have that one already installed :-)

The bad thing is that the pkg_chk takes quite a long time, and during
that time the machine is mostly unusable as there are lots of binaries

Then I realized that as I actually only use only few of those packages
I could extract that information and create pkgchk.conf that only
contains the packages that I have used in last say 200 days.

This ended up to small perl script called pkg_show_used. It will check
for all packages installed on your system and check if they have any
files that has been modified or accessed in last <n> days. If so it
will find out the directory of the package and print it out. The
output of this script is directly suitable for pkg_chk. 

Of course using this requires that you take backups in ways that do
not modify the timestamps in files.

Have fun:
#!/usr/pkg/bin/perl -w 
# -*- perl -*-

if ($#ARGV >= 0) {
    $days = $ARGV[0];
} else {
    $days = 200;

$check_time = time() - $days * 86400;

open(PKG_INFO, "pkg_info |") || die "Cannot run pkg_info: $!";
while (<PKG_INFO>) {
    s/ .*//g;
    push(@pkgs, $_);

foreach $pkg (@pkgs) {
    open(PKG_INFO, "pkg_info -q -L $pkg |") ||
	die "Cannot run pkg_info -q -L $pkg: $!";
    print(STDERR "# Checking $pkg...");
    while (<PKG_INFO>) {
	(undef, undef, undef, undef, undef, undef, undef,
	 undef, $a, $m, $c) = stat($_);
	if (defined($a) && defined($m) && defined($c) &&
	    ($a > $check_time || $m > $check_time || $c > $check_time)) {
	    push(@used_pkgs, $pkg);
	    print(STDERR "used");
    print(STDERR "\n");

foreach $pkg (@used_pkgs) {
    open(PKG_INFO, "pkg_info -q -B $pkg |") ||
	die "Cannot run pkg_info -q -B $pkg : $!";
    while (<PKG_INFO>) {
	next if (!/^PKGPATH=\s*(.*)$/);
	print($1, "\n");
SSH Communications Security        
SSH IPSEC Toolkit