openpkg/aux.wrapbin.sh

changeset 430
9b4bbbae3a98
parent 429
b363f8ef6dcb
child 431
127559aa0c5e
     1.1 --- a/openpkg/aux.wrapbin.sh	Tue Jul 31 12:27:54 2012 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,252 +0,0 @@
     1.4 -#!/bin/sh
     1.5 -##
     1.6 -##  OpenPKG Binary Bootstrap Package (self-extracting shell script)
     1.7 -##  Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
     1.8 -##  Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
     1.9 -##
    1.10 -##  Permission to use, copy, modify, and distribute this software for
    1.11 -##  any purpose with or without fee is hereby granted, provided that
    1.12 -##  the above copyright notice and this permission notice appear in all
    1.13 -##  copies.
    1.14 -##
    1.15 -##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    1.16 -##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    1.17 -##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    1.18 -##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    1.19 -##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.20 -##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.21 -##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    1.22 -##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    1.23 -##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    1.24 -##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    1.25 -##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.26 -##  SUCH DAMAGE.
    1.27 -##
    1.28 -
    1.29 -#   configuration
    1.30 -l_me="$0"
    1.31 -o_help=no
    1.32 -o_version=no
    1.33 -o_tar=no
    1.34 -l_prefix='@l_prefix@'
    1.35 -l_musr='@MUSR@'
    1.36 -l_mgrp='@MGRP@'
    1.37 -l_platform="@l_platform@"
    1.38 -l_release="@l_release@"
    1.39 -l_version="@l_version@"
    1.40 -
    1.41 -#   establish standard environment
    1.42 -PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin"
    1.43 -LC_CTYPE=C
    1.44 -export LC_CTYPE
    1.45 -umask 022
    1.46 -
    1.47 -#   parse command line options
    1.48 -for opt
    1.49 -do
    1.50 -    case $opt in
    1.51 -        -*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
    1.52 -           *) arg='' ;;
    1.53 -    esac
    1.54 -    case $opt in
    1.55 -        -h | --help    ) o_help=yes     ;;
    1.56 -        -v | --version ) o_version=yes  ;;
    1.57 -        -t | --tar     ) o_tar=yes      ;;
    1.58 -        --prefix=*     ) l_prefix=$arg  ;;
    1.59 -        *              ) o_help=yes     ;;
    1.60 -    esac
    1.61 -done
    1.62 -if [ ".$o_version" = .no -a ".$l_prefix" = . ]; then
    1.63 -    o_help=yes
    1.64 -fi
    1.65 -if [ ".$o_help" = .yes ]; then
    1.66 -    echo "Usage: sh $l_me" 2>&1
    1.67 -    echo "       [--prefix=<prefix>] [-t|--tar]" 2>&1
    1.68 -    echo "       [-h|--help] [-v|--version]" 2>&1
    1.69 -    exit 1
    1.70 -fi
    1.71 -
    1.72 -#   make sure all essential installation tools are available
    1.73 -for tool in sed mkdir dd tar chown chgrp; do
    1.74 -    found=no
    1.75 -    case $tool in
    1.76 -        /* )
    1.77 -            if [ -f $tool ]; then
    1.78 -                found=yes
    1.79 -            fi
    1.80 -            ;;
    1.81 -        * )
    1.82 -            for p in `IFS=:; echo $PATH`; do
    1.83 -                if [ -f "$p/$tool" ]; then
    1.84 -                    found=yes
    1.85 -                    break
    1.86 -                fi
    1.87 -            done
    1.88 -            ;;
    1.89 -    esac
    1.90 -    if [ ".$found" = .no ]; then
    1.91 -        echo "$l_me:ERROR: unable to find installation tool \"$tool\"" 1>&2
    1.92 -        exit 1
    1.93 -    fi
    1.94 -done
    1.95 -
    1.96 -#   optionally extract the embedded tarball only
    1.97 -if [ ".$o_tar" = .yes ]; then
    1.98 -    tmpdir="${TMPDIR-/tmp}/openpkg.$$"
    1.99 -    ( umask 077 && mkdir $tmpdir) || exit 1
   1.100 -    dd if=$l_me bs=8192 skip=8 2>/dev/null |\
   1.101 -    ( cd $tmpdir || exit 1
   1.102 -      tar xf - 2>/dev/null || exit 1
   1.103 -      ./openpkg.bzip2 -d -c openpkg.tar.bz2
   1.104 -    ) || exit 1
   1.105 -    rm -rf $tmpdir
   1.106 -    exit 0
   1.107 -fi
   1.108 -
   1.109 -#   display version and copyright header
   1.110 -echo "OpenPKG ${l_release} Binary Bootstrap Package, version ${l_version}"
   1.111 -echo "Built for prefix ${l_prefix} on target platform ${l_platform}"
   1.112 -if [ ".$o_version" = .yes ]; then
   1.113 -    exit 0
   1.114 -fi
   1.115 -
   1.116 -#   determine current username
   1.117 -cusr=`(id -un) 2>/dev/null ||\
   1.118 -      (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
   1.119 -      (whoami) 2>/dev/null ||\
   1.120 -      (who am i | cut "-d " -f1) 2>/dev/null ||\
   1.121 -      echo ${LOGNAME-"NN"}`
   1.122 -
   1.123 -#   running the embedded %pre script for hooking into the system environment
   1.124 -echo "++ hooking OpenPKG instance into system environment"
   1.125 -prefix="$l_prefix"
   1.126 -susr='@SUSR@'; sgrp='@SGRP@'
   1.127 -musr='@MUSR@'; mgrp='@MGRP@'
   1.128 -rusr='@RUSR@'; rgrp='@RGRP@'
   1.129 -nusr='@NUSR@'; ngrp='@NGRP@'
   1.130 -suid='@SUID@'; sgid='@SGID@'
   1.131 -muid='@MUID@'; mgid='@MGID@'
   1.132 -ruid='@RUID@'; rgid='@RGID@'
   1.133 -nuid='@NUID@'; ngid='@NGID@'
   1.134 -set -- 1 # emulate RPM's $1 when executing scripts
   1.135 -#   ---- BEGIN EMBEDDED %pre SCRIPT ----
   1.136 -@PRE@
   1.137 -#   ---- END EMBEDDED %pre SCRIPT ----
   1.138 -
   1.139 -#   make sure prefix/root directory exists
   1.140 -#   and has correct permissions and owner/group
   1.141 -if [ ! -d $l_prefix ]; then
   1.142 -    #   create prefix/root directory from scratch
   1.143 -    echo "++ creating OpenPKG instance root directory \"$l_prefix\""
   1.144 -    d=''
   1.145 -    for c in `IFS=/; echo $l_prefix`; do
   1.146 -        d="$d/$c"
   1.147 -        if [ ! -d $d ]; then
   1.148 -            mkdir $d || exit 1
   1.149 -            chmod 755 $d || exit 1
   1.150 -            if [ ".$cusr" = .root ]; then
   1.151 -                chown $musr $d >/dev/null 2>&1 || true
   1.152 -                chgrp $mgrp $d >/dev/null 2>&1 || true
   1.153 -            fi
   1.154 -        fi
   1.155 -    done
   1.156 -else
   1.157 -    #   adjust already existing prefix/root directory
   1.158 -    echo "++ fixating OpenPKG instance root directory \"$l_prefix\""
   1.159 -    ( cd $l_prefix || exit 1
   1.160 -      chmod 755 . || exit 1
   1.161 -      if [ ".$cusr" = .root ]; then
   1.162 -          chown $musr . >/dev/null 2>&1 || true
   1.163 -          chgrp $mgrp . >/dev/null 2>&1 || true
   1.164 -      fi
   1.165 -    ) || exit 1
   1.166 -fi
   1.167 -
   1.168 -#   extract and install binary distribution files
   1.169 -echo "++ extracting OpenPKG binary distribution"
   1.170 -dd if=$l_me bs=8192 skip=8 2>/dev/null |\
   1.171 -    (cd $l_prefix; tar xf - 2>/dev/null)
   1.172 -echo "++ installing OpenPKG binary distribution"
   1.173 -( cd $l_prefix || exit 1
   1.174 -  ./openpkg.bzip2 -d -c openpkg.tar.bz2 | ./openpkg.tar xf - 2>/dev/null
   1.175 -  rm -f openpkg.tar openpkg.bzip2 openpkg.tar.bz2 >/dev/null 2>&1 || true
   1.176 -) || exit 1
   1.177 -
   1.178 -#   fixate installation files
   1.179 -#   (ATTENTION: order of chgrp/chown and chmod is important because of "set-UID" bits)
   1.180 -echo "++ fixating OpenPKG instance filesystem hierarchy"
   1.181 -( echo 'fixate () {'
   1.182 -  echo '    chgrp "$3" "$4"'
   1.183 -  echo '    chown "$2" "$4"'
   1.184 -  echo '    chmod "$1" "$4"'
   1.185 -  echo '}'
   1.186 -  $l_prefix/bin/openpkg --keep-privileges rpm -q openpkg \
   1.187 -      --qf '[fixate %7.7{FILEMODES:octal} %{FILEUSERNAME:shescape} %{FILEGROUPNAME:shescape} ::%{FILENAMES:shescape}\n]' |\
   1.188 -      grep -v '(none)' | sed 's/^fixate .../fixate /' | sed -e "s; ::\\(.\\)@l_prefix@; \\1$l_prefix;"
   1.189 -) | sh 2>/dev/null || true
   1.190 -
   1.191 -#   running the embedded %post script
   1.192 -echo "++ post-processing OpenPKG bootstrap installation"
   1.193 -prefix="$l_prefix"
   1.194 -susr='@SUSR@'; sgrp='@SGRP@'
   1.195 -musr='@MUSR@'; mgrp='@MGRP@'
   1.196 -rusr='@RUSR@'; rgrp='@RGRP@'
   1.197 -nusr='@NUSR@'; ngrp='@NGRP@'
   1.198 -suid='@SUID@'; sgid='@SGID@'
   1.199 -muid='@MUID@'; mgid='@MGID@'
   1.200 -ruid='@RUID@'; rgid='@RGID@'
   1.201 -nuid='@NUID@'; ngid='@NGID@'
   1.202 -set -- 1 # emulate RPM's $1 when executing scripts
   1.203 -#   ---- BEGIN EMBEDDED %post SCRIPT ----
   1.204 -@POST@
   1.205 -#   ---- END EMBEDDED %post SCRIPT ----
   1.206 -
   1.207 -#   display final information
   1.208 -( echo "Congratulations!"
   1.209 -  echo ""
   1.210 -  echo "You have successfully installed an OpenPKG ${l_release} instance"
   1.211 -  echo "under prefix ${l_prefix} on target platform ${l_platform}."
   1.212 -  echo ""
   1.213 -  echo "For details about this OpenPKG instance, run any of the"
   1.214 -  echo "following typical OpenPKG RPM query commands:"
   1.215 -  echo ""
   1.216 -  echo "    \$ ${l_prefix}/bin/openpkg rpm -qa"
   1.217 -  echo "    \$ ${l_prefix}/bin/openpkg rpm -qi  openpkg"
   1.218 -  echo "    \$ ${l_prefix}/bin/openpkg rpm -qlv openpkg"
   1.219 -  echo ""
   1.220 -  echo "To check the integrity of the entire OpenPKG instance,"
   1.221 -  echo "run the following OpenPKG RPM verify command:"
   1.222 -  echo ""
   1.223 -  echo "    \$ ${l_prefix}/bin/openpkg rpm -Va"
   1.224 -  echo ""
   1.225 -  echo "To install software packages into this OpenPKG instance, run"
   1.226 -  echo "the following two OpenPKG RPM build commands for each package:"
   1.227 -  echo ""
   1.228 -  echo "    \$ ${l_prefix}/bin/openpkg rpm --rebuild /path/to/foo-*.src.rpm"
   1.229 -  echo "    \$ ${l_prefix}/bin/openpkg rpm -Uvh ${l_prefix}/RPM/PKG/foo-*.rpm"
   1.230 -  echo ""
   1.231 -  echo "To remove a software package later, just run:"
   1.232 -  echo ""
   1.233 -  echo "    \$ ${l_prefix}/bin/openpkg rpm -e foo"
   1.234 -  echo ""
   1.235 -  echo "To remove the whole OpenPKG instance under prefix ${l_prefix},"
   1.236 -  echo "just remove every package as shown above. As you finally"
   1.237 -  echo "remove the package \"openpkg\", the OpenPKG instance itself"
   1.238 -  echo "will be unlinked from the system and removed as well."
   1.239 -  echo ""
   1.240 -  echo "Thank you for flying OpenPKG..."
   1.241 -  echo "                                        Ralf S. Engelschall"
   1.242 -  echo "                                        The OpenPKG Project"
   1.243 -  echo "                                        openpkg@openpkg.org"
   1.244 -) | $l_prefix/lib/openpkg/rpmtool msg -b -t info
   1.245 -
   1.246 -#   die explicitly just before the shell would discover
   1.247 -#   that we carry mega-bytes of data with us... ;-)
   1.248 -exit 0
   1.249 -
   1.250 -#   the distribution tarball is appended in raw format directly to the
   1.251 -#   end of this script, just leaded by padding whitespaces which make
   1.252 -#   sure that the tarball data starts at the pre-defined offset of 64KB.
   1.253 -#   This allows us to unpack the tarball by just skipping the leading
   1.254 -#   64KB (= 8192*8, see above).
   1.255 -

mercurial