Re: automatically tracking just a few unstable packages
I wrote:
>>
>> My system is mostly bo, but I've installed a couple of packages out
>> of hamm. I have my dselect access method set to ftp and pointing at
>> the bo Packages files. I'd like a way to know when the hamm packages
>> I'm tracking are updated. Does the system have a way to do that?
"Jaldhar H. Vyas" <jaldhar@braincells.com> responded:
>
> There's a package in the net section of unstable called ftpwatch which
> sounds like it could do what you want.
Thanks, I looked at it, but unless I'm missing something I don't think
it's appropriate. It would need to watch for files by pattern, but I
think it can only watch whole directories or perhaps files by name (and
I'm not sure that it can watch files by name).
"Aaron M. Johnson" <ajohnson@math.ukans.edu> responded:
>
> I believe dftp has what you are looking for. [...]
I found the dftp manual hard to follow so I might have missed something,
but I also don't see how dftp can be made to help me.
I wrote a little script to do what I want. It checks the available and
status files to see what packages are installed which are newer than
what are available (and therefore I manually installed from hamm) and
then it reads the hamm packages files and reports what newer versions of
these modules are available. I then wrote a short wrapper script to
fetch the hamm packages files and run the main script.
Here are the scripts in case anyone else might find them useful.
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1997-05-21 12:09 EDT by <roderick@eeyore>.
# Source directory was `/home/roderick/bin/linux'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 2519 -r-xr-xr-x tracked-packages
# 2041 -r-xr-xr-x tracked-packages-run
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
echo 'WARNING: not restoring timestamps. Consider getting and'
echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
# ============= tracked-packages ==============
if test -f 'tracked-packages' && test X"$1" != X"-c"; then
echo 'x - skipping tracked-packages (file already exists)'
else
echo 'x - extracting tracked-packages (text)'
sed 's/^X//' << 'SHAR_EOF' > 'tracked-packages' &&
#!/usr/bin/perl -w
use strict;
X
# $Id: tracked-packages,v 1.3 1997-05-21 12:07:05-04 roderick Exp $
#
# Roderick Schertler <roderick@argon.org>
X
# This program checks the Debian available and status files to see what
# packages are installed which are newer than what are available (and
# therefore were manually installed from a newer release) and then it
# reads some given packages files (presumable from the newer release)
# and reports what newer versions of the tracked modules are available.
X
use FileHandle ();
use Proc::WaitStat qw(close_die);
use Sort::Versions qw(versioncmp);
X
(my $Me = $0) =~ s-.*/--;
X
my $Available = '/var/lib/dpkg/available';
my $Debug = 0;
my $Exit = 0;
my $Status = '/var/lib/dpkg/status';
X
sub xmess {
X push @_, " $!\n" if $_[$#_] =~ /:$/;
X "$Me: ", @_;
}
X
sub xwarn {
X warn xmess @_;
X $Exit ||= 1;
}
X
sub xdie {
X die xmess @_;
}
X
sub parse {
X local $_ = shift;
X my ($pkg, $version);
X
X chomp;
X /^Package:\s*(\S+)\s*$/im or xdie "bad status line:\n$_";
X $pkg = $1;
X /^Version:\s*(\S+)\s*$/im or xdie "bad status line:\n$_";
X $version = $1;
X return $pkg, $version;
}
X
sub main {
X my (%have, $pkg, $version, %tracking, $file);
X
X @ARGV or ! -t or xdie "no packages files specified\n";
X open STATUS, $Status or xdie "can't read $Status:";
X open AVAIL, $Available or xdie "can't read $Available:";
X
X STATUS->input_record_separator('');
X AVAIL->input_record_separator('');
X
X while (<STATUS>) {
X if (/^Status:.*\sinstalled\b/im) {
X ($pkg, $version) = parse $_;
X $have{$pkg} = $version;
X }
X }
X close_die \*STATUS, $Status;
X
X while (<AVAIL>) {
X ($pkg, $version) = parse $_;
X if (exists $have{$pkg} && versioncmp($have{$pkg}, $version) > 0) {
X $tracking{$pkg} = $have{$pkg};
X printf "tracking %-20s have %s\n", $pkg, $have{$pkg}
X if $Debug;
X }
X }
X close_die \*AVAIL, $Available;
X
X @ARGV = qw(-) unless @ARGV;
X for $file (@ARGV) {
X unless (open PACKAGES, $file) {
X xwarn "can't read $file:";
X next;
X }
X PACKAGES->input_record_separator('');
X while (<PACKAGES>) {
X ($pkg, $version) = parse $_;
X if (exists $tracking{$pkg}) {
X printf "compare %-20s available %s\n", $pkg, $version
X if $Debug;
X printf "updated %-20s have %-20s available %s\n",
X $pkg, $tracking{$pkg}, $version
X if versioncmp($tracking{$pkg}, $version) < 0;
X }
X }
X close_die \*PACKAGES, $file;
X }
X
X return 0;
}
X
$Exit = main || $Exit;
$Exit = 1 if $Exit and not $Exit % 256;
exit $Exit;
SHAR_EOF
$shar_touch -am 0521120797 'tracked-packages' &&
chmod 0555 'tracked-packages' ||
echo 'restore of tracked-packages failed'
shar_count="`wc -c < 'tracked-packages'`"
test 2519 -eq "$shar_count" ||
echo "tracked-packages: original size 2519, current size $shar_count"
fi
# ============= tracked-packages-run ==============
if test -f 'tracked-packages-run' && test X"$1" != X"-c"; then
echo 'x - skipping tracked-packages-run (file already exists)'
else
echo 'x - extracting tracked-packages-run (text)'
sed 's/^X//' << 'SHAR_EOF' > 'tracked-packages-run' &&
#!/bin/sh
X
# $Id: tracked-packages-run,v 1.3 1997-05-21 12:06:49-04 roderick Exp $
#
# Roderick Schertler <roderick@argon.org>
X
# This script fetches the unstable packages files and then calls
# tracked-packages on them. Run it from the directory in which you
# want to store the packages files. tracked-packages must be on your
# path.
X
script=`basename "$0"`
exit=0
info() { [ -n "$quiet" ] || echo "$script:" "$@"; }
warn() { echo "$script:" "$@" >&2; exit=1; }
die() { warn "$@"; exit $exit; }
usage() {
X [ $# = 0 ] || warn "$@"
X echo >&2 "usage: $script [-nq] [-h host] [-d dir] [distribution]..."
X echo >&2 " -d dir host keeps debian tree in alternate location"
X echo >&2 " -h host fetch files from alternate host"
X echo >&2 " -n don't fetch new packages files"
X echo >&2 " -q no informational messages"
X exit 1
}
X
host=ftp.debian.org
dir=/pub/debian
no_fetch=
quiet=
X
set -- `getopt d:h:nq "$@"` || usage
while [ $# != 0 ]
do
X case x$1 in
X x-d) dir=$2; shift;;
X x-h) host=$2; shift;;
X x-n) no_fetch=t;;
X x-q) quiet=t;;
X x--) shift; break;;
X esac
X shift
done
X
[ $# = 0 ] && set -- main contrib non-free
X
dist_file() {
X echo "Packages.new.$1.gz"
}
X
if [ -n "$no_fetch" ]
then
X info "not fetching"
else
X info "fetching"
X mail_name=`cat /etc/mailname 2>/dev/null || hostname --fqdn 2>/dev/null` ||
X die "can't get mail name"
X tmp=/tmp/$script.$$
X exec 3>$tmp || die "can't write to $tmp"
X echo >&3 "open $host"
X echo >&3 "user anonymous $LOGNAME@$mail_name"
X echo >&3 "cd $dir/unstable/.."
X echo >&3 "binary"
X for dist
X do
X echo >&3 "newer $dist/binary/Packages.gz `dist_file $dist`"
X done
X exec 3>&-
X ftp -ping <$tmp || die "return $? from ftp"
X rm $tmp
fi
X
for dist
do
X [ -f `dist_file $dist` ] || die "`dist_file $dist` doesn't exist"
done
X
info "checking"
for dist
do
X zcat `dist_file $dist` || die "error zcatting `dist_file $dist`"
X echo
done | tracked-packages || warn "return $? from tracked-packages"
X
exit $exit
SHAR_EOF
$shar_touch -am 0521120697 'tracked-packages-run' &&
chmod 0555 'tracked-packages-run' ||
echo 'restore of tracked-packages-run failed'
shar_count="`wc -c < 'tracked-packages-run'`"
test 2041 -eq "$shar_count" ||
echo "tracked-packages-run: original size 2041, current size $shar_count"
fi
exit 0
--
Roderick Schertler
roderick@argon.org
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: