diff options
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkg_install/files/add/perform.c | 38 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/bpm/bpm.1 | 117 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/bpm/bpm.cat1 | 61 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/bpm/bpm.sh | 222 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/delete/main.c | 7 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/file.c | 6 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/lib.h | 6 | ||||
-rw-r--r-- | pkgtools/pkg_install/files/lib/version.h | 4 |
8 files changed, 428 insertions, 33 deletions
diff --git a/pkgtools/pkg_install/files/add/perform.c b/pkgtools/pkg_install/files/add/perform.c index 3bd555b9d56..6c42e60a474 100644 --- a/pkgtools/pkg_install/files/add/perform.c +++ b/pkgtools/pkg_install/files/add/perform.c @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.14 2004/01/04 01:49:38 hubertf Exp $ */ +/* $NetBSD: perform.c,v 1.15 2004/01/14 23:55:29 jlam Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -11,7 +11,7 @@ #if 0 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp"; #else -__RCSID("$NetBSD: perform.c,v 1.14 2004/01/04 01:49:38 hubertf Exp $"); +__RCSID("$NetBSD: perform.c,v 1.15 2004/01/14 23:55:29 jlam Exp $"); #endif #endif @@ -288,23 +288,23 @@ pkg_do(const char *pkg) goto bomb; } - if (uname(&host_uname) == 0) { + if (uname(&host_uname) < 0) { + warnx("uname() failed."); + if (!Force) { + warnx("aborting."); + goto bomb; + } + } else { int osbad = 0; - /* handle Darwin's uname(3) on powerpc writing - * "Power Macintosh" in struct uname.machine. - */ - if (strcmp(host_uname.machine, "Power Macintosh") == 0) - strcpy(host_uname.machine, "powerpc"); /* it fits */ - /* If either the OS or arch are different, bomb */ - if (strcmp(host_uname.sysname, buildinfo[BI_OPSYS]) != 0 || - strcmp(host_uname.machine, buildinfo[BI_MACHINE_ARCH]) != 0) + if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) != 0 || + strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) != 0) osbad = 2; /* If OS and arch are the same, warn if version differs */ - if (strcmp(host_uname.sysname, buildinfo[BI_OPSYS]) == 0 && - strcmp(host_uname.machine, buildinfo[BI_MACHINE_ARCH]) == 0) { + if (strcmp(OPSYS_NAME, buildinfo[BI_OPSYS]) == 0 && + strcmp(MACHINE_ARCH, buildinfo[BI_MACHINE_ARCH]) == 0) { if (strcmp(host_uname.release, buildinfo[BI_OS_VERSION]) != 0) osbad = 1; } else @@ -316,20 +316,14 @@ pkg_do(const char *pkg) buildinfo[BI_OPSYS], buildinfo[BI_MACHINE_ARCH], buildinfo[BI_OS_VERSION], - host_uname.sysname, - host_uname.machine, + OPSYS_NAME, + MACHINE_ARCH, host_uname.release); } if (!Force && (osbad >= 2)) { warnx("aborting."); goto bomb; } - } else { - warnx("uname() failed."); - if (!Force) { - warnx("aborting."); - goto bomb; - } } /* @@ -516,7 +510,7 @@ ignore_replace_depends_check: installed); } fexec(BINDIR "/pkg_delete", "-K", dbdir, installed, NULL); - } else { + } else if (!is_depoted_pkg) { warnx("other version '%s' already installed", installed); errc = 1; diff --git a/pkgtools/pkg_install/files/bpm/bpm.1 b/pkgtools/pkg_install/files/bpm/bpm.1 new file mode 100644 index 00000000000..a9e63c15b95 --- /dev/null +++ b/pkgtools/pkg_install/files/bpm/bpm.1 @@ -0,0 +1,117 @@ +.\" $NetBSD: bpm.1,v 1.1 2004/01/14 23:55:29 jlam 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 hnVv +.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 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 +Print version number and exit. +.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 +The environment variables which govern the behaviour of +.Xr ftp 1 +and +.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 . diff --git a/pkgtools/pkg_install/files/bpm/bpm.cat1 b/pkgtools/pkg_install/files/bpm/bpm.cat1 new file mode 100644 index 00000000000..9e451370333 --- /dev/null +++ b/pkgtools/pkg_install/files/bpm/bpm.cat1 @@ -0,0 +1,61 @@ +BPM(1) NetBSD Reference Manual BPM(1) + +NNAAMMEE + bbppmm - menu-based binary package manager + +SSYYNNOOPPSSIISS + bbppmm [--hhnnVVvv] [--bb _b_a_s_e_U_R_L] [--mm _m_a_c_h_i_n_e] [--rr _r_e_l_e_a_s_e] [--ww _s_e_c_o_n_d_s] + +DDEESSCCRRIIPPTTIIOONN + The bbppmm command is used to locate and install binary packages from any + reachable URL. + + The following command-line options are supported: + + --bb _b_a_s_e_U_R_L + Specify a base URL from which to download binary packages. The + default URL is _f_t_p_:_/_/_f_t_p_._n_e_t_b_s_d_._o_r_g_/_p_u_b_/_N_e_t_B_S_D_/_p_a_c_k_a_g_e_s. + + --hh Print a help message and then exit. + + --mm _m_a_c_h_i_n_e + Use _m_a_c_h_i_n_e as the machine architecture to be used, instead of + that returned by uname(1). + + --nn Don't actually execute the commands to add the package. + + --rr _r_e_l_e_a_s_e + Use _r_e_l_e_a_s_e as the operating system release to be used, instead + of that returned by uname(1). + + --VV Print version number and exit. + + --vv Turn on verbose output. + + --ww _s_e_c_o_n_d_s + The number of _s_e_c_o_n_d_s to wait after displaying an error message + and returning to normal menu operations. + + bbppmm provides a menu-based binary package manager for NetBSD. bbppmm first + connects to the URL using 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 as- + signed to it, the package will be downloaded automatically, and in- + stalled, using the 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. + +EENNVVIIRROONNMMEENNTT + The environment variables which govern the behaviour of ftp(1) and + pkg_add(1) are valid for bbppmm. + +SSEEEE AALLSSOO + ftp(1), pkg_add(1), uname(1) + +AAUUTTHHOORRSS + The bbppmm utility was written by Alistair Crooks <agc@NetBSD.org>. + +NetBSD 1.6.1 December 21, 2003 1 diff --git a/pkgtools/pkg_install/files/bpm/bpm.sh b/pkgtools/pkg_install/files/bpm/bpm.sh new file mode 100644 index 00000000000..f12f8fcd0a6 --- /dev/null +++ b/pkgtools/pkg_install/files/bpm/bpm.sh @@ -0,0 +1,222 @@ +#! /bin/sh +# +# $NetBSD: bpm.sh,v 1.1 2004/01/14 23:55:29 jlam 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 + + # display possible packages + ${awkprog} '{ print NR ". " $0 }' < $tmppackages | ${moreprog} + + # read a package number from the user + ${echoprog} -n "Please type the package number: " + read choice + + # validate user's choice + case "$choice" in + 1) ${rmprog} -f $tmppackages $tmpcategories; exit 0 ;; + 2) category=""; continue ;; # no package to install - choose new category + [3-9]|[0-9]*) package=`${awkprog} 'NR == '$choice' { print }' < $tmppackages` ;; + *) package="" ;; + esac + case "$package" in + "") ${echoprog} "No such package \"$choice\"" + sleep $sleepsecs + continue + ;; + esac + + # check it's not already installed + pkgbase=`${echoprog} ${package} | ${sedprog} -e 's|-[0-9].*||'` + installed=`pkg_info -e $pkgbase` + case "$installed" in + "") ;; + *) ${echoprog} "$package selected, but $installed already installed" + sleep $sleepsecs + continue + ;; + esac + + # Tell people what we're doing + ${echoprog} "" + ${echoprog} "Adding package ${base}/${release}/${machine}/${category}/${package}" + + cmd="env PKG_PATH=${base}/${release}/${machine}/All ${pkg_addprog} ${package}" + + # check if we need to become root for this + if [ `${idprog} -u` != 0 ]; then + ${echoprog} "Becoming root@`/bin/hostname` to add a binary package" + ${echoprog} -n "`${echoprog} ${suprog} | $awkprog '{ print $1 }'` " + $doit ${suprog} root -c "$cmd" + success=$? + else + $doit $cmd + success=$? + fi + + # give feedback after adding the package + case $success in + 0) ${echoprog} "$package successfully installed" ;; + *) ${echoprog} "Problems when installing $package - please try again" ;; + esac + + ${echoprog} "" + ${echoprog} -n "[Q]uit, [C]hange category, [I]nstall another package: " + read choice + + case "$choice" in + [Qq]) break ;; + [Cc]) category="" ;; + [Ii]) ;; + esac +done + +${rmprog} -f $tmpcategories $tmppackages + +exit 0 diff --git a/pkgtools/pkg_install/files/delete/main.c b/pkgtools/pkg_install/files/delete/main.c index e5d48078244..e9b2af39bcf 100644 --- a/pkgtools/pkg_install/files/delete/main.c +++ b/pkgtools/pkg_install/files/delete/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.9 2003/09/23 07:13:50 grant Exp $ */ +/* $NetBSD: main.c,v 1.10 2004/01/14 23:55:29 jlam Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -11,7 +11,7 @@ #if 0 static char *rcsid = "from FreeBSD Id: main.c,v 1.11 1997/10/08 07:46:48 charnier Exp"; #else -__RCSID("$NetBSD: main.c,v 1.9 2003/09/23 07:13:50 grant Exp $"); +__RCSID("$NetBSD: main.c,v 1.10 2004/01/14 23:55:29 jlam Exp $"); #endif #endif @@ -39,9 +39,6 @@ __RCSID("$NetBSD: main.c,v 1.9 2003/09/23 07:13:50 grant Exp $"); #if HAVE_ERR_H #include <err.h> #endif -#if HAVE_ERRNO_H -#include <errno.h> -#endif #include "lib.h" #include "delete.h" diff --git a/pkgtools/pkg_install/files/lib/file.c b/pkgtools/pkg_install/files/lib/file.c index 74c46c44b0d..c3e65b17aee 100644 --- a/pkgtools/pkg_install/files/lib/file.c +++ b/pkgtools/pkg_install/files/lib/file.c @@ -1,4 +1,4 @@ -/* $NetBSD: file.c,v 1.11 2003/12/20 04:23:05 grant Exp $ */ +/* $NetBSD: file.c,v 1.12 2004/01/14 23:55:29 jlam Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -11,7 +11,7 @@ #if 0 static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp"; #else -__RCSID("$NetBSD: file.c,v 1.11 2003/12/20 04:23:05 grant Exp $"); +__RCSID("$NetBSD: file.c,v 1.12 2004/01/14 23:55:29 jlam Exp $"); #endif #endif @@ -584,7 +584,7 @@ unpack(const char *pkg, const char *flist) { char args[10] = "-"; char cmd[FILENAME_MAX]; - const char *decompress_cmd; + const char *decompress_cmd = NULL; const char *suf; if (!IS_STDIN(pkg)) { diff --git a/pkgtools/pkg_install/files/lib/lib.h b/pkgtools/pkg_install/files/lib/lib.h index f6bab96781f..34bd366288a 100644 --- a/pkgtools/pkg_install/files/lib/lib.h +++ b/pkgtools/pkg_install/files/lib/lib.h @@ -1,4 +1,4 @@ -/* $NetBSD: lib.h,v 1.7 2003/12/20 04:23:05 grant Exp $ */ +/* $NetBSD: lib.h,v 1.8 2004/01/14 23:55:29 jlam Exp $ */ /* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */ @@ -78,6 +78,10 @@ #define FALSE (0) #endif +#ifndef OPSYS_NAME +#define OPSYS_NAME "NetBSD" +#endif + /* Usually "rm", but often "echo" during debugging! */ #define REMOVE_CMD "rm" diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index 95604f88209..56253168af5 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.21 2004/01/06 15:53:41 hubertf Exp $ */ +/* $NetBSD: version.h,v 1.22 2004/01/14 23:55:29 jlam Exp $ */ /* * Copyright (c) 2001 Thomas Klausner. All rights reserved. @@ -33,6 +33,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION "20040106" +#define PKGTOOLS_VERSION "20040114" #endif /* _INST_LIB_VERSION_H_ */ |