pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Seriously confused about keeping packages current



Sarton O'Brien <bsd-xen%roguewrt.org@localhost> writes:

> I used to use 'pkg_chk -u' but since have started using
> pkg_rolling-replace -suv' or just with -uv depending on the
> situation. pkg_rolling-replace does not rely on pkg_chk or it's conf
> files but it is useful to generate a conf file for reference if
> something doesn't work or is missing. With pkgsrc on NFS I tend to
> store them as pkgchk-$hostname.conf.

pkg_rolling-replace -u does run 'pkg_chk -uq' to find out what needs
updating.

Here's a script I use with pkg_rr; someday I should put it in the pkg....
I run it from /usr/pkgsrc

#!/bin/sh

# $Id: _update-pkgsrc,v 1.16 2009/01/26 15:33:36 gdt Exp $
# Copyright 2007-2009 Gregory D. Troxel, BBN Technologies
# Permission to copy granted under 3-clause BSD license.

# Do automatic periodic maintenance in pkgsrc.  Typically followed
# by pkg_rolling-replace.

# This script expects to be invoked as a user, and uses sudo.
# Consider invoking as root and a reverse su for cvs.  For now, do the
# sudo tasks early if possible.

# XXX This script assumes that it is operating in /usr/pkgsrc.  It
# should be extended to work with the current directory, checking that
# it is a pkgsrc directory.

# Suggested procedure:
#
#   run _update-pkgsrc
#
#   review PKG.{automatic,manual}-{notrequired,required} to see if
#   they are right, and do set/unset of automatic on packages.
#
#   review, or ask the user to review manual-*.  pkg_delete any that
#   are not needed.
#
#   remove all automatic-notrequired packages (and repeat until none)
#
#   then run pkg_rolling-replace -uv
#     (Note that without -u, some prereqs won't be up to date, and
#     rebuilds of unsafe_depends packages will perhaps depend on the
#     newer version, so -u is typically a good idea unless you have
#     looked at the unsafe_depends list.)

if [ "$1" = "noupdate" ]; then
    noupdate=t
fi

# XXX Substitute this at build time.
MAKE=make
if [ `uname` = "Darwin" ]; then
    MAKE=bmake
fi

# Get new vulnerability data.
sudo download-vulnerability-list

# Ensure that we have binary packages for all installed packages.
mkdir -p /usr/pkgsrc/packages/All
rm -f PKG.missing
(cd /var/db/pkg && ls) \
    | while read d; do
    if [ -d /var/db/pkg/"$d" ]; then
        if [ ! -f /usr/pkgsrc/packages/All/"$d".tgz ]; then
            echo $d >> PKG.missing
            sudo pkg_tarup -d /usr/pkgsrc/packages/All $d
        fi
    fi
done
                
# List working directories (for manual cleanup).
rm -f PKG.WORK
ls -d */*/work > PKG.WORK
if [ ! -s PKG.WORK ]; then
    rm PKG.WORK
fi

# Update sources
rm -f PKG.UPDATE
if [ "$noupdate" = "" ]; then
    cvs -q up -d -P > PKG.UPDATE.full 2>&1
else
    echo "NOUPDATE" > PKG.UPDATE.full
fi
egrep -v '(^[UP]|is no longer in)' PKG.UPDATE.full > PKG.UPDATE

# Check for vulnerable packages.
rm -f PKG.AUDIT; audit-packages | sort > PKG.AUDIT

# Check for mismatched packages
rm -f PKG.MISMATCH; pkg_chk -uq | sort > PKG.MISMATCH

# Make a list of packages not required by anything else.
rm -f PKG.automatic-required PKG.automatic-notrequired \
    PKG.manual-required PKG.manual-notrequired
for d in `cd /var/db/pkg && ls`; do
    D=/var/db/pkg/$d
    DREQ=$D/+REQUIRED_BY
    DINS=$D/+INSTALLED_INFO
    REQ=notrequired
    AUTO=manual
    if [ ! -d $D ]; then
        continue;
    fi
    if [ -s $DREQ ]; then
        REQ=required
    fi
    if [ -f $DINS ] && egrep 'automatic=(yes|YES)' $DINS > /dev/null; then
        AUTO=automatic
    fi
    echo $d >> PKG.$AUTO-$REQ
done

# Remove distfiles that are out of date. 
lintpkgsrc -mor

# Ensure that we have sources for all packages that are installed,
# plus all packages requested.
pkg_chk -g
cat pkgchk.conf pkgchk-manual.conf | egrep -v \# | while read pkg; do
    echo $pkg
    (cd $pkg && $MAKE fetch)
done

# Make list of out-dated binary packages, separated by whether they
# are installed or not.
rm -f PKG.old-installed PKG.old-notinstalled
lintpkgsrc -p | egrep -v '^(Cannot extract|Bogus:)' | egrep . | while read p; do
    pbase=`basename $p .tgz`
    installed=notinstalled
    if [ -d /var/db/pkg/$pbase ]; then
        installed=installed
    fi
    echo "$p" >> PKG.old-$installed
done

# Delete binary packages that are old and not installed.
# This must be done after the cvs update, and thus will probably not
# be able to ride the sudo timer.
if [ -f PKG.old-notinstalled ]; then
    cat PKG.old-notinstalled | sudo xargs rm -f && \
        rm PKG.old-notinstalled
fi

Attachment: pgpqfmm6w3PZZ.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index