openpkg/openpkg.spec

Tue, 31 Jul 2012 12:12:54 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 31 Jul 2012 12:12:54 +0200
changeset 427
71503088f51b
parent 346
c403d9dd5e0e
child 428
f880f219c566
permissions
-rw-r--r--

Correct english, add missing rpl_strnlen, include RPM vars by default.

     1 ##
     2 ##  openpkg.spec -- OpenPKG RPM Package Specification
     3 ##  Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
     4 ##  Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
     5 ##
     6 ##  Permission to use, copy, modify, and distribute this software for
     7 ##  any purpose with or without fee is hereby granted, provided that
     8 ##  the above copyright notice and this permission notice appear in all
     9 ##  copies.
    10 ##
    11 ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    12 ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    13 ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    14 ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    15 ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    16 ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    17 ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    18 ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    19 ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    20 ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    21 ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    22 ##  SUCH DAMAGE.
    23 ##
    25 #   NOTICE: This OpenPKG RPM specification is _very_ special, because
    26 #   it is used both for bootstrapping OpenPKG with its OpenPKG RPM and
    27 #   for regular builds of OpenPKG RPM in order to upgrade an existing
    28 #   installation. For this it has to interact correctly with the
    29 #   "openpkg.boot" script. See the documentation in the file "README"
    30 #   and the source of the companion script "openpkg.boot" for details,
    31 #   but do not touch anything here until you are 100% sure about what
    32 #   you are doing. In short: This script is allowed to use only a very
    33 #   restricted subset of the OpenPKG RPM functionality!
    35 #   BUILD REQUIREMENTS:
    36 #   o any sh(1)
    37 #   o any tar(1)
    38 #   o any make(1)
    39 #   o any cc(1)
    41 #   the package version/release
    42 %define       V_openpkg  20120714
    44 #   the used software versions
    45 %define       V_rpm      4.2.1
    46 %define       V_zlib     1.2.5
    47 %define       V_bzip2    1.0.5
    48 %define       V_beecrypt 4.1.2
    49 %define       V_curl     7.21.1
    50 %define       V_make     3.82
    51 %define       V_gzip     1.4
    52 %define       V_gzip_r   1.13
    53 %define       V_patch    2.6.1
    54 %define       V_tar      1.23
    55 %define       V_bash     3.2
    56 %define       V_uuid     1.6.2
    57 %define       V_config   20060923
    58 %define       V_registry 1.1.3
    59 %define       V_perl     5.10.0
    60 %define       V_openssl  0.9.8g
    61 %define       V_tools    1.4.5
    62 %define       V_exec     2.0.1-C
    64 #   package information
    65 Name:         openpkg
    66 Summary:      OpenPKG Bootstrap
    67 URL:          http://www.openpkg.org/
    68 Vendor:       OpenPKG
    69 Packager:     OpenPKG Foundation e.V.
    70 Distribution: OpenPKG Community
    71 Class:        CORE
    72 Group:        Bootstrapping
    73 License:      MIT/BSD/LGPL/GPL
    74 Version:      %{V_openpkg}
    75 Release:      %{V_openpkg}
    77 #   list of sources
    78 Source0:      ftp://ftp.gnu.org/gnu/patch/patch-%{V_patch}.tar.gz
    79 Source1:      ftp://ftp.cwru.edu/pub/bash/bash-%{V_bash}.tar.gz
    80 Source2:      ftp://ftp.gnu.org/gnu/make/make-%{V_make}.tar.gz
    81 Source3:      ftp://ftp.gnu.org/gnu/tar/tar-%{V_tar}.tar.gz
    82 Source4:      ftp://ftp.openpkg.org/sources/CPY/config/config-%{V_config}.tar.gz
    83 Source5:      ftp://ftp.openpkg.org/sources/CPY/openpkg-registry/openpkg-registry-%{V_registry}.tar.gz
    84 Source6:      ftp://ftp.openpkg.org/sources/CPY/openpkg-tools/openpkg-tools-%{V_tools}.tar.gz
    85 Source7:      ftp://ftp.openpkg.org/sources/CPY/openpkg/gzip-%{V_gzip}-openpkg-r%{V_gzip_r}.tar
    86 Source8:      ftp://ftp.gnu.org/gnu/gzip/gzip-%{V_gzip}.tar
    87 Source9:      ftp://ftp.openpkg.org/sources/CPY/openpkg/openpkg-executable-%{V_exec}.tar.gz
    88 Source10:     ftp://ftp.openpkg.org/sources/CPY/openpkg/rpm-%{V_rpm}.tar.gz
    89 Source11:     ftp://ftp.openpkg.org/sources/CPY/perl/perl-%{V_perl}-mini.tar.gz
    90 Source12:     ftp://ftp.openssl.org/source/openssl-%{V_openssl}.tar.gz
    91 Source13:     ftp://ftp.ossp.org/pkg/lib/uuid/uuid-%{V_uuid}.tar.gz
    92 Source14:     http://curl.haxx.se/download/curl-%{V_curl}.tar.gz
    93 Source15:     http://switch.dl.sourceforge.net/beecrypt/beecrypt-%{V_beecrypt}.tar.gz
    94 Source16:     http://www.bzip.org/%{V_bzip2}/bzip2-%{V_bzip2}.tar.gz
    95 Source17:     http://www.zlib.net/zlib-%{V_zlib}.tar.gz
    96 Source100:    bash.patch
    97 Source101:    beecrypt.patch
    98 Source102:    make.patch
    99 Source103:    openssl.patch
   100 Source104:    perl.patch
   101 Source105:    tar.patch
   102 Source106:    rpm.patch.bugfix
   103 Source107:    rpm.patch.feature
   104 Source108:    rpm.patch.porting
   105 Source109:    rpm.patch.regen
   106 Source200:    HISTORY
   107 Source201:    README
   108 Source202:    aux.prereq.sh
   109 Source203:    aux.usrgrp.sh
   110 Source204:    aux.wrapbin.sh
   111 Source205:    aux.wrapsrc.sh
   112 Source206:    dot.bash_login
   113 Source207:    dot.bashrc
   114 Source208:    dot.lsyncrc
   115 Source209:    install.sh
   116 Source210:    local.README
   117 Source211:    lsync
   118 Source212:    lsync.8
   119 Source213:    lsync.pod
   120 Source214:    man.sh
   121 Source215:    openpkg.1
   122 Source216:    openpkg.boot
   123 Source217:    openpkg.com.pgp
   124 Source218:    openpkg.net.pgp
   125 Source219:    openpkg.org.pgp
   126 Source220:    openpkg.pod
   127 Source221:    openpkg.sh
   128 Source222:    pod2man.sh
   129 Source223:    rc
   130 Source224:    rc.8
   131 Source225:    rc.conf
   132 Source226:    rc.func
   133 Source227:    rc.openpkg
   134 Source228:    rc.pod
   135 Source229:    release.8
   136 Source230:    release.pod
   137 Source231:    release.sh
   138 Source232:    root.README
   139 Source233:    rpm-config.8
   140 Source234:    rpm-config.pod
   141 Source235:    rpm-config.sh
   142 Source236:    rpmdb
   143 Source237:    rpmtool
   144 Source238:    rpmtool.8
   145 Source239:    rpmtool.pod
   146 Source240:    shtool
   147 Source241:    uuid.8
   148 Source242:    uuid.pod
   149 Source243:    uuid.sh
   150 Source244:    rpmmacros
   151 Source245:    rpmpopt
   152 Source246:    rpmrc
   154 #   build information
   155 Prefix:       %{l_prefix}
   156 BuildRoot:    %{l_buildroot}
   157 AutoReq:      no
   158 AutoReqProv:  no
   159 Provides:     OpenPKG
   161 %description
   162     This is the bootstrap package for the RPM-based Unix Software
   163     Package Hierarchy OpenPKG. The RPM Package Manager (RPM) is a
   164     sophisticated and portable package manager for Unix platforms,
   165     which supports automated building, installation, management and
   166     deinstallation of Unix software. RPM was originally designed and
   167     implemented for the RedHat Linux operating system where it manages
   168     every file on the whole system. OpenPKG uses RPM only for managing
   169     the files in a particular filesystem hierarchy dedicated to the
   170     installation of third-party software packages provided by the
   171     OpenPKG project.
   173     The OpenPKG bootstrap package includes the following software:
   174         RPM %{V_rpm}, ZLib %{V_zlib}, GNU Bzip2 %{V_bzip2},
   175         GNU Gzip %{V_gzip}, GNU Tar %{V_tar}, GNU Patch %{V_patch},
   176         GNU Make %{V_make}, GNU Bash %{V_bash}, cURL %{V_curl},
   177         OSSP uuid %{V_uuid}, BeeCrypt %{V_beecrypt},
   178         OpenSSL %{V_openssl}, Perl %{V_perl}
   180 %track
   181     prog openpkg:bash = {
   182         version   = %{V_bash}
   183         url       = ftp://ftp.cwru.edu/pub/bash/
   184         regex     = bash-(__VER__)\.tar\.gz
   185     }
   186     prog openpkg:bzip2 = {
   187         version   = %{V_bzip2}
   188         url       = http://www.bzip.org/downloads.html
   189         regex     = bzip2-(__VER__)\.tar\.gz
   190     }
   191     prog openpkg:curl = {
   192         version   = %{V_curl}
   193         url       = http://curl.haxx.se/download/
   194         regex     = curl-(__VER__)\.tar\.gz
   195     }
   196     prog openpkg:gzip = {
   197         comment   = "rse: intentionally tracked at gnu.org, although fetched from openpkg.org because of uncompression"
   198         version   = %{V_gzip}
   199         url       = ftp://ftp.gnu.org/gnu/gzip/
   200         regex     = gzip-(__VER__)\.tar(\.gz)?
   201     }
   202     prog openpkg:gzip_r = {
   203         version   = %{V_gzip_r}
   204         url       = ftp://ftp.openpkg.org/sources/CPY/openpkg/
   205         regex     = gzip-%{V_gzip}-openpkg-r(__VER__)\.tar
   206     }
   207     prog openpkg:make = {
   208         version   = %{V_make}
   209         url       = ftp://ftp.gnu.org/gnu/make/
   210         regex     = make-(__VER__)\.tar\.gz
   211     }
   212     prog openpkg:patch = {
   213         disabled
   214         comment   = "rse: directory missing after GNU.org security issues"
   215         version   = %{V_patch}
   216         url       = ftp://alpha.gnu.org/gnu/patch/
   217         regex     = patch-(__VER__)\.tar\.gz
   218     }
   219     prog openpkg:rpm = {
   220         disabled
   221         comment   = "rse: we have a .src.rpm extracted .tar.gz, because there is still no tarball for 4.2.1"
   222         version   = %{V_rpm}
   223         url       = ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.2.x/
   224         regex     = rpm-(4\.2\.\d+)\.tar\.gz
   225     }
   226     prog openpkg:tar = {
   227         version   = %{V_tar}
   228         url       = ftp://ftp.gnu.org/gnu/tar/
   229         regex     = tar-(__VER__)\.tar\.gz
   230     }
   231     prog openpkg:zlib = {
   232         version   = %{V_zlib}
   233         url       = http://www.zlib.net/
   234         regex     = zlib-(__VER__)\.tar\.gz
   235     }
   236     prog openpkg:uuid = {
   237         version   = %{V_uuid}
   238         url       = ftp://ftp.ossp.org/pkg/lib/uuid/
   239         regex     = uuid-(__VER__)\.tar\.gz
   240     }
   241     prog openpkg:config = {
   242         version   = %{V_config}
   243         url       = ftp://ftp.openpkg.org/sources/CPY/config/
   244         regex     = config-(__VER__)\.tar\.gz
   245     }
   246     prog openpkg:beecrypt = {
   247         version   = %{V_beecrypt}
   248         url       = http://prdownloads.sourceforge.net/beecrypt/
   249         regex     = beecrypt-(__VER__)\.tar\.gz
   250     }
   251     prog openpkg:registry = {
   252         version   = %{V_registry}
   253         url       = ftp://ftp.openpkg.org/sources/CPY/openpkg-registry/
   254         regex     = openpkg-registry-(__VER__)\.tar\.gz
   255     }
   256     prog openpkg:perl = {
   257         version   = %{V_perl}
   258         url       = ftp://ftp.openpkg.org/sources/CPY/perl/
   259         regex     = perl-(__VER__)-mini\.tar\.gz
   260     }
   261     prog openpkg:openssl = {
   262         version   = %{V_openssl}
   263         url       = ftp://ftp.openssl.org/source/
   264         regex     = openssl-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz
   265     }
   266     prog openpkg:openpkg-tools = {
   267         version   = %{V_tools}
   268         url       = ftp://ftp.openpkg.org/sources/CPY/openpkg-tools/
   269         regex     = openpkg-tools-(__VER__)\.tar\.gz
   270     }
   271     prog openpkg:openpkg-executable = {
   272         version   = %{V_exec}
   273         url       = ftp://ftp.openpkg.org/sources/CPY/openpkg/
   274         regex     = openpkg-executable-(__VER__-C)\.tar\.gz
   275     }
   277 %prep
   278     #   skip in bootstrap phase 2 (see openpkg.boot)
   279     [ ".$OPENPKG_BOOT" = .1 ] && exit 0
   281     #   switch into a temporary build area
   282     rm -rf openpkg-%{version}
   283     mkdir openpkg-%{version}
   284     cd openpkg-%{version}
   285     rm -f .buildenv
   286     touch .buildenv
   288     #   provide a bootstrap alternative to %{SOURCE xxx} because else
   289     #   it is not possible to upgrade a newer OpenPKG RPM with an older
   290     #   OpenPKG RPM.
   291     echo >>.buildenv 'SOURCE () {'
   292     echo >>.buildenv '    if [ -f "%{_specdir}/$1" ]; then'
   293     echo >>.buildenv '        echo "%{_specdir}/$1"'
   294     echo >>.buildenv '    else'
   295     echo >>.buildenv '        echo "%{_sourcedir}/$1"'
   296     echo >>.buildenv '    fi'
   297     echo >>.buildenv '}'
   298     echo >>.buildenv 'VERBOSE () {'
   299     echo >>.buildenv '    if [ -f "%{_specdir}/rpmtool" ]; then'
   300     echo >>.buildenv '        echo "$*" | sh %{_specdir}/rpmtool msg'
   301     echo >>.buildenv '    else'
   302     echo >>.buildenv '        echo "$*" | sh %{_sourcedir}/rpmtool msg'
   303     echo >>.buildenv '    fi'
   304     echo >>.buildenv '}'
   305     . ./.buildenv
   307     #   display verbosity header
   308     set +x; VERBOSE "PREPARATION: Determine Build Tool Paths"; set -x
   310     #   determine path to shtool
   311     shtool=`SOURCE shtool`
   312     echo "shtool=$shtool" >>./.buildenv
   314     #   determine development tools
   315     #   - bootstrapping: %{l_xxx} is set via sed(1)
   316     #   - upgrading new: %{l_xxx} is set via rpmmacros
   317     #   - upgrading old: %{l_xxx} is not set at all
   319     #   manually make sure tar(1) is available
   320     l_tar=""; export l_tar
   321     [ ".%{?l_tar:set}"   = .set ] && l_tar="%{l_tar}"
   322     [ ".%{?use_tar:set}" = .set ] && l_tar="%{use_tar}"
   323     if [ ".$l_tar" = . ]; then
   324         l_tar=`sh $shtool path gtar tar`
   325         if [ ".$l_tar" = . ]; then
   326             echo "openpkg: prerequisite tool \`gtar' or \`tar' not found"
   327             exit 1
   328         fi
   329     fi
   330     echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv
   332     #   manually make sure make(1) is available
   333     l_make=""; export l_make
   334     [ ".%{?l_make:set}"   = .set ] && l_make="%{l_make}"
   335     [ ".%{?use_make:set}" = .set ] && l_make="%{use_make}"
   336     if [ ".$l_make" = . ]; then
   337         l_make=`sh $shtool path gmake make`
   338         if [ ".$l_make" = . ]; then
   339             echo "openpkg: prerequisite tool \`gmake' or \`make' not found"
   340             exit 1
   341         fi
   342     fi
   343     echo "l_make=\"$l_make\"; export l_make" >>.buildenv
   345     #   manually make sure cc(1) is available
   346     l_cc=""; export l_cc
   347     [ ".%{?l_cc:set}"   = .set ] && l_cc="%{l_cc}"
   348     [ ".%{?use_cc:set}" = .set ] && l_cc="%{use_cc}"
   349     if [ ".$l_cc" = . ]; then
   350         l_cc=`sh $shtool path gcc cc`
   351         if [ ".$l_cc" = . ]; then
   352             echo "openpkg: prerequisite tool \`gcc' or \`cc' not found"
   353             exit 1
   354         fi
   355     fi
   356     echo "l_cc=\"$l_cc\"; export l_cc" >>.buildenv
   358     #   manually make sure ar(1) is available
   359     l_ar=""; export l_ar
   360     [ ".%{?l_ar:set}"   = .set ] && l_ar="%{l_ar}"
   361     [ ".%{?use_ar:set}" = .set ] && l_ar="%{use_ar}"
   362     if [ ".$l_ar" = . ]; then
   363         l_ar=`sh $shtool path ar`
   364         if [ ".$l_ar" = . ]; then
   365             echo "openpkg: prerequisite tool \`ar' not found"
   366             exit 1
   367         fi
   368     fi
   369     echo "l_ar=\"$l_ar\"; export l_ar" >>.buildenv
   371     #   manually make sure ld(1) is available
   372     l_ld=""; export l_ld
   373     [ ".%{?l_ld:set}"   = .set ] && l_ld="%{l_ld}"
   374     [ ".%{?use_ld:set}" = .set ] && l_ld="%{use_ld}"
   375     if [ ".$l_ld" = . ]; then
   376         l_ld=`sh $shtool path ld`
   377         if [ ".$l_ld" = . ]; then
   378             echo "openpkg: prerequisite tool \`ld' not found"
   379             exit 1
   380         fi
   381     fi
   382     echo "l_ld=\"$l_ld\"; export l_ld" >>.buildenv
   384     #   manually make sure as(1) is available
   385     l_as=""; export l_as
   386     [ ".%{?l_as:set}"   = .set ] && l_as="%{l_as}"
   387     [ ".%{?use_as:set}" = .set ] && l_as="%{use_as}"
   388     if [ ".$l_as" = . ]; then
   389         l_as=`sh $shtool path as`
   390         if [ ".$l_as" = . ]; then
   391             echo "openpkg: prerequisite tool \`as' not found"
   392             exit 1
   393         fi
   394     fi
   395     echo "l_as=\"$l_as\"; export l_as" >>.buildenv
   397     #   manually make sure strip(1) is available or use a null replacement
   398     l_strip=""; export l_strip
   399     [ ".%{?l_strip:set}"   = .set ] && l_strip="%{l_strip}"
   400     [ ".%{?use_strip:set}" = .set ] && l_strip="%{use_strip}"
   401     if [ ".$l_strip" = . ]; then
   402         l_strip=`sh $shtool path strip ls`
   403         if [ ".$l_strip" = . ]; then
   404             echo "openpkg: prerequisite tool \`strip' not found"
   405             exit 1
   406         fi
   407     fi
   408     echo "l_strip=\"$l_strip\"; export l_strip" >>.buildenv
   410     #   determine path to aux.usrgrp.sh script
   411     usrgrp=`SOURCE aux.usrgrp.sh`
   412     echo "usrgrp=$usrgrp; export usrgrp" >>./.buildenv
   414     #   display verbosity header
   415     set +x; VERBOSE "PREPARATION: Determine OpenPKG User/Group Name/Id Pairs"; set -x
   417     #   determine user/group name/id pairs
   418     #   - bootstrapping: %{l_[smrn]{usr,grp}} is set via sed(1)
   419     #   - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
   420     #   - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
   421     susr=""; [ ".%{?l_susr:set}"  = .set ] && susr="%{l_susr}"
   422     sgrp=""; [ ".%{?l_sgrp:set}"  = .set ] && sgrp="%{l_sgrp}"
   423     musr=""; [ ".%{?l_musr:set}"  = .set ] && musr="%{l_musr}"
   424     mgrp=""; [ ".%{?l_mgrp:set}"  = .set ] && mgrp="%{l_mgrp}"
   425     rusr=""; [ ".%{?l_rusr:set}"  = .set ] && rusr="%{l_rusr}"
   426     rgrp=""; [ ".%{?l_rgrp:set}"  = .set ] && rgrp="%{l_rgrp}"
   427     nusr=""; [ ".%{?l_nusr:set}"  = .set ] && nusr="%{l_nusr}"
   428     ngrp=""; [ ".%{?l_ngrp:set}"  = .set ] && ngrp="%{l_ngrp}"
   429     #   corresponding ids
   430     suid=""; [ ".%{?l_suid:set}"  = .set ] && suid="%{l_suid}"
   431     sgid=""; [ ".%{?l_sgid:set}"  = .set ] && sgid="%{l_sgid}"
   432     muid=""; [ ".%{?l_muid:set}"  = .set ] && muid="%{l_muid}"
   433     mgid=""; [ ".%{?l_mgid:set}"  = .set ] && mgid="%{l_mgid}"
   434     ruid=""; [ ".%{?l_ruid:set}"  = .set ] && ruid="%{l_ruid}"
   435     rgid=""; [ ".%{?l_rgid:set}"  = .set ] && rgid="%{l_rgid}"
   436     nuid=""; [ ".%{?l_nuid:set}"  = .set ] && nuid="%{l_nuid}"
   437     ngid=""; [ ".%{?l_ngid:set}"  = .set ] && ngid="%{l_ngid}"
   438     #   compat:
   439     usr="";  [ ".%{?l_fsusr:set}" = .set ] && usr="%{l_fsusr}"
   440     grp="";  [ ".%{?l_fsgrp:set}" = .set ] && grp="%{l_fsgrp}"
   441     eval `sh $usrgrp \
   442           --usr="$usr" --grp="$grp" \
   443           --susr="$susr" --sgrp="$sgrp" \
   444           --musr="$musr" --mgrp="$mgrp" \
   445           --rusr="$rusr" --rgrp="$rgrp" \
   446           --nusr="$nusr" --ngrp="$ngrp" \
   447           --suid="$suid" --sgid="$sgid" \
   448           --muid="$muid" --mgid="$mgid" \
   449           --ruid="$ruid" --rgid="$rgid" \
   450           --nuid="$nuid" --ngid="$ngid"`
   451     echo "susr=\"$susr\"; export susr" >>.buildenv
   452     echo "sgrp=\"$sgrp\"; export sgrp" >>.buildenv
   453     echo "musr=\"$musr\"; export musr" >>.buildenv
   454     echo "mgrp=\"$mgrp\"; export mgrp" >>.buildenv
   455     echo "rusr=\"$rusr\"; export rusr" >>.buildenv
   456     echo "rgrp=\"$rgrp\"; export rgrp" >>.buildenv
   457     echo "nusr=\"$nusr\"; export nusr" >>.buildenv
   458     echo "ngrp=\"$ngrp\"; export ngrp" >>.buildenv
   459     echo "suid=\"$suid\"; export suid" >>.buildenv
   460     echo "sgid=\"$sgid\"; export sgid" >>.buildenv
   461     echo "muid=\"$muid\"; export muid" >>.buildenv
   462     echo "mgid=\"$mgid\"; export mgid" >>.buildenv
   463     echo "ruid=\"$ruid\"; export ruid" >>.buildenv
   464     echo "rgid=\"$rgid\"; export rgid" >>.buildenv
   465     echo "nuid=\"$nuid\"; export nuid" >>.buildenv
   466     echo "ngid=\"$ngid\"; export ngid" >>.buildenv
   468     #   display verbosity header
   469     set +x; VERBOSE "PREPARATION: Determine OpenPKG Instance Environment"; set -x
   471     #   determine installation location id
   472     if [ ".%{?l_tag_fmt:set}" = .set ]; then
   473         tag="%{l_tag_fmt}"
   474     else
   475         tag="<compat>"
   476     fi
   477     echo "tag=\"$tag\"; export tag" >>.buildenv
   479     #   determine platform id
   480     s=`(uname -s) 2>/dev/null` || s='Unknown'
   481     r=`(uname -r) 2>/dev/null` || r='0.0'
   482     plid="${s}/${r}"
   483     echo "plid=\"$plid\"; export plid" >>.buildenv
   485     #   determine platform-specific build environment
   486     case $plid in
   487         FreeBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   488         NetBSD/*  ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   489         Linux/*   ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   490         SunOS/*   ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
   491         UnixWare/*) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
   492         AIX/*     ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;;
   493         Darwin/*  ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   494         OSF1/V5.* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   495         HP-UX/*   ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   496         IRIX*/6.* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   497         *         ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;;
   498     esac
   499     case $plid in
   500         FreeBSD/* ) l_build_ldlp="/lib:/usr/lib" ;;
   501         NetBSD/*  ) l_build_ldlp="/lib:/usr/lib" ;;
   502         Linux/*   ) l_build_ldlp="/lib:/usr/lib" ;;
   503         SunOS/*   ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
   504         UnixWare/*) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
   505         AIX/*     ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;;
   506         Darwin/*  ) l_build_ldlp="/usr/lib" ;;
   507         OSF1/V5.* ) l_build_ldlp="/usr/lib" ;;
   508         HP-UX/*   ) l_build_ldlp="/usr/lib" ;;
   509         IRIX*/6.* ) l_build_ldlp="/usr/lib" ;;
   510         *         ) l_build_ldlp="/usr/lib" ;;
   511     esac
   512     case $plid in
   513         *         ) l_build_ulim=":" ;;
   514     esac
   515     echo "l_build_path=\"$l_build_path\"; export l_build_path" >>.buildenv
   516     echo "l_build_ldlp=\"$l_build_ldlp\"; export l_build_ldlp" >>.buildenv
   517     echo "l_build_ulim=\"$l_build_ulim\"; export l_build_ulim" >>.buildenv
   519     #   display verbosity header
   520     set +x; VERBOSE "PREPARATION: Build GNU gzip (Compression Tool)"; set -x
   522     #   bootstrap GNU zip tool
   523     ${l_tar} xf `SOURCE gzip-%{V_gzip}.tar` 2>/dev/null || true
   524     ${l_tar} xf `SOURCE gzip-%{V_gzip}-openpkg-r%{V_gzip_r}.tar` 2>/dev/null || true
   525     ( cd gzip-%{V_gzip}
   526       echo "ac_cv_prog_cc_g=no" >config.cache
   527       case $plid in
   528           Darwin/* ) echo "gzip_cv_assembler=no" >>config.cache ;;
   529       esac
   530       CC="${l_cc}" \
   531       GREP="grep" \
   532       MAKE="${l_make}" \
   533       ./configure \
   534           --cache-file=./config.cache
   535       ${l_make} || exit $?
   536       ( mv gzip ..; ${l_make} clean || true; mv ../gzip . ) || exit $?
   537     ) || exit $?
   538     l_gzip="`pwd`/gzip-%{V_gzip}/gzip"; export l_gzip
   539     echo "l_gzip=\"$l_gzip\"; export l_gzip" >>.buildenv
   541     #   display verbosity header
   542     set +x; VERBOSE "PREPARATION: Unpack GNU configuration guessing utilities"; set -x
   544     #   unpack GNU config.guess
   545     ${l_gzip} -dc `SOURCE config-%{V_config}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
   547     #   display verbosity header
   548     set +x; VERBOSE "PREPARATION: Build GNU patch (Source Patching Tool)"; set -x
   550     #   bootstrap GNU patch tool
   551     ${l_gzip} -dc `SOURCE patch-%{V_patch}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
   552     ( cd patch-%{V_patch}
   553       cp `SOURCE rplstrnlen.c` gl/lib/strnlen.c
   554       chmod u+w config.guess config.sub >/dev/null 2>&1 || true
   555       cp ../config/config.guess .
   556       cp ../config/config.sub   .
   557       ( echo 'ac_cv_func_setmode=${ac_cv_func_setmode=no}'
   558         echo 'ac_cv_prog_cc_g=no'
   559         false=`sh $shtool path false`
   560         echo "ac_cv_path_ed_PROGRAM=\${ac_cv_path_ed_PROGRAM=$false}"
   561       ) >config.cache
   562       CC="${l_cc}" \
   563       GREP="grep" \
   564       ./configure \
   565           --cache-file=./config.cache \
   566           --disable-largefile
   567       ${l_make} || exit $?
   568       ( mv src/patch ..; ${l_make} clean || true; mv ../patch . ) || exit $?
   569     ) || exit $?
   570     l_patch="`pwd`/patch-%{V_patch}/patch"; export l_patch
   571     echo "l_patch=\"$l_patch\"; export l_patch" >>.buildenv
   573     #   display verbosity header
   574     set +x; VERBOSE "BUILD: Build GNU tar (Archiving Tool)"; set -x
   576     #   build GNU tar tool
   577     ${l_gzip} -dc `SOURCE tar-%{V_tar}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
   578     ( cd tar-%{V_tar}
   579       ${l_patch} -p0 <`SOURCE tar.patch`
   580       ( echo 'am_cv_func_iconv=no'
   581         echo 'am_cv_lib_iconv=no'
   582         echo 'ac_cv_lib_iconv_iconv=no'
   583         echo 'ac_cv_header_iconv_h=no'
   584         echo 'ac_cv_type_iconv_t=no'
   585       ) >config.cache
   586       CC="${l_cc}" \
   587       MAKE="${l_make}" \
   588       MAKEINFO="true" \
   589       GREP="grep" \
   590       ./configure \
   591           --cache-file=./config.cache \
   592           --prefix=%{l_prefix} \
   593           --disable-nls
   594       ${l_make} || exit $?
   595       ( mv src/tar ..; ${l_make} clean || true; mv ../tar . ) || exit $?
   596     ) || exit $?
   597     l_tar="`pwd`/tar-%{V_tar}/tar"; export l_tar
   598     echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv
   600     #   display verbosity header
   601     set +x; VERBOSE "PREPARATION: Unpack Distribution Tarballs"; set -x
   603     #   unpack distribution tarballs
   604     ${l_gzip} -dc `SOURCE rpm-%{V_rpm}.tar.gz`                        | ${l_tar} xf - 2>/dev/null || true
   605     ${l_gzip} -dc `SOURCE zlib-%{V_zlib}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   606     ${l_gzip} -dc `SOURCE bzip2-%{V_bzip2}.tar.gz`                    | ${l_tar} xf - 2>/dev/null || true
   607     ${l_gzip} -dc `SOURCE curl-%{V_curl}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   608     ${l_gzip} -dc `SOURCE make-%{V_make}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   609     ${l_gzip} -dc `SOURCE bash-%{V_bash}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   610     ${l_gzip} -dc `SOURCE uuid-%{V_uuid}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   611     ${l_gzip} -dc `SOURCE beecrypt-%{V_beecrypt}.tar.gz`              | ${l_tar} xf - 2>/dev/null || true
   612     ${l_gzip} -dc `SOURCE openpkg-registry-%{V_registry}.tar.gz`      | ${l_tar} xf - 2>/dev/null || true
   613     ${l_gzip} -dc `SOURCE perl-%{V_perl}-mini.tar.gz`                 | ${l_tar} xf - 2>/dev/null || true
   614     ${l_gzip} -dc `SOURCE openssl-%{V_openssl}.tar.gz`                | ${l_tar} xf - 2>/dev/null || true
   615     ${l_gzip} -dc `SOURCE openpkg-tools-%{V_tools}.tar.gz`            | ${l_tar} xf - 2>/dev/null || true
   616     ${l_gzip} -dc `SOURCE openpkg-executable-%{V_exec}.tar.gz`        | ${l_tar} xf - 2>/dev/null || true
   618     #   update config.guess/config.sub
   619     for dir in rpm-%{V_rpm} rpm-%{V_rpm}/popt beecrypt-%{V_beecrypt} \
   620                curl-%{V_curl} make-%{V_make} bash-%{V_bash}/support; do
   621         chmod u+w $dir/config.guess $dir/config.sub >/dev/null 2>&1 || true
   622         cp config/config.guess $dir/
   623         cp config/config.sub   $dir/
   624     done
   626     #   display verbosity header
   627     set +x; VERBOSE "PREPARATION: Apply OpenPKG Patches to Distributions"; set -x
   629     #   apply OpenPKG patches to distribution trees
   630     ( cd rpm-%{V_rpm}
   631       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.bugfix`  | ${l_patch} -p0
   632       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.feature` | ${l_patch} -p0
   633       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.porting` | ${l_patch} -p0
   634       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.regen`   | ${l_patch} -p0
   635       rm -rf db/docs # just reduce disk size of source tree
   636     ) || exit $?
   637     ( cd make-%{V_make}
   638       ${l_patch} -p0 <`SOURCE make.patch`
   639     ) || exit $?
   640     ( cd bash-%{V_bash}
   641       ${l_patch} -p0 <`SOURCE bash.patch`
   642       sleep 1
   643       touch y.tab.[ch]
   644       touch configure config.h.in
   645     ) || exit $?
   646     ( cd beecrypt-%{V_beecrypt}
   647       ${l_patch} -p0 <`SOURCE beecrypt.patch`
   648     ) || exit $?
   649     ( cd perl-%{V_perl}
   650       ${l_patch} -p0 <`SOURCE perl.patch`
   651     ) || exit $?
   652     ( cd openssl-%{V_openssl}
   653       ${l_patch} -p0 <`SOURCE openssl.patch`
   654     ) || exit $?
   656     #   display verbosity header
   657     set +x; VERBOSE "PREPARATION: Build GNU make (Build Tool)"; set -x
   659     #   bootstrap GNU make tool
   660     ( cd make-%{V_make}
   661       CC="${l_cc}" \
   662       GREP="grep" \
   663       ./configure \
   664           --without-libiconv-prefix \
   665           --without-libintl-prefix \
   666           --disable-nls \
   667           --disable-largefile
   668       ${l_make}
   669       ( mv make ..; ${l_make} clean || true; mv ../make . ) || exit $?
   670     ) || exit $?
   671     l_make="`pwd`/make-%{V_make}/make"; export l_make
   672     echo "l_make=\"$l_make\"; export l_make" >>.buildenv
   674 %build
   675     #   skip in bootstrap phase 2 (see openpkg.boot)
   676     [ ".$OPENPKG_BOOT" = .1 ] && exit 0
   678     #   switch into a temporary build area
   679     cd openpkg-%{version}
   680     . ./.buildenv
   682     #   display verbosity header
   683     set +x; VERBOSE "BUILD: Build GNU bash (Bourne-Again Shell)"; set -x
   685     #   build GNU bash tool
   686     ( cd bash-%{V_bash}
   687       sh $shtool subst \
   688           -e 's;@l_openpkg_release@;OpenPKG;' \
   689           version.c
   690       ( #   force disabled wide-character support
   691         echo "ac_cv_header_wchar_h=no"
   692         echo "ac_cv_header_wctype_h=no"
   693         echo "ac_cv_func_mbsrtowcs=no"
   694         #   force disabled internationalization support
   695         echo "ac_cv_header_libintl_h=no"
   696         echo "ac_cv_func_gettext=no"
   697         echo "ac_cv_func_textdomain=no"
   698         echo "ac_cv_func_bindtextdomain=no"
   699         echo "ac_cv_lib_intl_bindtextdomain=no"
   700         #   disable building with debug symbols
   701         echo "ac_cv_prog_cc_g=no"
   702       ) >config.cache
   703       AUTOCONF="true" \
   704       CC="${l_cc}" \
   705       MAKE="${l_make}" \
   706       ./configure \
   707           --cache-file=./config.cache \
   708           --prefix=%{l_prefix} \
   709           --without-curses \
   710           --without-gnu-malloc \
   711           --disable-nls
   712       ${l_make} || exit $?
   713       ( mv bash ..; ${l_make} clean || true; mv ../bash . ) || exit $?
   714     ) || exit $?
   716     #   display verbosity header
   717     set +x; VERBOSE "BUILD: Build GNU bzip2 (Compression Library)"; set -x
   719     #   build BZIP2 library
   720     ( cd bzip2-%{V_bzip2}
   721       ${l_make} CC="${l_cc}" CFLAGS="-O" libbz2.a bzip2 || exit $?
   722       ( echo "# libbz2.la - a libtool library file"
   723         echo "# Generated by ltmain.sh - GNU libtool x.x.x"
   724         echo "dlname=''"
   725         echo "library_names=''"
   726         echo "old_library='libbz2.a'"
   727         echo "dependency_libs=''"
   728         echo "current=0"
   729         echo "age=0"
   730         echo "revision=0"
   731         echo "installed=no"
   732         echo "dlopen=''"
   733         echo "dlpreopen=''"
   734         echo "libdir='%{l_prefix}'"
   735       ) >libbz2.la
   736       ln -s . .libs
   737     ) || exit $?
   739     #   display verbosity header
   740     set +x; VERBOSE "BUILD: Build Zlib (Compression Library)"; set -x
   742     #   build ZLIB library
   743     ( cd zlib-%{V_zlib}
   744       CC="${l_cc}" CFLAGS="-O" ./configure
   745       ${l_make} CC="${l_cc}" libz.a || exit $? # intentionally do not pass CFLAGS here
   746     ) || exit $?
   748     #   display verbosity header
   749     set +x; VERBOSE "BUILD: Build OSSP uuid (UUID Generation Tool)"; set -x
   751     #   build OSSP uuid tool
   752     ( cd uuid-%{V_uuid}
   753       CC="${l_cc}" \
   754       CFLAGS="-O" \
   755       GREP="grep" \
   756       ./configure \
   757         --prefix=%{l_prefix} \
   758         --disable-shared
   759       ${l_make} || exit $?
   760       ( mv uuid ..; ${l_make} clean || true; mv ../uuid . ) || exit $?
   761     ) || exit $?
   763     #   display verbosity header
   764     set +x; VERBOSE "BUILD: Build Perl (Programming Language)"; set -x
   766     #   build Perl tool
   767     ( cd perl-%{V_perl}
   768       chmod -R u+w .
   769       sh $shtool subst \
   770           -e 's;\(.*for thislib in $libswanted.*\);libswanted=`echo " $libswanted " | sed -e "s/ bind / /g" -e "s/ db / /g" -e "s/ gdbm / /g" -e "s/ iconv / /g"`\; \1;' \
   771           -e 's;package=perl5;package=perl;' \
   772           Configure
   773       sh $shtool subst \
   774           -e 's; */usr/local/lib;;' \
   775           hints/freebsd.sh hints/netbsd.sh
   776       libdirs=""
   777       for dir in %{l_prefix}/lib /lib64 /usr/lib64 /lib /usr/lib /usr/ccs/lib; do
   778           [ -d $dir ] && libdirs="$libdirs $dir"
   779       done
   780       loclibs=""
   781       case `(uname -s) 2>/dev/null` in
   782           Linux ) loclibs="-lm -lrt" ;;
   783       esac
   784       PATH=$PATH:`echo "${l_make}" | sed -e 's;\(.*\)/[^/][^/]*$;\1;'` \
   785       ./Configure \
   786           -d -e -s \
   787           -Dprefix=%{l_prefix} \
   788           -Dvendorprefix=%{l_prefix} \
   789           -Dinstallprefix=%{l_prefix} \
   790           -Dinstallstyle="lib/perl5" \
   791           -Dman1dir=%{l_prefix}/man/man1 \
   792           -Dman3dir=%{l_prefix}/man/man3 \
   793           -Dcc="${l_cc}" -Uoptimize \
   794           -Dlocincpth="%{l_prefix}/include" \
   795           -Dloclibpth="%{l_prefix}/lib" \
   796           -Dldflags="-L""%{l_prefix}/lib" \
   797           -Dlibpth="$libdirs" \
   798           -Dglibpth="$libdirs" \
   799           -Dlibs="$loclibs" \
   800           -Dscriptdir="%{l_prefix}/bin" \
   801           -Uinstallusrbinperl \
   802           -Adefine:useshrplib='false' \
   803           -Ui_malloc -Ui_iconv -Ui_db
   804       ${l_make} miniperl || exit $?
   805       rm -f *.o >/dev/null 2>&1 || true
   806     ) || exit $?
   807     l_perl="`pwd`/perl-%{V_perl}/miniperl"; export l_perl
   808     echo "l_perl=\"$l_perl\"; export l_perl" >>.buildenv
   810     #   display verbosity header
   811     set +x; VERBOSE "BUILD: Build OpenSSL (Crypography and SSL/TLS Toolkit)"; set -x
   813     #   build OpenSSL toolkit
   814     ( cd openssl-%{V_openssl}
   815       sh $shtool subst \
   816           -e 's;-m486;-march=i486;g' \
   817           -e 's;BN_LLONG *;;' \
   818           Configure
   819       sh $shtool subst \
   820           -e 's;test "$OSTYPE" = msdosdjgpp;true;' \
   821           util/point.sh
   822       sh $shtool subst \
   823           -e "1s;^.*\$;#!$l_perl;" \
   824           Configure `find . -name "*.pl" -print`
   825       opts=""
   826       case `sh $shtool platform -n -L -S "" -C "+" -F "%<ap>-%<sp>"` in
   827           *-solaris*       ) opts="-lnsl -lsocket" ;;
   828       esac
   829       case `sh $shtool platform -n -L -S "" -C "+" -F "%<ap>-%<sp>"` in
   830           amd64-*          ) opts="$opts -fPIC" ;;
   831           ia64-*           ) opts="$opts -fPIC" ;;
   832           sparc64-freebsd* ) opts="$opts -fPIC" ;;
   833       esac
   834       CC="${l_cc}" \
   835       PERL="${l_perl}" \
   836       ./config \
   837           --prefix=%{l_prefix} \
   838           no-asm no-shared no-dso \
   839           no-zlib no-idea no-threads no-krb5 no-hw \
   840           $opts
   841       ${l_make} CC="${l_cc}" build_libs build_apps || exit $?
   842       ( mkdir lib; cd lib; ln -s ../lib*.a . ) || exit $?
   843     ) || exit $?
   845     #   display verbosity header
   846     set +x; VERBOSE "BUILD: Build cURL (URL Fetching Tool)"; set -x
   848     #   build cURL tool
   849     ( cd curl-%{V_curl}
   850       ( echo 'ac_cv_header_openssl_engine_h=no'
   851         echo 'lt_cv_prog_compiler_c_o_F77=no'
   852         echo 'lt_cv_sys_max_cmd_len=100'
   853       ) >config.cache
   854       CC="${l_cc}" \
   855       MAKE="${l_make}" \
   856       CFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
   857       CPPFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
   858       LDFLAGS="-L`pwd`/../zlib-%{V_zlib}" \
   859       GREP="grep" \
   860       ./configure \
   861           --cache-file=./config.cache \
   862           --without-libidn \
   863           --disable-shared \
   864           --disable-thread \
   865           --disable-ipv6 \
   866           --disable-ldap \
   867           --with-zlib=`pwd`/../zlib-%{V_zlib} \
   868           --with-ssl=`pwd`/../openssl-%{V_openssl} \
   869           --with-ca-bundle=%{l_prefix}/etc/openpkg/openpkg.x509
   870       ${l_make} || exit $?
   871       ( mv src/curl ..; ${l_make} clean || true; mv ../curl ./src ) || exit $?
   872     ) || exit $?
   874     #   display verbosity header
   875     set +x; VERBOSE "BUILD: Build BeeCrypt (Cryptography Library)"; set -x
   877     #   build BeeCrypt library
   878     ( cd beecrypt-%{V_beecrypt}
   879       sh $shtool subst \
   880           -e 's;^[ 	][ 	]*#;#;' \
   881           aes.c base64.c blowfish.c entropy.c fips186.c fips186.h md5.c \
   882           md5.h mp.c mtprng.c mtprng.h sha1.c sha1.h sha256.c sha256.h timestamp.c
   883       sh $shtool subst \
   884          -e 's;cppglue\.lo;;g' \
   885          -e 's;cppglue\.cxx;;g' \
   886          -e '/^CXX = /s;@CXX@;@CC@;g' \
   887          Makefile.in
   888       sh $shtool subst \
   889           -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
   890           configure
   891       ( echo 'ac_cv_have_dev_dsp=no'
   892         echo 'ac_cv_have_dev_audio=no'
   893         echo 'ac_cv_func_gettimeofday=yes'
   894         echo 'bc_cv_as_noexecstack=no'
   895       ) >config.cache
   896       CC="${l_cc}" \
   897       MAKE="${l_make}" \
   898       CFLAGS="-O" \
   899       ./configure \
   900         --cache-file=./config.cache \
   901         --prefix=%{l_prefix} \
   902         --without-cplusplus \
   903         --without-java \
   904         --without-python \
   905         --with-cpu=none \
   906         --with-arch=none \
   907         --disable-threads \
   908         --disable-shared
   909       ${l_make} || exit $?
   910       cp .libs/libbeecrypt.a .
   911     ) || exit $?
   913     #   display verbosity header
   914     set +x; VERBOSE "BUILD: Build RPM (RPM Package Manager)"; set -x
   916     #   build RPM
   917     ( br=`pwd`
   918       cd rpm-%{V_rpm}
   920       #   remove object files accidentally distributed with the RPM tarball
   921       rm -f db/build_unix/*.o
   922       rm -f db/build_unix/*.lo
   924       #   remove embedded zlib (we are linking with an external one)
   925       rm -rf zlib
   927       #   kill Linux-based preconfigured DB header, to allow the Makefiles to
   928       #   symlink to it the header that is configured for the current system.
   929       rm -f rpmdb/db.h
   931       #   make sure we do not trigger Autoconf/Automake tools
   932       touch configure
   933       touch config.h.in
   935       #   disable running of any Autoconf/Automake tools
   936       ACLOCAL=true
   937       AUTOCONF=true
   938       AUTOMAKE=true
   939       AUTOHEADER=true
   940       MAKEINFO=true
   941       AMTAR=true
   942       export ACLOCAL AUTOMAKE AUTOHEADER MAKEINFO AMTAR
   944       #   cheat GNU Autoconf
   945       ( echo 'ac_cv_path_MSGFMT=:'
   946         echo 'ac_cv_path_GMSGFMT=:'
   947         echo 'ac_cv_path_XGETTEXT=:'
   948         echo 'ac_cv_path_MSGMERGE=:'
   949         echo "ac_cv_path_MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'"
   950         echo "ac_cv_path___MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'"
   951         echo "ac_cv_path___PYTHON=true"
   952         echo "ac_cv_path___DOXYGEN=true"
   953         echo "acl_cv_rpath=no"
   954         echo "ac_cv_header_getopt_h=no"
   955       ) >config.cache
   957       #   provide platform identification
   958       os_name=`(uname -s) 2>/dev/null` || os_name='Unknown'
   959       os_name=`echo "${os_name}" |\
   960                sed -e 's;[^a-zA-Z0-9];;g' |\
   961                tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   963       #   set build tool flags
   964       CC="${l_cc}"
   965       CPPFLAGS="-DOPENPKG -DOPENPKG_${os_name} -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2} -I$br/beecrypt-%{V_beecrypt}"
   966       CFLAGS="$CPPFLAGS"
   967       LDFLAGS="-L$br/zlib-%{V_zlib} -L$br/bzip2-%{V_bzip2} -L$br/beecrypt-%{V_beecrypt}"
   968       LIBS="$LDFLAGS -lz -lbz2 -lbeecrypt"
   969       case $os_name in
   970            SUNOS* ) LIBS="$LIBS -lresolv" ;;
   971            IRIX*  ) LIBS="$LIBS -lgen" ;;
   972       esac
   973       export CC CPPFLAGS CFLAGS LDFLAGS LIBS
   975       #   adjust for BeeCrypt 4.0
   976       sh $shtool subst \
   977           -e 's;beecrypt\.api\.h;beecrypt.h;g' \
   978           rpmio/rpmio_internal.h
   979       sh $shtool subst \
   980           -e 's;\(rsavrfy(\)\(&dig->rsa_pk\);\1\2.n, \2.e;g' \
   981           lib/signature.c
   982       sh $shtool subst \
   983           -e 's;\(^LIBS =\)[ \t]*;\1 -ldb;' \
   984           -e 's;\(^rpmdb_[^_][^_]*_LDFLAGS =\)[ \t]*;\1 -L$(top_srcdir)/db3;g' \
   985           rpmdb/Makefile.in
   986       sh $shtool subst \
   987           -e 's;\(^myLDFLAGS =\);\1 -L$(top_srcdir)/db3;' \
   988           Makefile.in
   990       #   configure the package
   991       MAKE="${l_make}" \
   992       sh ./configure \
   993           --cache-file=./config.cache \
   994           --prefix=%{l_prefix} \
   995           --with-db \
   996           --with-glob \
   997           --without-python \
   998           --without-apidocs \
   999           --disable-shared \
  1000           --disable-rpath \
  1001           --disable-nls
  1003       #   deny automatic dependency calculations
  1004       rm -f find-provides find-requires
  1005       ln -s autodeps/none find-provides
  1006       ln -s autodeps/none find-requires
  1008       #   build the package
  1009       ${l_make}
  1010     ) || exit $?
  1012     #   display verbosity header
  1013     set +x; VERBOSE "BUILD: Build OpenPKG Frontend (Set-UID Wrapper)"; set -x
  1015     #   build "openpkg" executable
  1016     ( cd openpkg-executable-%{V_exec}
  1017       ${l_make} \
  1018           CC="${l_cc}" \
  1019           OPENPKG_PREFIX="%{l_prefix}" \
  1020           OPENPKG_SUSR="%{l_susr}" \
  1021           OPENPKG_MUSR="%{l_musr}"
  1022     ) || exit $?
  1024 %install
  1025     #   skip in bootstrap phase 2 (see openpkg.boot)
  1026     [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  1028     #   switch into a temporary build area
  1029     cd openpkg-%{version}
  1030     . ./.buildenv
  1032     #   display verbosity header
  1033     set +x; VERBOSE "INSTALL: Create Installation Filesystem Hierarchy"; set -x
  1035     #   create installation hierarchy
  1036     rm -rf $RPM_BUILD_ROOT
  1037     sh $shtool mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}
  1038     for dir in bin etc include info lib libexec man sbin share var cgi pub local; do
  1039         test -d $RPM_BUILD_ROOT%{l_prefix}/$dir || \
  1040         mkdir $RPM_BUILD_ROOT%{l_prefix}/$dir
  1041     done
  1042     for i in 1 2 3 4 5 6 7 8 9; do
  1043         test -d $RPM_BUILD_ROOT%{l_prefix}/man/man$i || \
  1044         mkdir $RPM_BUILD_ROOT%{l_prefix}/man/man$i
  1045         test -d $RPM_BUILD_ROOT%{l_prefix}/man/cat$i || \
  1046         mkdir $RPM_BUILD_ROOT%{l_prefix}/man/cat$i
  1047     done
  1048     for dir in PKG bin etc include info lib man sbin; do
  1049         test -d $RPM_BUILD_ROOT%{l_prefix}/local/$dir || \
  1050         mkdir $RPM_BUILD_ROOT%{l_prefix}/local/$dir
  1051     done
  1052     for i in 1 2 3 4 5 6 7 8 9; do
  1053         test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i || \
  1054         mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i
  1055         test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i || \
  1056         mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i
  1057     done
  1058     test -d $RPM_BUILD_ROOT%{l_prefix}/RPM || \
  1059     mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM
  1060     for dir in SRC PKG DB TMP; do
  1061         test -d $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir || \
  1062         mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir
  1063     done
  1064     mkdir $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg
  1065     mkdir $RPM_BUILD_ROOT%{l_prefix}/include/openpkg
  1067     #   display verbosity header
  1068     set +x; VERBOSE "INSTALL: Installation of RPM"; set -x
  1070     #   install RPM into installation hierarchy
  1071     ( cd rpm-%{V_rpm}
  1072       DESTDIR="$RPM_BUILD_ROOT"
  1073       export DESTDIR
  1074       ${l_make} install
  1075     ) || exit $?
  1077     #   display verbosity header
  1078     set +x; VERBOSE "INSTALL: Install Additional Files"; set -x
  1080     #   add additional development files
  1081     cp rpm-%{V_rpm}/misc/glob.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1082     cp zlib-%{V_zlib}/zlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1083     cp zlib-%{V_zlib}/zconf.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1084     cp zlib-%{V_zlib}/libz.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmz.a
  1085     cp bzip2-%{V_bzip2}/bzlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1086     cp bzip2-%{V_bzip2}/libbz2.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbz2.a
  1087     cp beecrypt-%{V_beecrypt}/beecrypt.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1088     cp beecrypt-%{V_beecrypt}/libbeecrypt.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbeecrypt.a
  1090     #   display verbosity header
  1091     set +x; VERBOSE "INSTALL: Post-Adjust Installation"; set -x
  1093     #   post-adjust RPM installation (namespace-clean POPT inclusion)
  1094     mv $RPM_BUILD_ROOT%{l_prefix}/lib/libpopt.a \
  1095        $RPM_BUILD_ROOT%{l_prefix}/lib/librpmpopt.a
  1096     mv $RPM_BUILD_ROOT%{l_prefix}/include/popt.h \
  1097        $RPM_BUILD_ROOT%{l_prefix}/include/rpm/popt.h
  1099     #   move C API into custom locations
  1100     mv $RPM_BUILD_ROOT%{l_prefix}/include/rpm \
  1101        $RPM_BUILD_ROOT%{l_prefix}/include/openpkg/rpm
  1102     mv $RPM_BUILD_ROOT%{l_prefix}/lib/librpm* \
  1103        $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/
  1105     #   move rpm tool to custom location
  1106     mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm \
  1107        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1108     mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm.8 \
  1109        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm.8
  1111     #   move rpm2cpio tool to custom location
  1112     mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm2cpio \
  1113        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio
  1114     mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm2cpio.8 \
  1115        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio.8
  1117     #   replace symlinks with hardlinks
  1118     for entry in rpme:rpmi rpmt:rpmb rpmu:rpmi rpmv:rpmq; do
  1119         eval `echo $entry | sed -e 's/^\(.*\):\(.*\)$/dst=\1; src=\2/'`
  1120         rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  1121         ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$src \
  1122            $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  1123     done
  1124     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/rpmbuild
  1125     ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmb \
  1126        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild
  1127     mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpmbuild.8 \
  1128        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild.8
  1130     #   display verbosity header
  1131     set +x; VERBOSE "INSTALL: Stripping Down Installation"; set -x
  1133     #   strip RPM installation
  1134     ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/* \
  1135           $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/* >/dev/null 2>&1 || true
  1136     for dir in man/ja man/pl man/ru man/sk src; do
  1137         rm -rf $RPM_BUILD_ROOT%{l_prefix}/$dir >/dev/null 2>&1 || true
  1138     done
  1139     rm -rf $RPM_BUILD_ROOT/var >/dev/null 2>&1 || true
  1140     for file in rpme rpmi rpmsign rpmu rpmverify rpmquery gendiff; do
  1141         rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/$file >/dev/null 2>&1 || true
  1142     done
  1143     rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/* >/dev/null 2>&1 || true
  1144     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/* >/dev/null 2>&1 || true
  1145     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man3/* >/dev/null 2>&1 || true
  1146     rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmpopt >/dev/null 2>&1 || true
  1147     rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmrc >/dev/null 2>&1 || true
  1148     rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.la >/dev/null 2>&1 || true
  1149     rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/lib >/dev/null 2>&1 || true
  1150     for file in \
  1151         u_pkg.sh vpkg-provides.sh vpkg-provides2.sh rpmdiff.cgi rpmdiff \
  1152         mkinstalldirs magic.prov magic.req http.req getpo.sh \
  1153         get_magic.pl find-provides find-requires find-requires.perl \
  1154         find-req.pl find-provides.perl find-prov.pl find-lang.sh \
  1155         cpanflute convertrpmrc.sh check-prereqs rpmputtext rpmgettext \
  1156         brp-compress brp-redhat brp-sparc64-linux brp-strip \
  1157         brp-strip-shared brp-strip-comment-note rpmrc \
  1158         config.guess config.sub check-files; do
  1159         rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$file >/dev/null 2>&1 || true
  1160     done
  1162     #   display verbosity header
  1163     set +x; VERBOSE "INSTALL: Install Additional Tools"; set -x
  1165     #   install lsync tool
  1166     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1167         <`SOURCE lsync` \
  1168         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync
  1169     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync
  1170     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1171         <`SOURCE dot.lsyncrc` \
  1172         >$RPM_BUILD_ROOT%{l_prefix}/local/.lsyncrc
  1173     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1174         <`SOURCE lsync.8` \
  1175         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync.8
  1177     #   install rpm-config tool
  1178     ( l_prefix="%{l_prefix}"
  1179       l_cc="%{l_cc}"
  1180       l_cflags=""
  1181       l_cppflags="-DOPENPKG -I${l_prefix}/include/openpkg/rpm -I${l_prefix}/include/openpkg"
  1182       l_ldflags="-L${l_prefix}/lib/openpkg"
  1183       l_libs="-lrpmbuild -lrpm -lrpmio -lrpmdb -lrpmpopt -lrpmbeecrypt -lrpmbz2 -lrpmz"
  1184       sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1185           -e "s:@l_cc@:$l_cc:g" \
  1186           -e "s:@l_cflags@:$l_cflags:g" \
  1187           -e "s:@l_cppflags@:$l_cppflags:g" \
  1188           -e "s:@l_ldflags@:$l_ldflags:g" \
  1189           -e "s:@l_libs@:$l_libs:g" \
  1190           -e "s:@l_version@:%{V_rpm}:g" \
  1191           <`SOURCE rpm-config.sh` \
  1192           >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config
  1193     ) || exit $?
  1194     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config
  1195     sed -e "s:RPM_VERSION:%{V_rpm}:g" \
  1196         <`SOURCE rpm-config.8` \
  1197         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config.8
  1199     #   install OpenPKG registry commands
  1200     ( cd openpkg-registry-%{V_registry}
  1201       mv  $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm \
  1202           $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpm
  1203       sed -e "s;@l_prefix@;%{l_prefix};g" \
  1204           rpm.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1205       chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1206       sed -e "s;@l_prefix@;%{l_prefix};g" \
  1207           register.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register
  1208       chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register
  1209       cp register.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register.8
  1210     ) || exit $?
  1212     #   install OpenPKG Tool Chain command subset
  1213     ( cd openpkg-tools-%{V_tools}
  1214       cp cmd/curl.sh $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/curl.sh
  1215       cp cmd/build.pl $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl
  1216       chmod 644 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl
  1217       cp cmd/build.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.8
  1218     ) || exit $?
  1220     #   install RPM extension
  1221     ( cd rpm-%{V_rpm}
  1222       cp file/file $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file
  1223       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file
  1224     ) || exit $?
  1225     ( cd perl-%{V_perl}
  1226       cp miniperl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl
  1227       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl
  1228     ) || exit $?
  1229     ( cd openssl-%{V_openssl}
  1230       cp apps/openssl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl
  1231       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl
  1232     ) || exit $?
  1233     ( cd curl-%{V_curl}
  1234       cp src/curl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  1235       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  1236     ) || exit $?
  1237     ( cd bzip2-%{V_bzip2}
  1238       cp bzip2 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  1239       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  1240     ) || exit $?
  1241     ( cd gzip-%{V_gzip}
  1242       cp gzip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  1243       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  1244     ) || exit $?
  1245     ( cd patch-%{V_patch}
  1246       cp patch $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  1247       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  1248     ) || exit $?
  1249     ( cd tar-%{V_tar}
  1250       cp tar $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  1251       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  1252     ) || exit $?
  1253     ( cd bash-%{V_bash}
  1254       cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  1255       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  1256     ) || exit $?
  1257     ( cd uuid-%{V_uuid}
  1258       cp uuid $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid
  1259       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid
  1260     ) || exit $?
  1261     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1262         -e "s;@l_musr@;%{l_musr};g" \
  1263         -e "s;@l_mgrp@;%{l_mgrp};g" \
  1264         <`SOURCE uuid.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid
  1265     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid
  1266     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1267         <`SOURCE uuid.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid.8
  1268     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1269         <`SOURCE release.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release
  1270     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release
  1271     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1272         <`SOURCE release.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release.8
  1273     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1274         -e "s;@l_musr@;%{l_musr};g" \
  1275         -e "s;@l_mgrp@;%{l_mgrp};g" \
  1276         <`SOURCE rpmdb` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb
  1277     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb
  1278     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1279         <`SOURCE rpmtool` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  1280     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  1282     #   install OpenPKG tool chain execution frontend and execution wrapper
  1283     cp openpkg-executable-%{V_exec}/openpkg $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1284     ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1285     chmod 4775 $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1286     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1287         <`SOURCE openpkg.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg
  1288     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg
  1289     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1290         <`SOURCE openpkg.1` \
  1291         >$RPM_BUILD_ROOT%{l_prefix}/man/man1/openpkg.1
  1293     #   install more OpenPKG tool chain commands
  1294     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1295         <`SOURCE install.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install
  1296     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install
  1297     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1298         <`SOURCE man.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man
  1299     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man
  1301     #   install an own copy of shtool
  1302     cp $shtool $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  1303     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  1305     #   display verbosity header
  1306     set +x; VERBOSE "INSTALL: Install Configuration Files"; set -x
  1308     #   install a few README files
  1309     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1310         <`SOURCE root.README` \
  1311         >$RPM_BUILD_ROOT%{l_prefix}/README
  1312     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1313         <`SOURCE local.README` \
  1314         >$RPM_BUILD_ROOT%{l_prefix}/local/README
  1316     #   install Bash environment
  1317     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1318         <`SOURCE dot.bashrc` \
  1319         >$RPM_BUILD_ROOT%{l_prefix}/.bashrc
  1320     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1321         <`SOURCE dot.bash_login` \
  1322         >$RPM_BUILD_ROOT%{l_prefix}/.bash_login
  1324     #   install Run-Command files
  1325     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1326         -e "s:@l_susr@:%{l_susr}:g" \
  1327         -e "s:@l_musr@:%{l_musr}:g" \
  1328         <`SOURCE rc` \
  1329         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc
  1330     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc
  1331     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1332         <`SOURCE rc.conf` \
  1333         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  1334     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  1335     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1336         <`SOURCE rc.func` \
  1337         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  1338     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  1339     mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  1340     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1341         -e "s:@l_musr@:%{l_musr}:g" \
  1342         <`SOURCE rc.openpkg` \
  1343         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  1344     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  1345     ( echo "#!/bin/sh"
  1346       echo "exec %{l_prefix}/etc/rc \${1+\"\$@\"}"
  1347     ) >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc
  1348     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc
  1349     ln  $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc \
  1350         $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rc
  1351     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1352         <`SOURCE rc.8` \
  1353         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc.8
  1355     #   create configuration directory
  1356     test -d $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg || \
  1357         mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg
  1359     #   install platform identification file
  1360     sh $shtool platform -n -L -S "" -C "+" -F "%<ap>-any-%<sp>" \
  1361         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform
  1362     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform
  1364     #   install UUID configuration file (ghost)
  1365     touch $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid
  1366     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid
  1368     #   install registry configuration files (ghost)
  1369     touch \
  1370         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.conf \
  1371         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \
  1372         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \
  1373         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util
  1374     chmod 644 \
  1375         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.conf \
  1376         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \
  1377         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \
  1378         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util
  1380     #   install default managers configuration file
  1381     ( echo "##"
  1382       echo "##  managers -- OpenPKG Instance Managers"
  1383       echo "##"
  1384       echo ""
  1385       echo "%{l_susr}"
  1386       echo "%{l_musr}"
  1387       echo ""
  1388     ) >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/managers
  1390     #   install overriding RPM configuration files
  1391     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1392         <`SOURCE rpmpopt` \
  1393         >>$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmpopt
  1394     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1395         <`SOURCE rpmrc` \
  1396         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc
  1397     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1398         -e "s:@l_prefix_static@:%{l_prefix}:g" \
  1399         -e "s;@l_build_path@;$l_build_path;g" \
  1400         -e "s;@l_build_ldlp@;$l_build_ldlp;g" \
  1401         -e "s;@l_build_ulim@;$l_build_ulim;g" \
  1402         -e "s:@TAG@:$tag:g" \
  1403         -e "s:@SUSR@:$susr:g" \
  1404         -e "s:@SGRP@:$sgrp:g" \
  1405         -e "s:@MUSR@:$musr:g" \
  1406         -e "s:@MGRP@:$mgrp:g" \
  1407         -e "s:@RUSR@:$rusr:g" \
  1408         -e "s:@RGRP@:$rgrp:g" \
  1409         -e "s:@NUSR@:$nusr:g" \
  1410         -e "s:@NGRP@:$ngrp:g" \
  1411         <`SOURCE rpmmacros` \
  1412         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros
  1413     cp `SOURCE openpkg.org.pgp` \
  1414        $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.org.pgp
  1415     cp `SOURCE openpkg.com.pgp` \
  1416        $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.com.pgp
  1417     cp `SOURCE openpkg.net.pgp` \
  1418        $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.net.pgp
  1420     #   display verbosity header
  1421     set +x; VERBOSE "INSTALL: Done. Thank you for flying OpenPKG..."; set -x
  1423 %files
  1424     %defattr(-,%{?l_musr}%{!?l_musr:%{l_fsusr}},%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}})
  1425     %{l_prefix}/README
  1426     %config(noreplace) %{l_prefix}/.bashrc
  1427     %config(noreplace) %{l_prefix}/.bash_login
  1428     %dir %{l_prefix}/RPM
  1429     %dir %{l_prefix}/RPM/SRC
  1430     %dir %{l_prefix}/RPM/PKG
  1431     %dir %{l_prefix}/RPM/DB
  1432     %dir %{l_prefix}/RPM/TMP
  1433     %dir %{l_prefix}/cgi
  1434     %dir %{l_prefix}/bin
  1435     %attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/openpkg
  1436     %dir %{l_prefix}/etc
  1437     %{l_prefix}/etc/rc
  1438     %config(noreplace) %{l_prefix}/etc/rc.conf
  1439     %{l_prefix}/etc/rc.func
  1440     %dir %{l_prefix}/etc/rc.d
  1441     %{l_prefix}/etc/rc.d/rc.openpkg
  1442     %dir %{l_prefix}/etc/openpkg
  1443     %ghost %{l_prefix}/etc/openpkg/uuid
  1444     %config %{l_prefix}/etc/openpkg/platform
  1445     %config %{l_prefix}/etc/openpkg/rpmmacros
  1446     %config %{l_prefix}/etc/openpkg/rpmrc
  1447     %ghost %{l_prefix}/etc/openpkg/register.conf
  1448     %ghost %{l_prefix}/etc/openpkg/register.prep
  1449     %ghost %{l_prefix}/etc/openpkg/register.tran
  1450     %ghost %{l_prefix}/etc/openpkg/register.util
  1451     %config %attr(664,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/openpkg/managers
  1452     %{l_prefix}/etc/openpkg/openpkg.org.pgp
  1453     %{l_prefix}/etc/openpkg/openpkg.com.pgp
  1454     %{l_prefix}/etc/openpkg/openpkg.net.pgp
  1455     %dir %{l_prefix}/include
  1456     %dir %{l_prefix}/include/openpkg
  1457     %dir %{l_prefix}/include/openpkg/rpm
  1458     %{l_prefix}/include/openpkg/rpm/argv.h
  1459     %{l_prefix}/include/openpkg/rpm/beecrypt.h
  1460     %{l_prefix}/include/openpkg/rpm/bzlib.h
  1461     %{l_prefix}/include/openpkg/rpm/db.h
  1462     %{l_prefix}/include/openpkg/rpm/fts.h
  1463     %{l_prefix}/include/openpkg/rpm/glob.h
  1464     %{l_prefix}/include/openpkg/rpm/hdrinline.h
  1465     %{l_prefix}/include/openpkg/rpm/header.h
  1466     %{l_prefix}/include/openpkg/rpm/misc.h
  1467     %{l_prefix}/include/openpkg/rpm/popt.h
  1468     %{l_prefix}/include/openpkg/rpm/rpmal.h
  1469     %{l_prefix}/include/openpkg/rpm/rpmbuild.h
  1470     %{l_prefix}/include/openpkg/rpm/rpmcli.h
  1471     %{l_prefix}/include/openpkg/rpm/rpmdb.h
  1472     %{l_prefix}/include/openpkg/rpm/rpmds.h
  1473     %{l_prefix}/include/openpkg/rpm/rpmerr.h
  1474     %{l_prefix}/include/openpkg/rpm/rpmfc.h
  1475     %{l_prefix}/include/openpkg/rpm/rpmfi.h
  1476     %{l_prefix}/include/openpkg/rpm/rpmfile.h
  1477     %{l_prefix}/include/openpkg/rpm/rpmhash.h
  1478     %{l_prefix}/include/openpkg/rpm/rpmio.h
  1479     %{l_prefix}/include/openpkg/rpm/rpmlib.h
  1480     %{l_prefix}/include/openpkg/rpm/rpmlog.h
  1481     %{l_prefix}/include/openpkg/rpm/rpmmacro.h
  1482     %{l_prefix}/include/openpkg/rpm/rpmmessages.h
  1483     %{l_prefix}/include/openpkg/rpm/rpmpgp.h
  1484     %{l_prefix}/include/openpkg/rpm/rpmps.h
  1485     %{l_prefix}/include/openpkg/rpm/rpmspec.h
  1486     %{l_prefix}/include/openpkg/rpm/rpmsw.h
  1487     %{l_prefix}/include/openpkg/rpm/rpmte.h
  1488     %{l_prefix}/include/openpkg/rpm/rpmts.h
  1489     %{l_prefix}/include/openpkg/rpm/rpmurl.h
  1490     %{l_prefix}/include/openpkg/rpm/stringbuf.h
  1491     %{l_prefix}/include/openpkg/rpm/ugid.h
  1492     %{l_prefix}/include/openpkg/rpm/zconf.h
  1493     %{l_prefix}/include/openpkg/rpm/zlib.h
  1494     %dir %{l_prefix}/info
  1495     %dir %{l_prefix}/lib
  1496     %dir %{l_prefix}/lib/openpkg
  1497     %{l_prefix}/lib/openpkg/bash
  1498     %{l_prefix}/lib/openpkg/bzip2
  1499     %{l_prefix}/lib/openpkg/curl
  1500     %{l_prefix}/lib/openpkg/file
  1501     %{l_prefix}/lib/openpkg/gzip
  1502     %{l_prefix}/lib/openpkg/librpm.a
  1503     %{l_prefix}/lib/openpkg/librpmbeecrypt.a
  1504     %{l_prefix}/lib/openpkg/librpmbuild.a
  1505     %{l_prefix}/lib/openpkg/librpmbz2.a
  1506     %{l_prefix}/lib/openpkg/librpmdb.a
  1507     %{l_prefix}/lib/openpkg/librpmio.a
  1508     %{l_prefix}/lib/openpkg/librpmpopt.a
  1509     %{l_prefix}/lib/openpkg/librpmz.a
  1510     %{l_prefix}/lib/openpkg/macros
  1511     %{l_prefix}/lib/openpkg/magic
  1512     %{l_prefix}/lib/openpkg/magic.mgc
  1513     %{l_prefix}/lib/openpkg/magic.mime
  1514     %{l_prefix}/lib/openpkg/magic.mime.mgc
  1515     %{l_prefix}/lib/openpkg/miniperl
  1516     %{l_prefix}/lib/openpkg/openpkg
  1517     %{l_prefix}/lib/openpkg/openssl
  1518     %{l_prefix}/lib/openpkg/patch
  1519     %{l_prefix}/lib/openpkg/rc
  1520     %{l_prefix}/lib/openpkg/rpm
  1521     %{l_prefix}/lib/openpkg/rpmb
  1522     %{l_prefix}/lib/openpkg/rpmd
  1523     %{l_prefix}/lib/openpkg/rpmdb
  1524     %{l_prefix}/lib/openpkg/rpmdb_dump
  1525     %{l_prefix}/lib/openpkg/rpmdb_load
  1526     %{l_prefix}/lib/openpkg/rpmdb_verify
  1527     %{l_prefix}/lib/openpkg/rpme
  1528     %{l_prefix}/lib/openpkg/rpmi
  1529     %{l_prefix}/lib/openpkg/rpmk
  1530     %{l_prefix}/lib/openpkg/rpmpopt
  1531     %{l_prefix}/lib/openpkg/rpmq
  1532     %{l_prefix}/lib/openpkg/rpmt
  1533     %{l_prefix}/lib/openpkg/rpmtool
  1534     %{l_prefix}/lib/openpkg/rpmu
  1535     %{l_prefix}/lib/openpkg/rpmv
  1536     %{l_prefix}/lib/openpkg/shtool
  1537     %{l_prefix}/lib/openpkg/tar
  1538     %{l_prefix}/lib/openpkg/uuid
  1539     %dir %{l_prefix}/libexec
  1540     %dir %{l_prefix}/libexec/openpkg
  1541     %{l_prefix}/libexec/openpkg/build.8
  1542     %{l_prefix}/libexec/openpkg/build.pl
  1543     %{l_prefix}/libexec/openpkg/curl.sh
  1544     %{l_prefix}/libexec/openpkg/install
  1545     %{l_prefix}/libexec/openpkg/lsync
  1546     %{l_prefix}/libexec/openpkg/lsync.8
  1547     %{l_prefix}/libexec/openpkg/man
  1548     %{l_prefix}/libexec/openpkg/rc
  1549     %{l_prefix}/libexec/openpkg/rc.8
  1550     %{l_prefix}/libexec/openpkg/register
  1551     %{l_prefix}/libexec/openpkg/register.8
  1552     %{l_prefix}/libexec/openpkg/release
  1553     %{l_prefix}/libexec/openpkg/release.8
  1554     %{l_prefix}/libexec/openpkg/rpm
  1555     %{l_prefix}/libexec/openpkg/rpm-config
  1556     %{l_prefix}/libexec/openpkg/rpm-config.8
  1557     %{l_prefix}/libexec/openpkg/rpm.8
  1558     %{l_prefix}/libexec/openpkg/rpm2cpio
  1559     %{l_prefix}/libexec/openpkg/rpm2cpio.8
  1560     %{l_prefix}/libexec/openpkg/rpmbuild
  1561     %{l_prefix}/libexec/openpkg/rpmbuild.8
  1562     %{l_prefix}/libexec/openpkg/uuid
  1563     %{l_prefix}/libexec/openpkg/uuid.8
  1564     %dir %{l_prefix}/man
  1565     %dir %{l_prefix}/man/man1
  1566     %dir %{l_prefix}/man/man2
  1567     %dir %{l_prefix}/man/man3
  1568     %dir %{l_prefix}/man/man4
  1569     %dir %{l_prefix}/man/man5
  1570     %dir %{l_prefix}/man/man6
  1571     %dir %{l_prefix}/man/man7
  1572     %dir %{l_prefix}/man/man8
  1573     %dir %{l_prefix}/man/man9
  1574     %dir %{l_prefix}/man/cat1
  1575     %dir %{l_prefix}/man/cat2
  1576     %dir %{l_prefix}/man/cat3
  1577     %dir %{l_prefix}/man/cat4
  1578     %dir %{l_prefix}/man/cat5
  1579     %dir %{l_prefix}/man/cat6
  1580     %dir %{l_prefix}/man/cat7
  1581     %dir %{l_prefix}/man/cat8
  1582     %dir %{l_prefix}/man/cat9
  1583     %{l_prefix}/man/man1/openpkg.1
  1584     %dir %{l_prefix}/sbin
  1585     %dir %{l_prefix}/pub
  1586     %dir %{l_prefix}/share
  1587     %dir %{l_prefix}/var
  1588     %dir %{l_prefix}/local
  1589     %{l_prefix}/local/README
  1590     %{l_prefix}/local/.lsyncrc
  1591     %dir %{l_prefix}/local/PKG
  1592     %dir %{l_prefix}/local/bin
  1593     %dir %{l_prefix}/local/etc
  1594     %dir %{l_prefix}/local/include
  1595     %dir %{l_prefix}/local/info
  1596     %dir %{l_prefix}/local/lib
  1597     %dir %{l_prefix}/local/man
  1598     %dir %{l_prefix}/local/man/man1
  1599     %dir %{l_prefix}/local/man/man2
  1600     %dir %{l_prefix}/local/man/man3
  1601     %dir %{l_prefix}/local/man/man4
  1602     %dir %{l_prefix}/local/man/man5
  1603     %dir %{l_prefix}/local/man/man6
  1604     %dir %{l_prefix}/local/man/man7
  1605     %dir %{l_prefix}/local/man/man8
  1606     %dir %{l_prefix}/local/man/man9
  1607     %dir %{l_prefix}/local/man/cat1
  1608     %dir %{l_prefix}/local/man/cat2
  1609     %dir %{l_prefix}/local/man/cat3
  1610     %dir %{l_prefix}/local/man/cat4
  1611     %dir %{l_prefix}/local/man/cat5
  1612     %dir %{l_prefix}/local/man/cat6
  1613     %dir %{l_prefix}/local/man/cat7
  1614     %dir %{l_prefix}/local/man/cat8
  1615     %dir %{l_prefix}/local/man/cat9
  1616     %dir %{l_prefix}/local/sbin
  1618 %clean
  1619     #   skip in bootstrap phase 2 (see openpkg.boot)
  1620     [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  1622     #   cleanup build area
  1623     rm -rf openpkg-%{version} >/dev/null 2>&1 || true
  1625     #   cleanup installation area
  1626     rm -rf $RPM_BUILD_ROOT >/dev/null 2>&1 || true
  1628 %pre
  1629     #   always performed for upgrades and because it doesn't harm!
  1630     #   [ ".$1" != .1 ] && exit 0
  1632     #   this procedure is only usable with root privileges
  1633     #   (for non-root installations it is not required at all)
  1634     cusr=`(id -un) 2>/dev/null ||\
  1635           (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  1636           (whoami) 2>/dev/null ||\
  1637           (who am i | cut "-d " -f1) 2>/dev/null ||\
  1638           echo $LOGNAME`
  1640     #   determine runtime details (for both inside and outside RPM!!)
  1641     #   - bootstrapping: $xxx is set from aux.wrapbin.sh
  1642     #   - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
  1643     #   - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
  1644     [ ".$susr" = . ] && susr="%{?l_susr}%{!?l_susr:root}"
  1645     [ ".$sgrp" = . ] && sgrp="%{?l_sgrp}%{!?l_sgrp:wheel}"
  1646     [ ".$musr" = . ] && musr="%{?l_musr}%{!?l_musr:%{l_fsusr}}"
  1647     [ ".$mgrp" = . ] && mgrp="%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}}"
  1648     [ ".$rusr" = . ] && rusr="%{?l_rusr}%{!?l_rusr:%{l_fsusr}-r}"
  1649     [ ".$rgrp" = . ] && rgrp="%{?l_rgrp}%{!?l_rgrp:%{l_fsgrp}-r}"
  1650     [ ".$nusr" = . ] && nusr="%{?l_nusr}%{!?l_nusr:%{l_fsusr}-n}"
  1651     [ ".$ngrp" = . ] && ngrp="%{?l_ngrp}%{!?l_ngrp:%{l_fsgrp}-n}"
  1652     [ ".$suid" = . ] && suid="%{?l_suid}"
  1653     [ ".$sgid" = . ] && sgid="%{?l_sgid}"
  1654     [ ".$muid" = . ] && muid="%{?l_muid}"
  1655     [ ".$mgid" = . ] && mgid="%{?l_mgid}"
  1656     [ ".$ruid" = . ] && ruid="%{?l_ruid}"
  1657     [ ".$rgid" = . ] && rgid="%{?l_rgid}"
  1658     [ ".$nuid" = . ] && nuid="%{?l_nuid}"
  1659     [ ".$ngid" = . ] && ngid="%{?l_ngid}"
  1661     #   if any of these optional params are not used we won't have a
  1662     #   corresponding macro either, so make use of one conditionally
  1663     [ ".$suid" = . ] && [ ".%{?l_suid:set}" = .set ] && suid="%{?l_suid}"
  1664     [ ".$sgid" = . ] && [ ".%{?l_sgid:set}" = .set ] && sgid="%{?l_sgid}"
  1665     [ ".$muid" = . ] && [ ".%{?l_muid:set}" = .set ] && muid="%{?l_muid}"
  1666     [ ".$mgid" = . ] && [ ".%{?l_mgid:set}" = .set ] && mgid="%{?l_mgid}"
  1667     [ ".$ruid" = . ] && [ ".%{?l_ruid:set}" = .set ] && ruid="%{?l_ruid}"
  1668     [ ".$rgid" = . ] && [ ".%{?l_rgid:set}" = .set ] && rgid="%{?l_rgid}"
  1669     [ ".$nuid" = . ] && [ ".%{?l_nuid:set}" = .set ] && nuid="%{?l_nuid}"
  1670     [ ".$ngid" = . ] && [ ".%{?l_ngid:set}" = .set ] && ngid="%{?l_ngid}"
  1672     #   determine prefix
  1673     [ ".$prefix" = . ] && prefix="%{l_prefix}"
  1674     prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  1676     #   register instance in presence file
  1677     presence="/etc/openpkg"
  1678     exists=`cat $presence 2>/dev/null | egrep "^ *${prefix} *\$"`
  1679     if [ ".$exists" = . ]; then
  1680         ( umask 022
  1681           echo "${prefix}" >>$presence
  1682         ) 2>/dev/null || true
  1683     fi
  1685     #   determine user/group ids
  1686     for class in s m r n; do
  1687         eval "xusr=\"\$${class}usr\""
  1688         eval "xgrp=\"\$${class}grp\""
  1689         eval "xuid=\"\$${class}uid\""
  1690         eval "xgid=\"\$${class}gid\""
  1691         if [ ".$xuid" = . ]; then
  1692             xuid=`(getent passwd "${xusr}"; \
  1693                    grep "^${xusr}:" /etc/passwd; \
  1694                    ypmatch "${xusr}" passwd; \
  1695                    nismatch "${xusr}" passwd; \
  1696                    nidump passwd . | grep "^${xusr}:") 2>/dev/null | \
  1697                    sed -e 'q' | awk -F: '{ print $3; }'`
  1698             if [ ".$xuid" = . ]; then
  1699                 #   seek for a reasonably uid/gid pair
  1700                 xuid=1000
  1701                 ok=0
  1702                 while [ ".$ok" = .0 ]; do
  1703                     eval "u_exists=\$u_exists_$xuid"
  1704                     if [ ".$u_exists" = . ]; then
  1705                         u_exists=`(getent passwd; cat /etc/passwd; ypcat passwd; niscat passwd; nidump passwd .) 2>/dev/null |\
  1706                                   grep "^[^:]*:[^:]*:$xuid:"`
  1707                     fi
  1708                     eval "g_exists=\$g_exists_$xuid"
  1709                     if [ ".$g_exists" = . ]; then
  1710                         g_exists=`(getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null |\
  1711                                   grep "^[^:]*:[^:]*:$xuid:"`
  1712                     fi
  1713                     if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
  1714                         ok=1
  1715                         break
  1716                     fi
  1717                     xuid=`expr $xuid + 1`
  1718                 done
  1719                 eval "u_exists_$xuid=yes"
  1720                 eval "g_exists_$xuid=yes"
  1721             fi
  1722         fi
  1723         if [ ".$xgid" = . ]; then
  1724             xgid=`(getent group "${xgrp}"; \
  1725                   grep "^${xgrp}:" /etc/group; \
  1726                   ypmatch "${xgrp}" group; \
  1727                   nismatch "${xgrp}" group; \
  1728                   nidump group . | grep "^${xgrp}:") 2>/dev/null | \
  1729                   sed -e 'q' | awk -F: '{ print $3; }'`
  1730             if [ ".$xgid" = . ]; then
  1731                 xgid="$xuid"
  1732             fi
  1733         fi
  1734         eval "${class}uid=\"$xuid\""
  1735         eval "${class}gid=\"$xgid\""
  1736     done
  1738     #   determine platform id
  1739     s=`(uname -s) 2>/dev/null` || s='Unknown'
  1740     r=`(uname -r) 2>/dev/null` || r='0.0'
  1741     plid="${s}/${r}"
  1743     #   add entry to /etc/shells
  1744     shell="${prefix}/lib/openpkg/bash"
  1745     if [ -f /etc/shells ]; then
  1746         exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  1747         if [ ".$exists" = . ]; then
  1748             if [ ".$cusr" != ".root" ]; then
  1749                 echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2
  1750                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1751             else
  1752                 echo "${shell}" >>/etc/shells
  1753             fi
  1754         fi
  1755     fi
  1757     #   clear pending deferred actions
  1758     rm -f %{l_prefix}.pre-group-process.sh %{l_prefix}.pre-post-process.sh >/dev/null 2>&1
  1760     #   create the hierarchy user/group
  1761     for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \
  1762                "management:${musr}:${muid}:${mgrp}:${mgid}" \
  1763                "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \
  1764                "non-privileged:${nusr}:${nuid}:${ngrp}:${ngid}"; do
  1765         #   split request into class/usr/uid/grp/gid
  1766         OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  1767         class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  1769         #   check whether user already exists
  1770         exists=`(getent passwd "$usr"; \
  1771                  grep "^$usr:" /etc/passwd; \
  1772                  ypmatch "$usr" passwd; \
  1773                  nismatch "$usr" passwd; \
  1774                  nidump passwd . | grep "^$usr:") 2>/dev/null | \
  1775                  sed -e 'q'`
  1776         if [ ".$exists" = . ]; then
  1777             if [ ".$cusr" != ".root" ]; then
  1778                 echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2
  1779                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1780             else
  1781                 #   add entry to passwd database
  1782                 realname="${prefix} OpenPKG ($class)"
  1783                 case "$plid" in
  1784                     FreeBSD/* | NetBSD/* )
  1785                         file=/etc/master.passwd
  1786                         entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}"
  1787                         update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
  1788                         ;;
  1789                     Linux/* )
  1790                         file=/etc/passwd
  1791                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1792                         update="(PATH=\$PATH:/usr/sbin; pwconv)"
  1793                         ;;
  1794                     SunOS/5.* | UnixWare/* )
  1795                         file=/etc/passwd
  1796                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1797                         update="(PATH=\$PATH:/usr/sbin; pwconv)"
  1798                         ;;
  1799                     AIX/* )
  1800                         #   intentionally do nothing here
  1802                         ;;
  1803                     OSF1/V5.* )
  1804                         file=/etc/passwd
  1805                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1806                         update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
  1807                         ;;
  1808                     HP-UX/* )
  1809                         file=/etc/passwd
  1810                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1811                         update=":"
  1812                         ;;
  1813                     Darwin/* )
  1814                         #   intentionally do nothing here
  1816                         ;;
  1817                     IRIX*/6.* )
  1818                         file=/etc/passwd
  1819                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1820                         if   [ -f /etc/shadow ]
  1821                         then update="(PATH=\$PATH:/sbin; pwconv)"
  1822                         else update=":"
  1823                         fi
  1824                         ;;
  1825                 esac
  1826                 case "$plid" in
  1827                     Darwin/* )
  1828                         niutil -create     . "/users/${usr}"
  1829                         niutil -createprop . "/users/${usr}" passwd   "*"
  1830                         niutil -createprop . "/users/${usr}" uid      "${uid}"
  1831                         niutil -createprop . "/users/${usr}" gid      "${gid}"
  1832                         niutil -createprop . "/users/${usr}" realname "${realname}"
  1833                         niutil -createprop . "/users/${usr}" home     "${prefix}"
  1834                         niutil -createprop . "/users/${usr}" shell    "${shell}"
  1835                         ;;
  1836                     AIX/* )
  1837                         mkuser id="${uid}" gecos="${realname}" home="${prefix}" "${usr}"
  1838                         cp /etc/security/login.cfg /etc/security/login.cfg.bak && \
  1839                         sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\) *\$;\\1,$shell;" \
  1840                             </etc/security/login.cfg.bak >/etc/security/login.cfg && \
  1841                         rm -f /etc/security/login.cfg.bak >/dev/null 2>&1
  1842                         #   defer both the setting of the primary group and the shell,
  1843                         #   as they do not exist at this stage of processing.
  1844                         echo "chuser pgrp=\"${grp}\" \"${usr}\"" >>%{l_prefix}.pre-group-process.sh
  1845                         echo "chuser shell=\"${shell}\" \"${usr}\"" >>%{l_prefix}.pre-post-process.sh
  1846                         ;;
  1847                     * )
  1848                         cp $file $file.bak && \
  1849                         (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  1850                         rm -f $file.bak >/dev/null 2>&1
  1851                         eval $update
  1852                         [ $? -ne 0 ] && exit $?
  1853                         ;;
  1854                 esac
  1855             fi
  1856         fi
  1858         #   check whether group already exists
  1859         exists=`(getent group "$grp"; \
  1860                 grep "^$grp:" /etc/group; \
  1861                 ypmatch "$grp" group; \
  1862                 nismatch "$grp" group; \
  1863                 nidump group . | grep "^$grp:") 2>/dev/null | \
  1864                 sed -e 'q'`
  1865         if [ ".$exists" = . ]; then
  1866             if [ ".$cusr" != ".root" ]; then
  1867                 echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2
  1868                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1869             else
  1870                 case "$plid" in
  1871                     Darwin/* )
  1872                         niutil -create     . "/groups/${grp}"
  1873                         niutil -createprop . "/groups/${grp}" gid   "${gid}"
  1874                         niutil -createprop . "/groups/${grp}" users "${usr}"
  1875                         ;;
  1876                     AIX/* )
  1877                         mkgroup id="${gid}" users="${usr}" "${grp}"
  1878                         ;;
  1879                     * )
  1880                         #   add entry to group database
  1881                         file=/etc/group
  1882                         entry="${grp}:*:${gid}:${usr}"
  1883                         cp $file $file.bak && \
  1884                         (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  1885                         rm -f $file.bak >/dev/null 2>&1
  1886                     ;;
  1887                 esac
  1888             fi
  1889         fi
  1890     done
  1892     #   optional group processing (deferred adjustment of primary group)
  1893     if [ -f %{l_prefix}.pre-group-process.sh ]; then
  1894         sh %{l_prefix}.pre-group-process.sh
  1895         rm -f %{l_prefix}.pre-group-process.sh
  1896     fi
  1898     #   invalidate passwd and group tables from Name Service Cache Daemon to
  1899     #   ensure chown/chgrp works immediately after pwconv on Linux and Solaris
  1900     if [ -x /usr/sbin/nscd ]; then
  1901         /usr/sbin/nscd -i passwd >/dev/null 2>&1 || true
  1902         /usr/sbin/nscd -i group >/dev/null 2>&1 || true
  1903     fi
  1905     #   create the startup/shutdown transfer script
  1906     name=`echo "$prefix" | sed -e 's;/;;g'`
  1907     if [ ".$cusr" != ".root" ]; then
  1908         echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2
  1909         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1910     else
  1911         case "$plid" in
  1912             FreeBSD/* )
  1913                 if [ ! -f /etc/rc.d/openpkg-${name} ]; then
  1914                     #   install transfer script
  1915                     rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1
  1916                     ( echo "#!/bin/sh"
  1917                       echo "##"
  1918                       echo "##  openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1919                       echo "##"
  1920                       echo ""
  1921                       echo "# PROVIDE: openpkg-${name}"
  1922                       echo "# REQUIRE: LOGIN"
  1923                       echo "# KEYWORD: shutdown"
  1924                       echo ""
  1925                       echo ". /etc/rc.subr"
  1926                       echo ""
  1927                       echo "name=\"openpkg_${name}\""
  1928                       echo "start_cmd=\"openpkg_rc_all start\""
  1929                       echo "stop_cmd=\"openpkg_rc_all stop\""
  1930                       echo "restart_cmd=\"openpkg_rc_all stop start\""
  1931                       echo ""
  1932                       echo "openpkg_rc_all () {"
  1933                       echo "    if [ -f ${prefix}/etc/rc ]; then"
  1934                       echo "        ${prefix}/etc/rc all \"\$@\""
  1935                       echo "    fi"
  1936                       echo "}"
  1937                       echo ""
  1938                       echo "load_rc_config \$name"
  1939                       echo "run_rc_command \"\$1\""
  1940                       echo ""
  1941                     ) >/etc/rc.d/openpkg-${name}
  1942                     chmod 755 /etc/rc.d/openpkg-${name}
  1943                 fi
  1944                 ;;
  1945             NetBSD/* )
  1946                 if [ ! -f /etc/rc.d/${name} ]; then
  1947                     ( echo "#!/bin/sh"
  1948                       echo "##"
  1949                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1950                       echo "##"
  1951                       echo "##  PROVIDE: ${name}"
  1952                       echo "##  REQUIRE: DAEMON LOGIN NETWORK SERVERS"
  1953                       echo "##"
  1954                       echo ""
  1955                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1956                       echo "case \$1 in"
  1957                       echo "    start   ) exec ${prefix}/etc/rc all start ;;"
  1958                       echo "    stop    ) exec ${prefix}/etc/rc all stop  ;;"
  1959                       echo "    restart ) exec ${prefix}/etc/rc all stop start ;;"
  1960                       echo "    status  ) ;;"
  1961                       echo "esac"
  1962                     ) >/etc/rc.d/${name}
  1963                     chmod 755 /etc/rc.d/${name}
  1964                 fi
  1965                 ;;
  1966             Linux/* )
  1967                 if [ -f /etc/gentoo-release ]; then
  1968                     if [ ! -f /etc/init.d/openpkg-${name} ]; then
  1969                         #   install transfer script
  1970                         ( echo "#!/sbin/runscript"
  1971                           echo "##"
  1972                           echo "##  openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1973                           echo "##"
  1974                           echo ""
  1975                           echo "depend() {"
  1976                           echo "    after *"
  1977                           echo "}"
  1978                           echo ""
  1979                           echo "checkconfig() {"
  1980                           echo "    [ -f ${prefix}/etc/rc ] || return 1"
  1981                           echo "    case $1 in"
  1982                           echo "        start ) exec ${prefix}/etc/rc all start ;;"
  1983                           echo "        stop  ) exec ${prefix}/etc/rc all stop  ;;"
  1984                           echo "    esac"
  1985                           echo "}"
  1986                           echo ""
  1987                           echo "start() {"
  1988                           echo "    checkconfig || return 1"
  1989                           echo "    ebegin "Starting OpenPKG ${prefix} hierarchy""
  1990                           echo "    exec ${prefix}/etc/rc all start"
  1991                           echo "    eend 0"
  1992                           echo "}"
  1993                           echo ""
  1994                           echo "stop() {"
  1995                           echo "    checkconfig || return 1"
  1996                           echo "    ebegin "Stopping OpenPKG ${prefix} hierarchy""
  1997                           echo "    exec ${prefix}/etc/rc all stop"
  1998                           echo "    eend 0"
  1999                           echo "}"
  2000                         ) >/etc/init.d/openpkg-${name}
  2001                         chmod 755 /etc/init.d/openpkg-${name}
  2002                         /sbin/rc-update add openpkg-${name} default
  2003                     fi
  2004                 else
  2005                     #   sroot: script root directory
  2006                     #   lroot: link   root directory
  2007                     if [ -f /etc/debian_version ]; then
  2008                         sroot=/etc/init.d
  2009                         lroot=/etc/rc%d.d
  2010                     elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  2011                         sroot=/etc/rc.d/init.d
  2012                         lroot=/etc/rc.d/rc%d.d
  2013                     elif [ -f /etc/SuSE-release ]; then
  2014                         sroot=/etc/init.d
  2015                         lroot=/etc/init.d/rc%d.d
  2016                     elif [ -f /etc/slackware-version ]; then
  2017                         sroot=/etc/rc.d
  2018                         lroot=/etc/rc.d/rc%d.d
  2019                         name="rc.${name}"
  2020                         for i in 0 1 2 3 4 5 6; do
  2021                             l=`echo $lroot | sed -e "s;%d;$i;"`
  2022                             if [ ! -d $l ]; then
  2023                                 mkdir $l 2>&1 || true
  2024                             fi
  2025                         done
  2026                     else
  2027                         echo "WARNING: you are not running one of the supported standard" 1>&2
  2028                         echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)."   1>&2
  2029                         echo "WARNING: Guessing the location of the system init scripts!" 1>&2
  2030                         sroot=""
  2031                         lroot=""
  2032                         for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  2033                             if [ -d $sr ]; then
  2034                                 sroot="$sr"
  2035                                 break
  2036                             fi
  2037                         done
  2038                         for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  2039                             if [ -d $lr ]; then
  2040                                 lroot="`echo $lr | sed -e 's;2;%d;'`"
  2041                                 break
  2042                             fi
  2043                         done
  2044                         if [ ".$sroot" = . -o ".$lroot" = . ]; then
  2045                             echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  2046                             exit 1
  2047                         fi
  2048                     fi
  2049                     if [ ! -f $sroot/${name} ]; then
  2050                         #   install transfer script
  2051                         ( echo "#!/bin/sh"
  2052                           echo "##"
  2053                           echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2054                           echo "##"
  2055                           echo ""
  2056                           echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2057                           echo "case \$1 in"
  2058                           echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2059                           echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2060                           echo "esac"
  2061                         ) >$sroot/${name}
  2062                         chmod 755 $sroot/${name}
  2063                         #   create corresponding symbolic links
  2064                         for i in 2 3 4 5; do
  2065                             ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/S99${name}
  2066                         done
  2067                         for i in 0 1 6; do
  2068                             ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/K00${name}
  2069                         done
  2070                     fi
  2071                 fi
  2072                 ;;
  2073             SunOS/5.1* )
  2074                 if [ ! -d /var/svc/manifest/openpkg ]; then
  2075                     mkdir /var/svc/manifest/openpkg
  2076                 fi
  2077                 if [ ! -f /var/svc/manifest/openpkg/${name}.xml ]; then
  2078                     #   install SMF manifest
  2079                     ( echo "<?xml version=\"1.0\"?>"
  2080                       echo "<!DOCTYPE service_bundle SYSTEM \"/usr/share/lib/xml/dtd/service_bundle.dtd.1\">"
  2081                       echo "<service_bundle type='manifest' name='OpenPKG:${name}'>"
  2082                       echo "    <service"
  2083                       echo "        name='openpkg/${name}'"
  2084                       echo "        type='service'"
  2085                       echo "        version='1'>"
  2086                       echo "        <single_instance />"
  2087                       echo "        <dependency"
  2088                       echo "            name='filesystem'"
  2089                       echo "            type='service'"
  2090                       echo "            grouping='require_all'"
  2091                       echo "            restart_on='none'>"
  2092                       echo "            <service_fmri value='svc:/system/filesystem/local' />"
  2093                       echo "        </dependency>"
  2094                       echo "        <dependency"
  2095                       echo "            name='name-services'"
  2096                       echo "            type='service'"
  2097                       echo "            grouping='require_all'"
  2098                       echo "            restart_on='none'>"
  2099                       echo "            <service_fmri value='svc:/milestone/name-services' />"
  2100                       echo "        </dependency>"
  2101                       echo "        <dependency"
  2102                       echo "            name='multi-user-server'"
  2103                       echo "            type='service'"
  2104                       echo "            grouping='require_all'"
  2105                       echo "            restart_on='none'>"
  2106                       echo "            <service_fmri value='svc:/milestone/multi-user-server' />"
  2107                       echo "        </dependency>"
  2108                       echo "        <dependency"
  2109                       echo "            name='network'"
  2110                       echo "            type='service'"
  2111                       echo "            grouping='require_all'"
  2112                       echo "            restart_on='none'>"
  2113                       echo "            <service_fmri value='svc:/milestone/network' />"
  2114                       echo "        </dependency>"
  2115                       echo "        <exec_method"
  2116                       echo "            type='method'"
  2117                       echo "            name='start'"
  2118                       echo "            exec='${prefix}/etc/rc all start'"
  2119                       echo "            timeout_seconds='180'>"
  2120                       echo "            <method_context>"
  2121                       echo "                <method_credential user='root' group='root' />"
  2122                       echo "            </method_context>"
  2123                       echo "        </exec_method>"
  2124                       echo "        <exec_method"
  2125                       echo "            type='method'"
  2126                       echo "            name='stop'"
  2127                       echo "            exec='${prefix}/etc/rc all stop'"
  2128                       echo "            timeout_seconds='180'>"
  2129                       echo "        </exec_method>"
  2130                       echo "        <property_group name='startd' type='framework'>"
  2131                       echo "            <propval"
  2132                       echo "                name='ignore_error'"
  2133                       echo "                type='astring'"
  2134                       echo "                value='core,signal' />"
  2135                       echo "        </property_group>"
  2136                       echo "        <property_group name='startd' type='framework'>"
  2137                       echo "            <propval"
  2138                       echo "                name='duration'"
  2139                       echo "                type='astring'"
  2140                       echo "                value='transient' />"
  2141                       echo "        </property_group>"
  2142                       echo "        <property_group name='general' type='framework'>"
  2143                       echo "            <propval"
  2144                       echo "                name='action_authorization'"
  2145                       echo "                type='astring'"
  2146                       echo "                value='solaris.smf.manage.openpkg.${name}' />"
  2147                       echo "        </property_group>"
  2148                       echo "        <instance name='default' enabled='false' />"
  2149                       echo "        <stability value='Unstable' />"
  2150                       echo "        <template>"
  2151                       echo "            <common_name>"
  2152                       echo "                <loctext xml:lang='C'>OpenPKG Instance ${prefix}</loctext>"
  2153                       echo "            </common_name>"
  2154                       echo "        </template>"
  2155                       echo "    </service>"
  2156                       echo "</service_bundle>"
  2157                     ) >/var/svc/manifest/openpkg/${name}.xml
  2158                     chmod 644 /var/svc/manifest/openpkg/${name}.xml
  2159                     /usr/sbin/svccfg import /var/svc/manifest/openpkg/${name}.xml
  2160                     ( echo "/usr/sbin/svcadm enable \"svc:/openpkg/${name}:default\""
  2161                     ) >%{l_prefix}.pre-post-process.sh
  2162                 fi
  2163                 ;;
  2164             SunOS/5.* )
  2165                 if [ ! -f /etc/init.d/${name} ]; then
  2166                     #   install transfer script
  2167                     ( echo "#!/bin/sh"
  2168                       echo "##"
  2169                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2170                       echo "##"
  2171                       echo ""
  2172                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2173                       echo "case \$1 in"
  2174                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2175                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2176                       echo "esac"
  2177                     ) >/etc/init.d/${name}
  2178                     chmod 755 /etc/init.d/${name}
  2179                     #   create corresponding symbolic links
  2180                     ( cd /etc
  2181                       ln init.d/${name} rc3.d/S99${name}
  2182                       ln init.d/${name} rc0.d/K00${name}
  2183                       ln init.d/${name} rc1.d/K00${name}
  2184                     ) || exit $?
  2185                 fi
  2186                 ;;
  2187             UnixWare/* )
  2188                 if [ ! -f /etc/init.d/${name} ]; then
  2189                     #   install transfer script
  2190                     ( echo "#!/bin/sh"
  2191                       echo "##"
  2192                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2193                       echo "##"
  2194                       echo ""
  2195                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2196                       echo "case \$1 in"
  2197                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2198                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2199                       echo "esac"
  2200                     ) >/etc/init.d/${name}
  2201                     chmod 755 /etc/init.d/${name}
  2202                     #   create corresponding symbolic links
  2203                     ( cd /etc
  2204                       ln init.d/${name} rc2.d/S99${name}
  2205                       ln init.d/${name} rc0.d/K00${name}
  2206                       ln init.d/${name} rc1.d/K00${name}
  2207                     ) || exit $?
  2208                 fi
  2209                 ;;
  2210             AIX/* )
  2211                 if [ ! -f /etc/rc.d/init.d/${name} ]; then
  2212                     #   install transfer script
  2213                     ( echo "#!/bin/sh"
  2214                       echo "##"
  2215                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2216                       echo "##"
  2217                       echo ""
  2218                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2219                       echo "case \$1 in"
  2220                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2221                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2222                       echo "esac"
  2223                     ) >/etc/rc.d/init.d/${name}
  2224                     chmod 755 /etc/rc.d/init.d/${name}
  2225                     #   create corresponding symbolic links
  2226                     ( cd /etc/rc.d
  2227                       ln -s ../init.d/${name} rc2.d/S99${name}
  2228                     ) || exit $?
  2229                 fi
  2230                 ;;
  2231             OSF1/V5.* )
  2232                 if [ ! -f /sbin/init.d/${name} ]; then
  2233                     #   install transfer script
  2234                     ( echo "#!/bin/sh"
  2235                       echo "##"
  2236                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2237                       echo "##"
  2238                       echo ""
  2239                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2240                       echo "case \$1 in"
  2241                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2242                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2243                       echo "esac"
  2244                     ) >/sbin/init.d/${name}
  2245                     chmod 755 /sbin/init.d/${name}
  2246                     #   create corresponding symbolic links
  2247                     ( cd /sbin
  2248                       ln -s ../init.d/${name} rc3.d/S99${name}
  2249                       ln -s ../init.d/${name} rc0.d/K00${name}
  2250                     ) || exit $?
  2251                 fi
  2252                 ;;
  2253             HP-UX/* )
  2254                 if [ ! -f /sbin/init.d/${name} ]; then
  2255                     #   install transfer script
  2256                     ( echo "#!/bin/sh"
  2257                       echo "##"
  2258                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2259                       echo "##"
  2260                       echo ""
  2261                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2262                       echo "case \$1 in"
  2263                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2264                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2265                       echo "esac"
  2266                     ) >/sbin/init.d/${name}
  2267                     chmod 755 /sbin/init.d/${name}
  2268                     #   create corresponding symbolic links
  2269                     ( cd /sbin
  2270                       ln -s ../init.d/${name} rc2.d/S900${name}
  2271                       ln -s ../init.d/${name} rc1.d/K100${name}
  2272                     ) || exit $?
  2273                 fi
  2274                 ;;
  2275             Darwin/* )
  2276                 darwin_rc_dir="/System/Library/StartupItems/${name}"
  2277                 if [ ! -d ${darwin_rc_dir} ]; then
  2278                     mkdir ${darwin_rc_dir}
  2279                 fi
  2281                 #   make sure hierarchy is activated in /etc/hostconfig
  2282                 #   FIXME: cs: simple and bad code here without any detection of existing entries
  2283                 echo "OPENPKG_${name}=-YES-" >>/etc/hostconfig
  2285                 #   install transfer script
  2286                 if [ ! -f ${darwin_rc_dir}/${name} ]; then
  2287                     rm -f ${darwin_rc_dir}/${name} >/dev/null 2>&1
  2288                     ( echo "#!/bin/sh"
  2289                       echo "##"
  2290                       echo "##  ${darwin_rc_dir}/${name}"
  2291                       echo "##      -- startup transfer script for OpenPKG ${prefix} hierarchy"
  2292                       echo "##"
  2293                       echo ""
  2294                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2295                       echo ""
  2296                       echo ". /etc/rc.common"
  2297                       echo ""
  2298                       echo "if [ \"\${OPENPKG_${name}:=-NO-}\" = \"-YES-\" ]; then"
  2299                       echo "    ConsoleMessage \"OpenPKG ${prefix} hierarchy\""
  2300                       echo "    ${prefix}/etc/rc all start"
  2301                       echo "fi"
  2302                     ) >${darwin_rc_dir}/${name}
  2303                     chmod 755 ${darwin_rc_dir}/${name}
  2304                 fi
  2305                 #   install startup parameter list
  2306                 if [ ! -f ${darwin_rc_dir}/StartupParameters.plist ]; then
  2307                     rm -f ${darwin_rc_dir}/StartupParameters.plist >/dev/null 2>&1
  2308                     ( echo "{"
  2309                       echo "  Description     = \"OpenPKG ${prefix} hierarchy\";"
  2310                       echo "  Provides        = (\"OpenPKG ${prefix}\");"
  2311                       echo "  Requires        = (\"Disks\", \"Network Configuration\", \"Resolver\");"
  2312                       echo "  Uses            = (\"Cron\");"
  2313                       echo "  OrderPreference = \"Last\";"
  2314                       echo "  Messages ="
  2315                       echo "  {"
  2316                       echo "    start = \"Starting OpenPKG ${prefix} hierarchy\";"
  2317                       echo "    stop  = \"Stopping OpenPKG ${prefix} hierarchy\";"
  2318                       echo "  };"
  2319                       echo "}"
  2320                     ) >${darwin_rc_dir}/StartupParameters.plist
  2321                     chmod 644 ${darwin_rc_dir}/StartupParameters.plist
  2322                 fi
  2323                 ;;
  2324             IRIX*/6.* )
  2325                 if [ ! -f /etc/init.d/${name} ]; then
  2326                     #   install transfer script
  2327                     ( echo "#!/bin/sh"
  2328                       echo "##"
  2329                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2330                       echo "##"
  2331                       echo ""
  2332                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2333                       echo "case \$1 in"
  2334                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2335                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2336                       echo "esac"
  2337                     ) >/etc/init.d/${name}
  2338                     chmod 755 /etc/init.d/${name}
  2339                     #   create corresponding links
  2340                     ( cd /etc
  2341                       ln -f init.d/${name} rc2.d/S99${name}
  2342                       ln -f init.d/${name} rc0.d/K00${name}
  2343                     ) || exit $?
  2344                 fi
  2345                 ;;
  2346         esac
  2347     fi
  2349     #   create the cron transfer entries
  2350     if [ ".$cusr" != ".root" ]; then
  2351         echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2
  2352         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2353     else
  2354         case "$plid" in
  2355             FreeBSD/* | Linux/* | Darwin/* )
  2356                 if [ -f /etc/slackware-version ]; then
  2357                     exists=`crontab -l | grep "$prefix/etc/rc"`
  2358                     if [ ".$exists" = . ]; then
  2359                         EDITOR=/tmp/vipw.$$
  2360                         VISUAL="$EDITOR"
  2361                         export EDITOR
  2362                         export VISUAL
  2363                         ( echo "#!/bin/sh"
  2364                           echo "(   echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  2365                           echo "    echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  2366                           echo "    echo \"0          0  1  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  2367                           echo "    echo \"0          0  *  *  0  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  2368                           echo "    echo \"0          0  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  2369                           echo "    echo \"0          *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  2370                           echo "    echo \"0,15,30,45 *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  2371                           echo "    echo \"# </OpenPKG>\""
  2372                           echo ") >>\$1"
  2373                         ) >$EDITOR
  2374                         chmod a+x $EDITOR
  2375                         ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2376                         rm -f $EDITOR
  2377                     fi
  2378                 else
  2379                     exists=`grep "$prefix/etc/rc" /etc/crontab`
  2380                     if [ ".$exists" = . ]; then
  2381                         ( echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  2382                           echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  2383                           echo "0    0  1  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  2384                           echo "0    0  *  *  0  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  2385                           echo "0    0  *  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  2386                           echo "0    *  *  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  2387                           echo "*/15 *  *  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  2388                           echo "# </OpenPKG>"
  2389                         ) >>/etc/crontab
  2390                     fi
  2391                 fi
  2392                 ;;
  2393             SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* )
  2394                 exists=`crontab -l | grep "$prefix/etc/rc"`
  2395                 if [ ".$exists" = . ]; then
  2396                     EDITOR=/tmp/vipw.$$
  2397                     VISUAL="$EDITOR"
  2398                     export EDITOR
  2399                     export VISUAL
  2400                     ( echo "#!/bin/sh"
  2401                       echo "(   echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  2402                       echo "    echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  2403                       echo "    echo \"0          0  1  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  2404                       echo "    echo \"0          0  *  *  0  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  2405                       echo "    echo \"0          0  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  2406                       echo "    echo \"0          *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  2407                       echo "    echo \"0,15,30,45 *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  2408                       echo "    echo \"# </OpenPKG>\""
  2409                       echo ") >>\$1"
  2410                     ) >$EDITOR
  2411                     chmod a+x $EDITOR
  2412                     ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2413                     rm -f $EDITOR
  2414                 fi
  2415                 ;;
  2416             IRIX*/6.* )
  2417                 exists=`crontab -l | grep "$prefix/etc/rc"`
  2418                 if [ ".$exists" = . ]; then
  2419                     ( crontab -l
  2420                       echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  2421                       echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  2422                       echo "0          0  1  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  2423                       echo "0          0  *  *  0  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  2424                       echo "0          0  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  2425                       echo "0          *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  2426                       echo "0,15,30,45 *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  2427                       echo "# </OpenPKG>"
  2428                     ) | /usr/bin/crontab || exit $?
  2429                 fi
  2430                 ;;
  2431         esac
  2432     fi
  2434     #   remember what OpenPKG RPM version was installed, so we can
  2435     #   correctly upgrade the RPM database in the %post section (see below).
  2436     if [ -d ${prefix}/RPM/DB ]; then
  2437         if [ -x "${prefix}/bin/openpkg" -a -x "${prefix}/libexec/openpkg/rpm" ]; then
  2438             #   OpenPKG 2.0
  2439             rpm="${prefix}/bin/openpkg rpm"
  2440         else
  2441             #   OpenPKG 1.x
  2442             rpm="${prefix}/bin/rpm"
  2443         fi
  2444         rm -f ${prefix}/RPM/DB/.version >/dev/null 2>&1 || true
  2445         $rpm --version |\
  2446             sed -e 's;^;X;' \
  2447                 -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \
  2448                 -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \
  2449                 -e 's;^X.*$;4.0;' \
  2450                 >${prefix}/RPM/DB/.version
  2451     fi
  2453 %post
  2454     #   optional post-processing from "pre" section
  2455     if [ -f %{l_prefix}.pre-post-process.sh ]; then
  2456         sh %{l_prefix}.pre-post-process.sh
  2457         rm -f %{l_prefix}.pre-post-process.sh
  2458     fi
  2460     #   update or initially create OpenPKG UUID configuration
  2461     %{l_prefix}/bin/openpkg uuid update >/dev/null 2>&1 || true
  2463     #   determine new and old OpenPKG RPM version
  2464     V_rpm_new="%{V_rpm}"
  2465     if [ -f %{l_prefix}/RPM/DB/.version ]; then
  2466         V_rpm_old="`cat %{l_prefix}/RPM/DB/.version`"
  2467         rm -f %{l_prefix}/RPM/DB/.version >/dev/null 2>&1 || true
  2468     else
  2469         V_rpm_old="4.0"
  2470     fi
  2472     #   make sure all RPM database files are present and that their
  2473     #   attributes are correct, etc. This is not a database rebuild
  2474     #   operation, so this is fully harmless and can be done always.
  2475     %{l_prefix}/lib/openpkg/rpmdb --quiet --fixate
  2477     #   check RPM database for upgrade requirements
  2478     if [ ".$1" = .2 -a ".$V_rpm_old" != ".$V_rpm_new" ]; then
  2479         #   RPM 4.0/4.1 does not allow concurrent database access, so we
  2480         #   cannot upgrade the database immediately from here (because
  2481         #   we are still running within the execution context of the
  2482         #   old RPM which in turn has the database locked) and instead
  2483         #   have to just drop a note to the administrator about database
  2484         #   upgrading. RPM 4.2 in general allows concurrent database
  2485         #   access, but the whole stuff is too risky here, too.
  2486         ( echo "You are upgrading the OpenPKG bootstrap from a previous"
  2487           echo "RPM $V_rpm_old based version to this RPM $V_rpm_new based"
  2488           echo "version. The RPM database in %{l_prefix}/RPM/DB/ can still"
  2489           echo "be used, but it is strongly recommended to upgrade it as"
  2490           echo "soon as possible to the latest Berkeley-DB format files by"
  2491           echo "executing the command:"
  2492           echo "    \$ %{l_prefix}/bin/openpkg rpm --db-rebuild"
  2493           echo "In case of problems with the RPM database you can always"
  2494           echo "execute the command:"
  2495           echo "    \$ %{l_prefix}/bin/openpkg rpm --db-cleanup"
  2496         ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t warn
  2497     fi
  2499     #   system command overriding support
  2500     #   ATTENTION: THIS BETTER SHOULD BE REPLACED WITH A MORE GENERIC
  2501     #   BUILD COMMAND OVERRIDE SOLUTION!
  2502     if [ ! -d %{l_prefix}/lib/openpkg/override ]; then
  2503         mkdir %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2504     fi
  2505     chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2506     case "`cat %{l_prefix}/etc/openpkg/platform`" in
  2507         *-*-debian* | *-*-ubuntu* )
  2508             #   FIXME: Evil hack to workaround build problems under Debian
  2509             #   (at least 3.1) (and similar platforms) where a Debian
  2510             #   install-info(8) exists which is both API and functionally
  2511             #   incompatible to the de-facto standardized install-info(8)
  2512             #   command from GNU Texinfo.
  2513             if [ ! -f %{l_prefix}/lib/openpkg/override/install-info ]; then
  2514                 ( echo "#!/bin/sh"
  2515                   echo "echo 'OpenPKG: NOTICE: install-info(8) command execution overridden'"
  2516                   echo "exit 0"
  2517                 ) >%{l_prefix}/lib/openpkg/override/install-info
  2518                 chmod 775 %{l_prefix}/lib/openpkg/override/install-info
  2519             fi
  2520             ;;
  2521         *-*-macosx* | *-*-darwin* )
  2522             #   FIXME: Evil hack to workaround the fact that Mac OS X'
  2523             #   linker by default prefers the /usr/lib libraries and does
  2524             #   not honor the -L options the way one would expect it.
  2525             gcc="`%{l_prefix}/lib/openpkg/shtool path gcc`"
  2526             cc="`%{l_prefix}/lib/openpkg/shtool path cc`"
  2527             ld="`%{l_prefix}/lib/openpkg/shtool path ld`"
  2528             if [ ".$gcc" != . -a ! -f %{l_prefix}/lib/openpkg/override/gcc ]; then
  2529                 ( echo "#!/bin/sh"
  2530                   echo "case \" \$* \" in"
  2531                   echo "    *\" -c \"* | *\" -E \"* ) exec $gcc \"\$@\" ;;"
  2532                   echo "    * ) exec $gcc -Wl,-search_paths_first \"\$@\" ;;"
  2533                   echo "esac"
  2534                 ) >%{l_prefix}/lib/openpkg/override/gcc
  2535                 chmod 775 %{l_prefix}/lib/openpkg/override/gcc
  2536             fi
  2537             if [ ".$cc" != . -a ! -f %{l_prefix}/lib/openpkg/override/cc ]; then
  2538                 ( echo "#!/bin/sh"
  2539                   echo "case \" \$* \" in"
  2540                   echo "    *\" -c \"* | *\" -E \"* ) exec $gcc \"\$@\" ;;"
  2541                   echo "    * ) exec $cc -Wl,-search_paths_first \"\$@\" ;;"
  2542                   echo "esac"
  2543                 ) >%{l_prefix}/lib/openpkg/override/cc
  2544                 chmod 775 %{l_prefix}/lib/openpkg/override/cc
  2545             fi
  2546             if [ ".$ld" != . -a ! -f %{l_prefix}/lib/openpkg/override/ld ]; then
  2547                 ( echo "#!/bin/sh"
  2548                   echo "exec $ld -search_paths_first \"\$@\""
  2549                 ) >%{l_prefix}/lib/openpkg/override/ld
  2550                 chmod 775 %{l_prefix}/lib/openpkg/override/ld
  2551             fi
  2552             ;;
  2553     esac
  2555     #   FIXME: hack to workaround problems in environments with too few
  2556     #   development tools. ATTENTION: see one paragraph above.
  2557     if [ ! -d %{l_prefix}/lib/openpkg/fallback ]; then
  2558         mkdir %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2559     fi
  2560     chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2562     #   check for "openpkg" executable from the OpenPKG Community series
  2563     #   print license if not OSS, otherwise register with openpkg.org
  2564     community_version=`%{l_prefix}/bin/openpkg --license 2>/dev/null | \
  2565         sed -e 'q' | egrep '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*-C'`
  2566     if [ ".$community_version" = . ]; then
  2567         ( echo ""
  2568           echo "NOTICE: This OpenPKG bootstrap package is based on an \"openpkg\""
  2569           echo "executable which is covered by the following terms of use:"
  2570           echo "______________________________________________________________________________"
  2571           echo ""
  2572           %{l_prefix}/bin/openpkg --license | sed -e '1d'
  2573         ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t notice
  2574     else
  2575         %{l_prefix}/bin/openpkg register </dev/null >/dev/null 2>&1 || true
  2576     fi
  2578 %preun
  2579     [ ".$1" != .0 ] && exit 0
  2581     #   remove override files
  2582     if [ -d %{l_prefix}/lib/openpkg/override ]; then
  2583         rm -rf %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2584     fi
  2586     #   remove fallback files
  2587     if [ -d %{l_prefix}/lib/openpkg/fallback ]; then
  2588         rm -rf %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2589     fi
  2591     #   remove files which are not RPM controlled
  2592     rm -rf %{l_prefix}/RPM/TMP/* %{l_prefix}/RPM/TMP/.[a-z]* >/dev/null 2>&1 || true
  2593     rm -rf %{l_prefix}/RPM/SRC/* %{l_prefix}/RPM/SRC/.[a-z]* >/dev/null 2>&1 || true
  2594     rm -rf %{l_prefix}/RPM/PKG/* %{l_prefix}/RPM/PKG/.[a-z]* >/dev/null 2>&1 || true
  2595     rm -rf %{l_prefix}/RPM/DB/*  %{l_prefix}/RPM/DB/.[a-z]*  >/dev/null 2>&1 || true
  2597     #   The following code usually would be done in a %postun section.
  2598     #   But because we already had to remove the database in this %preun
  2599     #   section (see the 'rm' commands above) in order to make RPM happy
  2600     #   inside its own removal procedure, RPM would no longer find the
  2601     #   %postun script (because it's recorded in the database files). So
  2602     #   we have to perform the procedure already in this %preun script.
  2603     #   except for the removal of the top-level directory it does not
  2604     #   matter. But the top-level directory can only be removed after
  2605     #   the RPM removal procedure took place, so we play a little delay
  2606     #   trick below.
  2608     #   determine current user
  2609     cusr=`(id -un) 2>/dev/null ||\
  2610           (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  2611           (whoami) 2>/dev/null ||\
  2612           (who am i | cut "-d " -f1) 2>/dev/null ||\
  2613           echo $LOGNAME`
  2615     #   determine runtime details (for both inside and outside RPM!!)
  2616     user="%{l_musr}"
  2617     group="%{l_mgrp}"
  2618     prefix="%{l_prefix}"
  2619     prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  2621     #   determine platform id
  2622     s=`(uname -s) 2>/dev/null` || s='Unknown'
  2623     r=`(uname -r) 2>/dev/null` || r='0.0'
  2624     plid="${s}/${r}"
  2626     #   unregister instance in presence file
  2627     presence="/etc/openpkg"
  2628     exists=`cat $presence 2>/dev/null | egrep "^ *${prefix} *\$"`
  2629     if [ ".$exists" != . ]; then
  2630         if [ ".$cusr" != ".root" ]; then
  2631             echo "openpkg:WARNING: skipping unregistering of $prefix in $presence" 1>&2
  2632             echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2633         else
  2634             cp $presence $presence.bak && \
  2635             egrep -v "^ *${prefix} *\$" $presence.bak >$presence
  2636             rm -f $presence.bak >/dev/null 2>&1
  2637             if [ ".`cat $presence`" = . ]; then
  2638                 rm -f $presence >/dev/null 2>&1
  2639             fi
  2640         fi
  2641     fi
  2643     #   remove entry in /etc/shells
  2644     shell="${prefix}/lib/openpkg/bash"
  2645     exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  2646     if [ ".$exists" != . ]; then
  2647         if [ ".$cusr" != ".root" ]; then
  2648             echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2
  2649             echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2650         else
  2651             cp /etc/shells /etc/shells.bak && \
  2652             grep -v "^${shell}" /etc/shells.bak >/etc/shells
  2653             rm -f /etc/shells.bak >/dev/null 2>&1
  2654         fi
  2655     fi
  2657     #   remove the hierarchy user/group
  2658     for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \
  2659                "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \
  2660                "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \
  2661                "non-privileged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do
  2662         #   split request into class/usr/uid/grp/gid
  2663         OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  2664         class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  2666         #   check whether user already exists
  2667         exists=`(getent passwd "$usr"; \
  2668                  grep "^$usr:" /etc/passwd; \
  2669                  ypmatch "$usr" passwd; \
  2670                  nismatch "$usr" passwd; \
  2671                  nidump passwd . | grep "^$usr:") 2>/dev/null | \
  2672                  sed -e 'q'`
  2673         if [ ".$exists" != . ]; then
  2674             if [ ".$cusr" != ".root" ]; then
  2675                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  2676                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2677             elif [ ".$usr" = ".root" ]; then
  2678                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  2679                 echo "openpkg:WARNING: (would remove system standard user)" 1>&2
  2680             else
  2681                 case "$plid" in
  2682                     FreeBSD/* | NetBSD/* )
  2683                         cp /etc/master.passwd /etc/master.passwd.bak && \
  2684                         grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd
  2685                         ( PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd ) || exit $?
  2686                         rm -f /etc/master.passwd.bak >/dev/null 2>&1
  2687                         ;;
  2688                     Linux/* | SunOS/5.* | UnixWare/* )
  2689                         cp /etc/passwd /etc/passwd.bak && \
  2690                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2691                         ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $?
  2692                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2693                         ;;
  2694                     AIX/* )
  2695                         rmuser -p "${usr}"
  2696                         cp /etc/security/login.cfg /etc/security/login.cfg.bak && \
  2697                         sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\),$shell\\(.*\\)\$;\\1\\2;" \
  2698                             </etc/security/login.cfg.bak >/etc/security/login.cfg && \
  2699                         rm -f /etc/security/login.cfg.bak >/dev/null 2>&1
  2700                         ;;
  2701                     OSF1/V5.* )
  2702                         cp /etc/passwd /etc/passwd.bak && \
  2703                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2704                         ( PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd ) || exit $?
  2705                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2706                         ;;
  2707                     HP-UX/* )
  2708                         cp /etc/passwd /etc/passwd.bak && \
  2709                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2710                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2711                         ;;
  2712                     Darwin/* )
  2713                         niutil -destroy . "/users/${usr}"
  2714                         ;;
  2715                     IRIX*/6.* )
  2716                         cp /etc/passwd /etc/passwd.bak && \
  2717                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2718                         if   [ -f /etc/shadow ]
  2719                         then ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $?
  2720                         fi
  2721                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2722                         ;;
  2723                 esac
  2724             fi
  2725         fi
  2727         #   check whether group already exists
  2728         exists=`(getent group "$grp"; \
  2729                 grep "^$grp:" /etc/group; \
  2730                 ypmatch "$grp" group; \
  2731                 nismatch "$grp" group; \
  2732                 nidump group . | grep "^$grp:") 2>/dev/null | \
  2733                 sed -e 'q'`
  2734         if [ ".$exists" != . ]; then
  2735             if [ ".$cusr" != ".root" ]; then
  2736                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  2737                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2738             elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then
  2739                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  2740                 echo "openpkg:WARNING: (would remove system standard group)" 1>&2
  2741             else
  2742                 case "$plid" in
  2743                     Darwin/* )
  2744                         niutil -destroy . "/groups/${grp}"
  2745                         ;;
  2746                     AIX/* )
  2747                         rmgroup "${grp}"
  2748                         ;;
  2749                     * )
  2750                         cp /etc/group /etc/group.bak && \
  2751                         grep -v "^${grp}:" /etc/group.bak >/etc/group
  2752                         rm -f /etc/group.bak >/dev/null 2>&1
  2753                         ;;
  2754                 esac
  2755             fi
  2756         fi
  2757     done
  2759     #   invalidate passwd and group tables from Name Service Cache Daemon to
  2760     #   ensure chown/chgrp works immediately after pwconv on Linux and Solaris
  2761     if [ -x /usr/sbin/nscd ]; then
  2762         /usr/sbin/nscd -i passwd >/dev/null 2>&1 || true
  2763         /usr/sbin/nscd -i group >/dev/null 2>&1 || true
  2764     fi
  2766     #   remove the startup/shutdown transfer scripts
  2767     name=`echo "$prefix" | sed -e 's;/;;g'`
  2768     if [ ".$cusr" != ".root" ]; then
  2769         echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2
  2770         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2771     else
  2772         case "$plid" in
  2773             FreeBSD/* )
  2774                 rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1
  2775                 ;;
  2776             NetBSD/* )
  2777                 rm -f /etc/rc.d/${name} >/dev/null 2>&1
  2778                 ;;
  2779             Linux/* )
  2780                 if [ -f /etc/gentoo-release ]; then
  2781                     /sbin/rc-update del openpkg-${name} >/dev/null 2>&1
  2782                     rm -f /etc/init.d/openpkg-${name}   >/dev/null 2>&1
  2783                 else
  2784                     #   sroot: script root directory
  2785                     #   lroot: link   root directory
  2786                     if [ -f /etc/debian_version ]; then
  2787                         sroot=/etc/init.d
  2788                         lroot=/etc/rc%d.d
  2789                     elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  2790                         sroot=/etc/rc.d/init.d
  2791                         lroot=/etc/rc.d/rc%d.d
  2792                     elif [ -f /etc/SuSE-release ]; then
  2793                         sroot=/etc/init.d
  2794                         lroot=/etc/init.d/rc%d.d
  2795                     elif [ -f /etc/slackware-version ]; then
  2796                         sroot=/etc/rc.d
  2797                         lroot=/etc/rc.d/rc%d.d
  2798                         name="rc.${name}"
  2799                     else
  2800                         echo "WARNING: you are not running one of the supported standard" 1>&2
  2801                         echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)."   1>&2
  2802                         echo "WARNING: Guessing the location of the system init scripts!" 1>&2
  2803                         sroot=""
  2804                         lroot=""
  2805                         for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  2806                             if [ -d $sr ]; then
  2807                                 sroot="$sr"
  2808                                 break
  2809                             fi
  2810                         done
  2811                         for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  2812                             if [ -d $lr ]; then
  2813                                 lroot="`echo $lr | sed -e 's;2;%d;'`"
  2814                                 break
  2815                             fi
  2816                         done
  2817                         if [ ".$sroot" = . -o ".$lroot" = . ]; then
  2818                             echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  2819                             exit 1
  2820                         fi
  2821                     fi
  2822                     rm -f ${sroot}/${name} >/dev/null 2>&1
  2823                     for i in 2 3 4 5; do
  2824                         rm -f `echo $lroot | sed -e "s;%d;$i;"`/S99${name} >/dev/null 2>&1
  2825                     done
  2826                     for i in 0 1 6; do
  2827                         rm -f `echo $lroot | sed -e "s;%d;$i;"`/K00${name} >/dev/null 2>&1
  2828                     done
  2829                     if [ -f /etc/slackware-version ]; then
  2830                         for i in 0 1 2 3 4 5 6; do
  2831                             l=`echo $lroot | sed -e "s;%d;$i;"`
  2832                             if [ -d $l ]; then
  2833                                 rmdir $l >/dev/null 2>&1 || true
  2834                             fi
  2835                         done
  2836                     fi
  2837                 fi
  2838                 ;;
  2839             SunOS/5.1* )
  2840                 /usr/sbin/svcadm disable "svc:/openpkg/${name}:default"; sleep 2
  2841                 /usr/sbin/svccfg delete -f "svc:/openpkg/${name}:default" >/dev/null 2>&1 || true
  2842                 rm -f /var/svc/manifest/openpkg/${name}.xml >/dev/null 2>&1
  2843                 rmdir /var/svc/manifest/openpkg >/dev/null 2>&1 || true
  2844                 ;;
  2845             SunOS/5.* )
  2846                 rm -f /etc/init.d/${name} >/dev/null 2>&1
  2847                 rm -f /etc/rc3.d/S99${name} >/dev/null 2>&1
  2848                 rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2849                 rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  2850                 ;;
  2851             UnixWare/* )
  2852                 rm -f /etc/init.d/${name} >/dev/null 2>&1
  2853                 rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1
  2854                 rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2855                 rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  2856                 ;;
  2857             AIX/* )
  2858                 rm -f /etc/rc.d/init.d/${name} >/dev/null 2>&1
  2859                 rm -f /etc/rc.d/rc2.d/S99${name} >/dev/null 2>&1
  2860                 ;;
  2861             OSF1/V5.* )
  2862                 rm -f /sbin/init.d/${name} >/dev/null 2>&1
  2863                 rm -f /sbin/rc3.d/S99${name} >/dev/null 2>&1
  2864                 rm -f /sbin/rc0.d/K00${name} >/dev/null 2>&1
  2865                 ;;
  2866             HP-UX/* )
  2867                 rm -f /sbin/init.d/${name} >/dev/null 2>&1
  2868                 rm -f /etc/rc2.d/S900${name} >/dev/null 2>&1
  2869                 rm -f /etc/rc1.d/K100${name} >/dev/null 2>&1
  2870                 ;;
  2871             Darwin/* )
  2872                 cp /etc/hostconfig /etc/hostconfig.bak && \
  2873                 grep -v "^OPENPKG_${name}=" /etc/hostconfig.bak >/etc/hostconfig
  2874                 rm -f /etc/hostconfig.bak >/dev/null 2>&1
  2875                 rm -rf /System/Library/StartupItems/${name} >/dev/null 2>&1
  2876                 ;;
  2877             IRIX*/6.* )
  2878                 rm -f /etc/init.d/${name} >/dev/null 2>&1
  2879                 rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1
  2880                 rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2881                 ;;
  2882         esac
  2883     fi
  2885     #   remove the cron transfer entries
  2886     if [ ".$cusr" != ".root" ]; then
  2887         echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2
  2888         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2889     else
  2890         case "$plid" in
  2891             FreeBSD/* | Linux/* | Darwin/* )
  2892                 if [ -f /etc/slackware-version ]; then
  2893                     EDITOR=/tmp/vipw.$$
  2894                     VISUAL="$EDITOR"
  2895                     export EDITOR
  2896                     export VISUAL
  2897                     p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  2898                     ( echo "cp \$1 \$1.bak"
  2899                       echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  2900                       echo "rm -f \$1.bak"
  2901                     ) >$EDITOR
  2902                     chmod a+x $EDITOR
  2903                     ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2904                     rm -f $EDITOR
  2905                 else
  2906                     exists=`grep "<OpenPKG prefix=$prefix pkg=openpkg>" /etc/crontab`
  2907                     if [ ".$exists" != . ]; then
  2908                         p=`echo $prefix | sed -e 's;/;\\\\/;g'`
  2909                         cp /etc/crontab /etc/crontab.bak
  2910                         cat /etc/crontab.bak |\
  2911                         sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\\/OpenPKG>/d" \
  2912                         >/etc/crontab
  2913                         rm -f /etc/crontab.bak >/dev/null 2>&1
  2914                     fi
  2915                 fi
  2916                 ;;
  2917             SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* )
  2918                 EDITOR=/tmp/vipw.$$
  2919                 VISUAL="$EDITOR"
  2920                 export EDITOR
  2921                 export VISUAL
  2922                 p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  2923                 ( echo "cp \$1 \$1.bak"
  2924                   echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  2925                   echo "rm -f \$1.bak"
  2926                 ) >$EDITOR
  2927                 chmod a+x $EDITOR
  2928                 ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2929                 rm -f $EDITOR
  2930                 ;;
  2931             IRIX*/6.* )
  2932                 p=`echo $prefix | sed -e 's;/;\\\\\\/;g'`
  2933                 ( crontab -l |
  2934                   sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\/OpenPKG>/d"
  2935                 ) | /usr/bin/crontab || exit $?
  2936                 ;;
  2937         esac
  2938     fi
  2940     #   delayed removal of top-level directory.
  2941     ( sleep 2
  2942       rm -rf %{l_prefix}/RPM/DB/* %{l_prefix}/RPM/DB/.[a-z]* >/dev/null 2>&1 || true
  2943       rmdir %{l_prefix}/RPM/DB >/dev/null 2>&1 || true
  2944       rmdir %{l_prefix}/RPM >/dev/null 2>&1 || true
  2945       rmdir %{l_prefix} >/dev/null 2>&1 || true
  2946     ) </dev/null >/dev/null 2>/dev/null &

mercurial