Module Name: othersrc
Committed By: cheusov
Date: Sun Nov 6 11:36:31 UTC 2011
Added Files:
othersrc/usr.sbin/pkg_setup: Makefile pkg_setup
Log Message:
pkg_setup is a replacement for pkg_install in base system.
It downloads pkg_install package from binary repository and installs it
creating pkgdb.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 othersrc/usr.sbin/pkg_setup/Makefile \
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.
Added files:
Index: othersrc/usr.sbin/pkg_setup/Makefile
diff -u /dev/null othersrc/usr.sbin/pkg_setup/Makefile:1.1
--- /dev/null Sun Nov 6 11:36:31 2011
+++ othersrc/usr.sbin/pkg_setup/Makefile Sun Nov 6 11:36:31 2011
@@ -0,0 +1,5 @@
+SCRIPTS= pkg_setup
+
+#MAN= pkg_setup.8
+
+.include <bsd.prog.mk>
Index: othersrc/usr.sbin/pkg_setup/pkg_setup
diff -u /dev/null othersrc/usr.sbin/pkg_setup/pkg_setup:1.1
--- /dev/null Sun Nov 6 11:36:31 2011
+++ othersrc/usr.sbin/pkg_setup/pkg_setup Sun Nov 6 11:36:31 2011
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+# $NetBSD: pkg_setup,v 1.1 2011/11/06 11:36:31 cheusov Exp $
+#
+# Copyright (c) 2011 Aleksey Cheusov <[email protected]>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
+# Variables changable by user
+: ${OPSYS:=`uname -s`}
+: ${OSVER:=`uname -r | sed 's/[_-]*$//'`}
+: ${ARCH:=`uname -m`}
+: ${MIRROR:='ftp://ftp.NetBSD.org'}
+: ${FTPDIR:="$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]]
+
+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
+EOF
+}
+
+vecho (){
+ test -n "$verbose" && echo "$@"
+}
+
+while getopts hvd: f; do
+ case $f in
+ h)
+ usage
+ exit 0;;
+ v)
+ verbose=1;;
+ d)
+ FTPDIR="$OPTARG";;
+ \?)
+ exit 1;;
+ esac
+done
+shift $(expr $OPTIND - 1)
+
+tmpdir=`mktemp -d /tmp/pkg_setup.XXXXXX`
+trap "rm -rf $tmpdir" 0
+test -n "$tmpdir" || exit 1
+
+cd "$tmpdir"
+
+vecho 'Downloading pkg_summary.gz...'
+$FTP_CMD "$FTPDIR/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
+ exit 1
+fi
+
+vecho "Downloading $pkgname.tgz..."
+$FTP_CMD "$FTPDIR/All/$pkgname.tgz"
+gzip -dc "$pkgname.tgz" | tar -xf -
+
+vecho "Installing..."
+./sbin/pkg_add "$@" ./"$pkgname.tgz"
+
+vecho "done"