Wed, 14 Jan 2009 15:59:12 +0100
Correct and improve many buildconf and code logic blocks. In particular:
1. Document potential problems building with current binutils releases.
2. Document the flawed webkit and explain its temporary exclusion.
3. Document the edition of Qt which is built and installed.
4. Remove the Solaris x11_supdir logic as it is no longer found.
5. Correct several .pr[io] files including QMAKE_CXXFLAGS and INCPATH,
which previously caused preexisting Qt installations to deliver
erroneous old include and library logic instead of relying on
that of the currently building package. -I/opkg/include is now
placed at the end of the compile statements.
6. Don't trust the QMAKE_[INC|LIB]DIR_X11 identifiers in qmake.conf.
7. Allow more 64-bit builds and more properly identify the platform.
8. Place plugins (which are shared objects) in lib instead of share.
9. Build components as plugins when possible if with_shared is enabled.
10. Translate German text to English to be more consistent.
11. Instead of removing the pkgconfig directory of with_shared builds,
place it in a child directory useful for shared building.
12. Document the nonstandard shared build directory structure,
including using the hidden pkgconfig directory (PKG_CONFIG_PATH.)
13. Change %doc to specify files rather than directories in the RPM DB.
michael@13 | 1 | #!@l_prefix@/lib/openpkg/bash |
michael@13 | 2 | ## |
michael@13 | 3 | ## rpmtool -- OpenPKG RPM Auxiliary Tool |
michael@13 | 4 | ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/> |
michael@13 | 5 | ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/> |
michael@13 | 6 | ## |
michael@13 | 7 | ## Permission to use, copy, modify, and distribute this software for |
michael@13 | 8 | ## any purpose with or without fee is hereby granted, provided that |
michael@13 | 9 | ## the above copyright notice and this permission notice appear in all |
michael@13 | 10 | ## copies. |
michael@13 | 11 | ## |
michael@13 | 12 | ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
michael@13 | 13 | ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
michael@13 | 14 | ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
michael@13 | 15 | ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
michael@13 | 16 | ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
michael@13 | 17 | ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
michael@13 | 18 | ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
michael@13 | 19 | ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
michael@13 | 20 | ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
michael@13 | 21 | ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
michael@13 | 22 | ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
michael@13 | 23 | ## SUCH DAMAGE. |
michael@13 | 24 | ## |
michael@13 | 25 | |
michael@13 | 26 | prog_path="$0" |
michael@13 | 27 | prog_name="rpmtool" |
michael@13 | 28 | prog_vers="1.1.0" |
michael@13 | 29 | prog_date="05-Mar-2007" |
michael@13 | 30 | |
michael@13 | 31 | if [ $# -eq 0 ]; then |
michael@13 | 32 | echo "$0:Error: invalid command line" 1>&2 |
michael@13 | 33 | echo "$0:Hint: run \`$0 -h' for usage" 1>&2 |
michael@13 | 34 | exit 1 |
michael@13 | 35 | fi |
michael@13 | 36 | if [ ".$1" = ".-h" -o ".$1" = ".--help" ]; then |
michael@13 | 37 | echo "This is $prog_name, version $prog_vers ($prog_date)" |
michael@13 | 38 | echo "Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>" |
michael@13 | 39 | echo '' |
michael@13 | 40 | echo "Usage: $prog_name [<options>] [<cmd-name> [<cmd-options>] [<cmd-args>]]" |
michael@13 | 41 | echo '' |
michael@13 | 42 | echo 'Available global <options>:' |
michael@13 | 43 | echo ' -d, --debug enable internal debugging' |
michael@13 | 44 | echo ' -v, --version display version information' |
michael@13 | 45 | echo ' -h, --help display usage help page (this one)' |
michael@13 | 46 | echo '' |
michael@13 | 47 | echo 'Available <cmd-name> [<cmd-options>] [<cmd-args>]:' |
michael@13 | 48 | echo ' platform' |
michael@13 | 49 | echo ' mflags [-O] <tool>' |
michael@13 | 50 | echo ' cflags [-O] <tool>' |
michael@13 | 51 | echo ' cppflags [-p <prefix>] [<subdir> ...]' |
michael@13 | 52 | echo ' ldflags [-p <prefix>] [<subdir> ...]' |
michael@13 | 53 | echo ' files [-v] [-o <outfile>] [-r <buildroot>] [<filelist>]' |
michael@13 | 54 | echo ' signal [-v] [-t] [-n] [-c] [-d <delay>] [-p <pid>] [-m <pattern>] <sig> [<sig> ...]' |
michael@13 | 55 | echo ' config [-v] [-s] [-a] [-r] [-b <ext>] [-p <tagprefix>] [-t <tagname>] [-i <tagid>] <file>' |
michael@13 | 56 | echo ' msg [-b] [-r] [-t <type>]' |
michael@13 | 57 | echo '' |
michael@13 | 58 | exit 0 |
michael@13 | 59 | fi |
michael@13 | 60 | if [ ".$1" = ".-v" -o ".$1" = ."--version" ]; then |
michael@13 | 61 | echo "$prog_name $prog_vers ($prog_date)" |
michael@13 | 62 | exit 0 |
michael@13 | 63 | fi |
michael@13 | 64 | if [ ".$1" = ".-d" -o ".$1" = ."--debug" ]; then |
michael@13 | 65 | shift |
michael@13 | 66 | set -x |
michael@13 | 67 | fi |
michael@13 | 68 | |
michael@13 | 69 | tool="$1" |
michael@13 | 70 | shift |
michael@13 | 71 | arg_spec="" |
michael@13 | 72 | opt_spec="" |
michael@13 | 73 | gen_tmpfile=no |
michael@13 | 74 | |
michael@13 | 75 | # configure tool specific option parsing |
michael@13 | 76 | case $tool in |
michael@13 | 77 | platform ) |
michael@13 | 78 | str_usage="" |
michael@13 | 79 | arg_spec="0=" |
michael@13 | 80 | opt_spec="" |
michael@13 | 81 | ;; |
michael@13 | 82 | mflags ) |
michael@13 | 83 | str_usage="[-O] <tool>" |
michael@13 | 84 | arg_spec="1=" |
michael@13 | 85 | opt_spec="O." |
michael@13 | 86 | opt_O=no |
michael@13 | 87 | ;; |
michael@13 | 88 | cflags ) |
michael@13 | 89 | str_usage="[-O] <tool>" |
michael@13 | 90 | arg_spec="1=" |
michael@13 | 91 | opt_spec="O." |
michael@13 | 92 | opt_O=no |
michael@13 | 93 | ;; |
michael@13 | 94 | cppflags ) |
michael@13 | 95 | str_usage="[-p <prefix>] [-i] [<subdir> ...]" |
michael@13 | 96 | arg_spec="0+" |
michael@13 | 97 | opt_spec="p:i." |
michael@13 | 98 | opt_p="/" |
michael@13 | 99 | ;; |
michael@13 | 100 | ldflags ) |
michael@13 | 101 | str_usage="[-p <prefix>] [<subdir> ...]" |
michael@13 | 102 | arg_spec="0+" |
michael@13 | 103 | opt_spec="p:" |
michael@13 | 104 | opt_p="/" |
michael@13 | 105 | ;; |
michael@13 | 106 | files ) |
michael@13 | 107 | gen_tmpfile=yes |
michael@13 | 108 | str_usage="[-v] [-o <outfile>] [-r <buildroot>] [<filelist>]" |
michael@13 | 109 | arg_spec="0+" |
michael@13 | 110 | opt_spec="v.o:r:" |
michael@13 | 111 | opt_v=no |
michael@13 | 112 | opt_o='' |
michael@13 | 113 | opt_r='' |
michael@13 | 114 | ;; |
michael@13 | 115 | signal ) |
michael@13 | 116 | str_usage="[-v] [-t] [-n] [-c] [-d <delay>] [-p <pid>] [-m <pattern>] <sig> [<sig> ...]" |
michael@13 | 117 | arg_spec="1+" |
michael@13 | 118 | opt_spec="v.t.n.c.d:p:m:" |
michael@13 | 119 | opt_v=no |
michael@13 | 120 | opt_t=no |
michael@13 | 121 | opt_n=no |
michael@13 | 122 | opt_c=no |
michael@13 | 123 | opt_d=1 |
michael@13 | 124 | opt_p="" |
michael@13 | 125 | opt_m="" |
michael@13 | 126 | ;; |
michael@13 | 127 | config ) |
michael@13 | 128 | str_usage="[-v] [-s] [-a] [-r] [-b <ext>] [-p <tagprefix>] [-t <tagname>] [-i <tagid>] <file>" |
michael@13 | 129 | arg_spec="1=" |
michael@13 | 130 | opt_spec="v.s.a.r.b:p:t:i:c:" |
michael@13 | 131 | opt_v=no |
michael@13 | 132 | opt_s=no |
michael@13 | 133 | opt_a=no |
michael@13 | 134 | opt_r=no |
michael@13 | 135 | opt_b="" |
michael@13 | 136 | opt_p="#" |
michael@13 | 137 | opt_t="OpenPKG" |
michael@13 | 138 | opt_i="" |
michael@13 | 139 | gen_tmpfile=yes |
michael@13 | 140 | ;; |
michael@13 | 141 | msg ) |
michael@13 | 142 | str_usage="[-b] [-r] [-t <type>]" |
michael@13 | 143 | arg_spec="0=" |
michael@13 | 144 | opt_spec="b.r.t:" |
michael@13 | 145 | opt_b=no |
michael@13 | 146 | opt_r=no |
michael@13 | 147 | opt_t=info |
michael@13 | 148 | ;; |
michael@13 | 149 | check-class ) |
michael@13 | 150 | str_usage="" |
michael@13 | 151 | arg_spec="1=" |
michael@13 | 152 | opt_spec="" |
michael@13 | 153 | ;; |
michael@13 | 154 | -* ) |
michael@13 | 155 | echo "$prog_name:Error: unknown option \`$tool'" 2>&1 |
michael@13 | 156 | echo "$prog_name:Hint: run \`$0 -h' for usage" 2>&1 |
michael@13 | 157 | exit 1 |
michael@13 | 158 | ;; |
michael@13 | 159 | * ) |
michael@13 | 160 | echo "$prog_name:Error: unknown command \`$tool'" 2>&1 |
michael@13 | 161 | echo "$prog_name:Hint: run \`$0 -h' for usage" 2>&1 |
michael@13 | 162 | exit 1 |
michael@13 | 163 | ;; |
michael@13 | 164 | esac |
michael@13 | 165 | |
michael@13 | 166 | # tool information |
michael@13 | 167 | toolcmd="$0 $tool" |
michael@13 | 168 | toolcmdhelp="$prog_name $tool" |
michael@13 | 169 | msgprefix="$prog_name:$tool" |
michael@13 | 170 | |
michael@13 | 171 | # parse argument specification string |
michael@13 | 172 | eval `echo $arg_spec |\ |
michael@13 | 173 | sed -e 's/^\([0-9]*\)\([+=]\)/arg_NUMS=\1; arg_MODE=\2/'` |
michael@13 | 174 | |
michael@13 | 175 | # parse option specification string |
michael@13 | 176 | eval `echo h.$opt_spec |\ |
michael@13 | 177 | sed -e 's/\([a-zA-Z0-9]\)\([.:+]\)/opt_MODE_\1=\2;/g'` |
michael@13 | 178 | |
michael@13 | 179 | # iterate over argument line |
michael@13 | 180 | opt_PREV='' |
michael@13 | 181 | while [ $# -gt 0 ]; do |
michael@13 | 182 | # special option stops processing |
michael@13 | 183 | if [ ".$1" = ".--" ]; then |
michael@13 | 184 | shift |
michael@13 | 185 | break |
michael@13 | 186 | fi |
michael@13 | 187 | |
michael@13 | 188 | # determine option and argument |
michael@13 | 189 | opt_ARG_OK=no |
michael@13 | 190 | if [ ".$opt_PREV" != . ]; then |
michael@13 | 191 | # merge previous seen option with argument |
michael@13 | 192 | opt_OPT="$opt_PREV" |
michael@13 | 193 | opt_ARG="$1" |
michael@13 | 194 | opt_ARG_OK=yes |
michael@13 | 195 | opt_PREV='' |
michael@13 | 196 | else |
michael@13 | 197 | # split argument into option and argument |
michael@13 | 198 | case "$1" in |
michael@13 | 199 | -[a-zA-Z0-9]*) |
michael@13 | 200 | eval `echo "x$1" |\ |
michael@13 | 201 | sed -e 's/^x-\([a-zA-Z0-9]\)/opt_OPT="\1";/' \ |
michael@13 | 202 | -e 's/";\(.*\)$/"; opt_ARG="\1"/'` |
michael@13 | 203 | ;; |
michael@13 | 204 | -[a-zA-Z0-9]) |
michael@13 | 205 | opt_OPT=`echo "x$1" | cut -c3-` |
michael@13 | 206 | opt_ARG='' |
michael@13 | 207 | ;; |
michael@13 | 208 | *) |
michael@13 | 209 | break |
michael@13 | 210 | ;; |
michael@13 | 211 | esac |
michael@13 | 212 | fi |
michael@13 | 213 | |
michael@13 | 214 | # eat up option |
michael@13 | 215 | shift |
michael@13 | 216 | |
michael@13 | 217 | # determine whether option needs an argument |
michael@13 | 218 | eval "opt_MODE=\$opt_MODE_${opt_OPT}" |
michael@13 | 219 | if [ ".$opt_ARG" = . -a ".$opt_ARG_OK" != .yes ]; then |
michael@13 | 220 | if [ ".$opt_MODE" = ".:" -o ".$opt_MODE" = ".+" ]; then |
michael@13 | 221 | opt_PREV="$opt_OPT" |
michael@13 | 222 | continue |
michael@13 | 223 | fi |
michael@13 | 224 | fi |
michael@13 | 225 | |
michael@13 | 226 | # process option |
michael@13 | 227 | case $opt_MODE in |
michael@13 | 228 | '.' ) |
michael@13 | 229 | # boolean option |
michael@13 | 230 | eval "opt_${opt_OPT}=yes" |
michael@13 | 231 | ;; |
michael@13 | 232 | ':' ) |
michael@13 | 233 | # option with argument (multiple occurances override) |
michael@13 | 234 | eval "opt_${opt_OPT}=\"\$opt_ARG\"" |
michael@13 | 235 | ;; |
michael@13 | 236 | '+' ) |
michael@13 | 237 | # option with argument (multiple occurances append) |
michael@13 | 238 | eval "opt_${opt_OPT}=\"\$opt_${opt_OPT} \$opt_ARG\"" |
michael@13 | 239 | ;; |
michael@13 | 240 | * ) |
michael@13 | 241 | echo "$msgprefix:Error: unknown option: \`-$opt_OPT'" 1>&2 |
michael@13 | 242 | echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man $prog_name' for details" 1>&2 |
michael@13 | 243 | exit 1 |
michael@13 | 244 | ;; |
michael@13 | 245 | esac |
michael@13 | 246 | done |
michael@13 | 247 | if [ ".$opt_PREV" != . ]; then |
michael@13 | 248 | echo "$msgprefix:Error: missing argument to option \`-$opt_PREV'" 1>&2 |
michael@13 | 249 | echo "$msgprefix:Hint: run \`$toolcmdhelp -h' or \`man $prog_name' for details" 1>&2 |
michael@13 | 250 | exit 1 |
michael@13 | 251 | fi |
michael@13 | 252 | |
michael@13 | 253 | # process help option |
michael@13 | 254 | if [ ".$opt_h" = .yes ]; then |
michael@13 | 255 | echo "Usage: $toolcmdhelp $str_usage" |
michael@13 | 256 | exit 0 |
michael@13 | 257 | fi |
michael@13 | 258 | |
michael@13 | 259 | # complain about incorrect number of arguments |
michael@13 | 260 | case $arg_MODE in |
michael@13 | 261 | '=' ) |
michael@13 | 262 | if [ $# -ne $arg_NUMS ]; then |
michael@13 | 263 | echo "$msgprefix:Error: invalid number of arguments (exactly $arg_NUMS expected)" 1>&2 |
michael@13 | 264 | echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man $prog_name' for details" 1>&2 |
michael@13 | 265 | exit 1 |
michael@13 | 266 | fi |
michael@13 | 267 | ;; |
michael@13 | 268 | '+' ) |
michael@13 | 269 | if [ $# -lt $arg_NUMS ]; then |
michael@13 | 270 | echo "$msgprefix:Error: invalid number of arguments (at least $arg_NUMS expected)" 1>&2 |
michael@13 | 271 | echo "$msgprefix:Hint: run \`$toolcmd -h' or \`man $prog_name' for details" 1>&2 |
michael@13 | 272 | exit 1 |
michael@13 | 273 | fi |
michael@13 | 274 | ;; |
michael@13 | 275 | esac |
michael@13 | 276 | |
michael@13 | 277 | # establish a temporary file on request |
michael@13 | 278 | if [ ".$gen_tmpfile" = .yes ]; then |
michael@13 | 279 | if [ ".$TMPDIR" != . ]; then |
michael@13 | 280 | tmpdir="$TMPDIR" |
michael@13 | 281 | else |
michael@13 | 282 | tmpdir="/tmp" |
michael@13 | 283 | fi |
michael@13 | 284 | tmpfile="$tmpdir/.$prog_name.$$" |
michael@13 | 285 | rm -f $tmpfile >/dev/null 2>&1 |
michael@13 | 286 | touch $tmpfile |
michael@13 | 287 | fi |
michael@13 | 288 | |
michael@13 | 289 | # provide a few useful variables |
michael@13 | 290 | NL=" |
michael@13 | 291 | " |
michael@13 | 292 | TAB=" " |
michael@13 | 293 | DIFS=" ${TAB}${NL}" |
michael@13 | 294 | |
michael@13 | 295 | # determine platform information |
michael@13 | 296 | platform_machine=`(uname -m) 2>/dev/null` ||\ |
michael@13 | 297 | platform_machine=`(uname -p) 2>/dev/null` ||\ |
michael@13 | 298 | platform_machine='unknown' |
michael@13 | 299 | if [ ".$platform_machine" = ".Power Macintosh" ]; then |
michael@13 | 300 | platform_machine=`(uname -p) 2>/dev/null` |
michael@13 | 301 | fi |
michael@13 | 302 | platform_release=`(uname -r) 2>/dev/null` ||\ |
michael@13 | 303 | platform_release='unknown' |
michael@13 | 304 | platform_system=`(uname -s) 2>/dev/null` ||\ |
michael@13 | 305 | platform_system='unknown' |
michael@13 | 306 | platform_version=`(uname -v) 2>/dev/null` ||\ |
michael@13 | 307 | platform_version='unknown' |
michael@13 | 308 | platform="${platform_machine}:${platform_system}:${platform_release}:${platform_version}" |
michael@13 | 309 | |
michael@13 | 310 | # dispatch into tools |
michael@13 | 311 | case $tool in |
michael@13 | 312 | platform ) |
michael@13 | 313 | # provide unique platform id |
michael@13 | 314 | m=`echo "$platform_machine" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` |
michael@13 | 315 | s=`echo "$platform_system" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` |
michael@13 | 316 | r=`echo "$platform_release" | sed -e 's;-.*$;;'` |
michael@13 | 317 | echo "${m}-${s}${r}" |
michael@13 | 318 | ;; |
michael@13 | 319 | |
michael@13 | 320 | mflags ) |
michael@13 | 321 | tool="$1" |
michael@13 | 322 | isgmake=no |
michael@13 | 323 | if [ ".`$tool -v -f /dev/null 2>/dev/null | grep 'GNU Make'`" != . ]; then |
michael@13 | 324 | isgmake=yes |
michael@13 | 325 | fi |
michael@13 | 326 | mflags='' |
michael@13 | 327 | if [ ".$isgmake" = .yes ]; then |
michael@13 | 328 | mflags="--no-print-directory" |
michael@13 | 329 | fi |
michael@13 | 330 | if [ ".$opt_O" = .yes ]; then |
michael@13 | 331 | case $platform in |
michael@13 | 332 | *:SunOS:5.*:* | *:OSF1:*:* ) |
michael@13 | 333 | if [ ".$isgmake" = .yes ]; then |
michael@13 | 334 | n=`(/bin/uname -X) 2>/dev/null | grep -i NumCPU | awk '{ print $3; }'` |
michael@13 | 335 | if [ ".$n" != . ]; then |
michael@13 | 336 | if [ $n -gt 1 ]; then |
michael@13 | 337 | n=`expr $n \* 2` |
michael@13 | 338 | mflags="$mflags -j$n" |
michael@13 | 339 | fi |
michael@13 | 340 | fi |
michael@13 | 341 | fi |
michael@13 | 342 | ;; |
michael@13 | 343 | *:FreeBSD:[4-8].*:* ) |
michael@13 | 344 | n=`/sbin/sysctl -n hw.ncpu` |
michael@13 | 345 | if [ ".$n" != . ]; then |
michael@13 | 346 | if [ $n -gt 1 ]; then |
michael@13 | 347 | n=`expr $n \* 2` |
michael@13 | 348 | mflags="$mflags -j$n" |
michael@13 | 349 | if [ ".$isgmake" = .no ]; then |
michael@13 | 350 | mflags="$mflags -B" |
michael@13 | 351 | fi |
michael@13 | 352 | fi |
michael@13 | 353 | fi |
michael@13 | 354 | ;; |
michael@13 | 355 | *:NetBSD:1.[56]*:* | *:NetBSD:[2345].*:* ) |
michael@13 | 356 | n=`/sbin/sysctl -n hw.ncpu` |
michael@13 | 357 | if [ ".$n" != . ]; then |
michael@13 | 358 | if [ $n -gt 1 ]; then |
michael@13 | 359 | n=`expr $n \* 2` |
michael@13 | 360 | mflags="$mflags -j$n" |
michael@13 | 361 | if [ ".$isgmake" = .no ]; then |
michael@13 | 362 | mflags="$mflags -B" |
michael@13 | 363 | fi |
michael@13 | 364 | fi |
michael@13 | 365 | fi |
michael@13 | 366 | ;; |
michael@13 | 367 | *:Linux:*:* ) |
michael@13 | 368 | n=`grep ^processor /proc/cpuinfo | wc -l | awk '{ print $1; }'` |
michael@13 | 369 | if [ ".$n" != . ]; then |
michael@13 | 370 | if [ $n -gt 1 ]; then |
michael@13 | 371 | n=`expr $n \* 2` |
michael@13 | 372 | mflags="$mflags -j$n" |
michael@13 | 373 | fi |
michael@13 | 374 | fi |
michael@13 | 375 | ;; |
michael@13 | 376 | *:HP-UX:*:* ) |
michael@13 | 377 | if [ ".$isgmake" = .yes ]; then |
michael@13 | 378 | n=`ioscan -d processor -k -F | wc -l` |
michael@13 | 379 | if [ ".$n" != . ]; then |
michael@13 | 380 | if [ $n -gt 1 ]; then |
michael@13 | 381 | n=`expr $n \* 2` |
michael@13 | 382 | mflags="$mflags -j$n" |
michael@13 | 383 | fi |
michael@13 | 384 | fi |
michael@13 | 385 | fi |
michael@13 | 386 | ;; |
michael@13 | 387 | *:IRIX64:6.*:* ) |
michael@13 | 388 | if [ ".$isgmake" = .yes ]; then |
michael@13 | 389 | n=`/usr/sbin/sysconf | awk '/NUM_PROCESSORS/ { print $2; }'` |
michael@13 | 390 | if [ ".$n" != . ]; then |
michael@13 | 391 | if [ $n -gt 1 ]; then |
michael@13 | 392 | n=`expr $n \* 2` |
michael@13 | 393 | mflags="$mflags -j$n" |
michael@13 | 394 | fi |
michael@13 | 395 | fi |
michael@13 | 396 | fi |
michael@13 | 397 | ;; |
michael@13 | 398 | *:Darwin:*:* ) |
michael@13 | 399 | n=`/usr/sbin/sysctl hw.ncpu | awk '{ print $3; }'` |
michael@13 | 400 | if [ ".$n" != . ]; then |
michael@13 | 401 | if [ $n -gt 1 ]; then |
michael@13 | 402 | n=`expr $n \* 2` |
michael@13 | 403 | mflags="$mflags -j$n" |
michael@13 | 404 | if [ ".$isgmake" = .no ]; then |
michael@13 | 405 | mflags="$mflags -B" |
michael@13 | 406 | fi |
michael@13 | 407 | fi |
michael@13 | 408 | fi |
michael@13 | 409 | ;; |
michael@13 | 410 | *:AIX:*:* ) |
michael@13 | 411 | if [ ".$isgmake" = .yes ]; then |
michael@13 | 412 | if [ -x /usr/sbin/lsdev ]; then |
michael@13 | 413 | n=`/usr/sbin/lsdev -C -c processor -S available | wc -l | awk '{ print $1; }'` |
michael@13 | 414 | if [ ".$n" != . ]; then |
michael@13 | 415 | if [ $n -gt 1 ]; then |
michael@13 | 416 | n=`expr $n \* 2` |
michael@13 | 417 | mflags="$mflags -j$n" |
michael@13 | 418 | fi |
michael@13 | 419 | fi |
michael@13 | 420 | fi |
michael@13 | 421 | fi |
michael@13 | 422 | ;; |
michael@13 | 423 | esac |
michael@13 | 424 | fi |
michael@13 | 425 | echo "x$mflags" | sed -e 's;^x;;' |
michael@13 | 426 | ;; |
michael@13 | 427 | |
michael@13 | 428 | cflags ) |
michael@13 | 429 | tool="$1" |
michael@13 | 430 | echo $tool | grep ^/ >/dev/null |
michael@13 | 431 | if [ $? -eq 0 ]; then |
michael@13 | 432 | if [ ! -x "$tool" -o -d "$tool" ]; then |
michael@13 | 433 | echo "$msgprefix:Error: specified tool \`$tool' not found or not executable" 1>&2 |
michael@13 | 434 | exit 1 |
michael@13 | 435 | fi |
michael@13 | 436 | else |
michael@13 | 437 | shtool=`echo $prog_path | sed -e 's;/[^/]*$;/shtool;'` |
michael@13 | 438 | sh $shtool path --suppress $tool |
michael@13 | 439 | if [ $? -ne 0 ]; then |
michael@13 | 440 | echo "$msgprefix:Error: specified tool \`$tool' not found in PATH" 1>&2 |
michael@13 | 441 | exit 1 |
michael@13 | 442 | fi |
michael@13 | 443 | fi |
michael@13 | 444 | isgcc=no |
michael@13 | 445 | if [ ".`($tool -v; $tool --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then |
michael@13 | 446 | isgcc=yes |
michael@13 | 447 | fi |
michael@13 | 448 | cflags='' |
michael@13 | 449 | if [ ".$opt_O" = .yes ]; then |
michael@13 | 450 | if [ ".$isgcc" = .yes ]; then |
michael@13 | 451 | case "$platform:`$tool -dumpversion 2>/dev/null`" in |
michael@13 | 452 | *:NetBSD:1.6*:*:2.* ) |
michael@13 | 453 | # NetBSD 1.6.x with GCC 2.95.x suffers from memory |
michael@13 | 454 | # exhaustion problems under GCC optimizations. |
michael@13 | 455 | ;; |
michael@13 | 456 | * ) |
michael@13 | 457 | cflags="-O2" |
michael@13 | 458 | ;; |
michael@13 | 459 | esac |
michael@13 | 460 | if [ ".`$tool -v 2>/dev/null | grep 'with-gnu-as'`" != . ] || \ |
michael@13 | 461 | [ ".`(as --version </dev/null) 2>/dev/null | grep 'GNU'`" != . ]; then |
michael@13 | 462 | cflags="$cflags -pipe" |
michael@13 | 463 | fi |
michael@13 | 464 | else |
michael@13 | 465 | cflags="-O" |
michael@13 | 466 | fi |
michael@13 | 467 | fi |
michael@13 | 468 | case "$platform" in |
michael@13 | 469 | amd64:FreeBSD:*:* | ia64:FreeBSD:*:* | sparc64:FreeBSD:*:* | x86_64:Linux:*:* ) |
michael@13 | 470 | # at least under FreeBSD on amd64, ia64 and sparc64 |
michael@13 | 471 | # the GNU binutils strictly require Position In- |
michael@13 | 472 | # dependent Code (PIC) when Dynamic Shared Objects |
michael@13 | 473 | # (DSO) are involved. As an ugly workaround we |
michael@13 | 474 | # build everything with PIC there, although this is |
michael@13 | 475 | # more than required. We also can assume that the C |
michael@13 | 476 | # compiler is always GCC, either the OpenPKG one or |
michael@13 | 477 | # the FreeBSD one. |
michael@13 | 478 | cflags="-fPIC" |
michael@13 | 479 | ;; |
michael@13 | 480 | esac |
michael@13 | 481 | echo "x$cflags" | sed -e 's;^x;;' |
michael@13 | 482 | ;; |
michael@13 | 483 | |
michael@13 | 484 | cppflags ) |
michael@13 | 485 | std=0 |
michael@13 | 486 | cppflags="" |
michael@13 | 487 | for pkg in .. $*; do |
michael@13 | 488 | [ ".$pkg" = ... ] && continue |
michael@13 | 489 | if [ ".$pkg" = .. ]; then |
michael@13 | 490 | cppflags="$cppflags -I${opt_p}/include" |
michael@13 | 491 | std=1 |
michael@13 | 492 | else |
michael@13 | 493 | cppflags="$cppflags -I${opt_p}/include/$pkg" |
michael@13 | 494 | fi |
michael@13 | 495 | done |
michael@13 | 496 | if [ $std -eq 0 ]; then |
michael@13 | 497 | cppflags="-I${opt_p}/include$cppflags" |
michael@13 | 498 | fi |
michael@13 | 499 | if [ ".$opt_i" = .yes ]; then |
michael@13 | 500 | arch="unknown"; os_name="unknown"; os_vers="0" |
michael@13 | 501 | shtool=`echo $prog_path | sed -e 's;/[^/]*$;/shtool;'` |
michael@13 | 502 | eval `sh $shtool platform -U -S ":" -C "" -F "%<ac>:%<st>" |\ |
michael@13 | 503 | sed -e 's/^\(.*\):\(.*\):\(.*\)$/arch="\1"; os_name="\2"; os_vers="\3";/'` |
michael@13 | 504 | V=0; R=0; L=0 |
michael@13 | 505 | eval `echo "$os_vers" |\ |
michael@13 | 506 | sed -e 's/^/X/' \ |
michael@13 | 507 | -e 's/^X[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\).*$/V="\1"; R="\2"; L="\3";/' \ |
michael@13 | 508 | -e 's/^X[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\).*$/V="\1"; R="\2";/' \ |
michael@13 | 509 | -e 's/^X[^0-9]*\([0-9][0-9]*\).*$/V="\1";/' \ |
michael@13 | 510 | -e 's/^X.*$/:/'` |
michael@13 | 511 | os_vers=`echo . | awk '{ printf("%02d%02d%02d", V, R, L); }' V="$V" R="$R" L="$L"` |
michael@13 | 512 | cppflags="$cppflags -D__OPENPKG_${arch} -D__OPENPKG_${os_name}=${os_vers}" |
michael@13 | 513 | fi |
michael@13 | 514 | echo "x$cppflags" | sed -e 's;^x;;' -e 's;^ *;;' |
michael@13 | 515 | ;; |
michael@13 | 516 | |
michael@13 | 517 | ldflags ) |
michael@13 | 518 | std=0 |
michael@13 | 519 | ldflags="" |
michael@13 | 520 | for pkg in .. $*; do |
michael@13 | 521 | [ ".$pkg" = ... ] && continue |
michael@13 | 522 | if [ ".$pkg" = .. ]; then |
michael@13 | 523 | ldflags="$ldflags -L${opt_p}/lib" |
michael@13 | 524 | std=1 |
michael@13 | 525 | else |
michael@13 | 526 | ldflags="$ldflags -L${opt_p}/lib/$pkg" |
michael@13 | 527 | fi |
michael@13 | 528 | done |
michael@13 | 529 | if [ $std -eq 0 ]; then |
michael@13 | 530 | ldflags="-L${opt_p}/lib$ldflags" |
michael@13 | 531 | fi |
michael@13 | 532 | echo "x$ldflags" | sed -e 's;^x;;' -e 's;^ *;;' |
michael@13 | 533 | ;; |
michael@13 | 534 | |
michael@13 | 535 | files ) |
michael@13 | 536 | # if a Perl interpreter is available, we perform the operation |
michael@13 | 537 | # with it because Perl is a magnitude (factor 10!) faster than |
michael@13 | 538 | # what we can do here in Bourne-Shell. |
michael@13 | 539 | perl='' |
michael@13 | 540 | for dir in `echo "$PATH:@l_prefix@/lib/openpkg" | sed -e 's/:/ /g'` .; do |
michael@13 | 541 | [ ".$dir" = .. -o ".$dir" = . ] && continue |
michael@13 | 542 | for tool in perl5 perl miniperl; do |
michael@13 | 543 | if [ -f "$dir/$tool" ]; then |
michael@13 | 544 | perl="$dir/$tool" |
michael@13 | 545 | break |
michael@13 | 546 | fi |
michael@13 | 547 | done |
michael@13 | 548 | if [ ".$perl" != . ]; then |
michael@13 | 549 | break |
michael@13 | 550 | fi |
michael@13 | 551 | done |
michael@13 | 552 | if [ ".$perl" != . ]; then |
michael@13 | 553 | cat >$tmpfile <<'EOT' |
michael@13 | 554 | ## |
michael@13 | 555 | ## PERL IMPLEMENTATION (FAST) |
michael@13 | 556 | ## |
michael@13 | 557 | |
michael@13 | 558 | my $opt_v = 0; |
michael@13 | 559 | my $opt_o = ''; |
michael@13 | 560 | my $opt_r = ''; |
michael@13 | 561 | while ($ARGV[0] =~ m|^-(.)(.*)$|) { |
michael@13 | 562 | my ($opt, $arg) = ($1, $2); |
michael@13 | 563 | shift(@ARGV); |
michael@13 | 564 | unshift(@ARGV, $arg) if ($arg ne ''); |
michael@13 | 565 | $opt_v = 1 if ($opt eq 'v'); |
michael@13 | 566 | $opt_o = shift(@ARGV) if ($opt eq 'o'); |
michael@13 | 567 | $opt_r = shift(@ARGV) if ($opt eq 'r'); |
michael@13 | 568 | } |
michael@13 | 569 | |
michael@13 | 570 | # remember the build root in a reasonable short variable ;) |
michael@13 | 571 | my $br = "$opt_r"; |
michael@13 | 572 | |
michael@13 | 573 | # read input file list |
michael@13 | 574 | my @L = (); |
michael@13 | 575 | if ($#ARGV == -1 or ($#ARGV == 0 and $ARGV[0] eq "-")) { |
michael@13 | 576 | # read file list from stdin |
michael@13 | 577 | while (<STDIN>) { |
michael@13 | 578 | s/\n$//s; |
michael@13 | 579 | push(@L, $_); |
michael@13 | 580 | } |
michael@13 | 581 | } |
michael@13 | 582 | else { |
michael@13 | 583 | # read file list from argument line |
michael@13 | 584 | @L = @ARGV; |
michael@13 | 585 | } |
michael@13 | 586 | |
michael@13 | 587 | # PASS 1: PREPARATION AND SYNTACTICAL EXPANSION |
michael@13 | 588 | if ($opt_v == 1) { |
michael@13 | 589 | print STDERR "rpmtool:files: pass 1 (preparation and syntactical expansions)\n"; |
michael@13 | 590 | } |
michael@13 | 591 | my @T = (); |
michael@13 | 592 | my $l; |
michael@13 | 593 | foreach $l (@L) { |
michael@13 | 594 | # replace tabs with spaces, reduce multiple spaces to single |
michael@13 | 595 | # spaces, and remove leading and trailing spaces |
michael@13 | 596 | $l =~ s|[ \t\n]+| |sg; |
michael@13 | 597 | $l =~ s|^[ \t]+||sg; |
michael@13 | 598 | $l =~ s|[ \t]+$||sg; |
michael@13 | 599 | |
michael@13 | 600 | # move tags to end of entry for easier parsing |
michael@13 | 601 | 1 while ($l =~ s|^(%\S+) (.+)|$2 $1|); |
michael@13 | 602 | |
michael@13 | 603 | # use `:' as a dummy path for tag-only entries (like `%defattr') |
michael@13 | 604 | # to avoid special cases in the later processing |
michael@13 | 605 | if ($l =~ m|^%.+|) { |
michael@13 | 606 | $l = ": $l"; |
michael@13 | 607 | } |
michael@13 | 608 | |
michael@13 | 609 | # split entry into path and optional tags |
michael@13 | 610 | my ($p, $t) = ($l =~ m|^(\S+)(.*)$|); |
michael@13 | 611 | |
michael@13 | 612 | # expand `{foo,bar,quux}' constructs in path (silent |
michael@13 | 613 | # assumtion to make life easier is that the constructs |
michael@13 | 614 | # occurs only once in a path!) |
michael@13 | 615 | if ($p =~ m|^(.*)\{([^\}]+)\}(.*)$|) { |
michael@13 | 616 | # split path into prolog, the set construct, and the epilog |
michael@13 | 617 | my ($pro, $set, $epi) = ($1, $2, $3); |
michael@13 | 618 | |
michael@13 | 619 | # repeat prolog and epilog for all elements in set |
michael@13 | 620 | my $x; |
michael@13 | 621 | foreach $x (split(/,/, $set)) { |
michael@13 | 622 | push(@T, "${pro}${x}${epi}${t}"); |
michael@13 | 623 | } |
michael@13 | 624 | } |
michael@13 | 625 | else { |
michael@13 | 626 | # else just take over the entry as is |
michael@13 | 627 | push(@T, $l); |
michael@13 | 628 | } |
michael@13 | 629 | } |
michael@13 | 630 | @L = @T; |
michael@13 | 631 | |
michael@13 | 632 | # PASS 2: FILESYSTEM-BASED EXPANSIONS |
michael@13 | 633 | if ($opt_v == 1) { |
michael@13 | 634 | print STDERR "rpmtool:files: pass 2 (filesystem-based expansions)\n"; |
michael@13 | 635 | } |
michael@13 | 636 | @T = (); |
michael@13 | 637 | foreach $l (@L) { |
michael@13 | 638 | # split entry into path and optional tags |
michael@13 | 639 | my ($p, $t) = ($l =~ m|^(\S*)(.*)$|); |
michael@13 | 640 | |
michael@13 | 641 | # expand... |
michael@13 | 642 | if (-d "$br$p" and $t !~ m|.*%dir.*|) { |
michael@13 | 643 | # expand path because it is not tagged with %dir |
michael@13 | 644 | my @X = `cd "$br$p" && find . -print`; |
michael@13 | 645 | my $x; |
michael@13 | 646 | foreach $x (@X) { |
michael@13 | 647 | $x =~ s|\n$||s; |
michael@13 | 648 | $x =~ s|^\.|$p|s; |
michael@13 | 649 | push(@T, "${x}${t}"); |
michael@13 | 650 | } |
michael@13 | 651 | } |
michael@13 | 652 | else { |
michael@13 | 653 | # expand path wildcards (`*' and `[..]') |
michael@13 | 654 | # (if not wildcards are present, this doesn't harm) |
michael@13 | 655 | my @X = glob("$br$p"); |
michael@13 | 656 | my $x; |
michael@13 | 657 | foreach $x (@X) { |
michael@13 | 658 | my $brqm = quotemeta($br); |
michael@13 | 659 | $x =~ s|^$brqm||s; |
michael@13 | 660 | push(@T, "${x}${t}"); |
michael@13 | 661 | } |
michael@13 | 662 | } |
michael@13 | 663 | } |
michael@13 | 664 | @L = @T; |
michael@13 | 665 | |
michael@13 | 666 | # PASS 3: DUPLICATION REMOVAL AND CLEANUP |
michael@13 | 667 | if ($opt_v == 1) { |
michael@13 | 668 | print STDERR "rpmtool:files: pass 3 (duplication removal and cleanup)\n"; |
michael@13 | 669 | } |
michael@13 | 670 | @T = (); |
michael@13 | 671 | foreach $l (@L) { |
michael@13 | 672 | # split entry into path and optional tags |
michael@13 | 673 | my ($p, $t) = ($l =~ m|^(\S*)(.*)$|); |
michael@13 | 674 | |
michael@13 | 675 | # add %dir tag if entry is a directory, but still not |
michael@13 | 676 | # tagged as such (else RPM would again expand it recursively) |
michael@13 | 677 | if (-d "$br$p") { |
michael@13 | 678 | if ($t !~ m|%dir|) { |
michael@13 | 679 | $t .= " %dir"; |
michael@13 | 680 | } |
michael@13 | 681 | } |
michael@13 | 682 | |
michael@13 | 683 | # remove duplicate entries in already processed part |
michael@13 | 684 | # (but make sure we keep the entries with the dummy tags) |
michael@13 | 685 | if ($p ne ":") { |
michael@13 | 686 | my @T2 = (); |
michael@13 | 687 | foreach $t (@T) { |
michael@13 | 688 | my $pqm = quotemeta($p); |
michael@13 | 689 | next if ($t =~ m|^$pqm | or $t eq $p); |
michael@13 | 690 | push(@T2, $t); |
michael@13 | 691 | } |
michael@13 | 692 | @T = @T2; |
michael@13 | 693 | } |
michael@13 | 694 | |
michael@13 | 695 | # keep entry only if no %not tag is present |
michael@13 | 696 | # (else all entries are removed) |
michael@13 | 697 | if ($t !~ m|.*%not.*|) { |
michael@13 | 698 | push(@T, "${p}${t}"); |
michael@13 | 699 | } |
michael@13 | 700 | } |
michael@13 | 701 | @L = @T; |
michael@13 | 702 | |
michael@13 | 703 | # write out new file list |
michael@13 | 704 | @T = (); |
michael@13 | 705 | foreach $l (@L) { |
michael@13 | 706 | $l =~ s|^(\S+) (.*)$|$2 $1|sg; |
michael@13 | 707 | $l =~ s|^\s+||s; |
michael@13 | 708 | $l =~ s|\s+$||s; |
michael@13 | 709 | $l =~ s|\s+:$||s; |
michael@13 | 710 | push(@T, $l); |
michael@13 | 711 | } |
michael@13 | 712 | @L = @T; |
michael@13 | 713 | if ($opt_o eq '' or $opt_o eq '-') { |
michael@13 | 714 | print STDOUT join("\n", @L)."\n"; |
michael@13 | 715 | } |
michael@13 | 716 | else { |
michael@13 | 717 | open(FP, ">$opt_o"); |
michael@13 | 718 | print FP join("\n", @L)."\n"; |
michael@13 | 719 | close(FP); |
michael@13 | 720 | } |
michael@13 | 721 | EOT |
michael@13 | 722 | cmd="$perl $tmpfile"; |
michael@13 | 723 | if [ ".$opt_v" = .yes ]; then |
michael@13 | 724 | cmd="$cmd -v" |
michael@13 | 725 | fi |
michael@13 | 726 | if [ ".$opt_o" != . ]; then |
michael@13 | 727 | cmd="$cmd -o \"$opt_o\"" |
michael@13 | 728 | fi |
michael@13 | 729 | if [ ".$opt_r" != . ]; then |
michael@13 | 730 | cmd="$cmd -r \"$opt_r\"" |
michael@13 | 731 | fi |
michael@13 | 732 | for arg |
michael@13 | 733 | do |
michael@13 | 734 | cmd="$cmd \"$arg\"" |
michael@13 | 735 | done |
michael@13 | 736 | eval "$cmd" |
michael@13 | 737 | else |
michael@13 | 738 | ## |
michael@13 | 739 | ## BOURNE-SHELL IMPLEMENTATION (PORTABLE) |
michael@13 | 740 | ## |
michael@13 | 741 | |
michael@13 | 742 | # remember the build root in a reasonable short variable ;) |
michael@13 | 743 | br="$opt_r" |
michael@13 | 744 | |
michael@13 | 745 | # make sure filename expansion is disabled per default |
michael@13 | 746 | set -f |
michael@13 | 747 | |
michael@13 | 748 | # read input file list |
michael@13 | 749 | L='' |
michael@13 | 750 | if [ $# -eq 0 ] || [ $# -eq 1 -a ".$1" = ".-" ]; then |
michael@13 | 751 | # read file list from stdin |
michael@13 | 752 | L=`cat` |
michael@13 | 753 | else |
michael@13 | 754 | # read file list from argument line |
michael@13 | 755 | for arg |
michael@13 | 756 | do |
michael@13 | 757 | L="$L$NL$arg" |
michael@13 | 758 | done |
michael@13 | 759 | fi |
michael@13 | 760 | |
michael@13 | 761 | # PASS 1: PREPARATION AND SYNTACTICAL EXPANSION |
michael@13 | 762 | if [ ".$opt_v" = .yes ]; then |
michael@13 | 763 | echo "rpmtool:files: pass 1 (preparation and syntactical expansions)" 1>&2 |
michael@13 | 764 | fi |
michael@13 | 765 | T='' |
michael@13 | 766 | OIFS="$IFS"; IFS="$NL" |
michael@13 | 767 | for l in $L; do |
michael@13 | 768 | [ ".$l" = . ] && continue |
michael@13 | 769 | |
michael@13 | 770 | # replace tabs with spaces, reduce multiple spaces to single |
michael@13 | 771 | # spaces, and remove leading and trailing spaces |
michael@13 | 772 | l=`echo "$l" | sed -e "s;${TAB}; ;g" -e 's; *; ;g' -e 's;^ *;;' -e 's; *$;;'` |
michael@13 | 773 | |
michael@13 | 774 | # move tags to end of entry for easier parsing |
michael@13 | 775 | while [ ".`echo \"$l\" | grep '^%[^ ]* .*'`" != . ]; do |
michael@13 | 776 | l=`echo "$l" | sed -e 's;^\(%[^ ]*\) \(.*\);\2 \1;'` |
michael@13 | 777 | done |
michael@13 | 778 | |
michael@13 | 779 | # use `:' as a dummy path for tag-only entries (like `%defattr') |
michael@13 | 780 | # to avoid special cases in the later processing |
michael@13 | 781 | if [ ".`echo \"$l\" | grep '^%.*'`" != . ]; then |
michael@13 | 782 | l=": $l" |
michael@13 | 783 | fi |
michael@13 | 784 | |
michael@13 | 785 | # split entry into path and optional tags |
michael@13 | 786 | eval `echo ".$l" | sed -e 's;^\.\([^ ]*\)\(.*\)$;p="\1" t="\2";'` |
michael@13 | 787 | |
michael@13 | 788 | # expand `{foo,bar,quux}' constructs in path (silent |
michael@13 | 789 | # assumtion to make life easier is that the constructs |
michael@13 | 790 | # occurs only once in a path!) |
michael@13 | 791 | if [ ".`echo \".$p\" | grep '^\..*{[^}]*}.*$'`" != . ]; then |
michael@13 | 792 | |
michael@13 | 793 | # split path into prolog, the set construct, and the epilog |
michael@13 | 794 | eval `echo ".$p" | sed -e 's;^\.\(.*\){\([^}]*\)}\(.*\)$;pro="\1" set="\2" epi="\3";'` |
michael@13 | 795 | |
michael@13 | 796 | # repeat prolog and epilog for all elements in set |
michael@13 | 797 | OIFS2="$IFS"; IFS="," |
michael@13 | 798 | for x in $set; do |
michael@13 | 799 | T="$T$NL${pro}${x}${epi}${t}" |
michael@13 | 800 | done |
michael@13 | 801 | IFS="$OIFS2" |
michael@13 | 802 | else |
michael@13 | 803 | # else just take over the entry as is |
michael@13 | 804 | T="$T$NL$l" |
michael@13 | 805 | fi |
michael@13 | 806 | done |
michael@13 | 807 | L="$T" |
michael@13 | 808 | IFS="$OIFS" |
michael@13 | 809 | |
michael@13 | 810 | # PASS 2: FILESYSTEM-BASED EXPANSIONS |
michael@13 | 811 | if [ ".$opt_v" = .yes ]; then |
michael@13 | 812 | echo "rpmtool:files: pass 2 (filesystem-based expansions)" 1>&2 |
michael@13 | 813 | fi |
michael@13 | 814 | T='' |
michael@13 | 815 | OIFS="$IFS"; IFS="$NL" |
michael@13 | 816 | for l in $L; do |
michael@13 | 817 | [ ".$l" = . ] && continue |
michael@13 | 818 | |
michael@13 | 819 | # split entry into path and optional tags |
michael@13 | 820 | eval `echo ".$l" | sed -e 's;^\.\([^ ]*\)\(.*\)$;p="\1" t="\2";'` |
michael@13 | 821 | |
michael@13 | 822 | # expand... |
michael@13 | 823 | if [ -d "$br$p" -a ".`expr \".$t\" : '\..*%dir.*'`" = .0 ]; then |
michael@13 | 824 | # expand path because it is not tagged with %dir |
michael@13 | 825 | OIFS2="$IFS"; IFS="$DIFS" |
michael@13 | 826 | for x in `cd "$br$p" && find . -print | sed -e "s;^\\.;$p;"`; do |
michael@13 | 827 | T="$T$NL${x}${t}" |
michael@13 | 828 | done |
michael@13 | 829 | IFS="$OIFS2" |
michael@13 | 830 | else |
michael@13 | 831 | # expand path wildcards (`*' and `[..]') |
michael@13 | 832 | # (if not wildcards are present, this doesn't harm) |
michael@13 | 833 | OIFS2="$IFS"; IFS="$DIFS" |
michael@13 | 834 | for x in `(set +f; echo $br$p) | sed -e "s;^$br;;" -e "s; $br; ;g"`; do |
michael@13 | 835 | T="$T$NL${x}${t}" |
michael@13 | 836 | done |
michael@13 | 837 | IFS="$OIFS2" |
michael@13 | 838 | fi |
michael@13 | 839 | done |
michael@13 | 840 | IFS="$OIFS" |
michael@13 | 841 | L="$T" |
michael@13 | 842 | |
michael@13 | 843 | # PASS 3: DUPLICATION REMOVAL AND CLEANUP |
michael@13 | 844 | if [ ".$opt_v" = .yes ]; then |
michael@13 | 845 | echo "rpmtool:files: pass 3 (duplication removal and cleanup)" 1>&2 |
michael@13 | 846 | fi |
michael@13 | 847 | T='' |
michael@13 | 848 | OIFS="$IFS"; IFS="$NL" |
michael@13 | 849 | for l in $L; do |
michael@13 | 850 | [ ".$l" = . ] && continue |
michael@13 | 851 | |
michael@13 | 852 | # split entry into path and optional tags |
michael@13 | 853 | eval `echo ".$l" | sed -e 's;^\.\([^ ]*\)\(.*\)$;p="\1" t="\2";'` |
michael@13 | 854 | |
michael@13 | 855 | # add %dir tag if entry is a directory, but still not |
michael@13 | 856 | # tagged as such (else RPM would again expand it recursively) |
michael@13 | 857 | if [ -d "$br$p" ]; then |
michael@13 | 858 | if [ ".`expr \".$t\" : '\..*%dir.*'`" = .0 ]; then |
michael@13 | 859 | t="$t %dir" |
michael@13 | 860 | fi |
michael@13 | 861 | fi |
michael@13 | 862 | |
michael@13 | 863 | # remove duplicate entries in already processed part |
michael@13 | 864 | # (but make sure we keep the entries with the dummy tags) |
michael@13 | 865 | if [ ".$p" != ".:" ]; then |
michael@13 | 866 | T=`echo "$T" | grep -v "^$p " | grep -v "^$p\$"` |
michael@13 | 867 | fi |
michael@13 | 868 | |
michael@13 | 869 | # keep entry only if no %not tag is present |
michael@13 | 870 | # (else all entries are removed) |
michael@13 | 871 | if [ ".`expr \".$t\" : '\..*%not.*'`" = .0 ]; then |
michael@13 | 872 | T="$T$NL${p}${t}" |
michael@13 | 873 | fi |
michael@13 | 874 | done |
michael@13 | 875 | IFS="$OIFS" |
michael@13 | 876 | L="$T" |
michael@13 | 877 | |
michael@13 | 878 | # write out new file list |
michael@13 | 879 | if [ ".$opt_o" = . -o ".$opt_o" = ".-" ]; then |
michael@13 | 880 | outcmd="cat" |
michael@13 | 881 | else |
michael@13 | 882 | outcmd="cat > $opt_o" |
michael@13 | 883 | fi |
michael@13 | 884 | echo "$L" |\ |
michael@13 | 885 | sed -e '/^$/d' \ |
michael@13 | 886 | -e 's;^\([^ ]*\) *\(.*\)$;\2 \1;g' \ |
michael@13 | 887 | -e 's;^ *;;' \ |
michael@13 | 888 | -e 's; *$;;' \ |
michael@13 | 889 | -e 's; *:$;;' | eval $outcmd |
michael@13 | 890 | fi |
michael@13 | 891 | ;; |
michael@13 | 892 | |
michael@13 | 893 | signal ) |
michael@13 | 894 | if [ ".$opt_p" = . -a ".$opt_m" = . ]; then |
michael@13 | 895 | echo "$msgprefix:Error: either option -p or -m has to be specified" 1>&2 |
michael@13 | 896 | exit 1 |
michael@13 | 897 | fi |
michael@13 | 898 | case "$platform" in |
michael@13 | 899 | *:FreeBSD:*:* | *:NetBSD:*:* ) |
michael@13 | 900 | cmd0="ps -ax -o pid" |
michael@13 | 901 | cmd1="ps -ax -o command" |
michael@13 | 902 | cmd2="ps -ax -o pid,command" |
michael@13 | 903 | cmd3="ps -ax -o pid,ppid" |
michael@13 | 904 | ;; |
michael@13 | 905 | *:Linux:*:* | *:OSF1:5.*:* ) |
michael@13 | 906 | cmd0="ps axo pid" |
michael@13 | 907 | cmd1="ps axo cmd" |
michael@13 | 908 | cmd2="ps axo pid,cmd" |
michael@13 | 909 | cmd3="ps axo pid,ppid" |
michael@13 | 910 | ;; |
michael@13 | 911 | *:SunOS:5.*:* ) |
michael@13 | 912 | cmd0="ps -ef -o pid" |
michael@13 | 913 | cmd1="ps -ef -o args" |
michael@13 | 914 | cmd2="ps -ef -o pid,args" |
michael@13 | 915 | cmd3="ps -ef -o pid,ppid" |
michael@13 | 916 | ;; |
michael@13 | 917 | *:HP-UX:*:* ) |
michael@13 | 918 | cmd0="ps -ef" # FIXME |
michael@13 | 919 | cmd1="ps -ef" # FIXME |
michael@13 | 920 | cmd2="ps -ef" # FIXME |
michael@13 | 921 | cmd3="ps -ef" # FIXME |
michael@13 | 922 | ;; |
michael@13 | 923 | *:IRIX64:6.*:* ) |
michael@13 | 924 | cmd0="ps -ef -o pid" |
michael@13 | 925 | cmd1="ps -ef -o args" |
michael@13 | 926 | cmd2="ps -ef -o pid,args" |
michael@13 | 927 | cmd3="ps -ef -o pid,ppid" |
michael@13 | 928 | ;; |
michael@13 | 929 | *:Darwin:*:* ) |
michael@13 | 930 | cmd0="ps -ax -opid" |
michael@13 | 931 | cmd1="ps -ax -ocommand" |
michael@13 | 932 | cmd2="ps -ax -opid,command" |
michael@13 | 933 | cmd3="ps -ax -opid,ppid" |
michael@13 | 934 | esac |
michael@13 | 935 | # try all signals in order |
michael@13 | 936 | i=$# |
michael@13 | 937 | for sig in "$@"; do |
michael@13 | 938 | # check whether program is still running/active |
michael@13 | 939 | active="" |
michael@13 | 940 | if [ ".$opt_p" != . ]; then |
michael@13 | 941 | active=`$cmd0 | grep "$opt_p" | grep -v grep | grep -v rpmtool` |
michael@13 | 942 | elif [ ".$opt_m" != . ]; then |
michael@13 | 943 | active=`$cmd1 | grep "$opt_m" | grep -v grep | grep -v rpmtool` |
michael@13 | 944 | fi |
michael@13 | 945 | if [ ".$active" = . ]; then |
michael@13 | 946 | break |
michael@13 | 947 | fi |
michael@13 | 948 | |
michael@13 | 949 | # send signal to program |
michael@13 | 950 | if [ ".$opt_p" != . ]; then |
michael@13 | 951 | pids="$opt_p" |
michael@13 | 952 | elif [ ".$opt_m" != . ]; then |
michael@13 | 953 | pids=`$cmd2 | sed -e "s;^[ ${TAB}]*;;" | egrep "[0-9]* .*$opt_m" |\ |
michael@13 | 954 | grep -v grep | grep -v rpmtool |\ |
michael@13 | 955 | awk '{ printf("%s\n", $1); }'` |
michael@13 | 956 | fi |
michael@13 | 957 | for pid in $pids; do |
michael@13 | 958 | if [ ".$opt_v" = .yes ]; then |
michael@13 | 959 | echo "sending $sig signal to process $pid" |
michael@13 | 960 | fi |
michael@13 | 961 | if [ ".$opt_t" = .yes ]; then |
michael@13 | 962 | echo "kill -$sig $pid" |
michael@13 | 963 | fi |
michael@13 | 964 | if [ ".$opt_n" = .no ]; then |
michael@13 | 965 | eval "kill -$sig $pid" |
michael@13 | 966 | fi |
michael@13 | 967 | done |
michael@13 | 968 | |
michael@13 | 969 | # optionally send signal to childs of program |
michael@13 | 970 | if [ ".$opt_c" = .yes ]; then |
michael@13 | 971 | for pid in $pids; do |
michael@13 | 972 | cpids=`$cmd3 | sed -e "s;^[ ${TAB}]*;;" | egrep "[0-9]* $pid" |\ |
michael@13 | 973 | grep -v grep | grep -v rpmtool |\ |
michael@13 | 974 | awk '{ printf("%s\n", $1); }'` |
michael@13 | 975 | for cpid in $cpids; do |
michael@13 | 976 | if [ ".$opt_v" = .yes ]; then |
michael@13 | 977 | echo "sending $sig signal to child process $cpid" |
michael@13 | 978 | fi |
michael@13 | 979 | if [ ".$opt_t" = .yes ]; then |
michael@13 | 980 | echo "kill -$sig $cpid" |
michael@13 | 981 | fi |
michael@13 | 982 | if [ ".$opt_n" = .no ]; then |
michael@13 | 983 | eval "kill -$sig $cpid >/dev/null 2>&1" |
michael@13 | 984 | fi |
michael@13 | 985 | done |
michael@13 | 986 | done |
michael@13 | 987 | fi |
michael@13 | 988 | |
michael@13 | 989 | # perform optional delay |
michael@13 | 990 | i=`expr $i - 1` |
michael@13 | 991 | if [ $i -gt 0 ]; then |
michael@13 | 992 | if [ ".$opt_d" != . -a ".$opt_d" != . ]; then |
michael@13 | 993 | sleep $opt_d |
michael@13 | 994 | fi |
michael@13 | 995 | fi |
michael@13 | 996 | done |
michael@13 | 997 | ;; |
michael@13 | 998 | |
michael@13 | 999 | config ) |
michael@13 | 1000 | # usage consistency |
michael@13 | 1001 | if [ ".$opt_a" = .no -a ".$opt_r" = .no ]; then |
michael@13 | 1002 | echo "$msgprefix:Error: either option -a or -r has to be specified" 1>&2 |
michael@13 | 1003 | exit 1 |
michael@13 | 1004 | fi |
michael@13 | 1005 | configfile="$1" |
michael@13 | 1006 | |
michael@13 | 1007 | # determine block markers |
michael@13 | 1008 | block_start="${opt_p}<${opt_t}" |
michael@13 | 1009 | if [ ".$opt_i" != . ]; then |
michael@13 | 1010 | block_start="${block_start} id=\"${opt_i}\"" |
michael@13 | 1011 | fi |
michael@13 | 1012 | block_start="${block_start}>" |
michael@13 | 1013 | block_end="${opt_p}</${opt_t}>" |
michael@13 | 1014 | |
michael@13 | 1015 | # slash-escaped versions of block markers (for sed(3) call) |
michael@13 | 1016 | block_start_esc=`echo "$block_start" | sed -e 's;/;\\\\/;g'` |
michael@13 | 1017 | block_end_esc=`echo "$block_end" | sed -e 's;/;\\\\/;g'` |
michael@13 | 1018 | |
michael@13 | 1019 | # determine backup extension |
michael@13 | 1020 | case "X$opt_b" in |
michael@13 | 1021 | X ) ext=".bak" ;; |
michael@13 | 1022 | X.* ) ext="$opt_b" ;; |
michael@13 | 1023 | X* ) ext=".$opt_b" ;; |
michael@13 | 1024 | esac |
michael@13 | 1025 | |
michael@13 | 1026 | # check for block in config file |
michael@13 | 1027 | if [ -f $configfile ]; then |
michael@13 | 1028 | check=`grep "^${block_start}" $configfile` |
michael@13 | 1029 | else |
michael@13 | 1030 | touch $configfile |
michael@13 | 1031 | check="" |
michael@13 | 1032 | fi |
michael@13 | 1033 | |
michael@13 | 1034 | # add entry |
michael@13 | 1035 | if [ ".$opt_a" = .yes ]; then |
michael@13 | 1036 | if [ ".$check" != . ]; then |
michael@13 | 1037 | if [ ".$opt_s" = .yes ]; then |
michael@13 | 1038 | exit 0 |
michael@13 | 1039 | else |
michael@13 | 1040 | echo "$msgprefix:Error: config entry already exists" 1>&2 |
michael@13 | 1041 | exit 1 |
michael@13 | 1042 | fi |
michael@13 | 1043 | fi |
michael@13 | 1044 | cp $configfile $configfile$ext |
michael@13 | 1045 | echo "${block_start}" >$tmpfile |
michael@13 | 1046 | cat >>$tmpfile |
michael@13 | 1047 | echo "${block_end}" >>$tmpfile |
michael@13 | 1048 | cat $tmpfile >>$configfile |
michael@13 | 1049 | |
michael@13 | 1050 | # remove entry |
michael@13 | 1051 | elif [ ".$opt_r" = .yes ]; then |
michael@13 | 1052 | if [ ".$check" = . ]; then |
michael@13 | 1053 | if [ ".$opt_s" = .yes ]; then |
michael@13 | 1054 | exit 0 |
michael@13 | 1055 | else |
michael@13 | 1056 | echo "$msgprefix:Error: config entry does not exist" 1>&2 |
michael@13 | 1057 | exit 1 |
michael@13 | 1058 | fi |
michael@13 | 1059 | fi |
michael@13 | 1060 | cp $configfile $configfile$ext |
michael@13 | 1061 | sed -e "/^${block_start_esc}/,/^${block_end_esc}/d" \ |
michael@13 | 1062 | <$configfile$ext >$configfile |
michael@13 | 1063 | fi |
michael@13 | 1064 | |
michael@13 | 1065 | # verbosity |
michael@13 | 1066 | if [ ".$opt_v" = .yes ]; then |
michael@13 | 1067 | (diff -u1 $configfile$ext $configfile >$tmpfile) 2>/dev/null |
michael@13 | 1068 | if [ ".`cat $tmpfile`" = . ]; then |
michael@13 | 1069 | (diff -C1 $configfile$ext $configfile >$tmpfile) 2>/dev/null |
michael@13 | 1070 | if [ ".`cat $tmpfile`" = . ]; then |
michael@13 | 1071 | if [ ".$opt_s" = .no ]; then |
michael@13 | 1072 | echo "$msgprefix:Warning: unable to show difference for config file \`$configfile'" 1>&2 |
michael@13 | 1073 | fi |
michael@13 | 1074 | fi |
michael@13 | 1075 | fi |
michael@13 | 1076 | echo "editing $configfile:" |
michael@13 | 1077 | cat $tmpfile |
michael@13 | 1078 | fi |
michael@13 | 1079 | |
michael@13 | 1080 | # optionally remove backup file |
michael@13 | 1081 | if [ ".$opt_b" = . ]; then |
michael@13 | 1082 | rm -f $configfile$ext |
michael@13 | 1083 | fi |
michael@13 | 1084 | ;; |
michael@13 | 1085 | |
michael@13 | 1086 | msg ) |
michael@13 | 1087 | # optionally beep before message |
michael@13 | 1088 | if [ ".$opt_b" = .yes ]; then |
michael@13 | 1089 | echo . | awk '{ printf("%c", 7); }' |
michael@13 | 1090 | fi |
michael@13 | 1091 | title="" |
michael@13 | 1092 | case $opt_t in |
michael@13 | 1093 | info ) title="-------" ;; |
michael@13 | 1094 | notice ) title="Notice-" ;; |
michael@13 | 1095 | warn ) title="Warning" ;; |
michael@13 | 1096 | error ) title="Error--" ;; |
michael@13 | 1097 | * ) echo "$msgprefix:Error: invalid message type \`$opt_t'" 1>&2; exit 1 ;; |
michael@13 | 1098 | esac |
michael@13 | 1099 | |
michael@13 | 1100 | # display message |
michael@13 | 1101 | if [ ".$opt_r" != .yes ]; then |
michael@13 | 1102 | echo . | awk '{ printf("\r"); }' |
michael@13 | 1103 | fi |
michael@13 | 1104 | echo "+----------------------------------${title}------------------------------------+" |
michael@13 | 1105 | expand -t 8 | sed -e 's; *$;;' | awk '{ printf("| %-75s |\n", substr($0, 0, 75)); }' |
michael@13 | 1106 | echo "+-----------------------------------------------------------------------------+" |
michael@13 | 1107 | ;; |
michael@13 | 1108 | check-class ) |
michael@13 | 1109 | # check package class from within .spec file macro expansion for %prep section |
michael@13 | 1110 | class="$1"; shift |
michael@13 | 1111 | case "$class" in |
michael@13 | 1112 | CORE|BASE ) |
michael@13 | 1113 | ;; |
michael@13 | 1114 | PLUS ) |
michael@13 | 1115 | echo "set +x" |
michael@13 | 1116 | ( echo "This OpenPKG package is of class PLUS." |
michael@13 | 1117 | echo "This means it is still in extended QUALITY ASSURANCE state." |
michael@13 | 1118 | echo "Hence it is still NOT ready for careless use." |
michael@13 | 1119 | echo "Do not use it in critical production environments." |
michael@13 | 1120 | echo "It might be still potentially unstable under run-time." |
michael@13 | 1121 | ) | sh $prog_path msg -r -t notice | sed -e 's;^;echo ";' -e 's;$;";' |
michael@13 | 1122 | echo "set -x" |
michael@13 | 1123 | ;; |
michael@13 | 1124 | EVAL ) |
michael@13 | 1125 | echo "set +x" |
michael@13 | 1126 | ( echo "This OpenPKG package is of class EVAL." |
michael@13 | 1127 | echo "This means it is still in EVALUATION and QUALITY ASSURANCE state." |
michael@13 | 1128 | echo "Hence it is still NOT ready for general use." |
michael@13 | 1129 | echo "Do not use it in production environments." |
michael@13 | 1130 | echo "It might be unstable under run-time or still incompletely packaged." |
michael@13 | 1131 | ) | sh $prog_path msg -r -t warn | sed -e 's;^;echo ";' -e 's;$;";' |
michael@13 | 1132 | echo "set -x" |
michael@13 | 1133 | ;; |
michael@13 | 1134 | JUNK ) |
michael@13 | 1135 | echo "set +x" |
michael@13 | 1136 | ( echo "This OpenPKG package is of class JUNK." |
michael@13 | 1137 | echo "This means it is still in DEVELOPMENT state." |
michael@13 | 1138 | echo "Hence it is still NOT ready even for general evaluation." |
michael@13 | 1139 | echo "Do not use it at all, except in development environments!" |
michael@13 | 1140 | echo "It is definitely unstable and incompletely packaged." |
michael@13 | 1141 | ) | sh $prog_path msg -r -t warn | sed -e 's;^;echo ";' -e 's;$;";' |
michael@13 | 1142 | echo "set -x" |
michael@13 | 1143 | ;; |
michael@13 | 1144 | esac |
michael@13 | 1145 | ;; |
michael@13 | 1146 | esac |
michael@13 | 1147 | |
michael@13 | 1148 | # cleanup |
michael@13 | 1149 | if [ ".$gen_tmpfile" = .yes ]; then |
michael@13 | 1150 | rm -f $tmpfile >/dev/null 2>&1 |
michael@13 | 1151 | fi |
michael@13 | 1152 | |
michael@13 | 1153 | # die gracefully ;) |
michael@13 | 1154 | exit 0 |
michael@13 | 1155 |