Module Name: othersrc
Committed By: cheusov
Date: Sun Nov 6 17:53:52 UTC 2011
Modified Files:
othersrc/usr.sbin/pkg_setup: pkg_setup
Log Message:
Use ${0##*/} and http:// instead of ftp:// as suggested by Jean-Yves Migeon
Fix bug in vecho
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 othersrc/usr.sbin/pkg_setup/pkg_setup
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: othersrc/usr.sbin/pkg_setup/pkg_setup
diff -u othersrc/usr.sbin/pkg_setup/pkg_setup:1.1 othersrc/usr.sbin/pkg_setup/pkg_setup:1.2
--- othersrc/usr.sbin/pkg_setup/pkg_setup:1.1 Sun Nov 6 11:36:31 2011
+++ othersrc/usr.sbin/pkg_setup/pkg_setup Sun Nov 6 17:53:52 2011
@@ -1,6 +1,6 @@
#!/bin/sh
-# $NetBSD: pkg_setup,v 1.1 2011/11/06 11:36:31 cheusov Exp $
+# $NetBSD: pkg_setup,v 1.2 2011/11/06 17:53:52 cheusov Exp $
#
# Copyright (c) 2011 Aleksey Cheusov <[email protected]>
#
@@ -29,28 +29,30 @@
: ${OPSYS:=`uname -s`}
: ${OSVER:=`uname -r | sed 's/[_-]*$//'`}
: ${ARCH:=`uname -m`}
-: ${MIRROR:='ftp://ftp.NetBSD.org'}
-: ${FTPDIR:="$MIRROR/pub/pkgsrc/packages/$OPSYS/$ARCH/$OSVER"}
+: ${MIRROR:='http://ftp.NetBSD.org'}
+: ${URL:="$MIRROR/pub/pkgsrc/packages/$OPSYS/$ARCH/$OSVER"}
: ${FTP_CMD:=ftp -V}
######################################################################
set -e
usage (){
- cat <<'EOF'
-pkg_setup downloads pkg_install binary package and installs it.
-usage: pkg_setup [options] [-- [pkg_add options]]
+ cat <<EOF
+${0##*/} downloads pkg_install binary package and installs it.
+usage: ${0##*/} [options] [-- [pkg_add options]]
options:
-h display this screen
-v verbose output
-d url to binary repository, the default is
- ftp://ftp.netbsd.org/pub/pkgsrc/packages/$OPSYS/$ARCH/$OSVER
+ http://ftp.netbsd.org/pub/pkgsrc/packages/\$OPSYS/\$ARCH/\$OSVER
EOF
}
vecho (){
- test -n "$verbose" && echo "$@"
+ if test -n "$verbose"; then
+ echo "$@"
+ fi
}
while getopts hvd: f; do
@@ -61,7 +63,7 @@ while getopts hvd: f; do
v)
verbose=1;;
d)
- FTPDIR="$OPTARG";;
+ URL="$OPTARG";;
\?)
exit 1;;
esac
@@ -75,7 +77,7 @@ test -n "$tmpdir" || exit 1
cd "$tmpdir"
vecho 'Downloading pkg_summary.gz...'
-$FTP_CMD "$FTPDIR/All/pkg_summary.gz"
+$FTP_CMD "$URL/All/pkg_summary.gz"
pkgname=`gzip -dc pkg_summary.gz | awk -F= '/^PKGNAME=pkg_install-[0-9]/ {print $2; exit}'`
if test -z "$pkgname"; then
echo 'Cannot find package pkg_install in pkg_summary(5)' 1>&2
@@ -83,7 +85,7 @@ if test -z "$pkgname"; then
fi
vecho "Downloading $pkgname.tgz..."
-$FTP_CMD "$FTPDIR/All/$pkgname.tgz"
+$FTP_CMD "$URL/All/$pkgname.tgz"
gzip -dc "$pkgname.tgz" | tar -xf -
vecho "Installing..."