pkg_radd/pkg_search: add support for BINPKG_BASE
authorSimon Schubert <corecode@dragonflybsd.org>
Wed, 16 Sep 2009 23:35:22 +0000 (01:35 +0200)
committerSimon Schubert <corecode@dragonflybsd.org>
Wed, 16 Sep 2009 23:38:31 +0000 (01:38 +0200)
BINPKG_BASE allows the user to set the base of a package mirror
hierarchy, instead of having to select a specific set of packages which
might get stale.

usr.bin/pkg_radd/pkg_radd.1
usr.bin/pkg_radd/pkg_radd.sh
usr.bin/pkg_search/pkg_search.sh

index 329bf3c..3fa8388 100644 (file)
@@ -48,9 +48,23 @@ variable to the
 .Dx
 default
 .Xr pkgsrc 7
-binary package server or reads out a value from the global
+binary package server or uses the global
 .Pa /etc/settings.conf
-config file.
+config file to calculate
+.Ev PKG_PATH .
+In
+.Pa /etc/settings.conf ,
+set
+.Ev BINPKG_BASE
+to your favorite binary packages mirror URL to allow
+.Nm
+to automatically retrieve the latest set of binary packages for your
+.Dx
+release.
+If you want to use a specific set of packages, set
+.Ev BINPKG_SITES
+instead.
+.Pp
 All options passed to
 .Nm
 are passed to
@@ -69,6 +83,12 @@ to find the correct version.
 .Pp
 .Dl "# pkg_search fvwm2"
 .Dl "# pkg_radd -v fvwm-2.4.20nb1"
+.Pp
+Add the following line to
+.Pa /etc/settings.conf
+to fetch packages from the European mirror:
+.Pp
+.Dl "BINPKG_BASE=http://chlamydia.fs.ei.tum.de/pub/DragonFly/packages"
 .Sh SEE ALSO
 .Xr pkg_add 1 ,
 .Xr pkg_create 1 ,
index 4ee91c9..8999f9b 100644 (file)
 #
 # $DragonFly: src/usr.bin/pkg_radd/pkg_radd.sh,v 1.1 2008/01/05 10:14:26 matthias Exp $
 
-if [ -z "$BINPKG_SITES" ]
-then
-       osver=`uname -r | awk -F - '{ print $1; }'`
-       cpuver=`uname -p | awk -F - '{ print $1; }'`
-       BINPKG_SITES=http://avalon.dragonflybsd.org/packages/$cpuver/DragonFly-$osver/stable
-       [ -f /etc/settings.conf ] && . /etc/settings.conf
-fi
-
-if [ -z "$PKG_PATH" ]
-then
-       PKG_PATH=$BINPKG_SITES/All
-fi
+osver=`uname -r | awk -F - '{ print $1; }'`
+cpuver=`uname -p | awk -F - '{ print $1; }'`
+[ -f /etc/settings.conf ] && . /etc/settings.conf
+: ${BINPKG_BASE:=http://avalon.dragonflybsd.org/packages}
+: ${BINPKG_SITES:=$BINPKG_BASE/$cpuver/DragonFly-$osver/stable}
+: ${PKG_PATH:=$BINPKG_SITES/All}
 
 export PKG_PATH
 
index 5c2a145..e6c690d 100644 (file)
 #
 # $DragonFly: src/usr.bin/pkg_search/pkg_search.sh,v 1.11 2008/09/04 10:33:50 matthias Exp $
 
+set_binpkg_sites() {
+       : ${BINPKG_BASE:=http://avalon.dragonflybsd.org/packages}
+       : ${BINPKG_SITES:=$BINPKG_BASE/$cpuver/DragonFly-$osver/stable}
+}
+
 UNAME=`uname -s`
-VERSION=`uname -r | awk -F - '{ print $1; }'`
-CPU=`uname -p | awk -F - '{ print $1; }'`
+osver=`uname -r | awk -F - '{ print $1; }'`
+cpuver=`uname -p | awk -F - '{ print $1; }'`
+[ -f /etc/settings.conf ] && . /etc/settings.conf
+set_binpkg_sites
+
 NO_INDEX=0
 PORTSDIR=/usr/pkgsrc
 PKGSUM=${PORTSDIR}/pkg_summary
-if [ -z "$BINPKG_SITES" ]; then
-       BINPKG_SITES=http://avalon.dragonflybsd.org/packages/${CPU}/${UNAME}-${VERSION}/stable/
-       [ -f /etc/settings.conf ] && . /etc/settings.conf
-fi
-PKGSRCBOX1=$BINPKG_SITES
-PKGSRCBOX2=http://avalon.dragonflybsd.org/packages/i386/DragonFly-2.2.0/stable/
 INDEXFILE=INDEX
 
 # Download the pkg_summary file
 download_summary()
 {
        echo "Fetching pkg_summary(5) file."
-       FETCHPATH=${PKGSRCBOX1}/All/pkg_summary.bz2
-       fetch -o ${PKGSUM}.bz2 ${FETCHPATH}
-       if [ $? -ne 0 ]; then
-               FETCHPATH=${PKGSRCBOX2}/All/pkg_summary.bz2
+       for tries in 1 2
+       do
+               FETCHPATH=${BINPKG_SITES}/All/pkg_summary.bz2
                fetch -o ${PKGSUM}.bz2 ${FETCHPATH}
-       fi
+               [ $? -eq 0 ] && break
+
+               # retry with default
+               unset BINPKG_BASE
+               unset BINPKG_SITES
+               set_binpkg_sites
+       done
        if [ $? -ne 0 ]; then
                echo "Unable to fetch pkg_summary(5) file."
                exit 1