Source-Changes-HG archive

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

[src/pkgviews]: src/usr.sbin/pkg_install/view Add some error checks for the e...



details:   https://anonhg.NetBSD.org/src/rev/00ca492be2ca
branches:  pkgviews
changeset: 534238:00ca492be2ca
user:      jlam <jlam%NetBSD.org@localhost>
date:      Fri Jul 25 17:27:26 2003 +0000

description:
Add some error checks for the existence of the package in the depot
directory before cd'ing into it and executing a lot of other shell code
that assumes its existence.

diffstat:

 usr.sbin/pkg_install/view/linkfarm.sh |  14 +++++++++++++-
 usr.sbin/pkg_install/view/pkg_view.sh |  14 +++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diffs (102 lines):

diff -r 495eed60d9a1 -r 00ca492be2ca usr.sbin/pkg_install/view/linkfarm.sh
--- a/usr.sbin/pkg_install/view/linkfarm.sh     Fri Jul 25 11:56:43 2003 +0000
+++ b/usr.sbin/pkg_install/view/linkfarm.sh     Fri Jul 25 17:27:26 2003 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: linkfarm.sh,v 1.1.2.7 2003/07/25 11:54:03 jlam Exp $
+# $NetBSD: linkfarm.sh,v 1.1.2.8 2003/07/25 17:27:26 jlam Exp $
 
 #
 # Copyright (c) 2002 Alistair G. Crooks.  All rights reserved.
@@ -54,6 +54,15 @@
        exit 0
 }
 
+checkdir() {
+       if [ -d "$1" ]; then
+               :
+       else
+               echo "linkfarm: \`$1' doesn't exist"
+               exit 1
+       fi
+}
+
 ignorefiles=${PLIST_IGNORE_FILES:-info/dir}
 linktype=-s
 
@@ -113,6 +122,7 @@
 # if we're checking the entries, check, then exit
 case $check in
 yes)
+       checkdir $stowdir/$package
        (cd $stowdir/$package; 
        ex=0;
        for f in `$findprog . ! -type d -print`; do
@@ -137,6 +147,7 @@
 # if we need to get rid of old linkfarms, do it
 case $delete in
 yes)   
+       checkdir $stowdir/$package
        (cd $stowdir/$package;
        for f in `$findprog . ! -type d -print`; do
                newf=`echo $f | $sedprog -e 's|^\./||'`
@@ -166,6 +177,7 @@
 # if we need to create new linkfarms, do it
 case $create in
 yes)
+       checkdir $stowdir/$package
        (cd $stowdir/$package; 
        for d in `$findprog . -type d -print`; do
                newd=`echo $d | $sedprog -e 's|^\./||'`
diff -r 495eed60d9a1 -r 00ca492be2ca usr.sbin/pkg_install/view/pkg_view.sh
--- a/usr.sbin/pkg_install/view/pkg_view.sh     Fri Jul 25 11:56:43 2003 +0000
+++ b/usr.sbin/pkg_install/view/pkg_view.sh     Fri Jul 25 17:27:26 2003 +0000
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# $NetBSD: pkg_view.sh,v 1.1.2.15 2003/07/25 11:54:03 jlam Exp $
+# $NetBSD: pkg_view.sh,v 1.1.2.16 2003/07/25 17:27:26 jlam Exp $
 
 #
 # Copyright (c) 2001 Alistair G. Crooks.  All rights reserved.
@@ -59,6 +59,15 @@
        exit 0
 }
 
+checkpkg() {
+       if [ -d "$2/$1" ]; then
+               :
+       else
+               echo "Package \`$1' doesn't exist in \`$2'"
+               exit 1
+       fi
+}
+
 stowdir=""
 prefix=${PREFIX:-/usr/pkg}
 view=${PKG_VIEW:-""}
@@ -124,6 +133,7 @@
                if [ -f ${pkg_dbdir}/$1/+DEPOT ]; then
                        echo "Package $1 already exists in $viewstr."
                else
+                       checkpkg $1 ${depot_pkg_dbdir}
                        dbs=`(cd ${depot_pkg_dbdir}/$1; echo +*)`
                        env PLIST_IGNORE_FILES="${ignorefiles} $dbs" $linkfarmprog --target=${targetdir} --dir=${depot_pkg_dbdir} $1
                        $mkdirprog -p ${depot_pkg_dbdir}/$1
@@ -144,6 +154,7 @@
                fi
                ;;
        check)
+               checkpkg $1 ${depot_pkg_dbdir}
                $linkfarmprog -c --target=${targetdir} --dir=${depot_pkg_dbdir} $1
                exit $?
                ;;
@@ -160,6 +171,7 @@
                                        exit $ec
                                fi
                        fi
+                       checkpkg $1 ${depot_pkg_dbdir}
                        dbs=`(cd ${depot_pkg_dbdir}/$1; echo +*)`
                        env PLIST_IGNORE_FILES="${ignorefiles} $dbs" $linkfarmprog -D --target=${targetdir} --dir=${depot_pkg_dbdir} $1
                        temp=${depot_pkg_dbdir}/$1/+VIEWS.$$



Home | Main Index | Thread Index | Old Index