Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/pkg_install Add a simple text menu-based binary pac...
details: https://anonhg.NetBSD.org/src/rev/2611544aeaf4
branches: trunk
changeset: 556594:2611544aeaf4
user: agc <agc%NetBSD.org@localhost>
date: Sun Dec 21 11:31:46 2003 +0000
description:
Add a simple text menu-based binary package manager, bpm(1).
bpm uses ftp(1) and pkg_add(1) to allow a menu-based addition of
binary packages from a URL. It first displays a list of categories,
and, within categories, binary packages, which can be added to the
local system simply by choosing them from a menu.
If no valid categories are found, a warning message will be displayed
(it is usually caused by people running NetBSD-current, and there are
rarely binary packages provided for such a fast-moving target, and the
"-r release" command-line switch to bpm(1) should be used).
Bump the pkg_install version number for this.
diffstat:
usr.sbin/pkg_install/Makefile | 4 +-
usr.sbin/pkg_install/bpm/Makefile | 6 +
usr.sbin/pkg_install/bpm/bpm.1 | 118 +++++++++++++++++++
usr.sbin/pkg_install/bpm/bpm.sh | 222 +++++++++++++++++++++++++++++++++++++
usr.sbin/pkg_install/lib/version.h | 4 +-
5 files changed, 350 insertions(+), 4 deletions(-)
diffs (truncated from 387 to 300 lines):
diff -r fb3f7262e35e -r 2611544aeaf4 usr.sbin/pkg_install/Makefile
--- a/usr.sbin/pkg_install/Makefile Sun Dec 21 11:18:25 2003 +0000
+++ b/usr.sbin/pkg_install/Makefile Sun Dec 21 11:31:46 2003 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.6 2003/09/02 07:34:47 jlam Exp $
+# $NetBSD: Makefile,v 1.7 2003/12/21 11:31:46 agc Exp $
# Original from FreeBSD, no rcs id.
-SUBDIR=lib .WAIT add admin create delete info view
+SUBDIR=lib .WAIT add admin bpm create delete info view
.include <bsd.subdir.mk>
diff -r fb3f7262e35e -r 2611544aeaf4 usr.sbin/pkg_install/bpm/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/pkg_install/bpm/Makefile Sun Dec 21 11:31:46 2003 +0000
@@ -0,0 +1,6 @@
+# $NetBSD: Makefile,v 1.1 2003/12/21 11:31:46 agc Exp $
+
+SCRIPTS= bpm.sh
+MAN= bpm.1
+
+.include <bsd.prog.mk>
diff -r fb3f7262e35e -r 2611544aeaf4 usr.sbin/pkg_install/bpm/bpm.1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/pkg_install/bpm/bpm.1 Sun Dec 21 11:31:46 2003 +0000
@@ -0,0 +1,118 @@
+.\" $NetBSD: bpm.1,v 1.1 2003/12/21 11:31:46 agc Exp $ */
+.\"
+.\"
+.\" Copyright (c) 2003 Alistair G. Crooks. All rights reserved.
+.\"
+.\" 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.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Alistair G. Crooks.
+.\" 4. The name of the author may not be used to endorse or promote
+.\" products derived from this software without specific prior written
+.\" permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+.\"
+.Dd December 21, 2003
+.Dt BPM 1
+.Os
+.Sh NAME
+.Nm bpm
+.Nd menu-based binary package manager
+.Sh SYNOPSIS
+.Nm
+.Op Fl Vhnv
+.Op Fl b Ar baseURL
+.Op Fl m Ar machine
+.Op Fl r Ar release
+.Op Fl w Ar seconds
+.Sh DESCRIPTION
+The
+.Nm
+command is used to locate and install binary packages from any
+reachable URL.
+.Pp
+The following command-line options are supported:
+.Bl -tag -width indent
+.It Fl V
+Print version number and exit.
+.It Fl b Ar baseURL
+Specify a base URL from which to download binary packages.
+The default URL is
+.Pa ftp://ftp.netbsd.org/pub/NetBSD/packages .
+.It Fl h
+Print a help message and then exit.
+.It Fl m Ar machine
+Use
+.Ar machine
+as the machine architecture to be used, instead of that returned by
+.Xr uname 1 .
+.It Fl n
+Don't actually execute the commands to add the package.
+.It Fl r Ar release
+Use
+.Ar release
+as the operating system release to be used, instead of that returned by
+.Xr uname 1 .
+.It Fl v
+Turn on verbose output.
+.It Fl w Ar seconds
+The number of
+.Ar seconds
+to wait after displaying an error message and returning to
+normal menu operations.
+.El
+.Pp
+.Nm
+provides a menu-based binary package manager for
+.Nx .
+.Nm
+first connects to the URL using
+.Xr ftp 1 ,
+and displays a list of categories
+for which binary packages exist.
+If no categories are displayed, it could
+be that the machine architecture or operating system release string
+have been wrongly interpreted, and that it will be necessary to override
+this values by means of the command line options.
+Within a category, a list of packages will be displayed, and by selecting
+one using the number assigned to it, the package will be downloaded
+automatically, and installed, using the
+.Xr pkg_add 1
+utility.
+It is also possible to change the category currently being examined,
+and to quit from the utility, simply by selecting the appropriate choices
+on the menu.
+.Sh ENVIRONMENT
+.Pp
+The environment variables which govern the behaviour
+.Xr ftp 1
+.Xr pkg_add 1
+are valid for
+.Nm .
+.Sh SEE ALSO
+.Xr ftp 1 ,
+.Xr pkg_add 1 ,
+.Xr uname 1
+.Sh AUTHORS
+The
+.Nm
+utility was written by
+.An Alistair Crooks Aq agc%NetBSD.org@localhost .
diff -r fb3f7262e35e -r 2611544aeaf4 usr.sbin/pkg_install/bpm/bpm.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/pkg_install/bpm/bpm.sh Sun Dec 21 11:31:46 2003 +0000
@@ -0,0 +1,222 @@
+#! /bin/sh
+#
+# $NetBSD: bpm.sh,v 1.1 2003/12/21 11:31:46 agc Exp $
+#
+# Copyright (c) 2003 Alistair G. Crooks. All rights reserved.
+#
+# 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.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Alistair G. Crooks.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+#
+
+die()
+{
+ echo >&2 "$@"
+ exit 1
+}
+
+check_prog()
+{
+ _var="$1"; _name="$2"
+
+ eval _tmp=\"\$$_var\"
+ if [ "x$_tmp" != "x" ]; then
+ # Variable is already set (by the user, for example)
+ return 0
+ fi
+
+ for _d in `echo $PATH | tr ':' ' '`; do
+ if [ -x "$_d/$_name" ]; then
+ # Program found
+ eval $_var=\""$_d/$_name"\"
+ return 1
+ fi
+ done
+
+ die "$_name not found in path."
+}
+
+check_prog awkprog awk
+check_prog echoprog echo
+check_prog ftpprog ftp
+check_prog idprog id
+check_prog moreprog more
+check_prog pkg_addprog pkg_add
+check_prog rmprog rm
+check_prog sedprog sed
+check_prog suprog su
+check_prog unameprog uname
+
+# print version and exit
+version() {
+ $pkg_addprog -V
+ exit 0
+}
+
+# temporary files
+tmpcategories=/tmp/categories.$$
+tmppackages=/tmp/packages.$$
+
+# some base parameters
+base=ftp://ftp.netbsd.org/pub/NetBSD/packages
+release=`${unameprog} -r | ${sedprog} -e 's/_STABLE//'`
+machine=`${unameprog} -m`
+
+sleepsecs=1
+
+doit=""
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -V) version ;;
+ -b) base=$2; shift ;;
+ -h) ${echoprog} "$0 [-b BaseURL] [-h] [-m machine] [-n] [-r release] [-v] [-w secs]"; exit 0;;
+ -m) machine=$2; shift ;;
+ -n) doit=":" ;;
+ -r) release=$2; shift ;;
+ -v) set -x ;;
+ -w) sleepsecs=$2; shift ;;
+ *) break ;;
+ esac
+ shift
+done
+
+category=""
+
+while true; do
+ # if we don't have a packages file, then we need to choose a category
+ case "$category" in
+ "") # get possible categories
+ if [ ! -f $tmpcategories ]; then
+ ${echoprog} "Downloading package categories from ${base}..."
+ ${echoprog} "** QUIT" > $tmpcategories
+ ${echoprog} ls | ${ftpprog} ${base}/${release}/${machine}/ 2>/dev/null | \
+ ${awkprog} 'NF == 9 { if ($9 != "All") print $9 }' >> $tmpcategories
+ fi
+
+ # check for bad release numbering
+ # - it usually shows with 0 categories being displayed
+ ${awkprog} 'END { if (NR == 1) { print "\n\n\n*** No categories found - is the OS release set properly? ***\n\n\n" } }' < $tmpcategories
+
+ # display possible categories
+ ${awkprog} '{ print NR ". " $0 }' < $tmpcategories | ${moreprog}
+
+ # read a category number from the user
+ ${echoprog} -n "Please type the category number: "
+ read choice
+
+ # validate user's choice
+ case "$choice" in
+ 0|1) ${rmprog} -f $tmpcategories $tmppackages; exit 0 ;;
+ [2-9]|[0-9]*) category=`${awkprog} 'NR == '$choice' { print }' < $tmpcategories` ;;
+ *) category="" ;;
+ esac
+ case "$category" in
+ "") ${echoprog} "No such category \"$choice\""
+ sleep $sleepsecs
+ continue
+ ;;
+ esac
+
+ # get possible packages
+ ${echoprog} ""
+ ${echoprog} "Downloading package names from ${base}/${category}..."
+ ${echoprog} "** QUIT" > $tmppackages
+ ${echoprog} "** Change category" >> $tmppackages
+ ${echoprog} ls | ${ftpprog} ${base}/${release}/${machine}/${category}/ 2>/dev/null \
+ | ${awkprog} 'NF == 11 { print $9 }' >> $tmppackages
+ ;;
+ esac
Home |
Main Index |
Thread Index |
Old Index