Przeglądaj źródła

Major overhauling and extending the OpenPKG bootstrap package: - replace l_{fs,np}{usr,grp} with l_{s,m,r,n}{usr,grp} and create the two additional l_{r,n}{usr,grp} Unix accounts on bootstrapping. This way OpenPKG is a little bit more nasty (because requires 3 instead of 1 Unix uid/gid pair) but this is a very important cange because more and more packages require more distinguished uid/gids. Now OpenPKG packages can use: variables: purpose: login: owns: l_susr/l_sgrp super user yes everything l_musr/l_mgrp management user yes regular files l_rusr/l_rgrp restricted user no some files l_nusr/l_ngrp non-priviledged user no no files The default usually is: l_susr/l_sgrp = root/wheel l_musr/l_mgrp = cw/cw l_rusr/l_rgrp = cw-r/cw-r l_nusr/l_ngrp = cw-n/cw-n This allows us to finally upgrade to Postfix 1.1.3, Sendmail 8.12.2, etc. - support an "openpkg_ignall" variable for ignoring "all" type requests which can be used to disable an OpenPKG instance from startup/shutdown/cron but still being able to use it manually. This allows one to have an OpenPKG instance staying around but which is not activated. - more precise tarball rolling to get rid of the nasty uninstallation problem because of additionally staying around files from RPM. This solves the "rpm -e openpkg" problems under Solaris and other platforms where RPM installs additional files.

Ralf S. Engelschall 24 lat temu
rodzic
commit
ecf640fbcb
13 zmienionych plików z 1012 dodań i 508 usunięć
  1. 4 2
      openpkg/README
  2. 138 0
      openpkg/aux.prereq.sh
  3. 173 0
      openpkg/aux.usrgrp.sh
  4. 111 0
      openpkg/aux.wrapbin.sh
  5. 109 0
      openpkg/aux.wrapsrc.sh
  6. 134 105
      openpkg/openpkg.boot
  7. 264 187
      openpkg/openpkg.spec
  8. 9 1
      openpkg/rc
  9. 1 0
      openpkg/rc.openpkg
  10. 51 34
      openpkg/rpmmacros
  11. 18 0
      openpkg/rpmrc
  12. 0 94
      openpkg/wrap1.sh
  13. 0 85
      openpkg/wrap2.sh

+ 4 - 2
openpkg/README

@@ -52,8 +52,10 @@
   lsync.8 ................. the lsync tool (manual page)
   lsync.pod ............... the lsync tool (manual page source)
 
-  wrap1.sh ................ wrapper script for generating openpkg-X.X-X.src.sh
-  wrap2.sh ................ wrapper script for generating openpkg-X.X-X.YYY-YYYY-ZZ.sh 
+  aux.wrapsrc.sh .......... wrapper script for generating openpkg-X.X-X.src.sh
+  aux.wrapbin.sh .......... wrapper script for generating openpkg-X.X-X.YYY-YYYY-ZZ.sh 
+  aux.usrgrp.sh ........... user/group name/id determination script
+  aux.prereq.sh ........... prerequisite checking script
 
   openpkg.pgp ............. the OpenPGP public key of "The OpenPKG Project"
 

+ 138 - 0
openpkg/aux.prereq.sh

@@ -0,0 +1,138 @@
+#!/bin/sh
+##
+##  aux.prereq.sh -- Platform Pre-Requisite Checks
+##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
+##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+##  Usage: aux.prereq.sh source|binary
+##
+
+mode=$1
+
+#   determine platform id
+platform=`sh ./shtool guessos`
+
+#
+#   CHECK: amount of platform support
+#
+support=no
+case $platform in
+    *-solaris* )
+       support=maybe
+       case $platform in
+           *-solaris2.[678] )
+               support=yes
+               ;;
+       esac
+       ;;
+    *-linux* ) 
+       support=maybe
+       if [ -f /etc/debian_version ]; then
+           debian=`cat /etc/debian_version`
+           if [ ".$debian" = ".2.2" ]; then
+               support=yes
+           fi
+       fi
+       ;;
+    *-freebsd* )
+       support=maybe
+       case $platform in
+           *-freebsd4.[12345] )
+               support=yes
+               ;;
+       esac
+       ;;
+    *-netbsd* )
+       support=maybe
+       case $platform in
+           *-netbsd1.5* )
+               support=yes
+               ;;
+       esac
+       ;;
+    *-osf* )
+       support=maybe
+       case $platform in
+           *-osf5.[01] )
+               support=yes
+               ;;
+       esac
+       ;;
+    *-hpux* )
+       support=maybe
+       case $platform in
+           *-hpux10.20 )
+               support=yes
+               ;;
+       esac
+       ;;
+esac
+case $support in
+    yes   ) support="Congratulations: fully supported" ;;
+    maybe ) support="Good luck: supported but wrong version!" ;;
+    no    ) support="Sorry: entirely unsupported!" ;;
+esac
+echo "++ platform: $platform ($support)"
+case $support in
+    no ) exit 1 ;;
+esac
+
+#
+#   CHECK: diskspace requirement
+#
+case $platform in
+    *-solaris* )
+       ;;
+    *-linux* ) 
+       ;;
+    *-freebsd* )
+       ;;
+    *-osf* )
+       ;;
+esac
+
+#
+#   CHECK: available vendor packages
+#
+case $platform in
+    *-solaris* )
+       ;;
+    *-linux* ) 
+       ;;
+    *-freebsd* )
+       ;;
+    *-osf* )
+       ;;
+esac
+
+# 
+#   CHECK: available tools in $PATH
+#
+
+# 
+#   CHECK: available devices /dev/random, etc.
+#
+
+#
+#   CHECK: consistency check for /cw (symlink!)
+#
+

+ 173 - 0
openpkg/aux.usrgrp.sh

@@ -0,0 +1,173 @@
+#!/bin/sh
+##
+##  usrgrp.sh -- user/group name/id determination
+##  Copyright (c) 2002 Cable & Wireless Deutschland GmbH
+##  Copyright (c) 2002 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2002 Ralf S. Engelschall <rse@engelschall.com>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   command line parameters (defaults)
+help=0
+usr='';  grp=''
+susr=''; sgrp=''
+musr=''; mgrp=''
+rusr=''; rgrp=''
+nusr=''; ngrp=''
+
+#   parse command line options
+for opt
+do
+    case $opt in
+        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
+           *) arg='' ;;
+    esac
+    case $opt in
+        -h | --help          ) help=1      ;;
+        --usr=* | --user=*   ) usr=$arg    ;;
+        --grp=* | --group=*  ) grp=$arg    ;;
+        --susr=*             ) susr=$arg   ;;
+        --sgrp=*             ) sgrp=$arg   ;;
+        --musr=*             ) musr=$arg   ;;
+        --mgrp=*             ) mgrp=$arg   ;;
+        --rusr=*             ) rusr=$arg   ;;
+        --rgrp=*             ) rgrp=$arg   ;;
+        --nusr=*             ) nusr=$arg   ;;
+        --ngrp=*             ) ngrp=$arg   ;;
+        *                    ) help=1      ;;
+    esac
+done
+if [ ".$help" = .1 ]; then
+    echo "Usage: sh $0 [-h|--help]" 2>&1
+    echo "             [--[smrn]?usr=<usr>] [--[smrn]?grp=<usr>]" 2>&1
+    echo "             [--[smrn]uid=<uid>] [--[smrn]gid=<gid>]" 2>&1
+    exit 1
+fi
+
+#   determine cusr/cgrp
+cusr=`(id -un) 2>/dev/null ||\
+      (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
+      (whoami) 2>/dev/null ||\
+      (who am i | cut "-d " -f1) 2>/dev/null ||\
+      echo $LOGNAME`
+cgid=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null |\
+      grep "^${cusr}:" | awk -F: '{ print $4; }'`
+cgrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
+      grep ":${cgid}:" | awk -F: '{ print $1; }'`
+[ ".$cgrp" = . ] && cgrp="$cusr"
+
+#   determine OpenPKG susr/sgrp
+if [ ".$susr" = . ]; then
+    susr="root"
+fi
+if [ ".$sgrp" = . ]; then
+    sgid=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null |\
+          grep "^${susr}:" | awk -F: '{ print $4; }'`
+    if [ ".$sgid" != . ]; then
+        sgrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
+              grep ":${sgid}:" | awk -F: '{ print $1; }'`
+    fi
+    if [ ".$sgrp" = . ]; then
+        sgrp="wheel"
+    fi
+fi
+
+#   determine OpenPKG musr/mgrp
+if [ ".$musr" = . ]; then 
+    musr="$usr"
+fi
+if [ ".$musr" = . ]; then
+    musr="$cusr"
+fi
+if [ ".$mgrp" = . ]; then
+    mgid=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null |\
+          grep "^${musr}:" | awk -F: '{ print $4; }'`
+    if [ ".$mgid" != . ]; then
+        mgrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
+              grep ":${mgid}:" | awk -F: '{ print $1; }'`
+    fi
+    if [ ".$mgrp" = . ]; then
+        mgrp="$grp"
+    fi
+    if [ ".$mgrp" = . ]; then
+        mgrp="$cgrp"
+    fi
+fi
+
+#   determine OpenPKG rusr/rgrp
+if [ ".$rusr" = . ]; then 
+    rusr="${usr}-r"
+fi
+if [ ".$rusr" = ".-r" ]; then
+    rusr="$cusr"
+fi
+if [ ".$rgrp" = . ]; then
+    rgid=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null |\
+          grep "^${rusr}:" | awk -F: '{ print $4; }'`
+    if [ ".$rgid" != . ]; then
+        rgrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
+              grep ":${rgid}:" | awk -F: '{ print $1; }'`
+    fi
+    if [ ".$rgrp" = . ]; then
+        rgrp="${grp}-r"
+    fi
+    if [ ".$rgrp" = ".-r" ]; then
+        rgrp="$cgrp"
+    fi
+fi
+
+#   determine OpenPKG nusr/ngrp
+if [ ".$nusr" = . ]; then 
+    nusr="${usr}-n"
+fi
+if [ ".$nusr" = ".-n" ]; then
+    nusr="$cusr"
+fi
+if [ ".$ngrp" = . ]; then
+    ngid=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null |\
+          grep "^${nusr}:" | awk -F: '{ print $4; }'`
+    if [ ".$ngid" != . ]; then
+        ngrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
+              grep ":${ngid}:" | awk -F: '{ print $1; }'`
+    fi
+    if [ ".$ngrp" = . ]; then
+        ngrp="${grp}-n"
+    fi
+    if [ ".$ngrp" = ".-n" ]; then
+        ngrp="$cgrp"
+    fi
+fi
+
+#   print results
+output=""
+for var in \
+    susr sgrp \
+    musr mgrp \
+    rusr rgrp \
+    nusr ngrp; do
+    eval "val=\"\$$var\""
+    if [ ".$output" = . ]; then
+        output="$var=$val"
+    else
+        output="$output; $var=$val"
+    fi
+done
+echo $output
+

+ 111 - 0
openpkg/aux.wrapbin.sh

@@ -0,0 +1,111 @@
+#!/bin/sh
+##
+##  Shell-based package for OpenPKG BINARY bootstrap installation
+##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
+##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   defaults
+f="$0"
+help=0
+verbose=0
+prefix='@l_prefix@'
+t='@TGZ@'
+susr='@SUSR@'
+sgrp='@SGRP@'
+musr='@MUSR@'
+mgrp='@MGRP@'
+rusr='@RUSR@'
+rgrp='@RGRP@'
+nusr='@NUSR@'
+ngrp='@NGRP@'
+
+#   parse command line options
+for opt
+do
+    case $opt in
+        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
+           *) arg='' ;;
+    esac
+    case $opt in
+        -h | --help    ) help=1      ;;
+        -v | --verbose ) verbose=1   ;;
+        --prefix=*     ) prefix=$arg ;;
+        *              ) help=1      ;;
+    esac
+done
+if [ ".$prefix" = . ]; then
+    help=1
+fi
+if [ ".$help" = .1 ]; then
+    echo "Usage: sh $0 [-h|--help] [-v|--verbose] [--prefix=<prefix>]" 2>&1
+    exit 1
+fi
+
+#   establish standard environment
+LC_CTYPE=C
+export LC_CTYPE
+umask 022
+
+#   determine current username
+cusr=`(id -un) 2>/dev/null ||\
+      (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
+      (whoami) 2>/dev/null ||\
+      (who am i | cut "-d " -f1) 2>/dev/null ||\
+      echo $LOGNAME`
+
+#   perform the installation
+echo "$0: installing into $prefix..."
+
+#   the reason of the following magic you certainly don't want to understand ;)
+set -- 1
+@PRE@
+
+d=''
+for c in `IFS=/; echo $prefix`; do
+    d="$d/$c"
+    if [ ! -d $d ]; then
+        mkdir $d || exit 1
+        chmod 755 $d || exit 1
+        if [ ".$cusr" = .root ]; then
+            chown $musr $d >/dev/null 2>&1 || true
+            chgrp $mgrp $d >/dev/null 2>&1 || true
+        fi
+    fi
+done
+uudecode $f
+uncompress <$t |\
+(cd $prefix; tar x${v}f -)
+rm -f $t >/dev/null 2>&1
+if [ ".$cusr" = .root ]; then
+    ( cd $prefix || exit 1
+      chown -R -h $musr . >/dev/null 2>&1 || true
+      chgrp -R -h $mgrp . >/dev/null 2>&1 || true
+    )
+fi
+echo "$0: installation done."
+
+#   die explicitly just before the shell would discover
+#   that we carry mega-bytes of data with us...
+exit 0
+
+#   the distribution tarball

+ 109 - 0
openpkg/aux.wrapsrc.sh

@@ -0,0 +1,109 @@
+#!/bin/sh
+##
+##  Shell-based package for OpenPKG SOURCE bootstrap procedure
+##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
+##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
+##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
+##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
+
+#   program parameters
+me="$0"
+dir='@DIR@'
+tgz='@TGZ@'
+
+#   establish standard environment
+LC_CTYPE=C
+export LC_CTYPE
+umask 022
+
+#   pre-parse command line options
+help=0
+prefix=''
+for opt
+do
+    case $opt in
+        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
+           *) arg='' ;;
+    esac
+    case $opt in
+        -h | --help          ) help=1      ;;
+        --prefix=*           ) prefix=$arg ;;
+    esac
+done
+if [ ".$prefix" = . ]; then
+    help=1
+fi
+if [ ".$help" = .1 ]; then
+    echo "Usage: sh $me" 2>&1
+    echo "       --prefix=<prefix> [--user=<usr>] [--group=<grp>]" 2>&1
+    echo "       [--{s,m,r,n}usr=<usr>] [--{s,m,r,n}grp=<grp>]" 2>&1
+    echo "       [--{s,m,r,n}uid=<uid>] [--{s,m,r,n}gid=<gid>]" 2>&1
+    echo "       [-h|--help] [-v|--verbose]" 2>&1
+    exit 1
+fi
+
+#   determine current user/group
+cusr=`(id -un) 2>/dev/null ||\
+      (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
+      (whoami) 2>/dev/null ||\
+      (who am i | cut "-d " -f1) 2>/dev/null ||\
+      echo $LOGNAME`
+cgrp=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
+      grep "^${cusr}:" | awk -F: '{ print $4; }'`
+cgrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
+      grep ":${cgrp}:" | awk -F: '{ print $1; }'`
+if [ ".$cgrp" = . ]; then
+    cgrp="$cusr"
+fi
+
+#   extract the tarball
+echo "$me: extracting to $dir..."
+uudecode $me
+rm -rf $dir >/dev/null 2>&1
+mkdir $dir || exit 1
+uncompress <$tgz |\
+(cd $dir; tar x${v}f - 2>/dev/null)
+if [ ".$cusr" = .root ]; then
+    ( cd $dir 
+      chown -R -h $cusr . >/dev/null 2>&1 || true
+      chgrp -R -h $cgrp . >/dev/null 2>&1 || true
+    )
+fi
+echo "$me: extraction done."
+
+#   perform bootstrap procedure
+echo "$me: building for $prefix..."
+cd $dir || exit 1
+/bin/sh ./openpkg.boot "$@" || exit 1
+echo "$me: building done."
+
+#   cleanup
+echo "$me: cleaning up..."
+cd ..
+rm -rf $dir >/dev/null 2>&1
+rm -f  $tgz >/dev/null 2>&1
+echo "$me: cleaned up."
+
+#   die explicitly just before the shell would discover
+#   that we carry mega-bytes of data with us...
+exit 0
+
+#   the distribution tarball

+ 134 - 105
openpkg/openpkg.boot

@@ -19,17 +19,65 @@
 #   by a non-priviledged user and no access to the real installation
 #   location filesystem location.
 
+me="openpkg.boot"
+
 ##
 ##  command line handling
 ##
 
-if [ $# -lt 1 -o $# -gt 3 ]; then
-    echo "Usage: $0 <prefix> [<user> [<group>]]" 1>&2
+#   command line parameters (defaults)
+help=0
+verbose=''
+prefix=''
+usr='';  grp=''
+susr=''; sgrp=''
+musr=''; mgrp=''
+rusr=''; rgrp=''
+nusr=''; ngrp=''
+bs=0
+
+#   parse command line options
+for opt
+do
+    case $opt in
+        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
+           *) arg='' ;;
+    esac
+    case $opt in
+        -h | --help          ) help=1      ;;
+        -v | --verbose       ) verbose=v   ;;
+        --prefix=*           ) prefix=$arg ;;
+        --usr=* | --user=*   ) usr=$arg    ;;
+        --grp=* | --group=*  ) grp=$arg    ;;
+        --susr=*             ) susr=$arg   ;;
+        --sgrp=*             ) sgrp=$arg   ;;
+        --musr=*             ) musr=$arg   ;;
+        --mgrp=*             ) mgrp=$arg   ;;
+        --rusr=*             ) rusr=$arg   ;;
+        --rgrp=*             ) rgrp=$arg   ;;
+        --nusr=*             ) nusr=$arg   ;;
+        --ngrp=*             ) ngrp=$arg   ;;
+        -bs | -s             ) bs=1        ;;
+        *                    ) help=1      ;;
+    esac
+done
+if [ ".$bs" = .0 -a ".$prefix" = . ]; then
+    help=1
+fi
+if [ ".$help" = .1 ]; then
+    echo "Usage: sh $me [-h|--help] [-v|--verbose]" 2>&1
+    echo "       --prefix=<prefix> [--user=<usr>] [--group=<grp>]" 2>&1
+    echo "       [--{s,m,r,n}usr=<usr>] [--{s,m,r,n}grp=<grp>]" 2>&1
     exit 1
 fi
-root="$1"
-fsusr="$2"
-fsgrp="$3"
+
+#   determine missing parameters
+eval `sh aux.usrgrp.sh \
+      --usr="$usr" --grp="$grp" \
+      --susr="$susr" --sgrp="$sgrp" \
+      --musr="$musr" --mgrp="$mgrp" \
+      --rusr="$rusr" --rgrp="$rgrp" \
+      --nusr="$nusr" --ngrp="$ngrp"`
 
 ##
 ##  determine package information
@@ -41,38 +89,47 @@ version=`grep V_openpkg $spec | head -1 | awk '{ printf("%s", $3); }'`
 release=`grep R_openpkg $spec | head -1 | awk '{ printf("%s", $3); }'`
 
 ##
-##   special argument processing
+##  display headline
+##
+
+sh ./shtool echo -e "%BOpenPKG Bootstrap Procedure%b"
+echo "++ bootstrap version: $version-$release"
+echo "++ user/group pairs: $susr/$sgrp $musr/$mgrp $rusr/$rgrp $nusr/$ngrp"
+
+##
+##   optionally roll just a bootstrap source package
 ##
 
-if [ ".$root" = ".-s" ]; then
+if [ ".$bs" = .1 ]; then
     srcdir=.
     if [ -d ../../DST ]; then
        dstdir=../../DST/openpkg
     else
        dstdir=.
     fi
-    tmpdir="/tmp/openpkg.boot.$$"
-    if [ -d ../PKG ]; then
+    tmpdir="/tmp/$me.$$"
+    if [ -d ../PKG/SRC ]; then
+       pkgdir=../PKG/SRC
+    elif [ -d ../PKG ]; then
        pkgdir=../PKG
-    elif [ -d ../../PKG/BIN ]; then
-       pkgdir=../../PKG/BIN
+    elif [ -d ../../PKG/SRC ]; then
+       pkgdir=../../PKG/SRC
     elif [ -d ../../PKG ]; then
        pkgdir=../../PKG
-    elif [ -d ../../ftp/current/SRC ]; then
-       pkgdir=../../ftp/current/SRC
     else
        pkgdir=..
     fi
-    echo "Rolling source bootstrap package: $pkgdir/$name-$version-$release.src.sh"
+    echo "** rolling source bootstrap package:"
+    echo "   $pkgdir/$name-$version-$release.src.sh"
     rm -rf $tmpdir
     mkdir $tmpdir
     (cd $dstdir && tar cf - *) | (cd $tmpdir && tar xf -)
     (cd $srcdir && tar cf - *) | (cd $tmpdir && tar xf -)
-    sed <$srcdir/wrap1.sh >$pkgdir/$name-$version-$release.src.sh \
+    sed <$srcdir/aux.wrapsrc.sh >$pkgdir/$name-$version-$release.src.sh \
         -e "s;@DIR@;$name-$version-$release.src;" -e "s;@TGZ@;$name-$version-$release.src.tar.Z;"
     (cd $tmpdir && tar cf - *) | compress |\
     uuencode $name-$version-$release.src.tar.Z \
-        | dd bs=64000 >>$pkgdir/$name-$version-$release.src.sh
+        | dd bs=64000 2>/dev/null >>$pkgdir/$name-$version-$release.src.sh
     exit 0
 fi
 
@@ -80,90 +137,31 @@ fi
 ##  calculate location id
 ##
 
-if [ ".`expr $root : '/[^/][^/]*$'`" != .0 ]; then
-    loc=`echo $root | cut -c2-4`
+prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
+if [ ".`expr $prefix : '/[^/][^/]*$'`" != .0 ]; then
+    loc=`echo $prefix | cut -c2-4`
 else
-    loc=`echo $root | sed -e 's;/\(.\)[^/]*;\1;g' | cut -c1-3`
+    loc=`echo $prefix | sed -e 's;/\(.\)[^/]*;\1;g' | cut -c1-3`
 fi
+echo "++ location id: $loc"
 
 ##
-##  determine distribution directory (developers only)
+##  determine distribution directory
 ##
 
 V_rpm=`grep V_rpm $spec | head -1 | awk '{ printf("%s", $3); }'`
 if [ -f "../../DST/openpkg/rpm-${V_rpm}.tar.gz" ]; then
-    distdir="`cd ../../DST/openpkg; pwd`"
+    distdir="`cd ../../DST/openpkg; pwd`" # developer only
 else
     distdir="`pwd`"
 fi
+echo "++ distribution directory: $distdir"
 
 ##
-##  make sure the underlying platform is a supported one
+##  perform prerequisite checks
 ##
 
-sh ./shtool echo -e "%BOpenPKG Bootstrap Procedure%b"
-platform=`sh ./shtool guessos`
-support=no
-case $platform in
-    *-solaris* )
-       support=maybe
-       case $platform in
-           *-solaris2.[678] )
-               support=yes
-               ;;
-       esac
-       ;;
-    *-linux* ) 
-       support=maybe
-       if [ -f /etc/debian_version ]; then
-           debian=`cat /etc/debian_version`
-           if [ ".$debian" = ".2.2" ]; then
-               support=yes
-           fi
-       fi
-       ;;
-    *-freebsd* )
-       support=maybe
-       case $platform in
-           *-freebsd4.[1234] )
-               support=yes
-               ;;
-       esac
-       ;;
-    *-netbsd* )
-       support=maybe
-       case $platform in
-           *-netbsd1.5* )
-               support=yes
-               ;;
-       esac
-       ;;
-    *-osf* )
-       support=maybe
-       case $platform in
-           *-osf5.[01] )
-               support=yes
-               ;;
-       esac
-       ;;
-    *-hpux* )
-       support=maybe
-       case $platform in
-           *-hpux10.20 )
-               support=yes
-               ;;
-       esac
-       ;;
-esac
-case $support in
-    yes   ) support="Congratulations: fully supported" ;;
-    maybe ) support="Good luck: still supported in general, but may break!" ;;
-    no    ) support="Sorry: entirely unsupported!" ;;
-esac
-sh ./shtool echo -e "Platform: %B$platform%b ($support)"
-case $support in
-    no ) exit 1 ;;
-esac
+sh ./aux.prereq.sh source
 
 ##
 ##  find reasonable run-time paths and tools
@@ -244,11 +242,17 @@ cp /dev/null $prolog
   echo "_sourcedir=$distdir" 
   echo "_tmppath=$tmpdir" 
   echo "_builddir=$tmpdir" 
-  echo "l_prefix=$root"
+  echo "l_prefix=$prefix"
   echo "l_location=$loc"
   echo "l_buildroot=$tmpdir/$name-$version-root"
-  echo "l_fsusr=$fsusr"
-  echo "l_fsgrp=$fsgrp"
+  echo "l_susr=$susr"
+  echo "l_sgrp=$sgrp"
+  echo "l_musr=$musr"
+  echo "l_mgrp=$mgrp"
+  echo "l_rusr=$rusr"
+  echo "l_rgrp=$rgrp"
+  echo "l_nusr=$nusr"
+  echo "l_ngrp=$ngrp"
   echo "l_tar=$l_tar"
   echo "l_make=$l_make"
   echo "l_cc=$l_cc"
@@ -288,7 +292,7 @@ runscript () {
     sed -e 's;%{[?]\([^:]*\):\([^}]*\)};${\1+\2};g' \
         -e 's;%{![?]\([^:]*\):\([^}]*\)};${\1-\2};g' \
         -e 's;%{\([^}]*\)};${\1};g' >>$script
-    echo "Executing(%$step): sh $script"
+    echo "++ executing(%$step): sh $script"
     sh $script
     if [ $? -ne 0 ]; then
         rm -f $script
@@ -312,11 +316,11 @@ cwd=`pwd`
 . $prolog
 cd $cwd
 
-#   suck in buildenv script in order to get fsusr/fsgrp
-#   ???XXX???
+#   suck in buildenv script in order to get musr/mgrp
 . $tmpdir/openpkg-*/.buildenv
 
 #   create a custom "rpm" command
+echo "++ creating custom RPM command"
 rm -f $tmpdir/rpm >/dev/null 2>&1
 rmdir $tmpdir/rpm >/dev/null 2>&1
 if [ -d "$tmpdir/rpm" ]; then
@@ -341,13 +345,19 @@ sed <$RPM_BUILD_ROOT$prefix/lib/openpkg/macros >$tmpdir/rpm.2 \
 
 #   override the vendor macro set
 sed <`SOURCE rpmmacros` >$tmpdir/rpm.3 \
-    -e "s;@FSUSR@;$fsusr;" \
-    -e "s;@FSGRP@;$fsgrp;" \
+    -e "s;@SUSR@;$susr;" \
+    -e "s;@SGRP@;$sgrp;" \
+    -e "s;@MUSR@;$musr;" \
+    -e "s;@MGRP@;$mgrp;" \
+    -e "s;@RUSR@;$rusr;" \
+    -e "s;@RGRP@;$rgrp;" \
+    -e "s;@NUSR@;$nusr;" \
+    -e "s;@NGRP@;$ngrp;" \
     -e "s;@LOC@;$loc;" \
     -e "s;^\\(%l_root_install *\\)@l_prefix@;\\1 $prefix;" \
     -e "s;^\\(%l_root_rpm *\\)@l_prefix@;\\1 $RPM_BUILD_ROOT$prefix;" \
+    -e "s;^\\(%_specdir *\\).*;\\1 `pwd`;" \
     -e "s;^\\(%_sourcedir *\\).*;\\1 $distdir;" \
-    -e "s;^\\(%_specdir *\\).*;\\1 $RPM_SOURCE_DIR;" \
     -e "s;^\\(%_builddir *\\).*;\\1 $tmpdir;" \
     -e "s;^\\(%_tmppath *\\).*;\\1 $tmpdir;" \
     -e "s;^\\(%_buildshell *\\).*;\\1 /bin/sh;"
@@ -366,6 +376,7 @@ export HOME
 ##   now initialize the RPM database under the temporary install location
 ##
 
+echo "++ initializing RPM database"
 $tmpdir/rpm --initdb
 
 ##
@@ -373,6 +384,7 @@ $tmpdir/rpm --initdb
 ##   with the real RPM tool.
 ##
 
+echo "++ re-iterating over RPM specification procedures"
 OPENPKG_BOOT=1
 export OPENPKG_BOOT
 $tmpdir/rpm -bb $spec
@@ -389,6 +401,7 @@ $tmpdir/rpm -bb $spec
 ##   anything. But as a side-effect, the database is now correct.
 ##
 
+echo "++ overwriting RPM installation by installing via RPM itself"
 $tmpdir/rpm -Uvh --force --noscripts --justdb --ignoresize \
     $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm
 
@@ -401,34 +414,50 @@ v="$version-$release"
 t="`$tmpdir/rpm --eval '%{_target}'`-$loc"
 
 #   find a reasonable destination directory for packages
-if [ -d $RPM_SOURCE_DIR/../PKG ]; then
-   dstdir=$RPM_SOURCE_DIR/../PKG
-elif [ -d $RPM_SOURCE_DIR/../../PKG ]; then
-   dstdir=$RPM_SOURCE_DIR/../../PKG
+if [ -d ../PKG/BIN ]; then
+   dstdir=../PKG/BIN
+elif [ -d ../PKG ]; then
+   dstdir=../PKG
+elif [ -d ../../PKG/BIN ]; then
+   dstdir=../../PKG/BIN
+elif [ -d ../../PKG ]; then
+   dstdir=../../PKG
 else
-   dstdir=$RPM_SOURCE_DIR/..
+   dstdir=..
 fi
 
 #   create Source-RPM file
-$tmpdir/rpm -bs --nodeps $RPM_SOURCE_DIR/$spec
+echo "++ creating bootstrap source RPM file"
+$tmpdir/rpm -bs --nodeps $spec
 cp $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.src.rpm $dstdir/
 rm -f $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.src.rpm
 
 #   create Binary-RPM file
+echo "++ creating bootstrap binary RPM file"
 cp $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.$t.rpm $dstdir/
 rm -f $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.$t.rpm
 
 #   create Binary-Bootstrap file
-cat $spec | sed -e "/^%pre$/,/^%/ p" -e 'd' | sed -e '/^%/d' -e 's/^  //' >$tmpdir/rpm.pre
-sed <`SOURCE wrap2.sh` \
-    -e "s;@FSUSR@;$fsusr;" -e "s;@FSGRP@;$fsgrp;" \
+echo "++ creating bootstrap binary shell script"
+cat $spec | sed -e "/^%pre$/,/^%/ p" -e 'd' | sed -e '/^%/d' -e 's/^ 	//' >$tmpdir/rpm.pre
+sed <`SOURCE aux.wrapbin.sh` \
+    -e "s;@SUSR@;$susr;" -e "s;@SGRP@;$sgrp;" \
+    -e "s;@MUSR@;$musr;" -e "s;@MGRP@;$mgrp;" \
+    -e "s;@RUSR@;$rusr;" -e "s;@RGRP@;$rgrp;" \
+    -e "s;@NUSR@;$nusr;" -e "s;@NGRP@;$ngrp;" \
     -e "s;@l_prefix@;$prefix;" -e "s;@TGZ@;openpkg-$v.$t.tar.Z;" \
     -e "/^@PRE@/r $tmpdir/rpm.pre" |\
     sed -e '/^@PRE@/d' >$dstdir/openpkg-$v.$t.sh
-(cd $RPM_BUILD_ROOT$prefix; tar cf - .[a-zA-Z]* *) |\
+files=`cat $spec |\
+       sed -e '1,/%files/d' -e '/%clean/,$d' |\
+       grep -v '^ *$' | grep -v '%defattr' |\
+       sed -e 's;%config *;;' -e 's;%dir *;;' -e 's;%{l_prefix}/;;' -e 's;^ *;;' -e "s;%{V_rpm};${V_rpm};"`
+( cd $RPM_BUILD_ROOT$prefix;
+  $RPM_BUILD_ROOT$prefix/lib/openpkg/tar --no-recursion -cf - $files) |\
 compress | uuencode openpkg-$v.$t.tar.Z >>$dstdir/openpkg-$v.$t.sh
 
 #   cleanup
+echo "++ cleaning up"
 rm -rf $RPM_BUILD_ROOT
 rm -rf $tmpdir/$name-$version
 rm -f $tmpdir/rpm $tmpdir/rpm.[123] $tmpdir/.popt $tmpdir/rpm.pre
@@ -436,6 +465,6 @@ rm -f $prolog
 
 #   final hint about results
 set +x
-echo "Resulting files (placed into $dstdir):"
+echo "++ resulting files (placed into $dstdir):"
 (cd $dstdir; ls -l openpkg-$v.$t.sh openpkg-$v.$t.rpm openpkg-$v.src.rpm)
 

+ 264 - 187
openpkg/openpkg.spec

@@ -39,8 +39,8 @@
 #   o any cc(1)
 
 #   the package version and release
-%define       V_openpkg 20020203
-%define       R_openpkg 20020203
+%define       V_openpkg 20020204
+%define       R_openpkg 20020204
 
 #   the used software versions
 %define       V_rpm     4.0.2
@@ -91,8 +91,8 @@ Source20:     rpmtool.pod
 Source21:     lsync
 Source22:     lsync.8
 Source23:     lsync.pod
-Source24:     wrap1.sh
-Source25:     wrap2.sh
+Source24:     aux.wrapsrc.sh
+Source25:     aux.wrapbin.sh
 Source26:     openpkg.pgp
 Source27:     shtool
 Source28:     rpmx.sh
@@ -108,6 +108,8 @@ Source37:     dot.bash_login
 Source38:     dot.lsyncrc
 Source39:     db-%{V_db}.patch
 Source40:     rc.conf
+Source41:     aux.prereq.sh
+Source42:     aux.usrgrp.sh
 
 #   build information
 Prefix:       %{l_prefix}
@@ -185,54 +187,41 @@ Provides:     OpenPKG
         exit 1
     fi
     echo "l_cc=\"$l_cc\"; export l_cc" >>.buildenv
-  
-    #   determine user and group for installed files
-    if [ ".%{?l_fsusr:set}" = .set ]; then
-        fsusr="%{l_fsusr}"
-    else
-        fsusr=`(id -un) 2>/dev/null ||\
-               (whoami) 2>/dev/null ||\
-               (who am i | cut "-d " -f1) 2>/dev/null ||\
-               echo $LOGNAME`
-    fi
-    echo "fsusr=\"$fsusr\"; export fsusr" >>.buildenv
-    if [ ".%{?l_fsgrp:set}" = .set ]; then
-        fsgrp="%{l_fsgrp}"
-    else
-        fsgrp=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
-               grep "^${fsusr}:" | head -1 | awk -F: '{ print $4; }'`
-        fsgrp=`(cat /etc/group; ypcat group) 2>/dev/null |\
-               grep ":${fsgrp}:" | head -1 | awk -F: '{ print $1; }'`
-    fi
-    fsgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
-           grep "^${fsgrp}:" | head -1 | awk -F: '{ print $3; }'`
-    echo "fsgrp=\"$fsgrp\"; export fsgrp" >>.buildenv
-    echo "fsgid=\"$fsgid\"; export fsgid" >>.buildenv
-  
-    #   determine user and group for non-priviledged operations
-    npusr=nobody
-    npuid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
-           grep "^${npusr}:" | head -1 | awk -F: '{ print $3; }'`
-    if [ ".$npuid" = . ]; then
-        echo "Ops, your system lacks a 'nobody' user!"
-        exit 1
-    fi
-    echo "npusr=\"$npusr\"; export npusr" >>.buildenv
-    echo "npuid=\"$npuid\"; export npuid" >>.buildenv
-    for npgrp in nobody nogroup; do
-        npgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
-               grep "^${npgrp}:" | head -1 | awk -F: '{ print $3; }'`
-        if [ ".$npgid" != . ]; then
-            break
-        fi
-    done
-    if [ ".$npgid" = . ]; then
-        echo "Ops, your system lacks a 'nobody' or 'nogroup' group!"
-        exit 1
-    fi
-    echo "npgrp=\"$npgrp\"; export npgrp" >>.buildenv
-    echo "npgid=\"$npgid\"; export npgid" >>.buildenv
 
+    #   determine path to aux.usrgrp.sh script
+    usrgrp=`SOURCE aux.usrgrp.sh`
+    echo "usrgrp=$usrgrp" >>./.buildenv
+
+    #   determine user/group name/id pairs
+    #   - bootstrapping: %{l_[smrn]{usr,grp}} is set via sed(1)
+    #   - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
+    #   - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
+    susr=""; [ ".%{?l_susr:set}"  = .set ] && susr="%{l_susr}"
+    sgrp=""; [ ".%{?l_sgrp:set}"  = .set ] && sgrp="%{l_sgrp}"
+    musr=""; [ ".%{?l_musr:set}"  = .set ] && musr="%{l_musr}"
+    mgrp=""; [ ".%{?l_mgrp:set}"  = .set ] && mgrp="%{l_mgrp}"
+    rusr=""; [ ".%{?l_rusr:set}"  = .set ] && rusr="%{l_rusr}"
+    rgrp=""; [ ".%{?l_rgrp:set}"  = .set ] && rgrp="%{l_rgrp}"
+    nusr=""; [ ".%{?l_nusr:set}"  = .set ] && nusr="%{l_nusr}"
+    ngrp=""; [ ".%{?l_ngrp:set}"  = .set ] && ngrp="%{l_ngrp}"
+    #   compat:
+    usr="";  [ ".%{?l_fsusr:set}" = .set ] && usr="%{l_fsusr}"
+    grp="";  [ ".%{?l_fsgrp:set}" = .set ] && grp="%{l_fsgrp}"
+    eval `sh $usrgrp \
+          --usr="$usr" --grp="$grp" \
+          --susr="$susr" --sgrp="$sgrp" \
+          --musr="$musr" --mgrp="$mgrp" \
+          --rusr="$rusr" --rgrp="$rgrp" \
+          --nusr="$nusr" --ngrp="$ngrp"`
+    echo "susr=\"$susr\"; export susr" >>.buildenv
+    echo "sgrp=\"$sgrp\"; export sgrp" >>.buildenv
+    echo "musr=\"$musr\"; export musr" >>.buildenv
+    echo "mgrp=\"$mgrp\"; export mgrp" >>.buildenv
+    echo "rusr=\"$rusr\"; export rusr" >>.buildenv
+    echo "rgrp=\"$rgrp\"; export rgrp" >>.buildenv
+    echo "nusr=\"$nusr\"; export nusr" >>.buildenv
+    echo "ngrp=\"$ngrp\"; export ngrp" >>.buildenv
+  
     #   determine installation location id
     if [ ".%{?l_location:set}" = .set ]; then
         loc="%{l_location}"
@@ -532,10 +521,10 @@ Provides:     OpenPKG
       cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
       strip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
     )
-    sed -e 's;@l_prefix@;%{l_prefix};g' \
+    sed -e "s;@l_prefix@;%{l_prefix};g" \
         <`SOURCE rpmx.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.sh
-    sed -e 's;@l_prefix@;%{l_prefix};g' \
+    sed -e "s;@l_prefix@;%{l_prefix};g" \
         <`SOURCE rpmx.pl` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmx.pl
   
@@ -595,19 +584,21 @@ Provides:     OpenPKG
         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc
     sed -e "s:@l_prefix@:%{l_prefix}:g" \
         -e "s:@LOC@:$loc:g" \
-        -e "s:@FSUSR@:$fsusr:g" \
-        -e "s:@FSGRP@:$fsgrp:g" \
-        -e "s:@NPUSR@:$npusr:g" \
-        -e "s:@NPUID@:$npuid:g" \
-        -e "s:@NPGRP@:$npgrp:g" \
-        -e "s:@NPGID@:$npgid:g" \
+        -e "s:@SUSR@:$susr:g" \
+        -e "s:@SGRP@:$sgrp:g" \
+        -e "s:@MUSR@:$musr:g" \
+        -e "s:@MGRP@:$mgrp:g" \
+        -e "s:@RUSR@:$rusr:g" \
+        -e "s:@RGRP@:$rgrp:g" \
+        -e "s:@NUSR@:$nusr:g" \
+        -e "s:@NGRP@:$ngrp:g" \
         <`SOURCE rpmmacros` \
         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros
     cp `SOURCE openpkg.pgp` \
        $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.pgp
   
 %files
-    %defattr(-,%{l_fsusr},%{l_fsgrp})
+    %defattr(-,%{l_musr},%{l_mgrp})
     %{l_prefix}/README
     %{l_prefix}/.bashrc
     %{l_prefix}/.bash_login
@@ -726,106 +717,165 @@ Provides:     OpenPKG
     rm -rf %{name}-%{version}
 
 %pre
-    [ ".$1" != .1 ] && exit 0
+    #   always performed for upgrades and because it doesn't harm!
+    #[ ".$1" != .1 ] && exit 0
 
     #   this procedure is only usable with root priviledges
     #   (for non-root installations it is not required at all)
-    thisuser=`(id -un) 2>/dev/null ||\
-              (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
-              (whoami) 2>/dev/null ||\
-              (who am i | cut "-d " -f1) 2>/dev/null ||\
-              echo $LOGNAME`
+    cusr=`(id -un) 2>/dev/null ||\
+          (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
+          (whoami) 2>/dev/null ||\
+          (who am i | cut "-d " -f1) 2>/dev/null ||\
+          echo $LOGNAME`
 
     #   determine runtime details (for both inside and outside RPM!!)
-    user="$fsusr";  [ ".$fsusr" = . ]  && fsusr="%{l_fsusr}"
-    group="$fsgrp"; [ ".$fsgrp" = . ]  && fsgrp="%{l_fsgrp}"
-    prefix="$p";    [ ".$prefix" = . ] && prefix="%{l_prefix}"
+    #   bootstrapping: $xxx is set
+    #   upgrading:     %{l_xxx} is set
+    [ ".$susr" = . ] && susr="%{l_susr}"
+    [ ".$sgrp" = . ] && sgrp="%{l_sgrp}"
+    [ ".$musr" = . ] && musr="%{l_musr}"
+    [ ".$mgrp" = . ] && mgrp="%{l_mgrp}"
+    [ ".$rusr" = . ] && rusr="%{l_rusr}"
+    [ ".$rgrp" = . ] && rgrp="%{l_rgrp}"
+    [ ".$nusr" = . ] && nusr="%{l_nusr}"
+    [ ".$ngrp" = . ] && ngrp="%{l_ngrp}"
+
+    #   determine prefix
+    prefix="%{l_prefix}"
     prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
-    name=`echo "$prefix" | sed -e 's;/;;g'` 
+
+    #   determine user/group ids
+    for class in s m r n; do
+        eval "xusr=\"\$${class}usr\""
+        eval "xgrp=\"\$${class}grp\""
+        eval "xuid=\"\$${class}uid\""
+        eval "xgid=\"\$${class}gid\""
+        if [ ".$xuid" = . ]; then
+            xuid=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
+                  grep "^${xusr}:" | awk -F: '{ print $3; }'`
+            if [ ".$xuid" = . ]; then
+                #   seek for a reasonably uid/gid pair
+                xuid=1000
+                ok=0
+                while [ ".$ok" = .0 ]; do
+                    eval "u_exists=\$u_exists_$xuid"
+                    if [ ".$u_exists" = . ]; then
+                        u_exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
+                    fi
+                    eval "g_exists=\$g_exists_$xuid"
+                    if [ ".$g_exists" = . ]; then
+                        g_exists=`(cat /etc/group;  ypcat group)  2>/dev/null | grep "^[^:]*:[^:]*:$xuid:"`
+                    fi
+                    if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
+                        ok=1
+                        break
+                    fi
+                    xuid=`expr $xuid + 1`
+                done
+                eval "u_exists_$xuid=yes"
+                eval "g_exists_$xuid=yes"
+            fi
+        fi
+        if [ ".$xgid" = . ]; then
+            xgid=`(cat /etc/group; ypcat group) 2>/dev/null |\
+                  grep "^${xgrp}:" | awk -F: '{ print $3; }'`
+            if [ ".$xgid" = . ]; then
+                xgid="$xuid"
+            fi
+        fi
+        eval "${class}uid=\"$xuid\""
+        eval "${class}gid=\"$xgid\""
+    done
 
     #   determine platform id
     s=`(uname -s) 2>/dev/null` || s='Unknown'
     r=`(uname -r) 2>/dev/null` || r='0.0'
     plid="${s}/${r}"
 
-    #   create the hierarchy user/group
-    exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^$user:"`
-    if [ ".$exists" = . ]; then
-        if [ ".$thisuser" != ".root" ]; then
-            echo "openpkg:WARNING: skipping creation of dedicated OpenPKG user/group $ugid" 1>&2
-            echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
-        else
-            #   seek for a reasonably uid/gid pair
-            ugid=1000
-            ok=0
-            while [ ".$ok" = .0 ]; do
-                u_exists=`(cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^[^:]*:[^:]*:$ugid:"`
-                g_exists=`(cat /etc/group;  ypcat group)  2>/dev/null | grep "^[^:]*:[^:]*:$ugid:"`
-                if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
-                    ok=1
-                    break
-                fi
-                ugid=`expr $ugid + 1`
-            done
-
-            #   add entry to passwd database
-            shell="${prefix}/lib/openpkg/bash"
-            realname="${prefix} OpenPKG"
-            case "$plid" in
-                FreeBSD/* | NetBSD/* )
-                    file=/etc/master.passwd
-                    entry="${user}:*:${ugid}:${ugid}::0:0:${realname}:${prefix}:${shell}" 
-                    update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
-                    ;;
-                Linux/* )
-                    file=/etc/passwd
-                    entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
-                    update="(PATH=\$PATH:/usr/sbin; pwconv)"
-                    ;;
-                SunOS/5.* )
-                    file=/etc/passwd
-                    entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
-                    update="(PATH=\$PATH:/usr/sbin; pwconv)"
-                    ;;
-                OSF1/V5.* )
-                    file=/etc/passwd
-                    entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
-                    update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
-                    ;;
-                HP-UX/* )
-                    file=/etc/passwd
-                    entry="${user}:*:${ugid}:${ugid}:${realname}:${prefix}:${shell}"
-                    update=":"
-                    ;;
-            esac
-            cp $file $file.old
-            (grep -v '^+:' $file.old; echo $entry; grep '^+:' $file.old) >$file
-            rm -f $file.old >/dev/null 2>&1
-            eval $update
-            
-            #   add entry to group database
-            file=/etc/group
-            entry="${user}:*:${ugid}:${user}"
-            cp $file $file.old
-            (grep -v '^+:' $file.old; echo $entry; grep '^+:' $file.old) >$file
-            rm -f $file.old >/dev/null 2>&1
-        fi
-    fi
-
     #   add entry to /etc/shells
     shell="${prefix}/lib/openpkg/bash"
     exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
     if [ ".$exists" = . ]; then
-        if [ ".$thisuser" != ".root" ]; then
+        if [ ".$cusr" != ".root" ]; then
             echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2
             echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
         else
             echo "${shell}" >>/etc/shells
         fi
     fi
-  
+
+    #   create the hierarchy user/group
+    for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \
+               "management:${musr}:${muid}:${mgrp}:${mgid}" \
+               "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \
+               "non-priviledged:${nusr}:${nuid}:${ngrp}:${ngid}"; do
+        #    split request into class/usr/uid/grp/gid
+        OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
+        class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
+
+        #    check whether user already exists
+        exists=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null | grep "^$usr:"`
+        if [ ".$exists" = . ]; then
+            if [ ".$cusr" != ".root" ]; then
+                echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2
+                echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
+            else
+                #   add entry to passwd database
+                realname="${prefix} OpenPKG ($class)"
+                case "$plid" in
+                    FreeBSD/* | NetBSD/* )
+                        file=/etc/master.passwd
+                        entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}" 
+                        update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
+                        ;;
+                    Linux/* )
+                        file=/etc/passwd
+                        entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
+                        update="(PATH=\$PATH:/usr/sbin; pwconv)"
+                        ;;
+                    SunOS/5.* )
+                        file=/etc/passwd
+                        entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
+                        update="(PATH=\$PATH:/usr/sbin; pwconv)"
+                        ;;
+                    OSF1/V5.* )
+                        file=/etc/passwd
+                        entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
+                        update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
+                        ;;
+                    HP-UX/* )
+                        file=/etc/passwd
+                        entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
+                        update=":"
+                        ;;
+                esac
+                cp $file $file.bak && \
+                (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
+                rm -f $file.bak >/dev/null 2>&1
+                eval $update
+            fi
+        fi
+                
+        #    check whether group already exists
+        exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$grp:"`
+        if [ ".$exists" = . ]; then
+            if [ ".$cusr" != ".root" ]; then
+                echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2
+                echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
+            else
+                #   add entry to group database
+                file=/etc/group
+                entry="${grp}:*:${gid}:${usr}"
+                cp $file $file.bak && \
+                (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
+                rm -f $file.bak >/dev/null 2>&1
+            fi
+        fi
+    done
+
     #   create the startup/shutdown transfer script
-    if [ ".$thisuser" != ".root" ]; then
+    name=`echo "$prefix" | sed -e 's;/;;g'` 
+    if [ ".$cusr" != ".root" ]; then
         echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2
         echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
     else
@@ -993,7 +1043,7 @@ Provides:     OpenPKG
     fi
 
     #   create the cron transfer entries
-    if [ ".$thisuser" != ".root" ]; then
+    if [ ".$cusr" != ".root" ]; then
         echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2
         echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
     else
@@ -1046,7 +1096,7 @@ Provides:     OpenPKG
     if [ ".$1" = .2 ]; then
         ( sleep 2
           %{l_prefix}/bin/rpm --rebuilddb
-          chown %{l_fsusr}:%{l_fsgrp} %{l_prefix}/RPM/DB/* || true
+          chown %{l_musr}:%{l_mgrp} %{l_prefix}/RPM/DB/* || true
         ) </dev/null >/dev/null 2>/dev/null &
     fi
 
@@ -1073,72 +1123,99 @@ Provides:     OpenPKG
     ##
 
     #   determine current user
-    thisuser=`(id -un) 2>/dev/null ||\
-              (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
-              (whoami) 2>/dev/null ||\
-              (who am i | cut "-d " -f1) 2>/dev/null ||\
-              echo $LOGNAME`
+    cusr=`(id -un) 2>/dev/null ||\
+          (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
+          (whoami) 2>/dev/null ||\
+          (who am i | cut "-d " -f1) 2>/dev/null ||\
+          echo $LOGNAME`
 
     #   determine runtime details (for both inside and outside RPM!!)
-    user="%{l_fsusr}"
-    group="%{l_fsgrp}"
+    user="%{l_musr}"
+    group="%{l_mgrp}"
     prefix="%{l_prefix}"
     prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
-    name=`echo "$prefix" | sed -e 's;/;;g'` 
 
     #   determine platform id
     s=`(uname -s) 2>/dev/null` || s='Unknown'
     r=`(uname -r) 2>/dev/null` || r='0.0'
     plid="${s}/${r}"
 
-    #   remove the hierarchy user/group
-    exists=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null | grep "^$user:"`
-    if [ ".$exists" != . ]; then
-        if [ ".$thisuser" != ".root" ]; then
-            echo "openpkg:WARNING: skipping deletion of dedicated OpenPKG user/group $ugid" 1>&2
-            echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
-        else
-            case "$plid" in
-                FreeBSD/* | NetBSD/* )
-                    cp /etc/master.passwd /etc/master.passwd.bak
-                    grep -v "^${user}:" /etc/master.passwd.bak >/etc/master.passwd
-                    (PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd)
-                    ;;
-                Linux/* | SunOS/5.* )
-                    cp /etc/passwd /etc/passwd.bak
-                    grep -v "^${user}:" /etc/passwd.bak >/etc/passwd
-                    (PATH="$PATH:/usr/sbin"; pwconv)
-                    ;;
-                OSF1/V5.* )
-                    cp /etc/passwd /etc/passwd.bak
-                    grep -v "^${user}:" /etc/passwd.bak >/etc/passwd
-                    (PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd)
-                    ;;
-                HP-UX/* )
-                    cp /etc/passwd /etc/passwd.bak
-                    grep -v "^${user}:" /etc/passwd.bak >/etc/passwd
-                    ;;
-            esac
-            cp /etc/group /etc/group.bak
-            grep -v "^${user}:" /etc/group.bak >/etc/group
-        fi
-    fi
-
     #   remove entry in /etc/shells
     shell="${prefix}/lib/openpkg/bash"
     exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
     if [ ".$exists" != . ]; then
-        if [ ".$thisuser" != ".root" ]; then
+        if [ ".$cusr" != ".root" ]; then
             echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2
             echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
         else
-            cp /etc/shells /etc/shells.bak
+            cp /etc/shells /etc/shells.bak && \
             grep -v "^${shell}" /etc/shells.bak >/etc/shells
         fi
     fi
   
+    #   remove the hierarchy user/group
+    for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \
+               "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \
+               "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \
+               "non-priviledged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do
+        #    split request into class/usr/uid/grp/gid
+        OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
+        class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
+
+        #    check whether user already exists
+        exists=`(cat /etc/passwd; cat /etc/master.passwd; ypcat passwd) 2>/dev/null | grep "^$usr:"`
+        if [ ".$exists" != . ]; then
+            if [ ".$cusr" != ".root" ]; then
+                echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
+                echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
+            elif [ ".$usr" = ".root" ]; then
+                echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
+                echo "openpkg:WARNING: (would remove system standard user)" 1>&2
+            else
+                case "$plid" in
+                    FreeBSD/* | NetBSD/* )
+                        cp /etc/master.passwd /etc/master.passwd.bak && \
+                        grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd
+                        (PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd)
+                        ;;
+                    Linux/* | SunOS/5.* )
+                        cp /etc/passwd /etc/passwd.bak && \
+                        grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
+                        (PATH="$PATH:/usr/sbin"; pwconv)
+                        ;;
+                    OSF1/V5.* )
+                        cp /etc/passwd /etc/passwd.bak && \
+                        grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
+                        (PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd)
+                        ;;
+                    HP-UX/* )
+                        cp /etc/passwd /etc/passwd.bak && \
+                        grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
+                        ;;
+                esac
+            fi
+        fi
+
+        #    check whether group already exists
+        exists=`(cat /etc/group; ypcat group) 2>/dev/null | grep "^$grp:"`
+        if [ ".$exists" = . ]; then
+            if [ ".$cusr" != ".root" ]; then
+                echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
+                echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
+            elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then
+                echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
+                echo "openpkg:WARNING: (would remove system standard group)" 1>&2
+            else
+                #   delete group entry
+                cp /etc/group /etc/group.bak && \
+                grep -v "^${grp}:" /etc/group.bak >/etc/group
+            fi
+        fi
+    done
+
     #   remove the startup/shutdown transfer ripts
-    if [ ".$thisuser" != ".root" ]; then
+    name=`echo "$prefix" | sed -e 's;/;;g'` 
+    if [ ".$cusr" != ".root" ]; then
         echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2
         echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
     else
@@ -1190,7 +1267,7 @@ Provides:     OpenPKG
     fi
 
     #   remove the cron transfer entries
-    if [ ".$thisuser" != ".root" ]; then
+    if [ ".$cusr" != ".root" ]; then
         echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2
         echo "openpkg:WARNING: (would require root-priviledges)" 1>&2
     else
@@ -1211,9 +1288,9 @@ Provides:     OpenPKG
                 export EDITOR
                 export VISUAL
                 p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
-                ( echo "cp \$1 \$1.old"
-                  echo "cat \$1.old | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
-                  echo "rm -f \$1.old"
+                ( echo "cp \$1 \$1.bak"
+                  echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
+                  echo "rm -f \$1.bak"
                 ) >$EDITOR
                 chmod a+x $EDITOR
                 (PATH="$PATH:/usr/bin"; crontab -e)

+ 9 - 1
openpkg/rc

@@ -166,7 +166,15 @@ fi
 scripts=`echo "$1" | sed -e 's;^.*rc\.;;'`
 shift
 if [ ".$scripts" = ".all" ]; then
-    scripts=`ls $rcdir/rc.* | sed -e "s;^$rcdir/rc\.;;"`
+    . $rcconf
+    case "$openpkg_ignall" in
+        [Yy][Ee][Ss] | [Tt][Rr][Uu][Ee] | [Oo][Nn] | 1 ) 
+            scripts=`ls $rcdir/rc.* | sed -e "s;^$rcdir/rc\.;;"`
+            ;;
+        * ) 
+            exit 0 
+            ;;
+    esac
 else
     if [ ! -f "$rcdir/rc.$scripts" ]; then
         echo "$0:ERROR: script \`$rcdir/rc.$scripts' not found" 1>&2

+ 1 - 0
openpkg/rc.openpkg

@@ -25,6 +25,7 @@
 ##
 
 %config
+    openpkg_ignall="yes"
     openpkg_envprio="high"
 
 %env -p0

+ 51 - 34
openpkg/rpmmacros

@@ -1,34 +1,64 @@
 ##
-##  @l_prefix@/etc/openpkg/rpmmacros -- RPM macros for @l_prefix@ hierarchy
+##  @l_prefix@/etc/openpkg/rpmmacros -- OpenPKG RPM macros for @l_prefix@ hierarchy
 ##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
 ##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
 ##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
 ##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
 ##  The purpose of this macro set is to override the default
-##  macros in the RPM installation for the @l_prefix@ hierarchy.
+##  macros in the OpenPKG RPM installation for the @l_prefix@ hierarchy.
 ##
 
-#   the OpenPKG identification 
-#   OpenPKG -CURRENT -> "YYYYMMDD"
-#   OpenPKG -STABLE  -> "X.Y"
-%l_branch                %(date '+%Y%m%d')
-
 #   the platform identification
 %l_target                %{_target}
 %l_location              @LOC@
 
-#   the user/group name/id pair for installed files
-#   (because of bootstrapping issues the l_fs[ug]id cannot be cleanly pre-determined) 
-%l_fsusr                 @FSUSR@
-%l_fsuid                 %((cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^%{l_fsusr}:" | head -1 | awk -F: '{ print $3; }')
-%l_fsgrp                 @FSGRP@
-%l_fsgid                 %((cat /etc/group; ypcat group) 2>/dev/null | grep "^%{l_fsgrp}:" | head -1 | awk -F: '{ print $3; }')
-
-#   the user/group name/id pair for non-priviledged operations
-%l_npusr                 @NPUSR@
-%l_npuid                 @NPUID@
-%l_npgrp                 @NPGRP@
-%l_npgid                 @NPGID@
+#   the *S*uper-user user/group name/id pair
+%l_susr                  @SUSR@
+%l_sgrp                  @SGRP@
+%l_suid                  %((cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^%{l_susr}:" | head -1 | awk -F: '{ print $3; }')
+%l_sgid                  %((cat /etc/group;  ypcat group)  2>/dev/null | grep "^%{l_sgrp}:" | head -1 | awk -F: '{ print $3; }')
+
+#   the *M*anagement user/group name/id pair
+%l_musr                  @MUSR@
+%l_mgrp                  @MGRP@
+%l_muid                  %((cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^%{l_musr}:" | head -1 | awk -F: '{ print $3; }')
+%l_mgid                  %((cat /etc/group;  ypcat group)  2>/dev/null | grep "^%{l_mgrp}:" | head -1 | awk -F: '{ print $3; }')
+
+#   the *R*restricted user/group name/id pair
+%l_rusr                  @RUSR@
+%l_rgrp                  @RGRP@
+%l_ruid                  %((cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^%{l_rusr}:" | head -1 | awk -F: '{ print $3; }')
+%l_rgid                  %((cat /etc/group;  ypcat group)  2>/dev/null | grep "^%{l_rgrp}:" | head -1 | awk -F: '{ print $3; }')
+
+#   the *N*on-priviledged user/group name/id pair
+%l_nusr                  @NUSR@
+%l_ngrp                  @NGRP@
+%l_nuid                  %((cat /etc/passwd; ypcat passwd) 2>/dev/null | grep "^%{l_nusr}:" | head -1 | awk -F: '{ print $3; }')
+%l_ngid                  %((cat /etc/group;  ypcat group)  2>/dev/null | grep "^%{l_ngrp}:" | head -1 | awk -F: '{ print $3; }')
+
+#   backward compatibility (openpkg < 20020204)
+%l_fsusr                 %{l_musr}
+%l_fsgrp                 %{l_mgrp}
+%l_fsuid                 %{l_muid}
+%l_fsgid                 %{l_mgid}
 
 #   the two root directories
 %l_root_install          @l_prefix@
@@ -137,7 +167,7 @@
 %l_whoami                %((id -un) 2>/dev/null || (whoami) 2>/dev/null || (who am i | cut "-d " -f1) 2>/dev/null || echo $LOGNAME)
 
 #   macros for dynamically generating a %files list
-%l_files_defattr         '%defattr(-,%{l_fsusr},%{l_fsgrp})'
+%l_files_defattr         '%defattr(-,%{l_musr},%{l_mgrp})'
 %l_files_all             '%{l_prefix}'
 %l_files_noshared        '%not %dir {%{l_prefix},%{l_prefix}/*,%{l_prefix}/etc/rc.d,%{l_prefix}/man/*}'
 %l_files_std(o:g:)       %l_files_defattr %l_files_all %l_files_noshared
@@ -146,7 +176,7 @@
 %l_buildroot             %{_tmppath}/%{name}-%{version}-root
 
 #   executable path for %post/%pre
-%_install_script_path    @l_prefix@/bin:@l_prefix@/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
+%_install_script_path    @l_prefix@/bin:@l_prefix@/sbin:/bin:/sbin:/usr/bin:/usr/sbin
 
 #   override the name scheme for RPM files
 %_rpmfilename            %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-@LOC@.rpm
@@ -159,16 +189,3 @@
 #   package signature type is OpenPGP via GnuPG
 %_signature              gpg
 
-#   the default repository list
-%l_repo_cache            %{l_root_rpm}/PKG/
-%l_repo_0                %{l_root_rpm}/PKG/
-%l_repo_1                -
-%l_repo_2                -
-%l_repo_3                -
-%l_repo_4                ftp://ftp.openpkg.org/current/SRC/
-%l_repo_5                -
-%l_repo_6                -
-%l_repo_7                -
-%l_repo_8                -
-%l_repo_9                -
-

+ 18 - 0
openpkg/rpmrc

@@ -4,6 +4,24 @@
 ##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
 ##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
 ##
+##  Permission to use, copy, modify, and distribute this software for
+##  any purpose with or without fee is hereby granted, provided that
+##  the above copyright notice and this permission notice appear in all
+##  copies.
+##
+##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+##  SUCH DAMAGE.
+##
 ##  The purpose of this configuration file is to override the
 ##  "macrofiles" directive in the default RPM configuration in order
 ##  to direct RPM to the special macro definitions for the @l_prefix@

+ 0 - 94
openpkg/wrap1.sh

@@ -1,94 +0,0 @@
-#!/bin/sh
-##
-##  Shell-based package for OpenPKG source bootstrap procedure
-##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
-##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
-##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
-##
-
-#   defaults
-f="$0"
-h=0
-v=''
-p=''
-u=''
-g=''
-d='@DIR@'
-t='@TGZ@'
-
-#   parse command line options
-for opt
-do
-    case $opt in
-        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
-           *) arg='' ;;
-    esac
-    case $opt in
-        -h | --help    ) h=1    ;;
-        -v | --verbose ) v=v    ;;
-        --prefix=*     ) p=$arg ;;
-        --user=*       ) u=$arg ;;
-        --group=*      ) g=$arg ;;
-        *              ) h=1    ;;
-    esac
-done
-if [ ".$p" = . ]; then
-    h=1
-fi
-if [ ".$h" = .1 ]; then
-    echo "Usage: sh $0 [-h|--help] [-v|--verbose] --prefix=<prefix> [--user=<user>] [--group=<group>]" 2>&1
-    exit 1
-fi
-
-#   establish standard environment
-LC_CTYPE=C
-export LC_CTYPE
-umask 022
-
-#   determine current user and group
-thisuser=`(id -un) 2>/dev/null ||\
-          (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
-          (whoami) 2>/dev/null ||\
-          (who am i | cut "-d " -f1) 2>/dev/null ||\
-          echo $LOGNAME`
-thisgroup=`(cat /etc/passwd; ypcat passwd) 2>/dev/null |\
-           grep "^${thisuser}:" | awk -F: '{ print $4; }'`
-thisgroup=`(cat /etc/group; ypcat group) 2>/dev/null |\
-           grep ":${thisgroup}:" | awk -F: '{ print $1; }'`
-if [ ".$thisgroup" = . ]; then
-    thisgroup="$thisuser"
-fi
-
-#   perform the extraction
-echo "$0: extracting to $d..."
-uudecode $f
-rm -rf $d >/dev/null 2>&1
-mkdir $d || exit 1
-uncompress <$t |\
-(cd $d; tar x${v}f - 2>/dev/null)
-if [ ".$thisuser" = .root ]; then
-    ( cd $d 
-      chown -R -h $thisuser  . >/dev/null 2>&1 || true
-      chgrp -R -h $thisgroup . >/dev/null 2>&1 || true
-    )
-fi
-echo "$0: extraction done."
-
-#   perform building
-echo "$0: building for $p..."
-cd $d || exit 1
-./openpkg.boot $p $u $g || exit 1
-echo "$0: build done."
-
-#   cleanup
-echo "$0: cleaning up..."
-cd ..
-rm -rf $d >/dev/null 2>&1
-rm -f $t >/dev/null 2>&1
-echo "$0: cleaned up."
-
-#   die explicitly just before the shell would discover
-#   that we carry mega-bytes of data with us...
-exit 0
-
-#   the distribution tarball

+ 0 - 85
openpkg/wrap2.sh

@@ -1,85 +0,0 @@
-#!/bin/sh
-##
-##  Shell-based package for OpenPKG binary bootstrap installation
-##  Copyright (c) 2000-2002 Cable & Wireless Deutschland GmbH
-##  Copyright (c) 2000-2002 The OpenPKG Project <http://www.openpkg.org/>
-##  Copyright (c) 2000-2002 Ralf S. Engelschall <rse@engelschall.com>
-##
-##
-
-#   defaults
-f="$0"
-h=0
-v=''
-p='@l_prefix@'
-t='@TGZ@'
-fsusr='@FSUSR@'
-fsgrp='@FSGRP@'
-
-#   parse command line options
-for opt
-do
-    case $opt in
-        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
-           *) arg='' ;;
-    esac
-    case $opt in
-        -h | --help    ) h=1    ;;
-        -v | --verbose ) v=v    ;;
-        --prefix=*     ) p=$arg ;;
-        *              ) h=1    ;;
-    esac
-done
-if [ ".$h" = .1 ]; then
-    echo "Usage: sh $0 [-h|--help] [-v|--verbose] [--prefix=<prefix>]" 2>&1
-    exit 1
-fi
-
-#   establish standard environment
-LC_CTYPE=C
-export LC_CTYPE
-umask 022
-
-#   determine current username
-thisuser=`(id -un) 2>/dev/null ||\
-          (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
-          (whoami) 2>/dev/null ||\
-          (who am i | cut "-d " -f1) 2>/dev/null ||\
-          echo $LOGNAME`
-
-#   perform the installation
-echo "$0: installing into $p..."
-
-#   the reason of the following magic you certainly don't want to understand ;)
-set -- 1
-@PRE@
-
-d=''
-for c in `IFS=/; echo $p`; do
-    d="$d/$c"
-    if [ ! -d $d ]; then
-        mkdir $d || exit 1
-        chmod 755 $d || exit 1
-        if [ ".$thisuser" = .root ]; then
-            chown $fsusr $d >/dev/null 2>&1 || true
-            chgrp $fsgrp $d >/dev/null 2>&1 || true
-        fi
-    fi
-done
-uudecode $f
-uncompress <$t |\
-(cd $p; tar x${v}f -)
-rm -f $t >/dev/null 2>&1
-if [ ".$thisuser" = .root ]; then
-    ( cd $p || exit 1
-      chown -R -h $fsusr . >/dev/null 2>&1 || true
-      chgrp -R -h $fsgrp . >/dev/null 2>&1 || true
-    )
-fi
-echo "$0: installation done."
-
-#   die explicitly just before the shell would discover
-#   that we carry mega-bytes of data with us...
-exit 0
-
-#   the distribution tarball