Merge changes from src/external/bsd/pkg_install.diff -r1.6 -r1.7 pkgsrc/pkgtools/pkg_install/files/bpm/bpm.1
(wiz)
@@ -1,117 +1,114 @@ | @@ -1,117 +1,114 @@ | |||
1 | .\" $NetBSD: bpm.1,v 1.6 2009/02/08 23:12:10 wiz Exp $ */ | 1 | .\" $NetBSD: bpm.1,v 1.7 2012/02/21 18:32:14 wiz Exp $ */ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2003,2009 The NetBSD Foundation, Inc. | |||
4 | .\" All rights reserved. | |||
3 | .\" | 5 | .\" | |
4 | .\" Copyright (c) 2003 Alistair G. Crooks. All rights reserved. | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Alistair Crooks (agc@NetBSD.org) | |||
5 | .\" | 8 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | 11 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | 15 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | 16 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. All advertising materials mentioning features or use of this software | |||
15 | .\" must display the following acknowledgement: | |||
16 | .\" This product includes software developed by Alistair G. Crooks. | |||
17 | .\" 4. The name of the author may not be used to endorse or promote | |||
18 | .\" products derived from this software without specific prior written | |||
19 | .\" permission. | |||
20 | .\" | 17 | .\" | |
21 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
22 | .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
23 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | 21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
25 | .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | .\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | .\" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | .\" POSSIBILITY OF SUCH DAMAGE. | |
32 | .\" | 29 | .\" | |
33 | .Dd August 3, 2007 | 30 | .Dd August 3, 2007 | |
34 | .Dt BPM 1 | 31 | .Dt BPM 1 | |
35 | .Os | 32 | .Os | |
36 | .Sh NAME | 33 | .Sh NAME | |
37 | .Nm bpm | 34 | .Nm bpm | |
38 | .Nd menu-based binary package manager | 35 | .Nd menu-based binary package manager | |
39 | .Sh SYNOPSIS | 36 | .Sh SYNOPSIS | |
40 | .Nm | 37 | .Nm | |
41 | .Op Fl hnVv | 38 | .Op Fl hnVv | |
42 | .Op Fl b Ar baseURL | 39 | .Op Fl b Ar baseURL | |
43 | .Op Fl m Ar machine | 40 | .Op Fl m Ar machine | |
44 | .Op Fl r Ar release | 41 | .Op Fl r Ar release | |
45 | .Op Fl w Ar seconds | 42 | .Op Fl w Ar seconds | |
46 | .Sh DESCRIPTION | 43 | .Sh DESCRIPTION | |
47 | The | 44 | The | |
48 | .Nm | 45 | .Nm | |
49 | command is used to locate and install binary packages from any | 46 | command is used to locate and install binary packages from any | |
50 | reachable URL. | 47 | reachable URL. | |
51 | .Pp | 48 | .Pp | |
52 | The following command-line options are supported: | 49 | The following command-line options are supported: | |
53 | .Bl -tag -width indent | 50 | .Bl -tag -width indent | |
54 | .It Fl b Ar baseURL | 51 | .It Fl b Ar baseURL | |
55 | Specify a base URL from which to download binary packages. | 52 | Specify a base URL from which to download binary packages. | |
56 | The default URL is | 53 | The default URL is | |
57 | .Pa ftp://ftp.NetBSD.org/pub/pkgsrc/packages . | 54 | .Pa ftp://ftp.NetBSD.org/pub/pkgsrc/packages . | |
58 | .It Fl h | 55 | .It Fl h | |
59 | Print a help message and then exit. | 56 | Print a help message and then exit. | |
60 | .It Fl m Ar machine | 57 | .It Fl m Ar machine | |
61 | Use | 58 | Use | |
62 | .Ar machine | 59 | .Ar machine | |
63 | as the machine architecture to be used, instead of that returned by | 60 | as the machine architecture to be used, instead of that returned by | |
64 | .Xr uname 1 . | 61 | .Xr uname 1 . | |
65 | .It Fl n | 62 | .It Fl n | |
66 | Don't actually execute the commands to add the package. | 63 | Don't actually execute the commands to add the package. | |
67 | .It Fl r Ar release | 64 | .It Fl r Ar release | |
68 | Use | 65 | Use | |
69 | .Ar release | 66 | .Ar release | |
70 | as the operating system release to be used, instead of that returned by | 67 | as the operating system release to be used, instead of that returned by | |
71 | .Xr uname 1 . | 68 | .Xr uname 1 . | |
72 | .It Fl V | 69 | .It Fl V | |
73 | Print version number and exit. | 70 | Print version number and exit. | |
74 | .It Fl v | 71 | .It Fl v | |
75 | Turn on verbose output. | 72 | Turn on verbose output. | |
76 | .It Fl w Ar seconds | 73 | .It Fl w Ar seconds | |
77 | The number of | 74 | The number of | |
78 | .Ar seconds | 75 | .Ar seconds | |
79 | to wait after displaying an error message and returning to | 76 | to wait after displaying an error message and returning to | |
80 | normal menu operations. | 77 | normal menu operations. | |
81 | .El | 78 | .El | |
82 | .Pp | 79 | .Pp | |
83 | .Nm | 80 | .Nm | |
84 | provides a menu-based binary package manager for | 81 | provides a menu-based binary package manager for | |
85 | .Nx . | 82 | .Nx . | |
86 | .Nm | 83 | .Nm | |
87 | first connects to the URL using | 84 | first connects to the URL using | |
88 | .Xr ftp 1 , | 85 | .Xr ftp 1 , | |
89 | and displays a list of categories for which binary packages exist. | 86 | and displays a list of categories for which binary packages exist. | |
90 | If no categories are displayed, it could | 87 | If no categories are displayed, it could | |
91 | be that the machine architecture or operating system release string | 88 | be that the machine architecture or operating system release string | |
92 | have been wrongly interpreted, and that it will be necessary to override | 89 | have been wrongly interpreted, and that it will be necessary to override | |
93 | this values by means of the command line options. | 90 | this values by means of the command line options. | |
94 | Within a category, a list of packages will be displayed, and by selecting | 91 | Within a category, a list of packages will be displayed, and by selecting | |
95 | one using the number assigned to it, the package will be downloaded | 92 | one using the number assigned to it, the package will be downloaded | |
96 | automatically, and installed, using the | 93 | automatically, and installed, using the | |
97 | .Xr pkg_add 1 | 94 | .Xr pkg_add 1 | |
98 | utility. | 95 | utility. | |
99 | It is also possible to change the category currently being examined, | 96 | It is also possible to change the category currently being examined, | |
100 | and to quit from the utility, simply by selecting the appropriate choices | 97 | and to quit from the utility, simply by selecting the appropriate choices | |
101 | on the menu. | 98 | on the menu. | |
102 | .Sh ENVIRONMENT | 99 | .Sh ENVIRONMENT | |
103 | The environment variables which govern the behavior of | 100 | The environment variables which govern the behavior of | |
104 | .Xr ftp 1 | 101 | .Xr ftp 1 | |
105 | and | 102 | and | |
106 | .Xr pkg_add 1 | 103 | .Xr pkg_add 1 | |
107 | are valid for | 104 | are valid for | |
108 | .Nm . | 105 | .Nm . | |
109 | .Sh SEE ALSO | 106 | .Sh SEE ALSO | |
110 | .Xr ftp 1 , | 107 | .Xr ftp 1 , | |
111 | .Xr pkg_add 1 , | 108 | .Xr pkg_add 1 , | |
112 | .Xr uname 1 | 109 | .Xr uname 1 | |
113 | .Sh AUTHORS | 110 | .Sh AUTHORS | |
114 | The | 111 | The | |
115 | .Nm | 112 | .Nm | |
116 | utility was written by | 113 | utility was written by | |
117 | .An Alistair Crooks Aq agc@NetBSD.org . | 114 | .An Alistair Crooks Aq agc@NetBSD.org . |
@@ -1,222 +1,220 @@ | @@ -1,222 +1,220 @@ | |||
1 | #! /bin/sh | 1 | #! /bin/sh | |
2 | # | 2 | # | |
3 | # $NetBSD: bpm.sh.in,v 1.4 2007/08/02 23:30:20 wiz Exp $ | 3 | # $NetBSD: bpm.sh.in,v 1.5 2012/02/21 18:32:14 wiz Exp $ | |
4 | # | 4 | # | |
5 | # Copyright (c) 2003 Alistair G. Crooks. All rights reserved. | 5 | # Copyright (c) 2003,2009 The NetBSD Foundation, Inc. | |
6 | # All rights reserved. | |||
7 | # | |||
8 | # This code is derived from software contributed to The NetBSD Foundation | |||
9 | # by Alistair Crooks (agc@NetBSD.org) | |||
6 | # | 10 | # | |
7 | # Redistribution and use in source and binary forms, with or without | 11 | # Redistribution and use in source and binary forms, with or without | |
8 | # modification, are permitted provided that the following conditions | 12 | # modification, are permitted provided that the following conditions | |
9 | # are met: | 13 | # are met: | |
10 | # 1. Redistributions of source code must retain the above copyright | 14 | # 1. Redistributions of source code must retain the above copyright | |
11 | # notice, this list of conditions and the following disclaimer. | 15 | # notice, this list of conditions and the following disclaimer. | |
12 | # 2. Redistributions in binary form must reproduce the above copyright | 16 | # 2. Redistributions in binary form must reproduce the above copyright | |
13 | # notice, this list of conditions and the following disclaimer in the | 17 | # notice, this list of conditions and the following disclaimer in the | |
14 | # documentation and/or other materials provided with the distribution. | 18 | # documentation and/or other materials provided with the distribution. | |
15 | # 3. All advertising materials mentioning features or use of this software | 19 | # | |
16 | # must display the following acknowledgement: | 20 | # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
17 | # This product includes software developed by Alistair G. Crooks. | 21 | # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
18 | # 4. The name of the author may not be used to endorse or promote | 22 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
19 | # products derived from this software without specific prior written | 23 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
20 | # permission. | 24 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | # | 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 30 | # POSSIBILITY OF SUCH DAMAGE. | |
27 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | |||
28 | # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |||
29 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |||
30 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |||
31 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |||
32 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
33 | # | 31 | # | |
34 | 32 | |||
35 | die() | 33 | die() | |
36 | { | 34 | { | |
37 | echo >&2 "$@" | 35 | echo >&2 "$@" | |
38 | exit 1 | 36 | exit 1 | |
39 | } | 37 | } | |
40 | 38 | |||
41 | check_prog() | 39 | check_prog() | |
42 | { | 40 | { | |
43 | _var="$1"; _name="$2" | 41 | _var="$1"; _name="$2" | |
44 | 42 | |||
45 | eval _tmp=\"\$$_var\" | 43 | eval _tmp=\"\$$_var\" | |
46 | if [ "x$_tmp" != "x" ]; then | 44 | if [ "x$_tmp" != "x" ]; then | |
47 | # Variable is already set (by the user, for example) | 45 | # Variable is already set (by the user, for example) | |
48 | return 0 | 46 | return 0 | |
49 | fi | 47 | fi | |
50 | 48 | |||
51 | for _d in `echo $PATH | tr ':' ' '`; do | 49 | for _d in `echo $PATH | tr ':' ' '`; do | |
52 | if [ -x "$_d/$_name" ]; then | 50 | if [ -x "$_d/$_name" ]; then | |
53 | # Program found | 51 | # Program found | |
54 | eval $_var=\""$_d/$_name"\" | 52 | eval $_var=\""$_d/$_name"\" | |
55 | return 1 | 53 | return 1 | |
56 | fi | 54 | fi | |
57 | done | 55 | done | |
58 | 56 | |||
59 | die "$_name not found in path." | 57 | die "$_name not found in path." | |
60 | } | 58 | } | |
61 | 59 | |||
62 | check_prog awkprog awk | 60 | check_prog awkprog awk | |
63 | check_prog echoprog echo | 61 | check_prog echoprog echo | |
64 | check_prog ftpprog ftp | 62 | check_prog ftpprog ftp | |
65 | check_prog idprog id | 63 | check_prog idprog id | |
66 | check_prog moreprog more | 64 | check_prog moreprog more | |
67 | check_prog pkg_addprog pkg_add | 65 | check_prog pkg_addprog pkg_add | |
68 | check_prog rmprog rm | 66 | check_prog rmprog rm | |
69 | check_prog sedprog sed | 67 | check_prog sedprog sed | |
70 | check_prog suprog su | 68 | check_prog suprog su | |
71 | check_prog unameprog uname | 69 | check_prog unameprog uname | |
72 | 70 | |||
73 | # print version and exit | 71 | # print version and exit | |
74 | version() { | 72 | version() { | |
75 | $pkg_addprog -V | 73 | $pkg_addprog -V | |
76 | exit 0 | 74 | exit 0 | |
77 | } | 75 | } | |
78 | 76 | |||
79 | # temporary files | 77 | # temporary files | |
80 | tmpcategories=/tmp/categories.$$ | 78 | tmpcategories=/tmp/categories.$$ | |
81 | tmppackages=/tmp/packages.$$ | 79 | tmppackages=/tmp/packages.$$ | |
82 | 80 | |||
83 | # some base parameters | 81 | # some base parameters | |
84 | base=ftp://ftp.NetBSD.org/pub/pkgsrc/packages | 82 | base=ftp://ftp.NetBSD.org/pub/pkgsrc/packages | |
85 | release=`${unameprog} -r | ${sedprog} -e 's/_STABLE//'` | 83 | release=`${unameprog} -r | ${sedprog} -e 's/_STABLE//'` | |
86 | machine=`${unameprog} -m` | 84 | machine=`${unameprog} -m` | |
87 | 85 | |||
88 | sleepsecs=1 | 86 | sleepsecs=1 | |
89 | 87 | |||
90 | doit="" | 88 | doit="" | |
91 | 89 | |||
92 | while [ $# -gt 0 ]; do | 90 | while [ $# -gt 0 ]; do | |
93 | case $1 in | 91 | case $1 in | |
94 | -V) version ;; | 92 | -V) version ;; | |
95 | -b) base=$2; shift ;; | 93 | -b) base=$2; shift ;; | |
96 | -h) ${echoprog} "$0 [-b BaseURL] [-h] [-m machine] [-n] [-r release] [-v] [-w secs]"; exit 0;; | 94 | -h) ${echoprog} "$0 [-b BaseURL] [-h] [-m machine] [-n] [-r release] [-v] [-w secs]"; exit 0;; | |
97 | -m) machine=$2; shift ;; | 95 | -m) machine=$2; shift ;; | |
98 | -n) doit=":" ;; | 96 | -n) doit=":" ;; | |
99 | -r) release=$2; shift ;; | 97 | -r) release=$2; shift ;; | |
100 | -v) set -x ;; | 98 | -v) set -x ;; | |
101 | -w) sleepsecs=$2; shift ;; | 99 | -w) sleepsecs=$2; shift ;; | |
102 | *) break ;; | 100 | *) break ;; | |
103 | esac | 101 | esac | |
104 | shift | 102 | shift | |
105 | done | 103 | done | |
106 | 104 | |||
107 | category="" | 105 | category="" | |
108 | 106 | |||
109 | while true; do | 107 | while true; do | |
110 | # if we don't have a packages file, then we need to choose a category | 108 | # if we don't have a packages file, then we need to choose a category | |
111 | case "$category" in | 109 | case "$category" in | |
112 | "") # get possible categories | 110 | "") # get possible categories | |
113 | if [ ! -f $tmpcategories ]; then | 111 | if [ ! -f $tmpcategories ]; then | |
114 | ${echoprog} "Downloading package categories from ${base}..." | 112 | ${echoprog} "Downloading package categories from ${base}..." | |
115 | ${echoprog} "** QUIT" > $tmpcategories | 113 | ${echoprog} "** QUIT" > $tmpcategories | |
116 | ${echoprog} ls | ${ftpprog} ${base}/${release}/${machine}/ 2>/dev/null | \ | 114 | ${echoprog} ls | ${ftpprog} ${base}/${release}/${machine}/ 2>/dev/null | \ | |
117 | ${awkprog} 'NF == 9 { if ($9 != "All") print $9 }' >> $tmpcategories | 115 | ${awkprog} 'NF == 9 { if ($9 != "All") print $9 }' >> $tmpcategories | |
118 | fi | 116 | fi | |
119 | 117 | |||
120 | # check for bad release numbering | 118 | # check for bad release numbering | |
121 | # - it usually shows with 0 categories being displayed | 119 | # - it usually shows with 0 categories being displayed | |
122 | ${awkprog} 'END { if (NR == 1) { print "\n\n\n*** No categories found - is the OS release set properly? ***\n\n\n" } }' < $tmpcategories | 120 | ${awkprog} 'END { if (NR == 1) { print "\n\n\n*** No categories found - is the OS release set properly? ***\n\n\n" } }' < $tmpcategories | |
123 | 121 | |||
124 | # display possible categories | 122 | # display possible categories | |
125 | ${awkprog} '{ print NR ". " $0 }' < $tmpcategories | ${moreprog} | 123 | ${awkprog} '{ print NR ". " $0 }' < $tmpcategories | ${moreprog} | |
126 | 124 | |||
127 | # read a category number from the user | 125 | # read a category number from the user | |
128 | ${echoprog} -n "Please type the category number: " | 126 | ${echoprog} -n "Please type the category number: " | |
129 | read choice | 127 | read choice | |
130 | 128 | |||
131 | # validate user's choice | 129 | # validate user's choice | |
132 | case "$choice" in | 130 | case "$choice" in | |
133 | 0|1) ${rmprog} -f $tmpcategories $tmppackages; exit 0 ;; | 131 | 0|1) ${rmprog} -f $tmpcategories $tmppackages; exit 0 ;; | |
134 | [2-9]|[0-9]*) category=`${awkprog} 'NR == '$choice' { print }' < $tmpcategories` ;; | 132 | [2-9]|[0-9]*) category=`${awkprog} 'NR == '$choice' { print }' < $tmpcategories` ;; | |
135 | *) category="" ;; | 133 | *) category="" ;; | |
136 | esac | 134 | esac | |
137 | case "$category" in | 135 | case "$category" in | |
138 | "") ${echoprog} "No such category \"$choice\"" | 136 | "") ${echoprog} "No such category \"$choice\"" | |
139 | sleep $sleepsecs | 137 | sleep $sleepsecs | |
140 | continue | 138 | continue | |
141 | ;; | 139 | ;; | |
142 | esac | 140 | esac | |
143 | 141 | |||
144 | # get possible packages | 142 | # get possible packages | |
145 | ${echoprog} "" | 143 | ${echoprog} "" | |
146 | ${echoprog} "Downloading package names from ${base}/${category}..." | 144 | ${echoprog} "Downloading package names from ${base}/${category}..." | |
147 | ${echoprog} "** QUIT" > $tmppackages | 145 | ${echoprog} "** QUIT" > $tmppackages | |
148 | ${echoprog} "** Change category" >> $tmppackages | 146 | ${echoprog} "** Change category" >> $tmppackages | |
149 | ${echoprog} ls | ${ftpprog} ${base}/${release}/${machine}/${category}/ 2>/dev/null \ | 147 | ${echoprog} ls | ${ftpprog} ${base}/${release}/${machine}/${category}/ 2>/dev/null \ | |
150 | | ${awkprog} 'NF == 11 { print $9 }' >> $tmppackages | 148 | | ${awkprog} 'NF == 11 { print $9 }' >> $tmppackages | |
151 | ;; | 149 | ;; | |
152 | esac | 150 | esac | |
153 | 151 | |||
154 | # display possible packages | 152 | # display possible packages | |
155 | ${awkprog} '{ print NR ". " $0 }' < $tmppackages | ${moreprog} | 153 | ${awkprog} '{ print NR ". " $0 }' < $tmppackages | ${moreprog} | |
156 | 154 | |||
157 | # read a package number from the user | 155 | # read a package number from the user | |
158 | ${echoprog} -n "Please type the package number: " | 156 | ${echoprog} -n "Please type the package number: " | |
159 | read choice | 157 | read choice | |
160 | 158 | |||
161 | # validate user's choice | 159 | # validate user's choice | |
162 | case "$choice" in | 160 | case "$choice" in | |
163 | 1) ${rmprog} -f $tmppackages $tmpcategories; exit 0 ;; | 161 | 1) ${rmprog} -f $tmppackages $tmpcategories; exit 0 ;; | |
164 | 2) category=""; continue ;; # no package to install - choose new category | 162 | 2) category=""; continue ;; # no package to install - choose new category | |
165 | [3-9]|[0-9]*) package=`${awkprog} 'NR == '$choice' { print }' < $tmppackages` ;; | 163 | [3-9]|[0-9]*) package=`${awkprog} 'NR == '$choice' { print }' < $tmppackages` ;; | |
166 | *) package="" ;; | 164 | *) package="" ;; | |
167 | esac | 165 | esac | |
168 | case "$package" in | 166 | case "$package" in | |
169 | "") ${echoprog} "No such package \"$choice\"" | 167 | "") ${echoprog} "No such package \"$choice\"" | |
170 | sleep $sleepsecs | 168 | sleep $sleepsecs | |
171 | continue | 169 | continue | |
172 | ;; | 170 | ;; | |
173 | esac | 171 | esac | |
174 | 172 | |||
175 | # check it's not already installed | 173 | # check it's not already installed | |
176 | pkgbase=`${echoprog} ${package} | ${sedprog} -e 's|-[0-9].*||'` | 174 | pkgbase=`${echoprog} ${package} | ${sedprog} -e 's|-[0-9].*||'` | |
177 | installed=`pkg_info -e $pkgbase` | 175 | installed=`pkg_info -e $pkgbase` | |
178 | case "$installed" in | 176 | case "$installed" in | |
179 | "") ;; | 177 | "") ;; | |
180 | *) ${echoprog} "$package selected, but $installed already installed" | 178 | *) ${echoprog} "$package selected, but $installed already installed" | |
181 | sleep $sleepsecs | 179 | sleep $sleepsecs | |
182 | continue | 180 | continue | |
183 | ;; | 181 | ;; | |
184 | esac | 182 | esac | |
185 | 183 | |||
186 | # Tell people what we're doing | 184 | # Tell people what we're doing | |
187 | ${echoprog} "" | 185 | ${echoprog} "" | |
188 | ${echoprog} "Adding package ${base}/${release}/${machine}/${category}/${package}" | 186 | ${echoprog} "Adding package ${base}/${release}/${machine}/${category}/${package}" | |
189 | 187 | |||
190 | cmd="env PKG_PATH=${base}/${release}/${machine}/All ${pkg_addprog} ${package}" | 188 | cmd="env PKG_PATH=${base}/${release}/${machine}/All ${pkg_addprog} ${package}" | |
191 | 189 | |||
192 | # check if we need to become root for this | 190 | # check if we need to become root for this | |
193 | if [ `${idprog} -u` != 0 ]; then | 191 | if [ `${idprog} -u` != 0 ]; then | |
194 | ${echoprog} "Becoming root@`/bin/hostname` to add a binary package" | 192 | ${echoprog} "Becoming root@`/bin/hostname` to add a binary package" | |
195 | ${echoprog} -n "`${echoprog} ${suprog} | $awkprog '{ print $1 }'` " | 193 | ${echoprog} -n "`${echoprog} ${suprog} | $awkprog '{ print $1 }'` " | |
196 | $doit ${suprog} root -c "$cmd" | 194 | $doit ${suprog} root -c "$cmd" | |
197 | success=$? | 195 | success=$? | |
198 | else | 196 | else | |
199 | $doit $cmd | 197 | $doit $cmd | |
200 | success=$? | 198 | success=$? | |
201 | fi | 199 | fi | |
202 | 200 | |||
203 | # give feedback after adding the package | 201 | # give feedback after adding the package | |
204 | case $success in | 202 | case $success in | |
205 | 0) ${echoprog} "$package successfully installed" ;; | 203 | 0) ${echoprog} "$package successfully installed" ;; | |
206 | *) ${echoprog} "Problems when installing $package - please try again" ;; | 204 | *) ${echoprog} "Problems when installing $package - please try again" ;; | |
207 | esac | 205 | esac | |
208 | 206 | |||
209 | ${echoprog} "" | 207 | ${echoprog} "" | |
210 | ${echoprog} -n "[Q]uit, [C]hange category, [I]nstall another package: " | 208 | ${echoprog} -n "[Q]uit, [C]hange category, [I]nstall another package: " | |
211 | read choice | 209 | read choice | |
212 | 210 | |||
213 | case "$choice" in | 211 | case "$choice" in | |
214 | [Qq]) break ;; | 212 | [Qq]) break ;; | |
215 | [Cc]) category="" ;; | 213 | [Cc]) category="" ;; | |
216 | [Ii]) ;; | 214 | [Ii]) ;; | |
217 | esac | 215 | esac | |
218 | done | 216 | done | |
219 | 217 | |||
220 | ${rmprog} -f $tmpcategories $tmppackages | 218 | ${rmprog} -f $tmpcategories $tmppackages | |
221 | 219 | |||
222 | exit 0 | 220 | exit 0 |
@@ -1,423 +1,430 @@ | @@ -1,423 +1,430 @@ | |||
1 | /* $NetBSD: show.c,v 1.32 2011/01/31 07:22:15 agc Exp $ */ | 1 | /* $NetBSD: show.c,v 1.33 2012/02/21 18:32:14 wiz Exp $ */ | |
2 | 2 | |||
3 | #if HAVE_CONFIG_H | 3 | #if HAVE_CONFIG_H | |
4 | #include "config.h" | 4 | #include "config.h" | |
5 | #endif | 5 | #endif | |
6 | #include <nbcompat.h> | 6 | #include <nbcompat.h> | |
7 | #if HAVE_SYS_CDEFS_H | 7 | #if HAVE_SYS_CDEFS_H | |
8 | #include <sys/cdefs.h> | 8 | #include <sys/cdefs.h> | |
9 | #endif | 9 | #endif | |
10 | __RCSID("$NetBSD: show.c,v 1.32 2011/01/31 07:22:15 agc Exp $"); | 10 | __RCSID("$NetBSD: show.c,v 1.33 2012/02/21 18:32:14 wiz Exp $"); | |
11 | 11 | |||
12 | /* | 12 | /* | |
13 | * FreeBSD install - a package for the installation and maintainance | 13 | * FreeBSD install - a package for the installation and maintainance | |
14 | * of non-core utilities. | 14 | * of non-core utilities. | |
15 | * | 15 | * | |
16 | * Redistribution and use in source and binary forms, with or without | 16 | * Redistribution and use in source and binary forms, with or without | |
17 | * modification, are permitted provided that the following conditions | 17 | * modification, are permitted provided that the following conditions | |
18 | * are met: | 18 | * are met: | |
19 | * 1. Redistributions of source code must retain the above copyright | 19 | * 1. Redistributions of source code must retain the above copyright | |
20 | * notice, this list of conditions and the following disclaimer. | 20 | * notice, this list of conditions and the following disclaimer. | |
21 | * 2. Redistributions in binary form must reproduce the above copyright | 21 | * 2. Redistributions in binary form must reproduce the above copyright | |
22 | * notice, this list of conditions and the following disclaimer in the | 22 | * notice, this list of conditions and the following disclaimer in the | |
23 | * documentation and/or other materials provided with the distribution. | 23 | * documentation and/or other materials provided with the distribution. | |
24 | * | 24 | * | |
25 | * Jordan K. Hubbard | 25 | * Jordan K. Hubbard | |
26 | * 23 Aug 1993 | 26 | * 23 Aug 1993 | |
27 | * | 27 | * | |
28 | * Various display routines for the info module. | 28 | * Various display routines for the info module. | |
29 | * | 29 | * | |
30 | */ | 30 | */ | |
31 | /*- | 31 | /*- | |
32 | * Copyright (c) 1999-2008 The NetBSD Foundation, Inc. | 32 | * Copyright (c) 1999-2008 The NetBSD Foundation, Inc. | |
33 | * All rights reserved. | 33 | * All rights reserved. | |
34 | * | 34 | * | |
35 | * This code is derived from software contributed to The NetBSD Foundation | 35 | * This code is derived from software contributed to The NetBSD Foundation | |
36 | * by Hubert Feyrer <hubert@feyrer.de>. | 36 | * by Hubert Feyrer <hubert@feyrer.de>. | |
37 | * | 37 | * | |
38 | * Redistribution and use in source and binary forms, with or without | 38 | * Redistribution and use in source and binary forms, with or without | |
39 | * modification, are permitted provided that the following conditions | 39 | * modification, are permitted provided that the following conditions | |
40 | * are met: | 40 | * are met: | |
41 | * 1. Redistributions of source code must retain the above copyright | 41 | * 1. Redistributions of source code must retain the above copyright | |
42 | * notice, this list of conditions and the following disclaimer. | 42 | * notice, this list of conditions and the following disclaimer. | |
43 | * 2. Redistributions in binary form must reproduce the above copyright | 43 | * 2. Redistributions in binary form must reproduce the above copyright | |
44 | * notice, this list of conditions and the following disclaimer in the | 44 | * notice, this list of conditions and the following disclaimer in the | |
45 | * documentation and/or other materials provided with the distribution. | 45 | * documentation and/or other materials provided with the distribution. | |
46 | * | 46 | * | |
47 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | 47 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
48 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 48 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
49 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 49 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
50 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 50 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
51 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 51 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
52 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 52 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
53 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 53 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
54 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 54 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
55 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 55 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
56 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 56 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
57 | * POSSIBILITY OF SUCH DAMAGE. | 57 | * POSSIBILITY OF SUCH DAMAGE. | |
58 | */ | 58 | */ | |
59 | 59 | |||
60 | #if HAVE_ERR_H | 60 | #if HAVE_ERR_H | |
61 | #include <err.h> | 61 | #include <err.h> | |
62 | #endif | 62 | #endif | |
63 | 63 | |||
64 | #include "defs.h" | 64 | #include "defs.h" | |
65 | #include "lib.h" | 65 | #include "lib.h" | |
66 | #include "info.h" | 66 | #include "info.h" | |
67 | 67 | |||
68 | /* Structure to define entries for the "show table" */ | 68 | /* Structure to define entries for the "show table" */ | |
69 | typedef struct show_t { | 69 | typedef struct show_t { | |
70 | pl_ent_t sh_type; /* type of entry */ | 70 | pl_ent_t sh_type; /* type of entry */ | |
71 | const char *sh_quiet; /* message when quiet */ | 71 | const char *sh_quiet; /* message when quiet */ | |
72 | const char *sh_verbose; /* message when verbose */ | 72 | const char *sh_verbose; /* message when verbose */ | |
73 | } show_t; | 73 | } show_t; | |
74 | 74 | |||
75 | /* | 75 | /* | |
76 | * The entries in this table must be ordered the same as | 76 | * The entries in this table must be ordered the same as | |
77 | * pl_ent_t constants | 77 | * pl_ent_t constants | |
78 | */ | 78 | */ | |
79 | static const show_t showv[] = { | 79 | static const show_t showv[] = { | |
80 | {PLIST_FILE, "%s", "\tFile: %s"}, | 80 | {PLIST_FILE, "", "\tFile: "}, | |
81 | {PLIST_CWD, "@cwd %s", "\tCWD to: %s"}, | 81 | {PLIST_CWD, "@cwd ", "\tCWD to: "}, | |
82 | {PLIST_CMD, "@exec %s", "\tEXEC '%s'"}, | 82 | {PLIST_CMD, "@exec ", "\tEXEC ''"}, | |
83 | {PLIST_CHMOD, "@chmod %s", "\tCHMOD to %s"}, | 83 | {PLIST_CHMOD, "@chmod ", "\tCHMOD to "}, | |
84 | {PLIST_CHOWN, "@chown %s", "\tCHOWN to %s"}, | 84 | {PLIST_CHOWN, "@chown ", "\tCHOWN to "}, | |
85 | {PLIST_CHGRP, "@chgrp %s", "\tCHGRP to %s"}, | 85 | {PLIST_CHGRP, "@chgrp ", "\tCHGRP to "}, | |
86 | {PLIST_COMMENT, "@comment %s", "\tComment: %s"}, | 86 | {PLIST_COMMENT, "@comment ", "\tComment: "}, | |
87 | {PLIST_IGNORE, "@ignore", "Ignore next file:"}, | 87 | {PLIST_IGNORE, "@ignore", "Ignore next file:"}, | |
88 | {PLIST_NAME, "@name %s", "\tPackage name: %s"}, | 88 | {PLIST_NAME, "@name ", "\tPackage name: "}, | |
89 | {PLIST_UNEXEC, "@unexec %s", "\tUNEXEC '%s'"}, | 89 | {PLIST_UNEXEC, "@unexec ", "\tUNEXEC ''"}, | |
90 | {PLIST_SRC, "@src: %s", "\tSRC to: %s"}, | 90 | {PLIST_SRC, "@src: ", "\tSRC to: "}, | |
91 | {PLIST_DISPLAY, "@display %s", "\tInstall message file: %s"}, | 91 | {PLIST_DISPLAY, "@display ", "\tInstall message file: "}, | |
92 | {PLIST_PKGDEP, "@pkgdep %s", "\tPackage depends on: %s"}, | 92 | {PLIST_PKGDEP, "@pkgdep ", "\tPackage depends on: "}, | |
93 | {PLIST_DIR_RM, "@dirrm %s", "\tObsolete deinstall directory removal hint: %s"}, | 93 | {PLIST_DIR_RM, "@dirrm ", "\tObsolete deinstall directory removal hint: "}, | |
94 | {PLIST_OPTION, "@option %s", "\tPackage has option: %s"}, | 94 | {PLIST_OPTION, "@option ", "\tPackage has option: "}, | |
95 | {PLIST_PKGCFL, "@pkgcfl %s", "\tPackage conflicts with: %s"}, | 95 | {PLIST_PKGCFL, "@pkgcfl ", "\tPackage conflicts with: "}, | |
96 | {PLIST_BLDDEP, "@blddep %s", "\tPackage depends exactly on: %s"}, | 96 | {PLIST_BLDDEP, "@blddep ", "\tPackage depends exactly on: "}, | |
97 | {PLIST_PKGDIR, "@pkgdir %s", "\tManaged directory: %s"}, | 97 | {PLIST_PKGDIR, "@pkgdir ", "\tManaged directory: "}, | |
98 | {-1, NULL, NULL} | 98 | {-1, NULL, NULL} | |
99 | }; | 99 | }; | |
100 | 100 | |||
101 | static int print_string_as_var(const char *, const char *); | 101 | static int print_string_as_var(const char *, const char *); | |
102 | 102 | |||
103 | void | 103 | void | |
104 | show_file(const char *buf, const char *title, Boolean separator) | 104 | show_file(const char *buf, const char *title, Boolean separator) | |
105 | { | 105 | { | |
106 | size_t len; | 106 | size_t len; | |
107 | 107 | |||
108 | if (!Quiet) | 108 | if (!Quiet) | |
109 | printf("%s%s", InfoPrefix, title); | 109 | printf("%s%s", InfoPrefix, title); | |
110 | 110 | |||
111 | len = strlen(buf); | 111 | len = strlen(buf); | |
112 | if (len == 0 || buf[len - 1] != '\n') | 112 | if (len == 0 || buf[len - 1] != '\n') | |
113 | puts(buf); | 113 | puts(buf); | |
114 | else | 114 | else | |
115 | fputs(buf, stdout); | 115 | fputs(buf, stdout); | |
116 | 116 | |||
117 | if (!Quiet || separator) | 117 | if (!Quiet || separator) | |
118 | printf("\n"); | 118 | printf("\n"); | |
119 | } | 119 | } | |
120 | 120 | |||
121 | void | 121 | void | |
122 | show_var(const char *buf, const char *variable) | 122 | show_var(const char *buf, const char *variable) | |
123 | { | 123 | { | |
124 | char *value; | 124 | char *value; | |
125 | 125 | |||
126 | if (buf == NULL) | 126 | if (buf == NULL) | |
127 | return; | 127 | return; | |
128 | 128 | |||
129 | if ((value = var_get_memory(buf, variable)) != NULL) { | 129 | if ((value = var_get_memory(buf, variable)) != NULL) { | |
130 | (void) printf("%s\n", value); | 130 | (void) printf("%s\n", value); | |
131 | free(value); | 131 | free(value); | |
132 | } | 132 | } | |
133 | } | 133 | } | |
134 | 134 | |||
135 | void | 135 | void | |
136 | show_index(const char *buf, const char *title) | 136 | show_index(const char *buf, const char *title) | |
137 | { | 137 | { | |
138 | size_t len; | 138 | size_t len; | |
139 | 139 | |||
140 | if (!Quiet) | 140 | if (!Quiet) | |
141 | printf("%s%s", InfoPrefix, title); | 141 | printf("%s%s", InfoPrefix, title); | |
142 | 142 | |||
143 | len = strlen(buf); | 143 | len = strlen(buf); | |
144 | if (len == 0 || buf[len - 1] != '\n') | 144 | if (len == 0 || buf[len - 1] != '\n') | |
145 | puts(buf); | 145 | puts(buf); | |
146 | else | 146 | else | |
147 | fputs(buf, stdout); | 147 | fputs(buf, stdout); | |
148 | } | 148 | } | |
149 | 149 | |||
150 | /* | 150 | /* | |
151 | * Show a packing list item type. If type is PLIST_SHOW_ALL, show all | 151 | * Show a packing list item type. If type is PLIST_SHOW_ALL, show all | |
152 | */ | 152 | */ | |
153 | void | 153 | void | |
154 | show_plist(const char *title, package_t *plist, pl_ent_t type) | 154 | show_plist(const char *title, package_t *plist, pl_ent_t type) | |
155 | { | 155 | { | |
156 | plist_t *p; | 156 | plist_t *p; | |
157 | Boolean ign; | 157 | Boolean ign; | |
158 | 158 | |||
159 | if (!Quiet) { | 159 | if (!Quiet) { | |
160 | printf("%s%s", InfoPrefix, title); | 160 | printf("%s%s", InfoPrefix, title); | |
161 | } | 161 | } | |
162 | for (ign = FALSE, p = plist->head; p; p = p->next) { | 162 | for (ign = FALSE, p = plist->head; p; p = p->next) { | |
163 | if (p->type == type || type == PLIST_SHOW_ALL) { | 163 | if (p->type == type || type == PLIST_SHOW_ALL) { | |
164 | switch (p->type) { | 164 | switch (p->type) { | |
165 | case PLIST_FILE: | 165 | case PLIST_FILE: | |
166 | printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose, p->name); | 166 | printf("%s%s", | |
167 | Quiet ? showv[p->type].sh_quiet : | |||
168 | showv[p->type].sh_verbose, p->name); | |||
167 | if (ign) { | 169 | if (ign) { | |
168 | if (!Quiet) { | 170 | if (!Quiet) { | |
169 | printf(" (ignored)"); | 171 | printf(" (ignored)"); | |
170 | } | 172 | } | |
171 | ign = FALSE; | 173 | ign = FALSE; | |
172 | } | 174 | } | |
173 | break; | 175 | break; | |
174 | case PLIST_CHMOD: | 176 | case PLIST_CHMOD: | |
175 | case PLIST_CHOWN: | 177 | case PLIST_CHOWN: | |
176 | case PLIST_CHGRP: | 178 | case PLIST_CHGRP: | |
177 | printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose, | 179 | printf("%s%s", | |
180 | Quiet ? showv[p->type].sh_quiet : | |||
181 | showv[p->type].sh_verbose, | |||
178 | p->name ? p->name : "(clear default)"); | 182 | p->name ? p->name : "(clear default)"); | |
179 | break; | 183 | break; | |
180 | case PLIST_IGNORE: | 184 | case PLIST_IGNORE: | |
181 | printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose); | 185 | printf("%s", Quiet ? showv[p->type].sh_quiet : | |
186 | showv[p->type].sh_verbose); | |||
182 | ign = TRUE; | 187 | ign = TRUE; | |
183 | break; | 188 | break; | |
184 | case PLIST_CWD: | 189 | case PLIST_CWD: | |
185 | case PLIST_CMD: | 190 | case PLIST_CMD: | |
186 | case PLIST_SRC: | 191 | case PLIST_SRC: | |
187 | case PLIST_UNEXEC: | 192 | case PLIST_UNEXEC: | |
188 | case PLIST_COMMENT: | 193 | case PLIST_COMMENT: | |
189 | case PLIST_NAME: | 194 | case PLIST_NAME: | |
190 | case PLIST_DISPLAY: | 195 | case PLIST_DISPLAY: | |
191 | case PLIST_PKGDEP: | 196 | case PLIST_PKGDEP: | |
192 | case PLIST_DIR_RM: | 197 | case PLIST_DIR_RM: | |
193 | case PLIST_OPTION: | 198 | case PLIST_OPTION: | |
194 | case PLIST_PKGCFL: | 199 | case PLIST_PKGCFL: | |
195 | case PLIST_BLDDEP: | 200 | case PLIST_BLDDEP: | |
196 | case PLIST_PKGDIR: | 201 | case PLIST_PKGDIR: | |
197 | printf(Quiet ? showv[p->type].sh_quiet : showv[p->type].sh_verbose, | 202 | printf("%s%s", | |
198 | (p->name) ? p->name : "(null)"); | 203 | Quiet ? showv[p->type].sh_quiet : | |
204 | showv[p->type].sh_verbose, | |||
205 | p->name ? p->name : "(null)"); | |||
199 | break; | 206 | break; | |
200 | default: | 207 | default: | |
201 | warnx("unknown command type %d (%s)", p->type, p->name); | 208 | warnx("unknown command type %d (%s)", p->type, p->name); | |
202 | } | 209 | } | |
203 | (void) fputc('\n', stdout); | 210 | (void) fputc('\n', stdout); | |
204 | } | 211 | } | |
205 | } | 212 | } | |
206 | } | 213 | } | |
207 | 214 | |||
208 | /* | 215 | /* | |
209 | * Show all files in the packing list (except ignored ones) | 216 | * Show all files in the packing list (except ignored ones) | |
210 | */ | 217 | */ | |
211 | void | 218 | void | |
212 | show_files(const char *title, package_t *plist) | 219 | show_files(const char *title, package_t *plist) | |
213 | { | 220 | { | |
214 | plist_t *p; | 221 | plist_t *p; | |
215 | Boolean ign; | 222 | Boolean ign; | |
216 | const char *dir = "."; | 223 | const char *dir = "."; | |
217 | 224 | |||
218 | if (!Quiet) { | 225 | if (!Quiet) { | |
219 | printf("%s%s", InfoPrefix, title); | 226 | printf("%s%s", InfoPrefix, title); | |
220 | } | 227 | } | |
221 | for (ign = FALSE, p = plist->head; p; p = p->next) { | 228 | for (ign = FALSE, p = plist->head; p; p = p->next) { | |
222 | switch (p->type) { | 229 | switch (p->type) { | |
223 | case PLIST_FILE: | 230 | case PLIST_FILE: | |
224 | if (!ign) { | 231 | if (!ign) { | |
225 | printf("%s%s%s\n", dir, | 232 | printf("%s%s%s\n", dir, | |
226 | (strcmp(dir, "/") == 0) ? "" : "/", p->name); | 233 | (strcmp(dir, "/") == 0) ? "" : "/", p->name); | |
227 | } | 234 | } | |
228 | ign = FALSE; | 235 | ign = FALSE; | |
229 | break; | 236 | break; | |
230 | case PLIST_CWD: | 237 | case PLIST_CWD: | |
231 | dir = p->name; | 238 | dir = p->name; | |
232 | break; | 239 | break; | |
233 | case PLIST_IGNORE: | 240 | case PLIST_IGNORE: | |
234 | ign = TRUE; | 241 | ign = TRUE; | |
235 | break; | 242 | break; | |
236 | default: | 243 | default: | |
237 | break; | 244 | break; | |
238 | } | 245 | } | |
239 | } | 246 | } | |
240 | } | 247 | } | |
241 | 248 | |||
242 | /* | 249 | /* | |
243 | * Show dependencies (packages this pkg requires) | 250 | * Show dependencies (packages this pkg requires) | |
244 | */ | 251 | */ | |
245 | void | 252 | void | |
246 | show_depends(const char *title, package_t *plist) | 253 | show_depends(const char *title, package_t *plist) | |
247 | { | 254 | { | |
248 | plist_t *p; | 255 | plist_t *p; | |
249 | int nodepends; | 256 | int nodepends; | |
250 | 257 | |||
251 | nodepends = 1; | 258 | nodepends = 1; | |
252 | for (p = plist->head; p && nodepends; p = p->next) { | 259 | for (p = plist->head; p && nodepends; p = p->next) { | |
253 | switch (p->type) { | 260 | switch (p->type) { | |
254 | case PLIST_PKGDEP: | 261 | case PLIST_PKGDEP: | |
255 | nodepends = 0; | 262 | nodepends = 0; | |
256 | break; | 263 | break; | |
257 | default: | 264 | default: | |
258 | break; | 265 | break; | |
259 | } | 266 | } | |
260 | } | 267 | } | |
261 | if (nodepends) | 268 | if (nodepends) | |
262 | return; | 269 | return; | |
263 | 270 | |||
264 | if (!Quiet) { | 271 | if (!Quiet) { | |
265 | printf("%s%s", InfoPrefix, title); | 272 | printf("%s%s", InfoPrefix, title); | |
266 | } | 273 | } | |
267 | for (p = plist->head; p; p = p->next) { | 274 | for (p = plist->head; p; p = p->next) { | |
268 | switch (p->type) { | 275 | switch (p->type) { | |
269 | case PLIST_PKGDEP: | 276 | case PLIST_PKGDEP: | |
270 | printf("%s\n", p->name); | 277 | printf("%s\n", p->name); | |
271 | break; | 278 | break; | |
272 | default: | 279 | default: | |
273 | break; | 280 | break; | |
274 | } | 281 | } | |
275 | } | 282 | } | |
276 | 283 | |||
277 | printf("\n"); | 284 | printf("\n"); | |
278 | } | 285 | } | |
279 | 286 | |||
280 | /* | 287 | /* | |
281 | * Show exact dependencies (packages this pkg was built with) | 288 | * Show exact dependencies (packages this pkg was built with) | |
282 | */ | 289 | */ | |
283 | void | 290 | void | |
284 | show_bld_depends(const char *title, package_t *plist) | 291 | show_bld_depends(const char *title, package_t *plist) | |
285 | { | 292 | { | |
286 | plist_t *p; | 293 | plist_t *p; | |
287 | int nodepends; | 294 | int nodepends; | |
288 | 295 | |||
289 | nodepends = 1; | 296 | nodepends = 1; | |
290 | for (p = plist->head; p && nodepends; p = p->next) { | 297 | for (p = plist->head; p && nodepends; p = p->next) { | |
291 | switch (p->type) { | 298 | switch (p->type) { | |
292 | case PLIST_BLDDEP: | 299 | case PLIST_BLDDEP: | |
293 | nodepends = 0; | 300 | nodepends = 0; | |
294 | break; | 301 | break; | |
295 | default: | 302 | default: | |
296 | break; | 303 | break; | |
297 | } | 304 | } | |
298 | } | 305 | } | |
299 | if (nodepends) | 306 | if (nodepends) | |
300 | return; | 307 | return; | |
301 | 308 | |||
302 | if (!Quiet) { | 309 | if (!Quiet) { | |
303 | printf("%s%s", InfoPrefix, title); | 310 | printf("%s%s", InfoPrefix, title); | |
304 | } | 311 | } | |
305 | for (p = plist->head; p; p = p->next) { | 312 | for (p = plist->head; p; p = p->next) { | |
306 | switch (p->type) { | 313 | switch (p->type) { | |
307 | case PLIST_BLDDEP: | 314 | case PLIST_BLDDEP: | |
308 | printf("%s\n", p->name); | 315 | printf("%s\n", p->name); | |
309 | break; | 316 | break; | |
310 | default: | 317 | default: | |
311 | break; | 318 | break; | |
312 | } | 319 | } | |
313 | } | 320 | } | |
314 | 321 | |||
315 | printf("\n"); | 322 | printf("\n"); | |
316 | } | 323 | } | |
317 | 324 | |||
318 | 325 | |||
319 | /* | 326 | /* | |
320 | * Show entry for pkg_summary.txt file. | 327 | * Show entry for pkg_summary.txt file. | |
321 | */ | 328 | */ | |
322 | void | 329 | void | |
323 | show_summary(struct pkg_meta *meta, package_t *plist, const char *binpkgfile) | 330 | show_summary(struct pkg_meta *meta, package_t *plist, const char *binpkgfile) | |
324 | { | 331 | { | |
325 | static const char *bi_vars[] = { | 332 | static const char *bi_vars[] = { | |
326 | "PKGPATH", | 333 | "PKGPATH", | |
327 | "CATEGORIES", | 334 | "CATEGORIES", | |
328 | "PROVIDES", | 335 | "PROVIDES", | |
329 | "REQUIRES", | 336 | "REQUIRES", | |
330 | "PKG_OPTIONS", | 337 | "PKG_OPTIONS", | |
331 | "OPSYS", | 338 | "OPSYS", | |
332 | "OS_VERSION", | 339 | "OS_VERSION", | |
333 | "MACHINE_ARCH", | 340 | "MACHINE_ARCH", | |
334 | "LICENSE", | 341 | "LICENSE", | |
335 | "HOMEPAGE", | 342 | "HOMEPAGE", | |
336 | "PKGTOOLS_VERSION", | 343 | "PKGTOOLS_VERSION", | |
337 | "BUILD_DATE", | 344 | "BUILD_DATE", | |
338 | "PREV_PKGPATH", | 345 | "PREV_PKGPATH", | |
339 | "SUPERSEDES", | 346 | "SUPERSEDES", | |
340 | NULL | 347 | NULL | |
341 | }; | 348 | }; | |
342 | 349 | |||
343 | plist_t *p; | 350 | plist_t *p; | |
344 | struct stat st; | 351 | struct stat st; | |
345 | 352 | |||
346 | for (p = plist->head; p; p = p->next) { | 353 | for (p = plist->head; p; p = p->next) { | |
347 | switch (p->type) { | 354 | switch (p->type) { | |
348 | case PLIST_NAME: | 355 | case PLIST_NAME: | |
349 | printf("PKGNAME=%s\n", p->name); | 356 | printf("PKGNAME=%s\n", p->name); | |
350 | break; | 357 | break; | |
351 | case PLIST_PKGDEP: | 358 | case PLIST_PKGDEP: | |
352 | printf("DEPENDS=%s\n", p->name); | 359 | printf("DEPENDS=%s\n", p->name); | |
353 | break; | 360 | break; | |
354 | case PLIST_PKGCFL: | 361 | case PLIST_PKGCFL: | |
355 | printf("CONFLICTS=%s\n", p->name); | 362 | printf("CONFLICTS=%s\n", p->name); | |
356 | break; | 363 | break; | |
357 | 364 | |||
358 | default: | 365 | default: | |
359 | break; | 366 | break; | |
360 | } | 367 | } | |
361 | } | 368 | } | |
362 | 369 | |||
363 | print_string_as_var("COMMENT", meta->meta_comment); | 370 | print_string_as_var("COMMENT", meta->meta_comment); | |
364 | if (meta->meta_size_pkg) | 371 | if (meta->meta_size_pkg) | |
365 | print_string_as_var("SIZE_PKG", meta->meta_size_pkg); | 372 | print_string_as_var("SIZE_PKG", meta->meta_size_pkg); | |
366 | 373 | |||
367 | if (meta->meta_build_info) | 374 | if (meta->meta_build_info) | |
368 | var_copy_list(meta->meta_build_info, bi_vars); | 375 | var_copy_list(meta->meta_build_info, bi_vars); | |
369 | else | 376 | else | |
370 | warnx("Build information missing"); | 377 | warnx("Build information missing"); | |
371 | 378 | |||
372 | if (binpkgfile != NULL && stat(binpkgfile, &st) == 0) { | 379 | if (binpkgfile != NULL && stat(binpkgfile, &st) == 0) { | |
373 | const char *base; | 380 | const char *base; | |
374 | 381 | |||
375 | base = strrchr(binpkgfile, '/'); | 382 | base = strrchr(binpkgfile, '/'); | |
376 | if (base == NULL) | 383 | if (base == NULL) | |
377 | base = binpkgfile; | 384 | base = binpkgfile; | |
378 | else | 385 | else | |
379 | base++; | 386 | base++; | |
380 | printf("FILE_NAME=%s\n", base); | 387 | printf("FILE_NAME=%s\n", base); | |
381 | printf("FILE_SIZE=%" MY_PRIu64 "\n", (uint64_t)st.st_size); | 388 | printf("FILE_SIZE=%" MY_PRIu64 "\n", (uint64_t)st.st_size); | |
382 | /* XXX: DIGETS */ | 389 | /* XXX: DIGETS */ | |
383 | } | 390 | } | |
384 | 391 | |||
385 | print_string_as_var("DESCRIPTION", meta->meta_desc); | 392 | print_string_as_var("DESCRIPTION", meta->meta_desc); | |
386 | putc('\n', stdout); | 393 | putc('\n', stdout); | |
387 | } | 394 | } | |
388 | 395 | |||
389 | /* | 396 | /* | |
390 | * Print the contents of file fname as value of variable var to stdout. | 397 | * Print the contents of file fname as value of variable var to stdout. | |
391 | */ | 398 | */ | |
392 | static int | 399 | static int | |
393 | print_string_as_var(const char *var, const char *str) | 400 | print_string_as_var(const char *var, const char *str) | |
394 | { | 401 | { | |
395 | const char *eol; | 402 | const char *eol; | |
396 | 403 | |||
397 | while ((eol = strchr(str, '\n')) != NULL) { | 404 | while ((eol = strchr(str, '\n')) != NULL) { | |
398 | printf("%s=%.*s\n", var, (int)(eol - str), str); | 405 | printf("%s=%.*s\n", var, (int)(eol - str), str); | |
399 | str = eol + 1; | 406 | str = eol + 1; | |
400 | } | 407 | } | |
401 | if (*str) | 408 | if (*str) | |
402 | printf("%s=%s\n", var, str); | 409 | printf("%s=%s\n", var, str); | |
403 | 410 | |||
404 | return 0; | 411 | return 0; | |
405 | } | 412 | } | |
406 | 413 | |||
407 | void | 414 | void | |
408 | show_list(lpkg_head_t *pkghead, const char *title) | 415 | show_list(lpkg_head_t *pkghead, const char *title) | |
409 | { | 416 | { | |
410 | lpkg_t *lpp; | 417 | lpkg_t *lpp; | |
411 | 418 | |||
412 | if (!Quiet) | 419 | if (!Quiet) | |
413 | printf("%s%s", InfoPrefix, title); | 420 | printf("%s%s", InfoPrefix, title); | |
414 | 421 | |||
415 | while ((lpp = TAILQ_FIRST(pkghead)) != NULL) { | 422 | while ((lpp = TAILQ_FIRST(pkghead)) != NULL) { | |
416 | TAILQ_REMOVE(pkghead, lpp, lp_link); | 423 | TAILQ_REMOVE(pkghead, lpp, lp_link); | |
417 | puts(lpp->lp_name); | 424 | puts(lpp->lp_name); | |
418 | free_lpkg(lpp); | 425 | free_lpkg(lpp); | |
419 | } | 426 | } | |
420 | 427 | |||
421 | if (!Quiet) | 428 | if (!Quiet) | |
422 | printf("\n"); | 429 | printf("\n"); | |
423 | } | 430 | } |
@@ -1,77 +1,75 @@ | @@ -1,77 +1,75 @@ | |||
1 | /* $NetBSD: defs.h,v 1.9 2008/04/18 12:01:46 joerg Exp $ */ | 1 | /* $NetBSD: defs.h,v 1.10 2012/02/21 18:32:14 wiz Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /*- | |
4 | * Copyright (c) 1999-2000 Alistair G. Crooks. All rights reserved. | 4 | * Copyright (c) 1999,2000,2009 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | |||
6 | * | |||
7 | * This code is derived from software contributed to The NetBSD Foundation | |||
8 | * by Alistair Crooks (agc@NetBSD.org) | |||
5 | * | 9 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 12 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 16 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 17 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | |||
15 | * must display the following acknowledgement: | |||
16 | * This product includes software developed by Alistair G. Crooks. | |||
17 | * 4. The name of the author may not be used to endorse or promote | |||
18 | * products derived from this software without specific prior written | |||
19 | * permission. | |||
20 | * | 18 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS | 19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | |
22 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 30 | */ | |
33 | #ifndef DEFS_H_ | 31 | #ifndef DEFS_H_ | |
34 | #define DEFS_H_ | 32 | #define DEFS_H_ | |
35 | 33 | |||
36 | #if HAVE_CONFIG_H | 34 | #if HAVE_CONFIG_H | |
37 | #include "config.h" | 35 | #include "config.h" | |
38 | #endif | 36 | #endif | |
39 | #include <nbcompat.h> | 37 | #include <nbcompat.h> | |
40 | #if HAVE_ERR_H | 38 | #if HAVE_ERR_H | |
41 | #include <err.h> | 39 | #include <err.h> | |
42 | #endif | 40 | #endif | |
43 | #if HAVE_STDLIB_H | 41 | #if HAVE_STDLIB_H | |
44 | #include <stdlib.h> | 42 | #include <stdlib.h> | |
45 | #endif | 43 | #endif | |
46 | #if HAVE_STRING_H | 44 | #if HAVE_STRING_H | |
47 | #include <string.h> | 45 | #include <string.h> | |
48 | #endif | 46 | #endif | |
49 | 47 | |||
50 | #ifndef MIN | 48 | #ifndef MIN | |
51 | #define MIN(a,b) (((a) < (b)) ? (a) : (b)) | 49 | #define MIN(a,b) (((a) < (b)) ? (a) : (b)) | |
52 | #endif | 50 | #endif | |
53 | 51 | |||
54 | #ifndef MAX | 52 | #ifndef MAX | |
55 | #define MAX(a,b) (((a) > (b)) ? (a) : (b)) | 53 | #define MAX(a,b) (((a) > (b)) ? (a) : (b)) | |
56 | #endif | 54 | #endif | |
57 | 55 | |||
58 | /* | 56 | /* | |
59 | * Some systems such as OpenBSD-3.6 do not provide PRIu64. | 57 | * Some systems such as OpenBSD-3.6 do not provide PRIu64. | |
60 | * Others such as AIX-4.3.2 have a broken PRIu64 which includes | 58 | * Others such as AIX-4.3.2 have a broken PRIu64 which includes | |
61 | * a leading "%". | 59 | * a leading "%". | |
62 | */ | 60 | */ | |
63 | #ifdef NEED_PRI_MACRO | 61 | #ifdef NEED_PRI_MACRO | |
64 | # if SIZEOF_INT == 8 | 62 | # if SIZEOF_INT == 8 | |
65 | # define MY_PRIu64 "u" | 63 | # define MY_PRIu64 "u" | |
66 | # elif SIZEOF_LONG == 8 | 64 | # elif SIZEOF_LONG == 8 | |
67 | # define MY_PRIu64 "lu" | 65 | # define MY_PRIu64 "lu" | |
68 | # elif SIZEOF_LONG_LONG == 8 | 66 | # elif SIZEOF_LONG_LONG == 8 | |
69 | # define MY_PRIu64 "llu" | 67 | # define MY_PRIu64 "llu" | |
70 | # else | 68 | # else | |
71 | # error "unable to find a suitable PRIu64" | 69 | # error "unable to find a suitable PRIu64" | |
72 | # endif | 70 | # endif | |
73 | #else | 71 | #else | |
74 | # define MY_PRIu64 PRIu64 | 72 | # define MY_PRIu64 PRIu64 | |
75 | #endif | 73 | #endif | |
76 | 74 | |||
77 | #endif /* !DEFS_H_ */ | 75 | #endif /* !DEFS_H_ */ |