summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorabs <abs@pkgsrc.org>2001-07-02 14:12:29 +0000
committerabs <abs@pkgsrc.org>2001-07-02 14:12:29 +0000
commite6ddc645625ab76dd1d0c9215dfa9d9e3024bea9 (patch)
tree1944b52b572f5b957b118e31d7ba32a642fdb784 /pkgtools
parentd6ae97c12c18cd5b8a157b0316ed9c7ebe58f346 (diff)
downloadpkgsrc-e6ddc645625ab76dd1d0c9215dfa9d9e3024bea9.tar.gz
Correctly import pkgchk-1.00 (into pkgtools not pkg_tools)
pkgchk verifies that the versions of installed packages matches those in pkgsrc, optionally adding missing or updating mismatched packages. It can verify all installed packages, or check against a set of packages based on the hostname, architecture, and other characteristics.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pkgchk/Makefile24
-rw-r--r--pkgtools/pkgchk/files/pkgchk.8134
-rwxr-xr-xpkgtools/pkgchk/files/pkgchk.sh216
-rw-r--r--pkgtools/pkgchk/pkg/DESCR5
-rw-r--r--pkgtools/pkgchk/pkg/PLIST3
5 files changed, 382 insertions, 0 deletions
diff --git a/pkgtools/pkgchk/Makefile b/pkgtools/pkgchk/Makefile
new file mode 100644
index 00000000000..7e4d4579d0f
--- /dev/null
+++ b/pkgtools/pkgchk/Makefile
@@ -0,0 +1,24 @@
+# $NetBSD: Makefile,v 1.1.1.1 2001/07/02 14:12:29 abs Exp $
+#
+
+DISTNAME= pkgchk-1.00
+CATEGORIES= pkgtools devel
+MASTER_SITES= # empty
+DISTFILES= # empty
+
+MAINTAINER= abs@netbsd.org
+HOMEPAGE= ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc/Packages.txt
+COMMENT= Check installed package versions against pkgsrc
+
+EXTRACT_ONLY= # empty
+NO_WRKSUBDIR= yes
+NO_CHECKSUM= yes
+NO_PATCH= yes
+NO_CONFIGURE= yes
+NO_BUILD= yes
+
+do-install:
+ ${INSTALL_SCRIPT} ${FILESDIR}/pkgchk.sh ${PREFIX}/sbin/pkgchk
+ ${INSTALL_MAN} ${FILESDIR}/pkgchk.8 ${PREFIX}/man/man8/pkgchk.8
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/pkgchk/files/pkgchk.8 b/pkgtools/pkgchk/files/pkgchk.8
new file mode 100644
index 00000000000..70ae632984c
--- /dev/null
+++ b/pkgtools/pkgchk/files/pkgchk.8
@@ -0,0 +1,134 @@
+.\" $NetBSD: pkgchk.8,v 1.1.1.1 2001/07/02 14:12:30 abs Exp $
+.\"
+.\" Copyright (c) 2001 by David Brownlee (abs@netbsd.org)
+.\" Absolutely no warranty.
+.\"
+.Dd June 28, 2001
+.Dt PKGCHK 1
+.Sh NAME
+.Nm pkgchk
+.Nd check, and optionally update, installed packages
+.Sh SYNOPSIS
+.Nm
+.Op Fl abhisv
+.Op Fl D Ar tags
+.Op Fl U Ar tags
+.Sh DESCRIPTION
+.Nm
+verifies that the versions of installed packages matches those in
+pkgsrc, optionally adding missing or updating mismatched packages.
+.Pp
+It can verify all installed packages, or check against a set of packages
+based on the hostname, architecture, and other characteristics.
+.Pp
+.Sy Options
+.Bl -tag -width xxxxxxxx
+.It Fl D Ar tags
+Add the comma separated list of tags to those checked when parsing
+pkgchk.conf.
+.It Fl U Ar tags
+Remove the comma separated list of tags from those checked when
+parsing pkgchk.conf.
+.It Fl a
+Automatically add any missing packages. If a binary package exists
+in
+.Ev ${PACKAGES}
+it will be used in preference to building from source, unless the
+.Fl b
+or
+.Fl s
+options are given.
+.It Fl b
+Limit additions or updates to using binary packages. If
+DEPENDS_TARGET=package
+is set in
+.Pa /etc/mk.conf ,
+then
+.Nm
+will automatically generate binary packages for later reuse.
+.It Fl h
+Brief help.
+.It Fl i
+Check versions of installed packages, ignoring pkgchk.conf.
+.It Fl s
+Limit additions or updates to building from source.
+.It Fl u
+Automatically update any missing packages. If a binary package exists
+in PACKAGES it will be used in preference to building from source, unless the
+.Fl b
+or
+.Fl s
+options are given.
+.Pp
+Note: If the update fails (particularly when building from source), the system
+will be left with missing packaged.
+.It Fl v
+Verbose - list the tags set, and all packages checked.
+.El
+.Sh FILE FORMAT
+.Pp
+Each non comment line in pkgsrc.conf should contain a package directory
+(such as sysutils/skill) followed by a list of 'tags'. If a tag starts with
+a hyphen (-), then any machine matching will be excluded, otherwise if any
+tags match the current machine the package will be included. The tag
+.Em *
+matches all machines.
+.Pp
+The default set of tags used to determine which packages to match in
+pkgsrc.conf are equivalent to the output of the following with any spaces
+converted to hypens (-): hostname -s, hostname, uname -srm, uname -sr, uname -sm, uname -s, uname -r, uname -m. If
+.Pa /usr/X11R6/lib/libX11.so
+or
+.Pa /usr/X11R6/lib/libX11.a
+is present,
+.Em x11
+is added to the list of tags.
+To see tags for the current machine, run
+.Nm
+with the
+.Fl v
+option.
+.Sh ENVIRONMENT
+.Nm
+uses the following environment variables.
+.Bl -tag -width xxxx
+.It Ev PKGSRCDIR
+Base of pkgsrc tree. If not set in environment then read from
+.Pa /etc/mk.conf .
+Defaults to
+.Pa /usr/pkgsrc
+.It Ev PACKAGES
+Location of binary packages. If not set in environment then read from
+.Pa /etc/mk.conf .
+Defaults to
+.Pa ${PKGSRCDIR}/packages.
+.Pp
+Unless in a completely homogeneous environment (every machine running
+exactly the same OS version and architecture) setting
+.Ev ${PACKAGES}
+in
+.Pa /etc/mk.conf
+to a value such as
+.Bd -literal
+${PKGSRCDIR}/packages/${LOWER_OPSYS}-${OS_VERSION}-${MACHINE_ARCH}
+
+.Ed
+is strongly recommended. If
+.Em cpuflags
+(devel/cpuflags) is being used to optimally target individual CPU types,
+then
+.Ev ${CPU_DIR}
+should be appended to
+.Ev ${PACKAGES} .
+.It Ev PKGCHK_CONF
+Pathname to pkgchk configuration file. If not set in environment
+then read from
+.Pa /etc/mk.conf .
+Defaults to
+.Pa ${PKGSRCDIR}/pkgchk.conf .
+.El
+.Sh AUTHOR
+David Brownlee <abs@netbsd.org>
+.Sh CAVEATS
+Updating packages on which other packages depend can currently only be done
+via source (not binary packages).
diff --git a/pkgtools/pkgchk/files/pkgchk.sh b/pkgtools/pkgchk/files/pkgchk.sh
new file mode 100755
index 00000000000..68011dd3d6e
--- /dev/null
+++ b/pkgtools/pkgchk/files/pkgchk.sh
@@ -0,0 +1,216 @@
+#!/bin/sh -e
+#
+# $Id: pkgchk.sh,v 1.1.1.1 2001/07/02 14:12:30 abs Exp $
+
+extract_variables()
+ {
+ # Establish PKGSRCDIR
+ #
+
+ if [ -z "$PKGSRCDIR" ];then
+ if [ -f /etc/mk.conf ] ;then
+ eval `printf 'all:\n\t@echo PKGSRCDIR=${PKGSRCDIR}\n' | make -f - -f /etc/mk.conf`
+ fi
+ if [ -z "$PKGSRCDIR" ];then
+ PKGSRCDIR=/usr/pkgsrc
+ fi
+ fi
+ if [ ! -d $PKGSRCDIR ];then
+ echo "Unable to locate PKGSRCDIR '$PKGSRCDIR'"
+ exit 1;
+ fi
+
+ # Now we have PKGSRCDIR, use it to determine PACKAGES, and PKGCHK_CONF
+ #
+ eval `printf 'CATEGORIES=x\nDISTNAME=x\nall:\n
+ @echo PACKAGES=${PACKAGES}
+ @echo PKGCHK_CONF=${PKGCHK_CONF}
+ ' | (cd $PKGSRCDIR ; make -f - -f $PKGSRCDIR/mk/bsd.prefs.mk)`
+
+ if [ -z "$PACKAGES" ];then
+ PACKAGES=$PKGSRCDIR/packages
+ fi
+
+ if [ -z "$PKGCHK_CONF" ];then
+ PKGCHK_CONF=$PKGSRCDIR/pkgchk.conf
+ fi
+ if [ ! -r $PKGCHK_CONF ];then
+ echo "Unable to read PKGCHK_CONF '$PKGCHK_CONF'"
+ exit 1;
+ fi
+ }
+
+pkg_install()
+ {
+ PKGNAME=$1
+ PKGDIR=$2
+ INSTALL=$3
+ if [ -n "$opt_b" -a -f $PACKAGES/All/$PKGNAME.tgz ] ; then
+ if [ $INSTALL = U ];then
+ if pkg_delete $PKGNAME ; then
+ echo "Deleted $PKGNAME"
+ else
+ echo "Can only update packages with dependencies via -s"
+ fi
+ fi
+ echo "Installing binary package $PKGNAME.tgz"
+ pkg_add $PACKAGES/All/$PKGNAME.tgz
+ elif [ -n "$opt_s" ]; then
+ echo "Building $PKGNAME"
+ cd $PKGSRCDIR/$PKGDIR
+ make update
+ fi
+ }
+
+args=`getopt D:IU:abchisuv $*`
+if [ $? != 0 ]; then
+ opt_h=1
+fi
+set -- $args
+while [ $# != 0 ]; do
+ case "$1" in
+ -D ) opt_D="$2" ; shift;;
+ -U ) opt_U="$2" ; shift;;
+ -a ) opt_a=1 ; opt_c=1 ;;
+ -b ) opt_b=1 ;;
+ -c ) opt_c=1 ;;
+ -h ) opt_h=1 ;;
+ -i ) opt_i=1 ;;
+ -s ) opt_s=1 ;;
+ -u ) opt_u=1 ;;
+ -v ) opt_v=1 ;;
+ -- ) break ;;
+ esac
+ shift
+done
+
+if [ -z "$opt_b" -a -z "$opt_s" ];then
+ opt_b=1; opt_s=1;
+fi
+
+if [ -z "$opt_a" -a -z "$opt_c" -a -z "$opt_i" ];then
+ echo "Must specify at least one of -a, -c, or -i";
+ echo
+ opt_h=1;
+fi
+
+if [ -n "$opt_h" -o $# != 1 ];then
+ echo 'Usage: pkgchk [opts]
+ -D tags Comma separated list of additional pkgchk.conf tags to set
+ -U tags Comma separated list of pkgchk.conf tags to unset
+ -a Add all missing packages (implies -c)
+ -b Limit installations to binary packages
+ -c Check installed packages against pkgchk.conf
+ -h This help
+ -i Check versions of installed packages (ignore pkgchk.conf)
+ -s Limit installations to building from source
+ -u Update all mismatched packages
+ -v Verbose
+
+pkgchk verifies installed packages against pkgsrc.
+The most common usage is 'pkgchk -i' to check all installed packages.
+For more advanced usage, including defining a set of desired packages based
+on hostname and type, see pkgchk(8).
+'
+ exit 1
+fi
+
+extract_variables
+
+if [ -n "$opt_i" ];then
+ PKGDIRLIST=`pkg_info -B \* | awk '/PKGPATH= /{print $2}'`
+fi
+
+if [ -n "$opt_c" ];then
+ # Determine list of tags
+ #
+ TAGS="`hostname -s`,`hostname`,`uname -srm | awk '{print $1"-"$2"-"$3","$1"-"$2","$1"-"$3","$1","$2","$3}'`"
+ if [ -f /usr/X11R6/lib/libX11.so -o /usr/X11R6/lib/libX11.a ];then
+ TAGS="$TAGS,x11"
+ fi
+ if [ -n "$opt_D" ];then
+ TAGS="$TAGS,$opt_D"
+ fi
+ if [ -n "$opt_v" ];then
+ echo "set TAGS=$TAGS"
+ echo "unset TAGS=$opt_U"
+ fi
+
+ # Extract list of valid pkgdirs
+ #
+ PKGDIRLIST="$PKGDIRLIST "`awk -v setlist=$TAGS -v unsetlist=$opt_U '
+ BEGIN {
+ split(setlist, tmp, ",");
+ for (tag in tmp)
+ { taglist[tmp[tag]] = 1; }
+ taglist["*"] = 1;
+ split(unsetlist, tmp, ",");
+ for (tag in tmp)
+ {
+ print "UN "notaglist[tag] > "/dev/stderr"
+ delete taglist[tmp[tag]]
+ }
+ taglist["*"] = "*"
+ }
+ {
+ sub("#.*", "");
+ split($0, chklist, "[ ]*");
+ need = 0;
+ for (chk in chklist) # For each word on the line
+ {
+ if (sub("^-", "", chklist[chk])) # If it begins with a '-'
+ {
+ if (chklist[chk] in taglist) # If match, discard
+ { next; }
+ }
+ else
+ {
+ if (chklist[chk] in taglist) # If match, note needed
+ { need = 1; }
+ }
+ }
+ if (need)
+ { print $1 }
+ }
+ ' < $PKGCHK_CONF
+ `
+fi
+
+# Check packages are installed
+#
+for pkgdir in $PKGDIRLIST ; do
+ cd $PKGSRCDIR/$pkgdir
+ # Use 'make x' rather than 'make all' to avoid potential licence errors
+ pkgname=`printf 'x:\n\t@echo ${PKGNAME}\n'|make -f - -f Makefile x`
+ if [ -z "$pkgname" ]; then
+ echo "Unable to extract PKGNAME for $pkgdir"
+ exit 1
+ fi
+
+ if [ ! -d /var/db/pkg/$pkgname ];then
+ echo -n "$pkgname: "
+ pkg=`echo $pkgname | sed 's/-[0-9].*//'`
+ pkginstalled=`pkg_info -e $pkg || true`
+ INSTALL=
+ if [ -n "$pkginstalled" ];then
+ echo -n "version mismatch - $pkginstalled"
+ if [ -n "$opt_u" ]; then
+ INSTALL=U
+ fi
+ else
+ echo -n "missing"
+ if [ -n "$opt_a" ] ; then
+ INSTALL=I
+ fi
+ fi
+ if [ -f $PACKAGES/All/$pkgname.tgz ] ;then
+ echo -n " (binary package available)"
+ fi
+ echo
+ if [ -n "$INSTALL" ];then
+ pkg_install $pkgname $pkgdir $INSTALL
+ fi
+ elif [ -n "$opt_v" ];then
+ echo "$pkgname: OK"
+ fi
+done
diff --git a/pkgtools/pkgchk/pkg/DESCR b/pkgtools/pkgchk/pkg/DESCR
new file mode 100644
index 00000000000..24d588aa43a
--- /dev/null
+++ b/pkgtools/pkgchk/pkg/DESCR
@@ -0,0 +1,5 @@
+pkgchk verifies that the versions of installed packages matches those in
+pkgsrc, optionally adding missing or updating mismatched packages.
+
+It can verify all installed packages, or check against a set of packages
+based on the hostname, architecture, and other characteristics.
diff --git a/pkgtools/pkgchk/pkg/PLIST b/pkgtools/pkgchk/pkg/PLIST
new file mode 100644
index 00000000000..2af38e2d43e
--- /dev/null
+++ b/pkgtools/pkgchk/pkg/PLIST
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2001/07/02 14:12:30 abs Exp $
+sbin/pkgchk
+man/man8/pkgchk.8