steffen: server obmtool,1.1,1.2

cvs at intevation.de cvs at intevation.de
Sun Apr 18 00:35:36 CEST 2004


Author: steffen

Update of /kolabrepository/server
In directory doto:/tmp/cvs-serv14280

Modified Files:
	obmtool 
Log Message:
new obmtool and version bump

Index: obmtool
===================================================================
RCS file: /kolabrepository/server/obmtool,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- obmtool	4 Apr 2004 20:36:50 -0000	1.1
+++ obmtool	17 Apr 2004 22:35:34 -0000	1.2
@@ -1,23 +1,18 @@
 #!/bin/sh
 ##
 ##  obmtool -- OpenPKG poor man's Boot, Build & Management Tool
-##  based on Ralf S. Engelschall's "obmtool -- Development Tool"
+##  based on Ralf S. Engelschall's "devtool -- Development Tool"
 ##  Copyright (c) 2003 Thomas Lotterer <thomas at lotterer.net>
+##   Id: obmtool,v 1.37 2004/04/06 21:40:36 thl cvs.ZfOS.org
 ##  $Id$
 ##
 
 #   default parameters
 prg="$0"
-silent=0
-verbose=0
-debug=0
-help=0
-query=0
-force=0
-file=""
-logs=""
-cmd=""
-cmdargs=""
+silent=0; verbose=0; debug=0; help=0
+query=0; force=0
+conf=""; logs=""; tmpdir=""
+tmpfile=""; cmd=""; cmdargs=""
 
 #   iterate over argument line
 while [ $# -gt 0 ]; do
@@ -26,7 +21,7 @@
     arg=`echo "${opt}" | sed -e 's;^[^=]*=*;;'`
     num=`echo "${arg}" | sed -e 's;^ *\([0-9]*\).*$;\1;'`
     opt=`echo "${opt}" | sed -e 's;=.*$;;'`
-    [ ".${debug}" = .1 ] && echo "DEBUG: main: opt=$opt, arg=$arg, num=$num" #FIXME
+    [ ".${debug}" = .1 ] && echo "DEBUG: main: opt=$opt, arg=$arg, num=$num"
     [ ".${num}" = . ] && num=1
     case $opt in
         -s|--silent    )  silent=${num} ;;
@@ -41,7 +36,7 @@
                                   conf="$1"
                               fi
                           else
-                              file="${arg}"
+                              conf="${arg}"
                           fi ;;
         -l|--logs      )  if [ ".${arg}" = . ]; then
                               if [ ".$2" != . ]; then
@@ -51,13 +46,23 @@
                           else
                               logs="${arg}"
                           fi ;;
+        -t|--tmpdir    )  if [ ".${arg}" = . ]; then
+                              if [ ".$2" != . ]; then
+                                  shift 2>/dev/null
+                                  tmpdir="$1"
+                              fi
+                          else
+                              tmpdir="${arg}"
+                          fi ;;
         -*             )  help="ERROR" ;;
         *              )  break;
     esac
     shift
 done
 cmd="$1"
-if [ ".$1" != . ]; then
+if [ ".$1" = . ]; then
+    help="ERROR"
+else
     shift
 fi
 cmdargs="$@"
@@ -66,7 +71,7 @@
 if [ ".$help" != .0 ]; then
     echo "obmtool:$help: obmtool [-s|--silent] [-v|--verbose] [-d|--debug] [-h|--help]" 1>&2
     echo "                       [-q|--query] [-f|--force]" 1>&2
-    echo "                       [-c|--conf <file>] [-l|--logs <dir>]" 1>&2
+    echo "                       [-c|--conf <file>] [-l|--logs <dir>] [-t|--tmpdir <dir>]" 1>&2
     echo "                       <cmd> [<arg> ...]" 1>&2
     if [ ".$help" = "USAGE" ]; then
         exit 0
@@ -75,36 +80,56 @@
     fi
 fi
 
-#   check for configuration file
-if [ ".${file}" = . ]; then
-    file="`echo ${prg} | sed -e 's;^.*/;./;'`.conf"
+#   compute reasonable defaults for omitted optional arguments
+[ ".${conf}" = . ] && conf="`echo ${prg} | sed -e 's;^.*/;./;'`.conf"
+[ ".$tmpdir" = . ] && tmpdir="${TMPDIR:-/tmp}"
+
+#   compute scratch file name
+tmpfile="$tmpdir/obmtool.$$.tmp"
+
+#   dump debug data
+if [ ".${debug}" = .1 ]; then
+    echo "DEBUG: main: prg=\"$prg\"";
+    echo "DEBUG: main: silent=\"$silent\" verbose=\"$verbose\" debug=\"$debug\" help=\"$help\"";
+    echo "DEBUG: main: query=\"$query\" force=\"$force\"";
+    echo "DEBUG: main: conf=\"$conf\" logs=\"$logs\" tmpdir=\"$tmpdir\"";
+    echo "DEBUG: main: cmd=\"$cmd\" cmdargs=\"$cmdargs\"";
 fi
-if [ ! -r ${file} ]; then
-    file=
-    echo "obmtool:ERROR: configuration file ${file} not readable" 1>&2
+
+#   check whether configuration file is readable
+if [ ! -r ${conf} ]; then
+    echo "obmtool:ERROR: configuration file ${conf} not readable" 1>&2
     exit 1
 fi
-[ ".${debug}" = .1 ] && echo "DEBUG: main: prg=\"$prg\" silent=\"$silent\" verbose=\"$verbose\" debug=\"$debug\" help=\"$help\" query=\"$query\" force=\"$force\" file=\"$file\" logs=\"$logs\" cmd=\"$cmd\" cmdargs=\"$cmdargs\""; #FIXME
 
-cmdline=`grep "^%${cmd}" ${file}`
+#   check whether command in configuration file exists
+cmdline=`grep "^%${cmd}$" ${conf}`
 if [ ".$cmdline" = . ]; then
-    echo "obmtool:ERROR: command ${cmd} not found in configuration file ${file}" 1>&2
+    echo "obmtool:ERROR: command ${cmd} not found in configuration file ${conf}" 1>&2
     exit 1
 fi
 
-tmpdir="/tmp"; [ ".$TMPDIR" != . ] && tmpdir="$TMPDIR"
-tmpfile="$tmpdir/rc.$$.tmp"
-rm -f $tmpfile
+#   check whether tmpdir exists
+if [ ! -d "$tmpdir" ]; then
+    echo "obmtool:ERROR: tmpdir \"$tmpdir\" does not exist" 1>&2
+    exit 1
+fi
+
+#   create script using name $tmpfile, pass through critical variables by exporting them and run script
+rm -f $tmpfile 2>&1 1>/dev/null || true
 (
     sed <"${prg}" -e '1,/^##  obmtool.func {/d' -e '/^##  } obmtool.func/,$d';
     echo "    @prolog";
-    sed <"${file}" -e "1,/^%common/d" -e '/^%.*/,$d';
+    sed <"${conf}" -e "1,/^%common/d" -e '/^%.*/,$d';
     echo "    @epilog";
-    sed <"${file}" -e "1,/^%${cmd}/d" -e '/^%.*/,$d'
+    sed <"${conf}" -e "1,/^%${cmd} *$/d" -e '/^%.*/,$d'
 ) \
-| sed -e 's;^\(.*[ 	]*\)@\([a-z].*\)$;\1obmtool_\2;' >$tmpfile
-#i $tmpfile
-export prg silent verbose debug help query force file logs cmd cmdargs tmpfile tmpdir
+| sed -e 's;^\([ 	]*\)@\([a-z].*\)$;\1obmtool_\2;' >$tmpfile
+export prg
+export silent verbose debug help
+export query force
+export conf logs tmpdir
+export tmpfile cmd cmdargs
 sh $tmpfile
 rc=$?
 rm -f $tmpfile
@@ -112,19 +137,68 @@
 
 ##  obmtool.func { # is now embedded. This line used as cutting point. Do not remove.
 
-##  
+##
 ##  obmtool.func -- OpenPKG poor man's Boot, Build & Management Tool Functions
 ##  based on Ralf S. Engelschall's "obmtool.func -- Development Tool Functions"
 ##  Copyright (c) 2003 Thomas Lotterer <thomas at lotterer.net>
 ##
 
+ at mkdirp ()
+{
+    (
+        p=`echo "$1" | sed -e 's;^/;;'`
+        IFS="/"
+        d="/"
+        for i in $p; do
+            d="$d$i"
+            [ -d "$d" ] || mkdir "$d" || exit 1
+            d="$d/"
+        done
+        exit 0
+    )
+    return $?
+}
+
+#   find a tool; works like which(1) but vendor neutral and sets TOOL variable
+ at findtool ()
+{
+    TOOL=""
+    for _tool in $*; do
+        _ifs="$IFS"; IFS=":"
+        for _path in $PATH; do
+            if [ -f "$_path/$_tool" ]; then
+                TOOL="$_path/$_tool"
+                break
+            fi
+        done
+        IFS="$_ifs"; unset _ifs
+        if [ ".$TOOL" != . ]; then
+            break
+        fi
+    done
+}
+
+ at rpm ()
+{
+    if [ -x ${PREFIX}/bin/rpm -a ! -x ${PREFIX}/libexec/openpkg/rpm ]; then
+        MPX=""
+        RPM="${PREFIX}/bin/rpm"
+    elif [ -x ${PREFIX}/bin/openpkg -a -x ${PREFIX}/libexec/openpkg/rpm ]; then
+        MPX="${PREFIX}/bin/openpkg"
+        RPM="rpm"
+    else
+        MPX=""
+        RPM=""
+    fi
+}
+
 #locate package
 #   supports CURRENT and STABLE trunk - autodetected by release id
 #   supports RELEASE and SOLID updates - autodetected by release id
 #   supports PLUS packages - prefix with '+'
 #   supports packages in CWD - prefix with './'
 #   supports private repository - prefix with '=' and set URL
-#   
+#
 @locate ()
 {
     LOC="."
@@ -194,8 +268,8 @@
     @locate "$@"
     echo "wiperpm ${PKG}"
     if [ ".$CHECKONLY" != ".yes" ]; then
-        if [ -f ${PREFIX}/RPM/PKG/${PKG}.*-${TAG}.rpm ]; then
-            rm ${PREFIX}/RPM/PKG/${PKG}.*-${TAG}.rpm
+        if [ -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
+            rm -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>/dev/null || true
         fi
     fi
 }
@@ -205,33 +279,68 @@
 {
     @locate "$@"
     shift
+    #   FIXME compensate architectural bug of obmtool 1.3[12] placing .src.rpm files into RPM/SRC
+    if [ -f ${PREFIX}/RPM/SRC/${PKG}.src.rpm ]; then
+        if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+            mv ${PREFIX}/RPM/SRC/${PKG}.src.rpm ${PREFIX}/RPM/PKG/${PKG}.src.rpm 2>/dev/null || true
+        fi
+        rm -f ${PREFIX}/RPM/SRC/${PKG}.src.rpm 2>/dev/null || true
+    fi
     if [ ".$CHECKONLY" != ".yes" ]; then
+        @sanity
+        @rpm
         if [ ".${TERM}" = .xterm ]; then
             echo "]0;`uname -n | sed -e 's;\..*$;;'` rebuild ${PKG} [`date '+%Y-%m-%d %H:%M:%S'`]rebuild ${PKG}"
         else
             echo "rebuild ${PKG}"
         fi
-        if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm -a ! -f ./${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
-            if [ -f ${HOME}/.rpmmacros ]; then
-                echo "obmtool:ERROR: rebuild() detected a \"${HOME}/.rpmmacros\". Please remove it." 1>&2
-                exit 1
+        #   download binary RPM only from local location
+        if [ ".${MPX}${RPM}" != . -a ! -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm -a ".${LOC}" = ..  ]; then
+            @fetch ${LOC}/${PKG}.${ARCH}-${OS}-${TAG}.rpm ${PREFIX}/RPM/PKG/
+            if [ -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
+                ${MPX} ${RPM} --checksig ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm | egrep ' md5 ' >/dev/null
+                if [ $? -ne 0 ]; then
+                    echo "obmtool:WARNING: removing damaged file ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm (md5)" 1>&2
+                    rm -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>/dev/null || true
+                fi
             fi
-            BUILDARGS=""
-            if [ -x ${PREFIX}/bin/openpkg ]; then
-                if [ ".${LOC}" = .. ]; then
-                    LOCPRESU=${PWD:-`pwd`}
-                else
-                    LOCPRESU=${LOC}
+        fi
+        #   download source RPM
+        if [ ".${MPX}${RPM}" -a ! -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+            for retrygaps in 1 4 16; do
+                @fetch ${LOC}/${PKG}.src.rpm ${PREFIX}/RPM/PKG/
+                if [ -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+                    ${MPX} ${RPM} --checksig ${PREFIX}/RPM/PKG/${PKG}.src.rpm | egrep ' md5 ' >/dev/null
+                    if [ $? -ne 0 ]; then
+                        echo "obmtool:WARNING: removing damaged file ${PREFIX}/RPM/PKG/${PKG}.src.rpm (md5)" 1>&2
+                        rm -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm 2>/dev/null || true
+                    fi
                 fi
-                BUILDUSER=`${PREFIX}/bin/openpkg rpm --eval '%{?l_musr:%{l_musr}}'`
-                BUILDEXEC="${PREFIX}/bin/openpkg rpm $@ --rebuild ${LOCPRESU}/${PKG}.src.rpm 2>&1"
-                BUILDEXEC=`echo ${BUILDEXEC} | sed -e 's;--\([^=][^=]*\)=;--\1 ;g'`
-                echo "BUILDEXEC=$BUILDEXEC" #FIXME ; read DUMMY
-                if [ ".${BUILDUSER}" = . ]; then
-                    eval "${BUILDEXEC}" | tee /tmp/${PRG}-${PKG}.rebuild.log
-                else
-                    su - "${BUILDUSER}" -c "${BUILDEXEC}" | tee /tmp/${PRG}-${PKG}.rebuild.log || true
+                if [ -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+                    break
                 fi
+                sleep $retrygaps
+            done
+        fi
+        #   build binary from source
+        if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm -a ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+            BUILDUSER=`${MPX} ${RPM} --eval '%{?l_musr:%{l_musr}}'`
+            BUILDEXEC="${MPX} ${RPM} --rebuild $@ ${PREFIX}/RPM/PKG/${PKG}.src.rpm 2>&1"
+            BUILDEXEC=`echo ${BUILDEXEC} | sed \
+                       -e 's;--\(define\)  *\([^=][^=]*\)=\([^ ][^ ]*\);--\\1 \\"\2 \3\\";g' \
+                       -e 's;--\(use_[^=][^=]*\)=\([^ ][^ ]*\);--define \\"\1 \2\\";g' \
+                       -e 's;--\(with\)=;--\1 ;g' \
+                       -e 's;--\(without\)=;--\1 ;g' \
+                       -e 's;--\(tag\)=;--\1 ;g' \
+                       `
+            [ ".${debug}" = .1 ] && echo "DEBUG: rebuild: BUILDEXEC=${BUILDEXEC}"
+            if [ ".${BUILDUSER}" = . ]; then
+                ( "${BUILDEXEC}" ) | tee /tmp/${PRG}-${PKG}.rebuild.log
+            else
+                su "${BUILDUSER}" -c "${BUILDEXEC}" | tee /tmp/${PRG}-${PKG}.rebuild.log
+            fi
+            if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+                    echo "obmtool:WARNING: rebuild failure. Missing ${PREFIX}/RPM/PKG/${PKG}.src.rpm" 1>&2
             fi
             echo "rebuild ${PKG} $?" >>/tmp/${PRG}.log
         fi
@@ -244,8 +353,8 @@
 #force rebuild
 @forcere ()
 {
-    @wiperpm "$@" 
-    @rebuild "$@" 
+    @wiperpm "$@"
+    @rebuild "$@"
 }
 
 #install, rebuilds if necessary, forcibly overwrite existing
@@ -254,133 +363,230 @@
     @locate "$@"
     TRACK="${TRACK} ${PKG}"
     if [ ".$CHECKONLY" != ".yes" ]; then
+        @sanity
         echo "forcein ${PKG}"
+        if [ ".${MPX}${RPM}" = . ]; then
+            echo "obmtool:ERROR: rpm multiplexer/binary missing" 1>&2
+            exit 1
+        fi
+        if [ -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
+            ${MPX} ${RPM} --checksig ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm | egrep ' md5 ' >/dev/null
+            if [ $? -ne 0 ]; then
+                echo "obmtool:WARNING: removing damaged file ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm (md5)" 1>&2
+                rm -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>/dev/null || true
+            fi
+        fi
         @rebuild "$@"
-        if [ -f ${HOME}/.rpmmacros ]; then
-            mv ${HOME}/.rpmmacros ${HOME}/.rpmmacros.${PRG}.save
+        if [ -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
+            ${MPX} ${RPM} -Uvh --oldpackage --nodeps --force ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>&1 | tee /tmp/${PRG}-${PKG}.forcein.log
+        else
+            echo "obmtool:WARNING: forcein failure. Missing ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm" 1>&2
         fi
-        ${PREFIX}/bin/rpm -Uvh --oldpackage --nodeps --force ${PREFIX}/RPM/PKG/${PKG}.*-${TAG}.rpm 2>&1 | tee /tmp/${PRG}-${PKG}.forcein.log
         echo "forcein ${PKG} $?" >>/tmp/${PRG}.log
     fi
 }
 
+#fetch a RPM (or .sh)
+ at fetch ()
+{
+    echo "$1 $2" | egrep '\*' >/dev/null && return 1 # short circuit for unsupported wildcards
+
+    url=`echo "$1" | sed -e 's;^\./;file://././;'` # revamp file:// URI to look like an URL
+    dst=`echo "$2" | sed -e 's;/$;;'`
+
+    prot=`echo $url | sed -e 's;^\([^:]*\)://\([^/]*\)/\(.*\)/\([^/]*\)$;\1;'`
+    host=`echo $url | sed -e 's;^\([^:]*\)://\([^/]*\)/\(.*\)/\([^/]*\)$;\2;'`
+    dire=`echo $url | sed -e 's;^\([^:]*\)://\([^/]*\)/\(.*\)/\([^/]*\)$;\3;'`
+    file=`echo $url | sed -e 's;^\([^:]*\)://\([^/]*\)/\(.*\)/\([^/]*\)$;\4;'`
+    [ ".${debug}" = .1 ] && echo "DEBUG: fetch: url=$url prot=$prot host=$host dire=$dire file=$file"
+
+    [ ".${debug}" = .1 ] && echo "DEBUG: fetch: checking whether \"$dst/$file\" already present"
+    [ -f "$dst/$file" ] && return 0
+
+    if [ ".$prot" = .file ]; then
+        [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying local link \"$dire/$file\" to \"$dst/$file\""
+        ln "$dire/$file" "$dst/$file" 2>/dev/null
+        [ $? -eq 0 -a -f "$dst/$file" ] && return 0
+        [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying local copy \"$dire/$file\" to \"$dst/$file\""
+        echo cp "$dire/$file" "$dst/$file" 2>/dev/null
+        cp "$dire/$file" "$dst/$file" 2>/dev/null
+        [ $? -eq 0 -a -f "$dst/$file" ] && return 0
+        return 1
+    else
+        TOOL="$PREFIX/lib/openpkg/curl"
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                $TOOL -o $file $url
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool curl
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                $TOOL -o $file $url
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool wget
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                $TOOL $url
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool lftp
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                ( echo "cd $dire"; echo "get $file" ) | $TOOL $host
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool ftp
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                $TOOL -? </dev/null 2>&1 | grep ftp:// >/dev/null
+                if [ $? -eq 0 ]; then
+                    $TOOL -n $url
+                else
+                    ( echo "user anonymous ftp"; echo "cd $dire"; echo "bin"; echo "get $file" ) | ftp -n $host
+                fi
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool lynx
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                $TOOL --source $url >$file
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool w3m
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                $TOOL -no-proxy -dump_source $url >$file
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool ncftpget
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                $TOOL $url
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+
+        @findtool ncftp
+        if [ -x "$TOOL" ]; then
+            [ ".${debug}" = .1 ] && echo "DEBUG: fetch: trying \"$TOOL\""
+            (
+                cd $dst || exit 1
+                ( echo "cd $dire"; echo "bin"; echo "get $file" ) | $TOOL $host
+            )
+            [ -f "$dst/$file" ] && return 0
+        fi
+    fi
+    return 1
+}
+
 #install, rebuilds if necessary
 @install ()
 {
     ARGS="$@"
     @locate "$@"
     TRACK="${TRACK} ${PKG}"
+    #   FIXME compensate architectural bug of obmtool 1.3[12] placing .src.rpm files into RPM/SRC
+    if [ -f ${PREFIX}/RPM/SRC/${PKG}.src.sh ]; then
+        if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.sh ]; then
+            mv ${PREFIX}/RPM/SRC/${PKG}.src.sh ${PREFIX}/RPM/PKG/${PKG}.src.sh 2>/dev/null || true
+        fi
+        rm -f ${PREFIX}/RPM/SRC/${PKG}.src.sh 2>/dev/null || true
+    fi
+    #   FIXME compensate architectural bug of obmtool 1.3[12] placing .src.rpm files into RPM/SRC
+    if [ -f ${PREFIX}/RPM/SRC/${PKG}.src.rpm ]; then
+        if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+            mv ${PREFIX}/RPM/SRC/${PKG}.src.rpm ${PREFIX}/RPM/PKG/${PKG}.src.rpm 2>/dev/null || true
+        fi
+        rm -f ${PREFIX}/RPM/SRC/${PKG}.src.rpm 2>/dev/null || true
+    fi
     if [ ".$CHECKONLY" != ".yes" ]; then
+        @sanity
         #check for special package "openpkg", detect new or broken hierarchy and bootstrap
         echo "${PKG}" | ${EGREP} >/dev/null '^openpkg-[^-]+-[^-]+$'
         if [ $? -eq 0 ]; then
-            echo "bootstrap check/execution"
-            if [ ! -d ${PREFIX} -o ! -x ${PREFIX}/bin/rpm ]; then
-                echo "did not find rpm executable, checking for binary sh"
-                tmpdir="/tmp"; test ".$TMPDIR" != . && tmpdir="$TMPDIR"
-                touch .writetest 2>/dev/null
-                if [ $? -eq 0 ]; then
-                    rm .writetest
-                    writedir="."
-                else
-                    writedir="$tmpdir"
-                    echo "CWD not writable, working in $tmpdir assuming to have approx. 300MB space there"
-                fi
-                if [ ! -f ${PKG}.${ARCH:-*}-${OS:-*}-${TAG:-*}.sh ]; then
-                    echo "did not find binary sh, checking for source sh"
-                    if [ ! -f $writedir/${PKG}.src.sh ]; then
-                        echo "did not find source sh, trying to download source sh"
-                        echo "$LOC/" | ${EGREP} >/dev/null '^\.\/'
-                        if [ $? -eq 0 ]; then
-                            echo "trying download from local using cp"
-                            cp ${LOC}/${PKG}.src.sh $writedir/${PKG}.src.sh
-                        else
-                            echo "checking for curl"
-                            if [ `which curl | ${EGREP} '^/' | wc -l` -ne 0 ]; then
-                                echo "trying download from remote using curl"
-                                curl -o $writedir/${PKG}.src.sh ${LOC}/${PKG}.src.sh
-                            fi
-                        fi
-                        if [ ! -f $writedir/${PKG}.src.sh ]; then
-                            [ ".$writedir" = .. ] && writedir=`pwd`
-                            echo "obmtool:ERROR: please download ${LOC}/${PKG}.src.sh to $writedir manually and restart ${PRG}" 1>&2
-                            exit 1
-                        fi
+            [ ".${debug}" = .1 ] && echo "DEBUG: checking whether instance below ${PREFIX} is bootstrapped"
+            @rpm
+            if [ ".${MPX}${RPM}" = . ]; then
+                echo "obmtool:NOTICE: did not find openpkg/rpm executable. Checking/fetching binary sh."
+                @fetch ${LOC}/${PKG}.${ARCH:-*}-${OS:-*}-${TAG:-*}.sh ${PREFIX}/RPM/PKG/
+                @fetch ${LOC}/${PKG}.${ARCH:-*}-${OS:-*}-${TAG:-*}.rpm ${PREFIX}/RPM/PKG/ #just to be complete
+                if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH:-*}-${OS:-*}-${TAG:-*}.sh ]; then
+                    echo "obmtool:NOTICE: did not find binary sh. Checking/fetching source sh."
+                    @fetch ${LOC}/${PKG}.src.sh ${PREFIX}/RPM/PKG/
+                    @fetch ${LOC}/${PKG}.src.rpm ${PREFIX}/RPM/PKG/ #just to be complete
+                    if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.sh ]; then
+                        echo "obmtool:ERROR: please download ${LOC}/${PKG}.src.sh to ${PREFIX}/RPM/PKG/ manually and restart ${PRG}" 1>&2
+                        exit 1
                     fi
                     shift
-                    if [ "$writedir" = . ]; then
-                        TMPDIR=$tmpdir sh ${PKG}.src.sh $@ 2>&1 | tee /tmp/${PRG}-${PKG}.rebuild.log
-                        if [ $? -ne 0 ]; then
-                            echo "obmtool:ERROR: bootstrapping from . \"${PKG}.src.sh\" failed to build from source" 1>&2
-                            exit 1
-                        fi
-                    else
-                        if [ ! -f $writedir/${PKG}.src.sh ]; then
-                            cp ${PKG}.src.sh $writedir/${PKG}.src.sh
-                        fi
-                        ( cd $writedir && TMPDIR=$tmpdir sh ${PKG}.src.sh $@ 2>&1 | tee /tmp/${PRG}-${PKG}.rebuild.log )
-                        if [ $? -ne 0 ]; then
-                            echo "obmtool:ERROR: bootstrapping from $writedir \"${PKG}.src.sh\" failed to build from source" 1>&2
-                            exit 1
-                        fi
+                    rm -f ${PREFIX}/RPM/TMP/${PKG}.src.sh 2>/dev/null || true
+                    if [ ! -f ${PREFIX}/RPM/TMP/${PKG}.src.sh ]; then
+                        ln ${PREFIX}/RPM/PKG/${PKG}.src.sh ${PREFIX}/RPM/TMP/${PKG}.src.sh 2>/dev/null || true
+                    fi
+                    if [ ! -f ${PREFIX}/RPM/TMP/${PKG}.src.sh ]; then
+                        cp ${PREFIX}/RPM/PKG/${PKG}.src.sh ${PREFIX}/RPM/TMP/${PKG}.src.sh 2>/dev/null || true
+                    fi
+                    if [ ! -f ${PREFIX}/RPM/TMP/${PKG}.src.sh ]; then
+                        echo "obmtool:ERROR: cannot create ${PREFIX}/RPM/TMP/${PKG}.src.sh" 1>&2
+                        exit 1
+                    fi
+                    ( cd ${PREFIX}/RPM/TMP && TMPDIR=${PREFIX}/RPM/TMP sh ${PKG}.src.sh $@ 2>&1 | tee /tmp/${PRG}-${PKG}.rebuild.log )
+                    if [ $? -ne 0 ]; then
+                        echo "obmtool:ERROR: building bootstrap from source using \"${PREFIX}/RPM/TMP/${PKG}.src.sh\" failed" 1>&2
+                        exit 1
                     fi
                 fi
-                if [ "$writedir" = . ]; then
-                    ALL=`( echo ${PKG}.${ARCH:-*}-${OS:-*}-${TAG:-*}.sh )`
-                    for i in $ALL; do
-                        if [ ".`
-                        ${EGREP} <$i . \
-                        | sed -e '/parse command line options/,$d' \
-                        | egrep -v '^ *#' \
-                        | egrep '^(p|prefix|l_prefix)=' \
-                        | sed -e 's;^[^=]*=.;;' -e 's;.$;;'`" = ".${PREFIX}" ]; then
-                            sh ${i} 2>&1 | tee /tmp/${PRG}-${PKG}.install.log
-                            if [ $? -ne 0 ]; then
-                                echo "obmtool:ERROR: bootstrapping from . \"${PKG}.*-${TAG:-*}.sh\" failed to install from binary" 1>&2
-                                exit 1
-                            fi
-                            #                                   NAME - VERSION     - RELEASE      . ARCH        - OS          - TAG
-                               F_NAME=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\1;'`
-                            F_VERSION=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\2;'`
-                            F_RELEASE=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\3;'`
-                               F_ARCH=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\4;'`
-                                 F_OS=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\5;'`
-                                F_TAG=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\6;'`
-                            mv ${F_NAME}-${F_VERSION}-${F_RELEASE}.src.sh ${PREFIX}/RPM/PKG/ || true
-                            mv ${F_NAME}-${F_VERSION}-${F_RELEASE}.src.rpm ${PREFIX}/RPM/PKG/ || true
-                            mv ${F_NAME}-${F_VERSION}-${F_RELEASE}.${F_ARCH}-${F_OS}-${F_TAG}.sh ${PREFIX}/RPM/PKG/ || true
-                            mv ${F_NAME}-${F_VERSION}-${F_RELEASE}.${F_ARCH}-${F_OS}-${F_TAG}.rpm ${PREFIX}/RPM/PKG/ || true
-                            break;
-                        fi
-                    done
-                else
-                    ALL=`( cd $writedir && echo ${PKG}.${ARCH:-*}-${OS:-*}-${TAG:-*}.sh )`
-                    for i in $ALL; do
-                        if [ ".`
-                        ${EGREP} <$writedir/$i . \
-                        | sed -e '/parse command line options/,$d' \
-                        | egrep -v '^ *#' \
-                        | egrep '^(p|prefix|l_prefix)=' \
-                        | sed -e 's;^[^=]*=.;;' -e 's;.$;;'`" = ".${PREFIX}" ]; then
-                            ( cd $writedir && sh ${i} 2>&1 | tee /tmp/${PRG}-${PKG}.install.log )
-                            if [ $? -ne 0 ]; then
-                                echo "obmtool:ERROR: bootstrapping from . \"${PKG}.*-${TAG:-*}.sh\" failed to install from binary" 1>&2
-                                exit 1
-                            fi
-                            #                                   NAME - VERSION     - RELEASE      . ARCH        - OS          - TAG
-                               F_NAME=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\1;'`
-                            F_VERSION=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\2;'`
-                            F_RELEASE=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\3;'`
-                               F_ARCH=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\4;'`
-                                 F_OS=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\5;'`
-                                F_TAG=`echo "${i}" | sed -e 's;^\(..*\)-\([^-][^-]*\)-\([^-][^-]*\)\.\([^-][^-]*\)-\([^-][^-]*\)-\([^-][^-]*\)\.sh$;\6;'`
-                            mv $writedir/${F_NAME}-${F_VERSION}-${F_RELEASE}.src.sh ${PREFIX}/RPM/PKG/ || true
-                            mv $writedir/${F_NAME}-${F_VERSION}-${F_RELEASE}.src.rpm ${PREFIX}/RPM/PKG/ || true
-                            mv $writedir/${F_NAME}-${F_VERSION}-${F_RELEASE}.${F_ARCH}-${F_OS}-${F_TAG}.sh ${PREFIX}/RPM/PKG/ || true
-                            mv $writedir/${F_NAME}-${F_VERSION}-${F_RELEASE}.${F_ARCH}-${F_OS}-${F_TAG}.rpm ${PREFIX}/RPM/PKG/ || true
-                            break;
+                ALL=`( cd ${PREFIX}/RPM/PKG && echo ${PKG}.${ARCH:-*}-${OS:-*}-${TAG:-*}.sh )`
+                for i in $ALL; do
+                    if [ ".`
+                    ${EGREP} <${PREFIX}/RPM/PKG/$i . \
+                    | sed -e '/parse command line options/,$d' \
+                    | egrep -v '^ *#' \
+                    | egrep '^(p|prefix|l_prefix)=' \
+                    | sed -e 's;^[^=]*=.;;' -e 's;.$;;'`" = ".${PREFIX}" ]; then
+                        ( cd /tmp && sh ${PREFIX}/RPM/PKG/${i} 2>&1 | tee /tmp/${PRG}-${PKG}.install.log )
+                        if [ $? -ne 0 ]; then
+                            echo "obmtool:WARNING: installing bootstrap from binary \"${PREFIX}/RPM/PKG/${i}\" failed" 1>&2
                         fi
-                    done
+                        break;
+                    fi
+                done
+                @rpm
+                if [ ".${MPX}${RPM}" = . ]; then
+                    echo "obmtool:ERROR: bootstrapping failed" 1>&2
+                    exit 1
                 fi
             else
                 if [ ".${TAGFMT}" = . ]; then
@@ -391,19 +597,25 @@
             fi
         fi
         echo "install ${PKG}"
-        ${PREFIX}/bin/rpm -q >/dev/null ${PKG}
+        @rpm
+        if [ ".${MPX}${RPM}" = . ]; then
+            echo "obmtool:ERROR: rpm multiplexer/binary missing" 1>&2
+            exit 1
+        fi
+        ${MPX} ${RPM} -q >/dev/null ${PKG}
         if [ $? -ne 0 ]; then
-            @rebuild ${ARGS}
-            if [ -f ${HOME}/.rpmmacros ]; then
-                mv ${HOME}/.rpmmacros ${HOME}/.rpmmacros.${PRG}.save
+            if [ -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
+                ${MPX} ${RPM} --checksig ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm | egrep ' md5 ' >/dev/null
+                if [ $? -ne 0 ]; then
+                    echo "obmtool:WARNING: removing damaged file ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm (md5)" 1>&2
+                    rm -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>/dev/null || true
+                fi
             fi
+            @rebuild ${ARGS}
             if [ -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
-                ${PREFIX}/bin/rpm -Uvh --oldpackage --nodeps ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>&1 | tee /tmp/${PRG}-${PKG}.install.log
-            elif [ -f ./${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
-                ${PREFIX}/bin/rpm -Uvh --oldpackage --nodeps ./${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>&1 | tee /tmp/${PRG}-${PKG}.install.log
+                ${MPX} ${RPM} -Uvh --oldpackage --nodeps ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm 2>&1 | tee /tmp/${PRG}-${PKG}.install.log
             else
-                echo "obmtool:ERROR: ${PKG}.${ARCH}-${OS}-${TAG}.rpm missing" 1>&2
-                exit 1
+                echo "obmtool:WARNING: install failure. Missing ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm" 1>&2
             fi
             echo "install ${PKG} $?" >>/tmp/${PRG}.log
         fi
@@ -419,7 +631,6 @@
 
 @prolog ()
 {
-    [ ".${debug}" = .1 ] && echo "DEBUG: prolog: prg=\"$prg\" silent=\"$silent\" verbose=\"$verbose\" debug=\"$debug\" help=\"$help\" query=\"$query\" force=\"$force\" file=\"$file\" logs=\"$logs\" cmd=\"$cmd\" cmdargs=\"$cmdargs\""; #FIXME
     ##
     ##  obmtool has the call to the prolog() function hardcoded as the
     ##  prolog of the %common scriplet. It is placed immediately after the
@@ -438,6 +649,15 @@
     #M  PREFIX = /openpkg; default can be overridden in %common scriptlet
     #M  NODE = dv1.dev.de.cw.net; uname -n
 
+    #   dump debug data
+    if [ ".${debug}" = .1 ]; then
+        echo "DEBUG: prolog: prg=\"$prg\"";
+        echo "DEBUG: prolog: silent=\"$silent\" verbose=\"$verbose\" debug=\"$debug\" help=\"$help\"";
+        echo "DEBUG: prolog: query=\"$query\" force=\"$force\"";
+        echo "DEBUG: prolog: conf=\"$conf\" logs=\"$logs\" tmpdir=\"$tmpdir\"";
+        echo "DEBUG: prolog: cmd=\"$cmd\" cmdargs=\"$cmdargs\"";
+    fi
+
     PRG="`echo ${prg} | sed -e 's/.*\///'`"
     CMD="${cmd}"
 
@@ -512,13 +732,22 @@
 
 @epilog ()
 {
-    [ ".${debug}" = .1 ] && echo "DEBUG: epilog: prg=\"$prg\" silent=\"$silent\" verbose=\"$verbose\" debug=\"$debug\" help=\"$help\" query=\"$query\" force=\"$force\" file=\"$file\" logs=\"$logs\" cmd=\"$cmd\" cmdargs=\"$cmdargs\""; #FIXME
     ##
     ##  obmtool has the call to the epilog() function hardcoded as the
     ##  epilog of the %common scriplet. It is placed immediately after the
     ##  %common scriptlet.
     ##
     #M  epilog() initializes variables which can be used throughout the scriptlets
+
+    #   dump debug data
+    if [ ".${debug}" = .1 ]; then
+        echo "DEBUG: epilog: prg=\"$prg\"";
+        echo "DEBUG: epilog: silent=\"$silent\" verbose=\"$verbose\" debug=\"$debug\" help=\"$help\"";
+        echo "DEBUG: epilog: query=\"$query\" force=\"$force\"";
+        echo "DEBUG: epilog: conf=\"$conf\" logs=\"$logs\" tmpdir=\"$tmpdir\"";
+        echo "DEBUG: epilog: cmd=\"$cmd\" cmdargs=\"$cmdargs\"";
+    fi
+
     @archostag
 
     # check whether a obsolete obmtool.conf tries to use us
@@ -530,10 +759,11 @@
             error=1
         fi
     done
-    if [ ${error} = 1 ]; then
+    if [ ${error} -ne 0 ]; then
         echo "obmtool:ERROR: variables used which are no longer supported by obmtool" 1>&2
         exit 1
     fi
+
 }
 
 @hasfeature ()
@@ -542,6 +772,8 @@
     for feature in "$@"; do
         case $feature in
             TAGFMT) ;;
+            USE)    ;;
+            DEFINE) ;;
                  *) missing="$missing $feature";;
         esac
     done
@@ -579,22 +811,54 @@
     #M    OS = freebsd4.8; operating system
 
     @tagfmtfromargs "$@"
-    if [ ".${PREFIX}" != . -a -x ${PREFIX}/bin/rpm ]; then
-        ARCH=`${PREFIX}/bin/rpm -q --qf "%{ARCH}" openpkg`
-        OS=`${PREFIX}/bin/rpm --eval "%{?l_host_os:%{l_host_os}}"`
+    @rpm
+    if [ ".${MPX}${RPM}" != . ]; then
+        ARCH=`${MPX} ${RPM} -q --qf "%{ARCH}" openpkg`
+        OS=`${MPX} ${RPM} --eval "%{?l_host_os:%{l_host_os}}"`
         if [ ".${OS}" = . ]; then
-            OS=`${PREFIX}/bin/rpm -q --qf "%{OS}" openpkg`
+            OS=`${MPX} ${RPM} -q --qf "%{OS}" openpkg`
         fi
         if [ ".${TAGFMT}" = . ]; then
-            TAG=`${PREFIX}/bin/rpm --eval '%{?l_tag:%{l_tag}}%{!?l_tag:%{l_location}}'`
+            TAG=`${MPX} ${RPM} --eval '%{?l_tag:%{l_tag}}%{!?l_tag:%{l_location}}'`
         else
-            TAG=`${PREFIX}/bin/rpm --define "l_tag_fmt ${TAGFMT}" --eval '%{?l_tag:%{l_tag}}%{!?l_tag:%{l_location}}'`
+            TAG=`${MPX} ${RPM} --define "l_tag_fmt ${TAGFMT}" --eval '%{?l_tag:%{l_tag}}%{!?l_tag:%{l_location}}'`
         fi
     else
         ARCH=""
         OS=""
         TAG=""
     fi
+
+}
+
+ at sanity ()
+{
+    #   sanity check
+    if [ ".$PREFIX" = . ]; then
+        echo "obmtool:ERROR: sanity check asserted PREFIX is set but it is empty" 1>&2
+        exit 1
+    fi
+
+    #   check whether SRC|PKG|TMP either exist or can be created and are writable
+    error=0
+    for s in SRC PKG TMP; do
+        d="$PREFIX/RPM/$s"
+        @mkdirp "$d"
+        if [ ! -d "$d" ]; then
+            echo "obmtool:WARNING: directory \"$d\" does not exist after attempt to create it"
+            error=1
+        fi
+        touch "$d/.writetest" 2>/dev/null
+        if [ $? -ne 0 ]; then
+            echo "obmtool:WARNING: directory \"$d\" not writable"
+            error=1
+        fi
+        rm "$d/.writetest"
+    done
+    if [ ${error} -ne 0 ]; then
+        echo "obmtool:ERROR: directory structure below prefix \"$PREFIX\" not accessible" 1>&2
+        exit 1
+    fi
 }
 
 @status ()
@@ -605,33 +869,63 @@
 @check ()
 {
     INSTALL=""
+    MISSSRC=""
+    MISSPKG=""
     MISSING=""
     SURPLUS=""
-    if [ ! -d ${PREFIX} -o ! -x ${PREFIX}/bin/rpm ]; then
+    @rpm
+    if [ ".${MPX}${RPM}" = . ]; then
         MISSING="${TRACK}"
     else
-        ALL=`${PREFIX}/bin/rpm -qa`
-        for i in ${TRACK}
+        ALL=`${MPX} ${RPM} -qa`
+        for PKG in ${TRACK}
         do
-            ${PREFIX}/bin/rpm -q $i 2>&1 >/dev/null
+            ${MPX} ${RPM} -q ${PKG} 2>&1 >/dev/null
             if [ $? -eq 0 ]; then
-                INSTALL="${INSTALL} $i"
-                ALL=`echo "${ALL}" | ${EGREP} -v "^$i"`
+                INSTALL="${INSTALL} ${PKG}"
+                ALL=`echo "${ALL}" | ${EGREP} -v "^${PKG}"`
             else
-                MISSING="${MISSING} $i"
+                MISSING="${MISSING} ${PKG}"
+            fi
+            echo "${PKG}" | ${EGREP} >/dev/null '^openpkg-[^-]+-[^-]+$'
+            if [ $? -eq 0 ]; then
+                if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.sh ]; then
+                    MISSPKG="${MISSPKG} ${PKG}.${ARCH}-${OS}-${TAG}.sh"
+                fi
+                if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
+                    MISSPKG="${MISSPKG} ${PKG}.${ARCH}-${OS}-${TAG}.rpm"
+                fi
+                if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.sh ]; then
+                    MISSSRC="${MISSSRC} ${PKG}.src.sh"
+                fi
+                if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+                    MISSSRC="${MISSSRC} ${PKG}.src.rpm"
+                fi
+            else
+                if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.${ARCH}-${OS}-${TAG}.rpm ]; then
+                    MISSPKG="${MISSPKG} ${PKG}"
+                fi
+                if [ ! -f ${PREFIX}/RPM/PKG/${PKG}.src.rpm ]; then
+                    MISSSRC="${MISSSRC} ${PKG}"
+                fi
             fi
         done
     fi
+    if [ ! -d ${PREFIX}/RPM/PKG ]; then
+        MISSPKG="all, ${PREFIX}/RPM/PKG empty"
+        MISSSRC="all, ${PREFIX}/RPM/PKG empty"
+    fi
 
     if [ ".${ALL}" != "." ]; then
         for i in ${ALL}
         do
-            echo "$i" | ${EGREP} "^gpg-pubkey-" 2>&1 >/dev/null || SURPLUS="${SURPLUS} $i"
+            echo "$i" | ${EGREP} "^gpg-pubkey-" 2>&1 >/dev/null || SURPLUS="${SURPLUS}${SURPLUS:+ }$i"
         done
         if [ ".${ERASESURPLUS}" = ".yes" ]; then
-            echo "---- erasing ----"
-            echo ${SURPLUS}
-            ${PREFIX}/bin/rpm -e ${SURPLUS} 2>&1 >/dev/null
+            echo "ERASING: ${SURPLUS:-none}"
+            if [ ".${SURPLUS}" != . ]; then
+                ${MPX} ${RPM} -e ${SURPLUS} --allmatches 2>&1 >/dev/null
+            fi
         fi
     fi
 
@@ -643,10 +937,14 @@
     SUMMARY="${SUMMARY}NODE=${NODE}; DATE=${DATE}; HASX11=${HASX11}; DONE"
 
     INSTALL="`echo ${INSTALL}`"
+    MISSSRC="`echo ${MISSSRC}`"
+    MISSPKG="`echo ${MISSPKG}`"
     MISSING="`echo ${MISSING}`"
     SURPLUS="`echo ${SURPLUS}`"
 
     echo "INSTALL: ${INSTALL:-none}"
+    echo "MISSSRC: ${MISSSRC:-none}"
+    echo "MISSPKG: ${MISSPKG:-none}"
     echo "MISSING: ${MISSING:-none}"
     echo "SURPLUS: ${SURPLUS:-none}"
     echo "SUMMARY: ${SUMMARY:-none}"





More information about the commits mailing list