openpkg/openpkg.spec

Tue, 06 Jan 2009 23:46:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2009 23:46:19 +0100
changeset 17
dabc4f22486f
parent 13
cb59d6afeb61
child 250
bda4f5eec616
permissions
-rw-r--r--

Rewrite out of scope identifiers and remove IPv6 to correct build.

     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  20090106
    44 #   the used software versions
    45 %define       V_rpm      4.2.1
    46 %define       V_zlib     1.2.3
    47 %define       V_bzip2    1.0.4
    48 %define       V_beecrypt 4.1.2
    49 %define       V_curl     7.17.1
    50 %define       V_make     3.81
    51 %define       V_gzip     1.3.12
    52 %define       V_gzip_r   1.13
    53 %define       V_patch    2.5.9
    54 %define       V_tar      1.19
    55 %define       V_bash     3.2
    56 %define       V_uuid     1.6.0
    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://alpha.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.openpkg.org/sources/CPY/openpkg/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       sh $shtool subst -e 's/futimens/gzip_&/' gzip.c lib/utimens.[ch]
   531       CC="${l_cc}" \
   532       GREP="grep" \
   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       chmod u+w config.guess config.sub >/dev/null 2>&1 || true
   554       cp ../config/config.guess .
   555       cp ../config/config.sub   .
   556       ( echo 'ac_cv_func_setmode=${ac_cv_func_setmode=no}'
   557         echo 'ac_cv_prog_cc_g=no'
   558         false=`sh $shtool path false`
   559         echo "ac_cv_path_ed_PROGRAM=\${ac_cv_path_ed_PROGRAM=$false}"
   560       ) >config.cache
   561       CC="${l_cc}" \
   562       ./configure \
   563           --cache-file=./config.cache \
   564           --disable-largefile
   565       ${l_make} || exit $?
   566       ( mv patch ..; ${l_make} clean || true; mv ../patch . ) || exit $?
   567     ) || exit $?
   568     l_patch="`pwd`/patch-%{V_patch}/patch"; export l_patch
   569     echo "l_patch=\"$l_patch\"; export l_patch" >>.buildenv
   571     #   display verbosity header
   572     set +x; VERBOSE "BUILD: Build GNU tar (Archiving Tool)"; set -x
   574     #   build GNU tar tool
   575     ${l_gzip} -dc `SOURCE tar-%{V_tar}.tar.gz` | ${l_tar} xf - 2>/dev/null || true
   576     ( cd tar-%{V_tar}
   577       ${l_patch} -p0 <`SOURCE tar.patch`
   578       ( echo 'am_cv_func_iconv=no'
   579         echo 'am_cv_lib_iconv=no'
   580         echo 'ac_cv_lib_iconv_iconv=no'
   581         echo 'ac_cv_header_iconv_h=no'
   582         echo 'ac_cv_type_iconv_t=no'
   583       ) >config.cache
   584       CC="${l_cc}" \
   585       MAKEINFO="true" \
   586       GREP="grep" \
   587       ./configure \
   588           --cache-file=./config.cache \
   589           --prefix=%{l_prefix} \
   590           --disable-nls
   591       ${l_make} || exit $?
   592       ( mv src/tar ..; ${l_make} clean || true; mv ../tar . ) || exit $?
   593     ) || exit $?
   594     l_tar="`pwd`/tar-%{V_tar}/tar"; export l_tar
   595     echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv
   597     #   display verbosity header
   598     set +x; VERBOSE "PREPARATION: Unpack Distribution Tarballs"; set -x
   600     #   unpack distribution tarballs
   601     ${l_gzip} -dc `SOURCE rpm-%{V_rpm}.tar.gz`                        | ${l_tar} xf - 2>/dev/null || true
   602     ${l_gzip} -dc `SOURCE zlib-%{V_zlib}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   603     ${l_gzip} -dc `SOURCE bzip2-%{V_bzip2}.tar.gz`                    | ${l_tar} xf - 2>/dev/null || true
   604     ${l_gzip} -dc `SOURCE curl-%{V_curl}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   605     ${l_gzip} -dc `SOURCE make-%{V_make}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   606     ${l_gzip} -dc `SOURCE bash-%{V_bash}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   607     ${l_gzip} -dc `SOURCE uuid-%{V_uuid}.tar.gz`                      | ${l_tar} xf - 2>/dev/null || true
   608     ${l_gzip} -dc `SOURCE beecrypt-%{V_beecrypt}.tar.gz`              | ${l_tar} xf - 2>/dev/null || true
   609     ${l_gzip} -dc `SOURCE openpkg-registry-%{V_registry}.tar.gz`      | ${l_tar} xf - 2>/dev/null || true
   610     ${l_gzip} -dc `SOURCE perl-%{V_perl}-mini.tar.gz`                 | ${l_tar} xf - 2>/dev/null || true
   611     ${l_gzip} -dc `SOURCE openssl-%{V_openssl}.tar.gz`                | ${l_tar} xf - 2>/dev/null || true
   612     ${l_gzip} -dc `SOURCE openpkg-tools-%{V_tools}.tar.gz`            | ${l_tar} xf - 2>/dev/null || true
   613     ${l_gzip} -dc `SOURCE openpkg-executable-%{V_exec}.tar.gz`        | ${l_tar} xf - 2>/dev/null || true
   615     #   update config.guess/config.sub
   616     for dir in rpm-%{V_rpm} rpm-%{V_rpm}/popt beecrypt-%{V_beecrypt} \
   617                curl-%{V_curl} make-%{V_make} bash-%{V_bash}/support; do
   618         chmod u+w $dir/config.guess $dir/config.sub >/dev/null 2>&1 || true
   619         cp config/config.guess $dir/
   620         cp config/config.sub   $dir/
   621     done
   623     #   display verbosity header
   624     set +x; VERBOSE "PREPARATION: Apply OpenPKG Patches to Distributions"; set -x
   626     #   apply OpenPKG patches to distribution trees
   627     ( cd rpm-%{V_rpm}
   628       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.bugfix`  | ${l_patch} -p0
   629       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.feature` | ${l_patch} -p0
   630       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.porting` | ${l_patch} -p0
   631       sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.regen`   | ${l_patch} -p0
   632       rm -rf db/docs # just reduce disk size of source tree
   633     ) || exit $?
   634     ( cd make-%{V_make}
   635       ${l_patch} -p0 <`SOURCE make.patch`
   636     ) || exit $?
   637     ( cd bash-%{V_bash}
   638       ${l_patch} -p0 <`SOURCE bash.patch`
   639       sleep 1
   640       touch y.tab.[ch]
   641       touch configure config.h.in
   642     ) || exit $?
   643     ( cd beecrypt-%{V_beecrypt}
   644       ${l_patch} -p0 <`SOURCE beecrypt.patch`
   645     ) || exit $?
   646     ( cd perl-%{V_perl}
   647       ${l_patch} -p0 <`SOURCE perl.patch`
   648     ) || exit $?
   649     ( cd openssl-%{V_openssl}
   650       ${l_patch} -p0 <`SOURCE openssl.patch`
   651     ) || exit $?
   653     #   display verbosity header
   654     set +x; VERBOSE "PREPARATION: Build GNU make (Build Tool)"; set -x
   656     #   bootstrap GNU make tool
   657     ( cd make-%{V_make}
   658       CC="${l_cc}" \
   659       ./configure \
   660           --without-libiconv-prefix \
   661           --without-libintl-prefix \
   662           --disable-nls \
   663           --disable-largefile
   664       ${l_make}
   665       ( mv make ..; ${l_make} clean || true; mv ../make . ) || exit $?
   666     ) || exit $?
   667     l_make="`pwd`/make-%{V_make}/make"; export l_make
   668     echo "l_make=\"$l_make\"; export l_make" >>.buildenv
   670 %build
   671     #   skip in bootstrap phase 2 (see openpkg.boot)
   672     [ ".$OPENPKG_BOOT" = .1 ] && exit 0
   674     #   switch into a temporary build area
   675     cd openpkg-%{version}
   676     . ./.buildenv
   678     #   display verbosity header
   679     set +x; VERBOSE "BUILD: Build GNU bash (Bourne-Again Shell)"; set -x
   681     #   build GNU bash tool
   682     ( cd bash-%{V_bash}
   683       sh $shtool subst \
   684           -e 's;@l_openpkg_release@;OpenPKG;' \
   685           version.c
   686       ( #   force disabled wide-character support
   687         echo "ac_cv_header_wchar_h=no"
   688         echo "ac_cv_header_wctype_h=no"
   689         echo "ac_cv_func_mbsrtowcs=no"
   690         #   force disabled internationalization support
   691         echo "ac_cv_header_libintl_h=no"
   692         echo "ac_cv_func_gettext=no"
   693         echo "ac_cv_func_textdomain=no"
   694         echo "ac_cv_func_bindtextdomain=no"
   695         echo "ac_cv_lib_intl_bindtextdomain=no"
   696         #   disable building with debug symbols
   697         echo "ac_cv_prog_cc_g=no"
   698       ) >config.cache
   699       AUTOCONF="true" \
   700       CC="${l_cc}"
   701       ./configure \
   702           --cache-file=./config.cache \
   703           --prefix=%{l_prefix} \
   704           --without-curses \
   705           --without-gnu-malloc \
   706           --disable-nls
   707       ${l_make} || exit $?
   708       ( mv bash ..; ${l_make} clean || true; mv ../bash . ) || exit $?
   709     ) || exit $?
   711     #   display verbosity header
   712     set +x; VERBOSE "BUILD: Build GNU bzip2 (Compression Library)"; set -x
   714     #   build BZIP2 library
   715     ( cd bzip2-%{V_bzip2}
   716       ${l_make} CC="${l_cc}" CFLAGS="-O" libbz2.a bzip2 || exit $?
   717       ( echo "# libbz2.la - a libtool library file"
   718         echo "# Generated by ltmain.sh - GNU libtool x.x.x"
   719         echo "dlname=''"
   720         echo "library_names=''"
   721         echo "old_library='libbz2.a'"
   722         echo "dependency_libs=''"
   723         echo "current=0"
   724         echo "age=0"
   725         echo "revision=0"
   726         echo "installed=no"
   727         echo "dlopen=''"
   728         echo "dlpreopen=''"
   729         echo "libdir='%{l_prefix}'"
   730       ) >libbz2.la
   731       ln -s . .libs
   732     ) || exit $?
   734     #   display verbosity header
   735     set +x; VERBOSE "BUILD: Build Zlib (Compression Library)"; set -x
   737     #   build ZLIB library
   738     ( cd zlib-%{V_zlib}
   739       CC="${l_cc}" CFLAGS="-O" ./configure
   740       ${l_make} CC="${l_cc}" libz.a || exit $? # intentionally do not pass CFLAGS here
   741     ) || exit $?
   743     #   display verbosity header
   744     set +x; VERBOSE "BUILD: Build OSSP uuid (UUID Generation Tool)"; set -x
   746     #   build OSSP uuid tool
   747     ( cd uuid-%{V_uuid}
   748       CC="${l_cc}" \
   749       CFLAGS="-O" \
   750       GREP="grep" \
   751       ./configure \
   752         --prefix=%{l_prefix} \
   753         --disable-shared
   754       ${l_make} || exit $?
   755       ( mv uuid ..; ${l_make} clean || true; mv ../uuid . ) || exit $?
   756     ) || exit $?
   758     #   display verbosity header
   759     set +x; VERBOSE "BUILD: Build Perl (Programming Language)"; set -x
   761     #   build Perl tool
   762     ( cd perl-%{V_perl}
   763       chmod -R u+w .
   764       sh $shtool subst \
   765           -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;' \
   766           -e 's;package=perl5;package=perl;' \
   767           Configure
   768       sh $shtool subst \
   769           -e 's; */usr/local/lib;;' \
   770           hints/freebsd.sh hints/netbsd.sh
   771       libdirs=""
   772       for dir in %{l_prefix}/lib /lib64 /usr/lib64 /lib /usr/lib /usr/ccs/lib; do
   773           [ -d $dir ] && libdirs="$libdirs $dir"
   774       done
   775       ./Configure \
   776           -d -e -s \
   777           -Dprefix=%{l_prefix} \
   778           -Dvendorprefix=%{l_prefix} \
   779           -Dinstallprefix=%{l_prefix} \
   780           -Dinstallstyle="lib/perl5" \
   781           -Dman1dir=%{l_prefix}/man/man1 \
   782           -Dman3dir=%{l_prefix}/man/man3 \
   783           -Dcc="${l_cc}" -Uoptimize \
   784           -Dlocincpth="%{l_prefix}/include" \
   785           -Dloclibpth="%{l_prefix}/lib" \
   786           -Dldflags="-L""%{l_prefix}/lib" \
   787           -Dlibpth="$libdirs" \
   788           -Dglibpth="$libdirs" \
   789           -Dscriptdir="%{l_prefix}/bin" \
   790           -Uinstallusrbinperl \
   791           -Adefine:useshrplib='false' \
   792           -Ui_malloc -Ui_iconv -Ui_db
   793       ${l_make} miniperl || exit $?
   794       rm -f *.o >/dev/null 2>&1 || true
   795     ) || exit $?
   796     l_perl="`pwd`/perl-%{V_perl}/miniperl"; export l_perl
   797     echo "l_perl=\"$l_perl\"; export l_perl" >>.buildenv
   799     #   display verbosity header
   800     set +x; VERBOSE "BUILD: Build OpenSSL (Crypography and SSL/TLS Toolkit)"; set -x
   802     #   build OpenSSL toolkit
   803     ( cd openssl-%{V_openssl}
   804       sh $shtool subst \
   805           -e 's;-m486;-march=i486;g' \
   806           -e 's;BN_LLONG *;;' \
   807           Configure
   808       sh $shtool subst \
   809           -e 's;test "$OSTYPE" = msdosdjgpp;true;' \
   810           util/point.sh
   811       sh $shtool subst \
   812           -e "1s;^.*\$;#!$l_perl;" \
   813           Configure `find . -name "*.pl" -print`
   814       opts=""
   815       case `sh $shtool platform -n -L -S "" -C "+" -F "%<ap>-%<sp>"` in
   816           *-solaris*       ) opts="-lnsl -lsocket" ;;
   817       esac
   818       case `sh $shtool platform -n -L -S "" -C "+" -F "%<ap>-%<sp>"` in
   819           amd64-*          ) opts="$opts -fPIC" ;;
   820           ia64-*           ) opts="$opts -fPIC" ;;
   821           sparc64-freebsd* ) opts="$opts -fPIC" ;;
   822       esac
   823       CC="${l_cc}" \
   824       PERL="${l_perl}" \
   825       ./config \
   826           --prefix=%{l_prefix} \
   827           no-asm no-shared no-dso \
   828           no-zlib no-idea no-threads no-krb5 no-hw \
   829           $opts
   830       ${l_make} CC="${l_cc}" build_libs build_apps || exit $?
   831       ( mkdir lib; cd lib; ln -s ../lib*.a . ) || exit $?
   832     ) || exit $?
   834     #   display verbosity header
   835     set +x; VERBOSE "BUILD: Build cURL (URL Fetching Tool)"; set -x
   837     #   build cURL tool
   838     ( cd curl-%{V_curl}
   839       sh $shtool subst \
   840           -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
   841           configure
   842       ( echo 'ac_cv_header_openssl_engine_h=no'
   843         echo 'lt_cv_prog_compiler_c_o_F77=no'
   844         echo 'lt_cv_sys_max_cmd_len=100'
   845       ) >config.cache
   846       CC="${l_cc}" \
   847       CFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
   848       CPPFLAGS="-I`pwd`/../zlib-%{V_zlib}" \
   849       LDFLAGS="-L`pwd`/../zlib-%{V_zlib}" \
   850       GREP="grep" \
   851       ./configure \
   852           --cache-file=./config.cache \
   853           --without-libidn \
   854           --disable-shared \
   855           --disable-thread \
   856           --disable-ipv6 \
   857           --disable-ldap \
   858           --with-zlib=`pwd`/../zlib-%{V_zlib} \
   859           --with-ssl=`pwd`/../openssl-%{V_openssl} \
   860           --with-ca-bundle=%{l_prefix}/etc/openpkg/openpkg.x509
   861       ${l_make} || exit $?
   862       ( mv src/curl ..; ${l_make} clean || true; mv ../curl ./src ) || exit $?
   863     ) || exit $?
   865     #   display verbosity header
   866     set +x; VERBOSE "BUILD: Build BeeCrypt (Cryptography Library)"; set -x
   868     #   build BeeCrypt library
   869     ( cd beecrypt-%{V_beecrypt}
   870       sh $shtool subst \
   871           -e 's;^[ 	][ 	]*#;#;' \
   872           aes.c base64.c blowfish.c entropy.c fips186.c fips186.h md5.c \
   873           md5.h mp.c mtprng.c mtprng.h sha1.c sha1.h sha256.c sha256.h timestamp.c
   874       sh $shtool subst \
   875          -e 's;cppglue\.lo;;g' \
   876          -e 's;cppglue\.cxx;;g' \
   877          -e '/^CXX = /s;@CXX@;@CC@;g' \
   878          Makefile.in
   879       sh $shtool subst \
   880           -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \
   881           configure
   882       ( echo 'ac_cv_have_dev_dsp=no'
   883         echo 'ac_cv_have_dev_audio=no'
   884         echo 'ac_cv_func_gettimeofday=yes'
   885         echo 'bc_cv_as_noexecstack=no'
   886       ) >config.cache
   887       CC="${l_cc}" \
   888       CFLAGS="-O" \
   889       ./configure \
   890         --cache-file=./config.cache \
   891         --prefix=%{l_prefix} \
   892         --without-cplusplus \
   893         --without-java \
   894         --without-python \
   895         --with-cpu=none \
   896         --with-arch=none \
   897         --disable-threads \
   898         --disable-shared
   899       ${l_make} || exit $?
   900       cp .libs/libbeecrypt.a .
   901     ) || exit $?
   903     #   display verbosity header
   904     set +x; VERBOSE "BUILD: Build RPM (RPM Package Manager)"; set -x
   906     #   build RPM
   907     ( br=`pwd`
   908       cd rpm-%{V_rpm}
   910       #   remove object files accidentally distributed with the RPM tarball
   911       rm -f db/build_unix/*.o
   912       rm -f db/build_unix/*.lo
   914       #   remove embedded zlib (we are linking with an external one)
   915       rm -rf zlib
   917       #   kill Linux-based preconfigured DB header, to allow the Makefiles to
   918       #   symlink to it the header that is configured for the current system.
   919       rm -f rpmdb/db.h
   921       #   make sure we do not trigger Autoconf/Automake tools
   922       touch configure
   923       touch config.h.in
   925       #   disable running of any Autoconf/Automake tools
   926       ACLOCAL=true
   927       AUTOCONF=true
   928       AUTOMAKE=true
   929       AUTOHEADER=true
   930       MAKEINFO=true
   931       AMTAR=true
   932       export ACLOCAL AUTOMAKE AUTOHEADER MAKEINFO AMTAR
   934       #   cheat GNU Autoconf
   935       ( echo 'ac_cv_path_MSGFMT=:'
   936         echo 'ac_cv_path_GMSGFMT=:'
   937         echo 'ac_cv_path_XGETTEXT=:'
   938         echo 'ac_cv_path_MSGMERGE=:'
   939         echo "ac_cv_path_MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'"
   940         echo "ac_cv_path___MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'"
   941         echo "ac_cv_path___PYTHON=true"
   942         echo "ac_cv_path___DOXYGEN=true"
   943         echo "acl_cv_rpath=no"
   944         echo "ac_cv_header_getopt_h=no"
   945       ) >config.cache
   947       #   provide platform identification
   948       os_name=`(uname -s) 2>/dev/null` || os_name='Unknown'
   949       os_name=`echo "${os_name}" |\
   950                sed -e 's;[^a-zA-Z0-9];;g' |\
   951                tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
   953       #   set build tool flags
   954       CC="${l_cc}"
   955       CPPFLAGS="-DOPENPKG -DOPENPKG_${os_name} -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2} -I$br/beecrypt-%{V_beecrypt}"
   956       CFLAGS="$CPPFLAGS"
   957       LDFLAGS="-L$br/zlib-%{V_zlib} -L$br/bzip2-%{V_bzip2} -L$br/beecrypt-%{V_beecrypt}"
   958       LIBS="$LDFLAGS -lz -lbz2 -lbeecrypt"
   959       case $os_name in
   960            SUNOS* ) LIBS="$LIBS -lresolv" ;;
   961            IRIX*  ) LIBS="$LIBS -lgen" ;;
   962       esac
   963       export CC CPPFLAGS CFLAGS LDFLAGS LIBS
   965       #   adjust for BeeCrypt 4.0
   966       sh $shtool subst \
   967           -e 's;beecrypt\.api\.h;beecrypt.h;g' \
   968           rpmio/rpmio_internal.h
   969       sh $shtool subst \
   970           -e 's;\(rsavrfy(\)\(&dig->rsa_pk\);\1\2.n, \2.e;g' \
   971           lib/signature.c
   973       #   configure the package
   974       sh ./configure \
   975           --cache-file=./config.cache \
   976           --prefix=%{l_prefix} \
   977           --with-db \
   978           --with-glob \
   979           --without-python \
   980           --without-apidocs \
   981           --disable-shared \
   982           --disable-rpath \
   983           --disable-nls
   985       #   build the package
   986       ${l_make}
   987     ) || exit $?
   989     #   display verbosity header
   990     set +x; VERBOSE "BUILD: Build OpenPKG Frontend (Set-UID Wrapper)"; set -x
   992     #   build "openpkg" executable
   993     ( cd openpkg-executable-%{V_exec}
   994       ${l_make} \
   995           CC="${l_cc}" \
   996           OPENPKG_PREFIX="%{l_prefix}" \
   997           OPENPKG_SUSR="%{l_susr}" \
   998           OPENPKG_MUSR="%{l_musr}"
   999     ) || exit $?
  1001 %install
  1002     #   skip in bootstrap phase 2 (see openpkg.boot)
  1003     [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  1005     #   switch into a temporary build area
  1006     cd openpkg-%{version}
  1007     . ./.buildenv
  1009     #   display verbosity header
  1010     set +x; VERBOSE "INSTALL: Create Installation Filesystem Hierarchy"; set -x
  1012     #   create installation hierarchy
  1013     rm -rf $RPM_BUILD_ROOT
  1014     sh $shtool mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix}
  1015     for dir in bin etc include info lib libexec man sbin share var cgi pub local; do
  1016         test -d $RPM_BUILD_ROOT%{l_prefix}/$dir || \
  1017         mkdir $RPM_BUILD_ROOT%{l_prefix}/$dir
  1018     done
  1019     for i in 1 2 3 4 5 6 7 8 9; do
  1020         test -d $RPM_BUILD_ROOT%{l_prefix}/man/man$i || \
  1021         mkdir $RPM_BUILD_ROOT%{l_prefix}/man/man$i
  1022         test -d $RPM_BUILD_ROOT%{l_prefix}/man/cat$i || \
  1023         mkdir $RPM_BUILD_ROOT%{l_prefix}/man/cat$i
  1024     done
  1025     for dir in PKG bin etc include info lib man sbin; do
  1026         test -d $RPM_BUILD_ROOT%{l_prefix}/local/$dir || \
  1027         mkdir $RPM_BUILD_ROOT%{l_prefix}/local/$dir
  1028     done
  1029     for i in 1 2 3 4 5 6 7 8 9; do
  1030         test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i || \
  1031         mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i
  1032         test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i || \
  1033         mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i
  1034     done
  1035     test -d $RPM_BUILD_ROOT%{l_prefix}/RPM || \
  1036     mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM
  1037     for dir in SRC PKG DB TMP; do
  1038         test -d $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir || \
  1039         mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir
  1040     done
  1041     mkdir $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg
  1042     mkdir $RPM_BUILD_ROOT%{l_prefix}/include/openpkg
  1044     #   display verbosity header
  1045     set +x; VERBOSE "INSTALL: Installation of RPM"; set -x
  1047     #   install RPM into installation hierarchy
  1048     ( cd rpm-%{V_rpm}
  1049       DESTDIR="$RPM_BUILD_ROOT"
  1050       export DESTDIR
  1051       ${l_make} install
  1052     ) || exit $?
  1054     #   display verbosity header
  1055     set +x; VERBOSE "INSTALL: Install Additional Files"; set -x
  1057     #   add additional development files
  1058     cp rpm-%{V_rpm}/misc/glob.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1059     cp zlib-%{V_zlib}/zlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1060     cp zlib-%{V_zlib}/zconf.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1061     cp zlib-%{V_zlib}/libz.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmz.a
  1062     cp bzip2-%{V_bzip2}/bzlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1063     cp bzip2-%{V_bzip2}/libbz2.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbz2.a
  1064     cp beecrypt-%{V_beecrypt}/beecrypt.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/
  1065     cp beecrypt-%{V_beecrypt}/libbeecrypt.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbeecrypt.a
  1067     #   display verbosity header
  1068     set +x; VERBOSE "INSTALL: Post-Adjust Installation"; set -x
  1070     #   post-adjust RPM installation (namespace-clean POPT inclusion)
  1071     mv $RPM_BUILD_ROOT%{l_prefix}/lib/libpopt.a \
  1072        $RPM_BUILD_ROOT%{l_prefix}/lib/librpmpopt.a
  1073     mv $RPM_BUILD_ROOT%{l_prefix}/include/popt.h \
  1074        $RPM_BUILD_ROOT%{l_prefix}/include/rpm/popt.h
  1076     #   move C API into custom locations
  1077     mv $RPM_BUILD_ROOT%{l_prefix}/include/rpm \
  1078        $RPM_BUILD_ROOT%{l_prefix}/include/openpkg/rpm
  1079     mv $RPM_BUILD_ROOT%{l_prefix}/lib/librpm* \
  1080        $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/
  1082     #   move rpm tool to custom location
  1083     mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm \
  1084        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1085     mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm.8 \
  1086        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm.8
  1088     #   move rpm2cpio tool to custom location
  1089     mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm2cpio \
  1090        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio
  1091     mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm2cpio.8 \
  1092        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio.8
  1094     #   replace symlinks with hardlinks
  1095     for entry in rpme:rpmi rpmt:rpmb rpmu:rpmi rpmv:rpmq; do
  1096         eval `echo $entry | sed -e 's/^\(.*\):\(.*\)$/dst=\1; src=\2/'`
  1097         rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  1098         ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$src \
  1099            $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst
  1100     done
  1101     rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/rpmbuild
  1102     ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmb \
  1103        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild
  1104     mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpmbuild.8 \
  1105        $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild.8
  1107     #   display verbosity header
  1108     set +x; VERBOSE "INSTALL: Stripping Down Installation"; set -x
  1110     #   strip RPM installation
  1111     ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/* \
  1112           $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/* >/dev/null 2>&1 || true
  1113     for dir in man/ja man/pl man/ru man/sk src; do
  1114         rm -rf $RPM_BUILD_ROOT%{l_prefix}/$dir >/dev/null 2>&1 || true
  1115     done
  1116     rm -rf $RPM_BUILD_ROOT/var >/dev/null 2>&1 || true
  1117     for file in rpme rpmi rpmsign rpmu rpmverify rpmquery gendiff; do
  1118         rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/$file >/dev/null 2>&1 || true
  1119     done
  1120     rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/* >/dev/null 2>&1 || true
  1121     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/* >/dev/null 2>&1 || true
  1122     rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man3/* >/dev/null 2>&1 || true
  1123     rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmpopt >/dev/null 2>&1 || true
  1124     rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmrc >/dev/null 2>&1 || true
  1125     rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.la >/dev/null 2>&1 || true
  1126     rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/lib >/dev/null 2>&1 || true
  1127     for file in \
  1128         u_pkg.sh vpkg-provides.sh vpkg-provides2.sh rpmdiff.cgi rpmdiff \
  1129         perl.prov perl.req mkinstalldirs magic.prov magic.req http.req \
  1130         getpo.sh get_magic.pl find-provides find-requires \
  1131         find-requires.perl find-req.pl find-provides.perl \
  1132         find-prov.pl find-lang.sh cpanflute convertrpmrc.sh check-prereqs \
  1133         rpmputtext rpmgettext brp-compress brp-redhat brp-sparc64-linux \
  1134         brp-strip brp-strip-shared brp-strip-comment-note rpmrc \
  1135         config.guess config.sub check-files; do
  1136         rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$file >/dev/null 2>&1 || true
  1137     done
  1139     #   display verbosity header
  1140     set +x; VERBOSE "INSTALL: Install Additional Tools"; set -x
  1142     #   install lsync tool
  1143     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1144         <`SOURCE lsync` \
  1145         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync
  1146     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync
  1147     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1148         <`SOURCE dot.lsyncrc` \
  1149         >$RPM_BUILD_ROOT%{l_prefix}/local/.lsyncrc
  1150     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1151         <`SOURCE lsync.8` \
  1152         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync.8
  1154     #   install rpm-config tool
  1155     ( l_prefix="%{l_prefix}"
  1156       l_cc="%{l_cc}"
  1157       l_cflags=""
  1158       l_cppflags="-DOPENPKG -I${l_prefix}/include/openpkg/rpm -I${l_prefix}/include/openpkg"
  1159       l_ldflags="-L${l_prefix}/lib/openpkg"
  1160       l_libs="-lrpmbuild -lrpm -lrpmio -lrpmdb -lrpmpopt -lrpmbeecrypt -lrpmbz2 -lrpmz"
  1161       sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1162           -e "s:@l_cc@:$l_cc:g" \
  1163           -e "s:@l_cflags@:$l_cflags:g" \
  1164           -e "s:@l_cppflags@:$l_cppflags:g" \
  1165           -e "s:@l_ldflags@:$l_ldflags:g" \
  1166           -e "s:@l_libs@:$l_libs:g" \
  1167           -e "s:@l_version@:%{V_rpm}:g" \
  1168           <`SOURCE rpm-config.sh` \
  1169           >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config
  1170     ) || exit $?
  1171     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config
  1172     sed -e "s:RPM_VERSION:%{V_rpm}:g" \
  1173         <`SOURCE rpm-config.8` \
  1174         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config.8
  1176     #   install OpenPKG registry commands
  1177     ( cd openpkg-registry-%{V_registry}
  1178       mv  $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm \
  1179           $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpm
  1180       sed -e "s;@l_prefix@;%{l_prefix};g" \
  1181           rpm.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1182       chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm
  1183       sed -e "s;@l_prefix@;%{l_prefix};g" \
  1184           register.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register
  1185       chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register
  1186       cp register.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register.8
  1187     ) || exit $?
  1189     #   install OpenPKG Tool Chain command subset
  1190     ( cd openpkg-tools-%{V_tools}
  1191       cp cmd/curl.sh $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/curl.sh
  1192       cp cmd/build.pl $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl
  1193       chmod 644 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl
  1194       cp cmd/build.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.8
  1195     ) || exit $?
  1197     #   install RPM extension
  1198     ( cd rpm-%{V_rpm}
  1199       cp file/file $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file
  1200       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file
  1201     ) || exit $?
  1202     ( cd perl-%{V_perl}
  1203       cp miniperl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl
  1204       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl
  1205     ) || exit $?
  1206     ( cd openssl-%{V_openssl}
  1207       cp apps/openssl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl
  1208       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl
  1209     ) || exit $?
  1210     ( cd curl-%{V_curl}
  1211       cp src/curl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  1212       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl
  1213     ) || exit $?
  1214     ( cd bzip2-%{V_bzip2}
  1215       cp bzip2 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  1216       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2
  1217     ) || exit $?
  1218     ( cd gzip-%{V_gzip}
  1219       cp gzip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  1220       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip
  1221     ) || exit $?
  1222     ( cd patch-%{V_patch}
  1223       cp patch $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  1224       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch
  1225     ) || exit $?
  1226     ( cd tar-%{V_tar}
  1227       cp tar $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  1228       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar
  1229     ) || exit $?
  1230     ( cd bash-%{V_bash}
  1231       cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  1232       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash
  1233     ) || exit $?
  1234     ( cd uuid-%{V_uuid}
  1235       cp uuid $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid
  1236       ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid
  1237     ) || exit $?
  1238     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1239         -e "s;@l_musr@;%{l_musr};g" \
  1240         -e "s;@l_mgrp@;%{l_mgrp};g" \
  1241         <`SOURCE uuid.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid
  1242     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid
  1243     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1244         <`SOURCE uuid.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid.8
  1245     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1246         <`SOURCE release.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release
  1247     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release
  1248     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1249         <`SOURCE release.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release.8
  1250     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1251         -e "s;@l_musr@;%{l_musr};g" \
  1252         -e "s;@l_mgrp@;%{l_mgrp};g" \
  1253         <`SOURCE rpmdb` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb
  1254     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb
  1255     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1256         <`SOURCE rpmtool` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  1257     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool
  1259     #   install OpenPKG tool chain execution frontend and execution wrapper
  1260     cp openpkg-executable-%{V_exec}/openpkg $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1261     ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1262     chmod 4775 $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg
  1263     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1264         <`SOURCE openpkg.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg
  1265     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg
  1266     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1267         <`SOURCE openpkg.1` \
  1268         >$RPM_BUILD_ROOT%{l_prefix}/man/man1/openpkg.1
  1270     #   install more OpenPKG tool chain commands
  1271     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1272         <`SOURCE install.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install
  1273     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install
  1274     sed -e "s;@l_prefix@;%{l_prefix};g" \
  1275         <`SOURCE man.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man
  1276     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man
  1278     #   install an own copy of shtool
  1279     cp $shtool $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  1280     chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool
  1282     #   display verbosity header
  1283     set +x; VERBOSE "INSTALL: Install Configuration Files"; set -x
  1285     #   install a few README files
  1286     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1287         <`SOURCE root.README` \
  1288         >$RPM_BUILD_ROOT%{l_prefix}/README
  1289     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1290         <`SOURCE local.README` \
  1291         >$RPM_BUILD_ROOT%{l_prefix}/local/README
  1293     #   install Bash environment
  1294     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1295         <`SOURCE dot.bashrc` \
  1296         >$RPM_BUILD_ROOT%{l_prefix}/.bashrc
  1297     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1298         <`SOURCE dot.bash_login` \
  1299         >$RPM_BUILD_ROOT%{l_prefix}/.bash_login
  1301     #   install Run-Command files
  1302     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1303         -e "s:@l_susr@:%{l_susr}:g" \
  1304         -e "s:@l_musr@:%{l_musr}:g" \
  1305         <`SOURCE rc` \
  1306         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc
  1307     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc
  1308     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1309         <`SOURCE rc.conf` \
  1310         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  1311     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf
  1312     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1313         <`SOURCE rc.func` \
  1314         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  1315     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.func
  1316     mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
  1317     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1318         -e "s:@l_musr@:%{l_musr}:g" \
  1319         <`SOURCE rc.openpkg` \
  1320         >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  1321     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg
  1322     ( echo "#!/bin/sh"
  1323       echo "exec %{l_prefix}/etc/rc \${1+\"\$@\"}"
  1324     ) >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc
  1325     chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc
  1326     ln  $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc \
  1327         $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rc
  1328     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1329         <`SOURCE rc.8` \
  1330         >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc.8
  1332     #   create configuration directory
  1333     test -d $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg || \
  1334         mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg
  1336     #   install platform identification file
  1337     sh $shtool platform -n -L -S "" -C "+" -F "%<ap>-any-%<sp>" \
  1338         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform
  1339     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform
  1341     #   install UUID configuration file (ghost)
  1342     touch $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid
  1343     chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid
  1345     #   install registry configuration files (ghost)
  1346     touch \
  1347         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.conf \
  1348         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \
  1349         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \
  1350         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util
  1351     chmod 644 \
  1352         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.conf \
  1353         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \
  1354         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \
  1355         $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util
  1357     #   install default managers configuration file
  1358     ( echo "##"
  1359       echo "##  managers -- OpenPKG Instance Managers"
  1360       echo "##"
  1361       echo ""
  1362       echo "%{l_susr}"
  1363       echo "%{l_musr}"
  1364       echo ""
  1365     ) >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/managers
  1367     #   install overriding RPM configuration files
  1368     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1369         <`SOURCE rpmpopt` \
  1370         >>$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmpopt
  1371     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1372         <`SOURCE rpmrc` \
  1373         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc
  1374     sed -e "s:@l_prefix@:%{l_prefix}:g" \
  1375         -e "s:@l_prefix_static@:%{l_prefix}:g" \
  1376         -e "s;@l_build_path@;$l_build_path;g" \
  1377         -e "s;@l_build_ldlp@;$l_build_ldlp;g" \
  1378         -e "s;@l_build_ulim@;$l_build_ulim;g" \
  1379         -e "s:@TAG@:$tag:g" \
  1380         -e "s:@SUSR@:$susr:g" \
  1381         -e "s:@SGRP@:$sgrp:g" \
  1382         -e "s:@MUSR@:$musr:g" \
  1383         -e "s:@MGRP@:$mgrp:g" \
  1384         -e "s:@RUSR@:$rusr:g" \
  1385         -e "s:@RGRP@:$rgrp:g" \
  1386         -e "s:@NUSR@:$nusr:g" \
  1387         -e "s:@NGRP@:$ngrp:g" \
  1388         <`SOURCE rpmmacros` \
  1389         >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros
  1390     cp `SOURCE openpkg.org.pgp` \
  1391        $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.org.pgp
  1392     cp `SOURCE openpkg.com.pgp` \
  1393        $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.com.pgp
  1394     cp `SOURCE openpkg.net.pgp` \
  1395        $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.net.pgp
  1397     #   display verbosity header
  1398     set +x; VERBOSE "INSTALL: Done. Thank you for flying OpenPKG..."; set -x
  1400 %files
  1401     %defattr(-,%{?l_musr}%{!?l_musr:%{l_fsusr}},%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}})
  1402     %{l_prefix}/README
  1403     %config(noreplace) %{l_prefix}/.bashrc
  1404     %config(noreplace) %{l_prefix}/.bash_login
  1405     %dir %{l_prefix}/RPM
  1406     %dir %{l_prefix}/RPM/SRC
  1407     %dir %{l_prefix}/RPM/PKG
  1408     %dir %{l_prefix}/RPM/DB
  1409     %dir %{l_prefix}/RPM/TMP
  1410     %dir %{l_prefix}/cgi
  1411     %dir %{l_prefix}/bin
  1412     %attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/openpkg
  1413     %dir %{l_prefix}/etc
  1414     %{l_prefix}/etc/rc
  1415     %config(noreplace) %{l_prefix}/etc/rc.conf
  1416     %{l_prefix}/etc/rc.func
  1417     %dir %{l_prefix}/etc/rc.d
  1418     %{l_prefix}/etc/rc.d/rc.openpkg
  1419     %dir %{l_prefix}/etc/openpkg
  1420     %ghost %{l_prefix}/etc/openpkg/uuid
  1421     %config %{l_prefix}/etc/openpkg/platform
  1422     %config %{l_prefix}/etc/openpkg/rpmmacros
  1423     %config %{l_prefix}/etc/openpkg/rpmrc
  1424     %ghost %{l_prefix}/etc/openpkg/register.conf
  1425     %ghost %{l_prefix}/etc/openpkg/register.prep
  1426     %ghost %{l_prefix}/etc/openpkg/register.tran
  1427     %ghost %{l_prefix}/etc/openpkg/register.util
  1428     %config %attr(664,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/openpkg/managers
  1429     %{l_prefix}/etc/openpkg/openpkg.org.pgp
  1430     %{l_prefix}/etc/openpkg/openpkg.com.pgp
  1431     %{l_prefix}/etc/openpkg/openpkg.net.pgp
  1432     %dir %{l_prefix}/include
  1433     %dir %{l_prefix}/include/openpkg
  1434     %dir %{l_prefix}/include/openpkg/rpm
  1435     %{l_prefix}/include/openpkg/rpm/argv.h
  1436     %{l_prefix}/include/openpkg/rpm/beecrypt.h
  1437     %{l_prefix}/include/openpkg/rpm/bzlib.h
  1438     %{l_prefix}/include/openpkg/rpm/db.h
  1439     %{l_prefix}/include/openpkg/rpm/fts.h
  1440     %{l_prefix}/include/openpkg/rpm/glob.h
  1441     %{l_prefix}/include/openpkg/rpm/hdrinline.h
  1442     %{l_prefix}/include/openpkg/rpm/header.h
  1443     %{l_prefix}/include/openpkg/rpm/misc.h
  1444     %{l_prefix}/include/openpkg/rpm/popt.h
  1445     %{l_prefix}/include/openpkg/rpm/rpmal.h
  1446     %{l_prefix}/include/openpkg/rpm/rpmbuild.h
  1447     %{l_prefix}/include/openpkg/rpm/rpmcli.h
  1448     %{l_prefix}/include/openpkg/rpm/rpmdb.h
  1449     %{l_prefix}/include/openpkg/rpm/rpmds.h
  1450     %{l_prefix}/include/openpkg/rpm/rpmerr.h
  1451     %{l_prefix}/include/openpkg/rpm/rpmfc.h
  1452     %{l_prefix}/include/openpkg/rpm/rpmfi.h
  1453     %{l_prefix}/include/openpkg/rpm/rpmfile.h
  1454     %{l_prefix}/include/openpkg/rpm/rpmhash.h
  1455     %{l_prefix}/include/openpkg/rpm/rpmio.h
  1456     %{l_prefix}/include/openpkg/rpm/rpmlib.h
  1457     %{l_prefix}/include/openpkg/rpm/rpmlog.h
  1458     %{l_prefix}/include/openpkg/rpm/rpmmacro.h
  1459     %{l_prefix}/include/openpkg/rpm/rpmmessages.h
  1460     %{l_prefix}/include/openpkg/rpm/rpmpgp.h
  1461     %{l_prefix}/include/openpkg/rpm/rpmps.h
  1462     %{l_prefix}/include/openpkg/rpm/rpmspec.h
  1463     %{l_prefix}/include/openpkg/rpm/rpmsw.h
  1464     %{l_prefix}/include/openpkg/rpm/rpmte.h
  1465     %{l_prefix}/include/openpkg/rpm/rpmts.h
  1466     %{l_prefix}/include/openpkg/rpm/rpmurl.h
  1467     %{l_prefix}/include/openpkg/rpm/stringbuf.h
  1468     %{l_prefix}/include/openpkg/rpm/ugid.h
  1469     %{l_prefix}/include/openpkg/rpm/zconf.h
  1470     %{l_prefix}/include/openpkg/rpm/zlib.h
  1471     %dir %{l_prefix}/info
  1472     %dir %{l_prefix}/lib
  1473     %dir %{l_prefix}/lib/openpkg
  1474     %{l_prefix}/lib/openpkg/bash
  1475     %{l_prefix}/lib/openpkg/bzip2
  1476     %{l_prefix}/lib/openpkg/curl
  1477     %{l_prefix}/lib/openpkg/file
  1478     %{l_prefix}/lib/openpkg/gzip
  1479     %{l_prefix}/lib/openpkg/librpm.a
  1480     %{l_prefix}/lib/openpkg/librpmbeecrypt.a
  1481     %{l_prefix}/lib/openpkg/librpmbuild.a
  1482     %{l_prefix}/lib/openpkg/librpmbz2.a
  1483     %{l_prefix}/lib/openpkg/librpmdb.a
  1484     %{l_prefix}/lib/openpkg/librpmio.a
  1485     %{l_prefix}/lib/openpkg/librpmpopt.a
  1486     %{l_prefix}/lib/openpkg/librpmz.a
  1487     %{l_prefix}/lib/openpkg/macros
  1488     %{l_prefix}/lib/openpkg/magic
  1489     %{l_prefix}/lib/openpkg/magic.mgc
  1490     %{l_prefix}/lib/openpkg/magic.mime
  1491     %{l_prefix}/lib/openpkg/magic.mime.mgc
  1492     %{l_prefix}/lib/openpkg/miniperl
  1493     %{l_prefix}/lib/openpkg/openpkg
  1494     %{l_prefix}/lib/openpkg/openssl
  1495     %{l_prefix}/lib/openpkg/patch
  1496     %{l_prefix}/lib/openpkg/rc
  1497     %{l_prefix}/lib/openpkg/rpm
  1498     %{l_prefix}/lib/openpkg/rpmb
  1499     %{l_prefix}/lib/openpkg/rpmd
  1500     %{l_prefix}/lib/openpkg/rpmdb
  1501     %{l_prefix}/lib/openpkg/rpmdb_dump
  1502     %{l_prefix}/lib/openpkg/rpmdb_load
  1503     %{l_prefix}/lib/openpkg/rpmdb_verify
  1504     %{l_prefix}/lib/openpkg/rpme
  1505     %{l_prefix}/lib/openpkg/rpmi
  1506     %{l_prefix}/lib/openpkg/rpmk
  1507     %{l_prefix}/lib/openpkg/rpmpopt
  1508     %{l_prefix}/lib/openpkg/rpmq
  1509     %{l_prefix}/lib/openpkg/rpmt
  1510     %{l_prefix}/lib/openpkg/rpmtool
  1511     %{l_prefix}/lib/openpkg/rpmu
  1512     %{l_prefix}/lib/openpkg/rpmv
  1513     %{l_prefix}/lib/openpkg/shtool
  1514     %{l_prefix}/lib/openpkg/tar
  1515     %{l_prefix}/lib/openpkg/uuid
  1516     %dir %{l_prefix}/libexec
  1517     %dir %{l_prefix}/libexec/openpkg
  1518     %{l_prefix}/libexec/openpkg/build.8
  1519     %{l_prefix}/libexec/openpkg/build.pl
  1520     %{l_prefix}/libexec/openpkg/curl.sh
  1521     %{l_prefix}/libexec/openpkg/install
  1522     %{l_prefix}/libexec/openpkg/lsync
  1523     %{l_prefix}/libexec/openpkg/lsync.8
  1524     %{l_prefix}/libexec/openpkg/man
  1525     %{l_prefix}/libexec/openpkg/rc
  1526     %{l_prefix}/libexec/openpkg/rc.8
  1527     %{l_prefix}/libexec/openpkg/register
  1528     %{l_prefix}/libexec/openpkg/register.8
  1529     %{l_prefix}/libexec/openpkg/release
  1530     %{l_prefix}/libexec/openpkg/release.8
  1531     %{l_prefix}/libexec/openpkg/rpm
  1532     %{l_prefix}/libexec/openpkg/rpm-config
  1533     %{l_prefix}/libexec/openpkg/rpm-config.8
  1534     %{l_prefix}/libexec/openpkg/rpm.8
  1535     %{l_prefix}/libexec/openpkg/rpm2cpio
  1536     %{l_prefix}/libexec/openpkg/rpm2cpio.8
  1537     %{l_prefix}/libexec/openpkg/rpmbuild
  1538     %{l_prefix}/libexec/openpkg/rpmbuild.8
  1539     %{l_prefix}/libexec/openpkg/uuid
  1540     %{l_prefix}/libexec/openpkg/uuid.8
  1541     %dir %{l_prefix}/man
  1542     %dir %{l_prefix}/man/man1
  1543     %dir %{l_prefix}/man/man2
  1544     %dir %{l_prefix}/man/man3
  1545     %dir %{l_prefix}/man/man4
  1546     %dir %{l_prefix}/man/man5
  1547     %dir %{l_prefix}/man/man6
  1548     %dir %{l_prefix}/man/man7
  1549     %dir %{l_prefix}/man/man8
  1550     %dir %{l_prefix}/man/man9
  1551     %dir %{l_prefix}/man/cat1
  1552     %dir %{l_prefix}/man/cat2
  1553     %dir %{l_prefix}/man/cat3
  1554     %dir %{l_prefix}/man/cat4
  1555     %dir %{l_prefix}/man/cat5
  1556     %dir %{l_prefix}/man/cat6
  1557     %dir %{l_prefix}/man/cat7
  1558     %dir %{l_prefix}/man/cat8
  1559     %dir %{l_prefix}/man/cat9
  1560     %{l_prefix}/man/man1/openpkg.1
  1561     %dir %{l_prefix}/sbin
  1562     %dir %{l_prefix}/pub
  1563     %dir %{l_prefix}/share
  1564     %dir %{l_prefix}/var
  1565     %dir %{l_prefix}/local
  1566     %{l_prefix}/local/README
  1567     %{l_prefix}/local/.lsyncrc
  1568     %dir %{l_prefix}/local/PKG
  1569     %dir %{l_prefix}/local/bin
  1570     %dir %{l_prefix}/local/etc
  1571     %dir %{l_prefix}/local/include
  1572     %dir %{l_prefix}/local/info
  1573     %dir %{l_prefix}/local/lib
  1574     %dir %{l_prefix}/local/man
  1575     %dir %{l_prefix}/local/man/man1
  1576     %dir %{l_prefix}/local/man/man2
  1577     %dir %{l_prefix}/local/man/man3
  1578     %dir %{l_prefix}/local/man/man4
  1579     %dir %{l_prefix}/local/man/man5
  1580     %dir %{l_prefix}/local/man/man6
  1581     %dir %{l_prefix}/local/man/man7
  1582     %dir %{l_prefix}/local/man/man8
  1583     %dir %{l_prefix}/local/man/man9
  1584     %dir %{l_prefix}/local/man/cat1
  1585     %dir %{l_prefix}/local/man/cat2
  1586     %dir %{l_prefix}/local/man/cat3
  1587     %dir %{l_prefix}/local/man/cat4
  1588     %dir %{l_prefix}/local/man/cat5
  1589     %dir %{l_prefix}/local/man/cat6
  1590     %dir %{l_prefix}/local/man/cat7
  1591     %dir %{l_prefix}/local/man/cat8
  1592     %dir %{l_prefix}/local/man/cat9
  1593     %dir %{l_prefix}/local/sbin
  1595 %clean
  1596     #   skip in bootstrap phase 2 (see openpkg.boot)
  1597     [ ".$OPENPKG_BOOT" = .1 ] && exit 0
  1599     #   cleanup build area
  1600     rm -rf openpkg-%{version} >/dev/null 2>&1 || true
  1602     #   cleanup installation area
  1603     rm -rf $RPM_BUILD_ROOT >/dev/null 2>&1 || true
  1605 %pre
  1606     #   always performed for upgrades and because it doesn't harm!
  1607     #   [ ".$1" != .1 ] && exit 0
  1609     #   this procedure is only usable with root privileges
  1610     #   (for non-root installations it is not required at all)
  1611     cusr=`(id -un) 2>/dev/null ||\
  1612           (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  1613           (whoami) 2>/dev/null ||\
  1614           (who am i | cut "-d " -f1) 2>/dev/null ||\
  1615           echo $LOGNAME`
  1617     #   determine runtime details (for both inside and outside RPM!!)
  1618     #   - bootstrapping: $xxx is set from aux.wrapbin.sh
  1619     #   - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros
  1620     #   - upgrading old: %{l_[smrn]{usr,grp}} is not set at all
  1621     [ ".$susr" = . ] && susr="%{?l_susr}%{!?l_susr:root}"
  1622     [ ".$sgrp" = . ] && sgrp="%{?l_sgrp}%{!?l_sgrp:wheel}"
  1623     [ ".$musr" = . ] && musr="%{?l_musr}%{!?l_musr:%{l_fsusr}}"
  1624     [ ".$mgrp" = . ] && mgrp="%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}}"
  1625     [ ".$rusr" = . ] && rusr="%{?l_rusr}%{!?l_rusr:%{l_fsusr}-r}"
  1626     [ ".$rgrp" = . ] && rgrp="%{?l_rgrp}%{!?l_rgrp:%{l_fsgrp}-r}"
  1627     [ ".$nusr" = . ] && nusr="%{?l_nusr}%{!?l_nusr:%{l_fsusr}-n}"
  1628     [ ".$ngrp" = . ] && ngrp="%{?l_ngrp}%{!?l_ngrp:%{l_fsgrp}-n}"
  1629     [ ".$suid" = . ] && suid="%{?l_suid}"
  1630     [ ".$sgid" = . ] && sgid="%{?l_sgid}"
  1631     [ ".$muid" = . ] && muid="%{?l_muid}"
  1632     [ ".$mgid" = . ] && mgid="%{?l_mgid}"
  1633     [ ".$ruid" = . ] && ruid="%{?l_ruid}"
  1634     [ ".$rgid" = . ] && rgid="%{?l_rgid}"
  1635     [ ".$nuid" = . ] && nuid="%{?l_nuid}"
  1636     [ ".$ngid" = . ] && ngid="%{?l_ngid}"
  1638     #   if any of these optional params are not used we won't have a
  1639     #   corresponding macro either, so make use of one conditionally
  1640     [ ".$suid" = . ] && [ ".%{?l_suid:set}" = .set ] && suid="%{?l_suid}"
  1641     [ ".$sgid" = . ] && [ ".%{?l_sgid:set}" = .set ] && sgid="%{?l_sgid}"
  1642     [ ".$muid" = . ] && [ ".%{?l_muid:set}" = .set ] && muid="%{?l_muid}"
  1643     [ ".$mgid" = . ] && [ ".%{?l_mgid:set}" = .set ] && mgid="%{?l_mgid}"
  1644     [ ".$ruid" = . ] && [ ".%{?l_ruid:set}" = .set ] && ruid="%{?l_ruid}"
  1645     [ ".$rgid" = . ] && [ ".%{?l_rgid:set}" = .set ] && rgid="%{?l_rgid}"
  1646     [ ".$nuid" = . ] && [ ".%{?l_nuid:set}" = .set ] && nuid="%{?l_nuid}"
  1647     [ ".$ngid" = . ] && [ ".%{?l_ngid:set}" = .set ] && ngid="%{?l_ngid}"
  1649     #   determine prefix
  1650     [ ".$prefix" = . ] && prefix="%{l_prefix}"
  1651     prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  1653     #   register instance in presence file
  1654     presence="/etc/openpkg"
  1655     exists=`cat $presence 2>/dev/null | egrep "^ *${prefix} *\$"`
  1656     if [ ".$exists" = . ]; then
  1657         ( umask 022
  1658           echo "${prefix}" >>$presence
  1659         ) 2>/dev/null || true
  1660     fi
  1662     #   determine user/group ids
  1663     for class in s m r n; do
  1664         eval "xusr=\"\$${class}usr\""
  1665         eval "xgrp=\"\$${class}grp\""
  1666         eval "xuid=\"\$${class}uid\""
  1667         eval "xgid=\"\$${class}gid\""
  1668         if [ ".$xuid" = . ]; then
  1669             xuid=`(getent passwd "${xusr}"; \
  1670                    grep "^${xusr}:" /etc/passwd; \
  1671                    ypmatch "${xusr}" passwd; \
  1672                    nismatch "${xusr}" passwd; \
  1673                    nidump passwd . | grep "^${xusr}:") 2>/dev/null | \
  1674                    sed -e 'q' | awk -F: '{ print $3; }'`
  1675             if [ ".$xuid" = . ]; then
  1676                 #   seek for a reasonably uid/gid pair
  1677                 xuid=1000
  1678                 ok=0
  1679                 while [ ".$ok" = .0 ]; do
  1680                     eval "u_exists=\$u_exists_$xuid"
  1681                     if [ ".$u_exists" = . ]; then
  1682                         u_exists=`(getent passwd; cat /etc/passwd; ypcat passwd; niscat passwd; nidump passwd .) 2>/dev/null |\
  1683                                   grep "^[^:]*:[^:]*:$xuid:"`
  1684                     fi
  1685                     eval "g_exists=\$g_exists_$xuid"
  1686                     if [ ".$g_exists" = . ]; then
  1687                         g_exists=`(getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null |\
  1688                                   grep "^[^:]*:[^:]*:$xuid:"`
  1689                     fi
  1690                     if [ ".$u_exists" = . -a ".$g_exists" = . ]; then
  1691                         ok=1
  1692                         break
  1693                     fi
  1694                     xuid=`expr $xuid + 1`
  1695                 done
  1696                 eval "u_exists_$xuid=yes"
  1697                 eval "g_exists_$xuid=yes"
  1698             fi
  1699         fi
  1700         if [ ".$xgid" = . ]; then
  1701             xgid=`(getent group "${xgrp}"; \
  1702                   grep "^${xgrp}:" /etc/group; \
  1703                   ypmatch "${xgrp}" group; \
  1704                   nismatch "${xgrp}" group; \
  1705                   nidump group . | grep "^${xgrp}:") 2>/dev/null | \
  1706                   sed -e 'q' | awk -F: '{ print $3; }'`
  1707             if [ ".$xgid" = . ]; then
  1708                 xgid="$xuid"
  1709             fi
  1710         fi
  1711         eval "${class}uid=\"$xuid\""
  1712         eval "${class}gid=\"$xgid\""
  1713     done
  1715     #   determine platform id
  1716     s=`(uname -s) 2>/dev/null` || s='Unknown'
  1717     r=`(uname -r) 2>/dev/null` || r='0.0'
  1718     plid="${s}/${r}"
  1720     #   add entry to /etc/shells
  1721     shell="${prefix}/lib/openpkg/bash"
  1722     if [ -f /etc/shells ]; then
  1723         exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  1724         if [ ".$exists" = . ]; then
  1725             if [ ".$cusr" != ".root" ]; then
  1726                 echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2
  1727                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1728             else
  1729                 echo "${shell}" >>/etc/shells
  1730             fi
  1731         fi
  1732     fi
  1734     #   clear pending deferred actions
  1735     rm -f %{l_prefix}.pre-group-process.sh %{l_prefix}.pre-post-process.sh >/dev/null 2>&1
  1737     #   create the hierarchy user/group
  1738     for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \
  1739                "management:${musr}:${muid}:${mgrp}:${mgid}" \
  1740                "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \
  1741                "non-privileged:${nusr}:${nuid}:${ngrp}:${ngid}"; do
  1742         #   split request into class/usr/uid/grp/gid
  1743         OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  1744         class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  1746         #   check whether user already exists
  1747         exists=`(getent passwd "$usr"; \
  1748                  grep "^$usr:" /etc/passwd; \
  1749                  ypmatch "$usr" passwd; \
  1750                  nismatch "$usr" passwd; \
  1751                  nidump passwd . | grep "^$usr:") 2>/dev/null | \
  1752                  sed -e 'q'`
  1753         if [ ".$exists" = . ]; then
  1754             if [ ".$cusr" != ".root" ]; then
  1755                 echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2
  1756                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1757             else
  1758                 #   add entry to passwd database
  1759                 realname="${prefix} OpenPKG ($class)"
  1760                 case "$plid" in
  1761                     FreeBSD/* | NetBSD/* )
  1762                         file=/etc/master.passwd
  1763                         entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}"
  1764                         update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)"
  1765                         ;;
  1766                     Linux/* )
  1767                         file=/etc/passwd
  1768                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1769                         update="(PATH=\$PATH:/usr/sbin; pwconv)"
  1770                         ;;
  1771                     SunOS/5.* | UnixWare/* )
  1772                         file=/etc/passwd
  1773                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1774                         update="(PATH=\$PATH:/usr/sbin; pwconv)"
  1775                         ;;
  1776                     AIX/* )
  1777                         #   intentionally do nothing here
  1779                         ;;
  1780                     OSF1/V5.* )
  1781                         file=/etc/passwd
  1782                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1783                         update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)"
  1784                         ;;
  1785                     HP-UX/* )
  1786                         file=/etc/passwd
  1787                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1788                         update=":"
  1789                         ;;
  1790                     Darwin/* )
  1791                         #   intentionally do nothing here
  1793                         ;;
  1794                     IRIX*/6.* )
  1795                         file=/etc/passwd
  1796                         entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}"
  1797                         if   [ -f /etc/shadow ]
  1798                         then update="(PATH=\$PATH:/sbin; pwconv)"
  1799                         else update=":"
  1800                         fi
  1801                         ;;
  1802                 esac
  1803                 case "$plid" in
  1804                     Darwin/* )
  1805                         niutil -create     . "/users/${usr}"
  1806                         niutil -createprop . "/users/${usr}" passwd   "*"
  1807                         niutil -createprop . "/users/${usr}" uid      "${uid}"
  1808                         niutil -createprop . "/users/${usr}" gid      "${gid}"
  1809                         niutil -createprop . "/users/${usr}" realname "${realname}"
  1810                         niutil -createprop . "/users/${usr}" home     "${prefix}"
  1811                         niutil -createprop . "/users/${usr}" shell    "${shell}"
  1812                         ;;
  1813                     AIX/* )
  1814                         mkuser id="${uid}" gecos="${realname}" home="${prefix}" "${usr}"
  1815                         cp /etc/security/login.cfg /etc/security/login.cfg.bak && \
  1816                         sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\) *\$;\\1,$shell;" \
  1817                             </etc/security/login.cfg.bak >/etc/security/login.cfg && \
  1818                         rm -f /etc/security/login.cfg.bak >/dev/null 2>&1
  1819                         #   defer both the setting of the primary group and the shell,
  1820                         #   as they do not exist at this stage of processing.
  1821                         echo "chuser pgrp=\"${grp}\" \"${usr}\"" >>%{l_prefix}.pre-group-process.sh
  1822                         echo "chuser shell=\"${shell}\" \"${usr}\"" >>%{l_prefix}.pre-post-process.sh
  1823                         ;;
  1824                     * )
  1825                         cp $file $file.bak && \
  1826                         (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  1827                         rm -f $file.bak >/dev/null 2>&1
  1828                         eval $update
  1829                         [ $? -ne 0 ] && exit $?
  1830                         ;;
  1831                 esac
  1832             fi
  1833         fi
  1835         #   check whether group already exists
  1836         exists=`(getent group "$grp"; \
  1837                 grep "^$grp:" /etc/group; \
  1838                 ypmatch "$grp" group; \
  1839                 nismatch "$grp" group; \
  1840                 nidump group . | grep "^$grp:") 2>/dev/null | \
  1841                 sed -e 'q'`
  1842         if [ ".$exists" = . ]; then
  1843             if [ ".$cusr" != ".root" ]; then
  1844                 echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2
  1845                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1846             else
  1847                 case "$plid" in
  1848                     Darwin/* )
  1849                         niutil -create     . "/groups/${grp}"
  1850                         niutil -createprop . "/groups/${grp}" gid   "${gid}"
  1851                         niutil -createprop . "/groups/${grp}" users "${usr}"
  1852                         ;;
  1853                     AIX/* )
  1854                         mkgroup id="${gid}" users="${usr}" "${grp}"
  1855                         ;;
  1856                     * )
  1857                         #   add entry to group database
  1858                         file=/etc/group
  1859                         entry="${grp}:*:${gid}:${usr}"
  1860                         cp $file $file.bak && \
  1861                         (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file
  1862                         rm -f $file.bak >/dev/null 2>&1
  1863                     ;;
  1864                 esac
  1865             fi
  1866         fi
  1867     done
  1869     #   optional group processing (deferred adjustment of primary group)
  1870     if [ -f %{l_prefix}.pre-group-process.sh ]; then
  1871         sh %{l_prefix}.pre-group-process.sh
  1872         rm -f %{l_prefix}.pre-group-process.sh
  1873     fi
  1875     #   invalidate passwd and group tables from Name Service Cache Daemon to
  1876     #   ensure chown/chgrp works immediately after pwconv on Linux and Solaris
  1877     if [ -x /usr/sbin/nscd ]; then
  1878         /usr/sbin/nscd -i passwd >/dev/null 2>&1 || true
  1879         /usr/sbin/nscd -i group >/dev/null 2>&1 || true
  1880     fi
  1882     #   create the startup/shutdown transfer script
  1883     name=`echo "$prefix" | sed -e 's;/;;g'`
  1884     if [ ".$cusr" != ".root" ]; then
  1885         echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2
  1886         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  1887     else
  1888         case "$plid" in
  1889             FreeBSD/* )
  1890                 if [ ! -f /etc/rc.d/openpkg-${name} ]; then
  1891                     #   install transfer script
  1892                     rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1
  1893                     ( echo "#!/bin/sh"
  1894                       echo "##"
  1895                       echo "##  openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1896                       echo "##"
  1897                       echo ""
  1898                       echo "# PROVIDE: openpkg-${name}"
  1899                       echo "# REQUIRE: LOGIN"
  1900                       echo "# KEYWORD: shutdown"
  1901                       echo ""
  1902                       echo ". /etc/rc.subr"
  1903                       echo ""
  1904                       echo "name=\"openpkg_${name}\""
  1905                       echo "start_cmd=\"openpkg_rc_all start\""
  1906                       echo "stop_cmd=\"openpkg_rc_all stop\""
  1907                       echo "restart_cmd=\"openpkg_rc_all stop start\""
  1908                       echo ""
  1909                       echo "openpkg_rc_all () {"
  1910                       echo "    if [ -f ${prefix}/etc/rc ]; then"
  1911                       echo "        ${prefix}/etc/rc all \"\$@\""
  1912                       echo "    fi"
  1913                       echo "}"
  1914                       echo ""
  1915                       echo "load_rc_config \$name"
  1916                       echo "run_rc_command \"\$1\""
  1917                       echo ""
  1918                     ) >/etc/rc.d/openpkg-${name}
  1919                     chmod 755 /etc/rc.d/openpkg-${name}
  1920                 fi
  1921                 ;;
  1922             NetBSD/* )
  1923                 if [ ! -f /etc/rc.d/${name} ]; then
  1924                     ( echo "#!/bin/sh"
  1925                       echo "##"
  1926                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1927                       echo "##"
  1928                       echo "##  PROVIDE: ${name}"
  1929                       echo "##  REQUIRE: DAEMON LOGIN NETWORK SERVERS"
  1930                       echo "##"
  1931                       echo ""
  1932                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  1933                       echo "case \$1 in"
  1934                       echo "    start   ) exec ${prefix}/etc/rc all start ;;"
  1935                       echo "    stop    ) exec ${prefix}/etc/rc all stop  ;;"
  1936                       echo "    restart ) exec ${prefix}/etc/rc all stop start ;;"
  1937                       echo "    status  ) ;;"
  1938                       echo "esac"
  1939                     ) >/etc/rc.d/${name}
  1940                     chmod 755 /etc/rc.d/${name}
  1941                 fi
  1942                 ;;
  1943             Linux/* )
  1944                 if [ -f /etc/gentoo-release ]; then
  1945                     if [ ! -f /etc/init.d/openpkg-${name} ]; then
  1946                         #   install transfer script
  1947                         ( echo "#!/sbin/runscript"
  1948                           echo "##"
  1949                           echo "##  openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  1950                           echo "##"
  1951                           echo ""
  1952                           echo "depend() {"
  1953                           echo "    after *"
  1954                           echo "}"
  1955                           echo ""
  1956                           echo "checkconfig() {"
  1957                           echo "    [ -f ${prefix}/etc/rc ] || return 1"
  1958                           echo "    case $1 in"
  1959                           echo "        start ) exec ${prefix}/etc/rc all start ;;"
  1960                           echo "        stop  ) exec ${prefix}/etc/rc all stop  ;;"
  1961                           echo "    esac"
  1962                           echo "}"
  1963                           echo ""
  1964                           echo "start() {"
  1965                           echo "    checkconfig || return 1"
  1966                           echo "    ebegin "Starting OpenPKG ${prefix} hierarchy""
  1967                           echo "    exec ${prefix}/etc/rc all start"
  1968                           echo "    eend 0"
  1969                           echo "}"
  1970                           echo ""
  1971                           echo "stop() {"
  1972                           echo "    checkconfig || return 1"
  1973                           echo "    ebegin "Stopping OpenPKG ${prefix} hierarchy""
  1974                           echo "    exec ${prefix}/etc/rc all stop"
  1975                           echo "    eend 0"
  1976                           echo "}"
  1977                         ) >/etc/init.d/openpkg-${name}
  1978                         chmod 755 /etc/init.d/openpkg-${name}
  1979                         /sbin/rc-update add openpkg-${name} default
  1980                     fi
  1981                 else
  1982                     #   sroot: script root directory
  1983                     #   lroot: link   root directory
  1984                     if [ -f /etc/debian_version ]; then
  1985                         sroot=/etc/init.d
  1986                         lroot=/etc/rc%d.d
  1987                     elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  1988                         sroot=/etc/rc.d/init.d
  1989                         lroot=/etc/rc.d/rc%d.d
  1990                     elif [ -f /etc/SuSE-release ]; then
  1991                         sroot=/etc/init.d
  1992                         lroot=/etc/init.d/rc%d.d
  1993                     elif [ -f /etc/slackware-version ]; then
  1994                         sroot=/etc/rc.d
  1995                         lroot=/etc/rc.d/rc%d.d
  1996                         name="rc.${name}"
  1997                         for i in 0 1 2 3 4 5 6; do
  1998                             l=`echo $lroot | sed -e "s;%d;$i;"`
  1999                             if [ ! -d $l ]; then
  2000                                 mkdir $l 2>&1 || true
  2001                             fi
  2002                         done
  2003                     else
  2004                         echo "WARNING: you are not running one of the supported standard" 1>&2
  2005                         echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)."   1>&2
  2006                         echo "WARNING: Guessing the location of the system init scripts!" 1>&2
  2007                         sroot=""
  2008                         lroot=""
  2009                         for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  2010                             if [ -d $sr ]; then
  2011                                 sroot="$sr"
  2012                                 break
  2013                             fi
  2014                         done
  2015                         for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  2016                             if [ -d $lr ]; then
  2017                                 lroot="`echo $lr | sed -e 's;2;%d;'`"
  2018                                 break
  2019                             fi
  2020                         done
  2021                         if [ ".$sroot" = . -o ".$lroot" = . ]; then
  2022                             echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  2023                             exit 1
  2024                         fi
  2025                     fi
  2026                     if [ ! -f $sroot/${name} ]; then
  2027                         #   install transfer script
  2028                         ( echo "#!/bin/sh"
  2029                           echo "##"
  2030                           echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2031                           echo "##"
  2032                           echo ""
  2033                           echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2034                           echo "case \$1 in"
  2035                           echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2036                           echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2037                           echo "esac"
  2038                         ) >$sroot/${name}
  2039                         chmod 755 $sroot/${name}
  2040                         #   create corresponding symbolic links
  2041                         for i in 2 3 4 5; do
  2042                             ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/S99${name}
  2043                         done
  2044                         for i in 0 1 6; do
  2045                             ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/K00${name}
  2046                         done
  2047                     fi
  2048                 fi
  2049                 ;;
  2050             SunOS/5.* )
  2051                 if [ ! -f /etc/init.d/${name} ]; then
  2052                     #   install transfer script
  2053                     ( echo "#!/bin/sh"
  2054                       echo "##"
  2055                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2056                       echo "##"
  2057                       echo ""
  2058                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2059                       echo "case \$1 in"
  2060                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2061                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2062                       echo "esac"
  2063                     ) >/etc/init.d/${name}
  2064                     chmod 755 /etc/init.d/${name}
  2065                     #   create corresponding symbolic links
  2066                     ( cd /etc
  2067                       ln init.d/${name} rc3.d/S99${name}
  2068                       ln init.d/${name} rc0.d/K00${name}
  2069                       ln init.d/${name} rc1.d/K00${name}
  2070                     ) || exit $?
  2071                 fi
  2072                 ;;
  2073             UnixWare/* )
  2074                 if [ ! -f /etc/init.d/${name} ]; then
  2075                     #   install transfer script
  2076                     ( echo "#!/bin/sh"
  2077                       echo "##"
  2078                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2079                       echo "##"
  2080                       echo ""
  2081                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2082                       echo "case \$1 in"
  2083                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2084                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2085                       echo "esac"
  2086                     ) >/etc/init.d/${name}
  2087                     chmod 755 /etc/init.d/${name}
  2088                     #   create corresponding symbolic links
  2089                     ( cd /etc
  2090                       ln init.d/${name} rc2.d/S99${name}
  2091                       ln init.d/${name} rc0.d/K00${name}
  2092                       ln init.d/${name} rc1.d/K00${name}
  2093                     ) || exit $?
  2094                 fi
  2095                 ;;
  2096             AIX/* )
  2097                 if [ ! -f /etc/rc.d/init.d/${name} ]; then
  2098                     #   install transfer script
  2099                     ( echo "#!/bin/sh"
  2100                       echo "##"
  2101                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2102                       echo "##"
  2103                       echo ""
  2104                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2105                       echo "case \$1 in"
  2106                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2107                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2108                       echo "esac"
  2109                     ) >/etc/rc.d/init.d/${name}
  2110                     chmod 755 /etc/rc.d/init.d/${name}
  2111                     #   create corresponding symbolic links
  2112                     ( cd /etc/rc.d
  2113                       ln -s ../init.d/${name} rc2.d/S99${name}
  2114                     ) || exit $?
  2115                 fi
  2116                 ;;
  2117             OSF1/V5.* )
  2118                 if [ ! -f /sbin/init.d/${name} ]; then
  2119                     #   install transfer script
  2120                     ( echo "#!/bin/sh"
  2121                       echo "##"
  2122                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2123                       echo "##"
  2124                       echo ""
  2125                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2126                       echo "case \$1 in"
  2127                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2128                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2129                       echo "esac"
  2130                     ) >/sbin/init.d/${name}
  2131                     chmod 755 /sbin/init.d/${name}
  2132                     #   create corresponding symbolic links
  2133                     ( cd /sbin
  2134                       ln -s ../init.d/${name} rc3.d/S99${name}
  2135                       ln -s ../init.d/${name} rc0.d/K00${name}
  2136                     ) || exit $?
  2137                 fi
  2138                 ;;
  2139             HP-UX/* )
  2140                 if [ ! -f /sbin/init.d/${name} ]; then
  2141                     #   install transfer script
  2142                     ( echo "#!/bin/sh"
  2143                       echo "##"
  2144                       echo "##  ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy"
  2145                       echo "##"
  2146                       echo ""
  2147                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2148                       echo "case \$1 in"
  2149                       echo "    start ) exec ${prefix}/etc/rc all start ;;"
  2150                       echo "    stop  ) exec ${prefix}/etc/rc all stop  ;;"
  2151                       echo "esac"
  2152                     ) >/sbin/init.d/${name}
  2153                     chmod 755 /sbin/init.d/${name}
  2154                     #   create corresponding symbolic links
  2155                     ( cd /sbin
  2156                       ln -s ../init.d/${name} rc2.d/S900${name}
  2157                       ln -s ../init.d/${name} rc1.d/K100${name}
  2158                     ) || exit $?
  2159                 fi
  2160                 ;;
  2161             Darwin/* )
  2162                 darwin_rc_dir="/System/Library/StartupItems/${name}"
  2163                 if [ ! -d ${darwin_rc_dir} ]; then
  2164                     mkdir ${darwin_rc_dir}
  2165                 fi
  2167                 #   make sure hierarchy is activated in /etc/hostconfig
  2168                 #   FIXME: cs: simple and bad code here without any detection of existing entries
  2169                 echo "OPENPKG_${name}=-YES-" >>/etc/hostconfig
  2171                 #   install transfer script
  2172                 if [ ! -f ${darwin_rc_dir}/${name} ]; then
  2173                     rm -f ${darwin_rc_dir}/${name} >/dev/null 2>&1
  2174                     ( echo "#!/bin/sh"
  2175                       echo "##"
  2176                       echo "##  ${darwin_rc_dir}/${name}"
  2177                       echo "##      -- startup transfer script for OpenPKG ${prefix} hierarchy"
  2178                       echo "##"
  2179                       echo ""
  2180                       echo "[ ! -f ${prefix}/etc/rc ] && exit 0"
  2181                       echo ""
  2182                       echo ". /etc/rc.common"
  2183                       echo ""
  2184                       echo "if [ \"\${OPENPKG_${name}:=-NO-}\" = \"-YES-\" ]; then"
  2185                       echo "    ConsoleMessage \"OpenPKG ${prefix} hierarchy\""
  2186                       echo "    ${prefix}/etc/rc all start"
  2187                       echo "fi"
  2188                     ) >${darwin_rc_dir}/${name}
  2189                     chmod 755 ${darwin_rc_dir}/${name}
  2190                 fi
  2191                 #   install startup parameter list
  2192                 if [ ! -f ${darwin_rc_dir}/StartupParameters.plist ]; then
  2193                     rm -f ${darwin_rc_dir}/StartupParameters.plist >/dev/null 2>&1
  2194                     ( echo "{"
  2195                       echo "  Description     = \"OpenPKG ${prefix} hierarchy\";"
  2196                       echo "  Provides        = (\"OpenPKG ${prefix}\");"
  2197                       echo "  Requires        = (\"Disks\", \"Network Configuration\", \"Resolver\");"
  2198                       echo "  Uses            = (\"Cron\");"
  2199                       echo "  OrderPreference = \"Last\";"
  2200                       echo "  Messages ="
  2201                       echo "  {"
  2202                       echo "    start = \"Starting OpenPKG ${prefix} hierarchy\";"
  2203                       echo "    stop  = \"Stopping OpenPKG ${prefix} hierarchy\";"
  2204                       echo "  };"
  2205                       echo "}"
  2206                     ) >${darwin_rc_dir}/StartupParameters.plist
  2207                     chmod 644 ${darwin_rc_dir}/StartupParameters.plist
  2208                 fi
  2209                 ;;
  2210             IRIX*/6.* )
  2211                 if [ ! -f /etc/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/init.d/${name}
  2224                     chmod 755 /etc/init.d/${name}
  2225                     #   create corresponding links
  2226                     ( cd /etc
  2227                       ln -f init.d/${name} rc2.d/S99${name}
  2228                       ln -f init.d/${name} rc0.d/K00${name}
  2229                     ) || exit $?
  2230                 fi
  2231                 ;;
  2232         esac
  2233     fi
  2235     #   create the cron transfer entries
  2236     if [ ".$cusr" != ".root" ]; then
  2237         echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2
  2238         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2239     else
  2240         case "$plid" in
  2241             FreeBSD/* | Linux/* | Darwin/* )
  2242                 if [ -f /etc/slackware-version ]; then
  2243                     exists=`crontab -l | grep "$prefix/etc/rc"`
  2244                     if [ ".$exists" = . ]; then
  2245                         EDITOR=/tmp/vipw.$$
  2246                         VISUAL="$EDITOR"
  2247                         export EDITOR
  2248                         export VISUAL
  2249                         ( echo "#!/bin/sh"
  2250                           echo "(   echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  2251                           echo "    echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  2252                           echo "    echo \"0          0  1  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  2253                           echo "    echo \"0          0  *  *  0  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  2254                           echo "    echo \"0          0  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  2255                           echo "    echo \"0          *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  2256                           echo "    echo \"0,15,30,45 *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  2257                           echo "    echo \"# </OpenPKG>\""
  2258                           echo ") >>\$1"
  2259                         ) >$EDITOR
  2260                         chmod a+x $EDITOR
  2261                         ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2262                         rm -f $EDITOR
  2263                     fi
  2264                 else
  2265                     exists=`grep "$prefix/etc/rc" /etc/crontab`
  2266                     if [ ".$exists" = . ]; then
  2267                         ( echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  2268                           echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  2269                           echo "0    0  1  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  2270                           echo "0    0  *  *  0  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  2271                           echo "0    0  *  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  2272                           echo "0    *  *  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  2273                           echo "*/15 *  *  *  *  root  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  2274                           echo "# </OpenPKG>"
  2275                         ) >>/etc/crontab
  2276                     fi
  2277                 fi
  2278                 ;;
  2279             SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* )
  2280                 exists=`crontab -l | grep "$prefix/etc/rc"`
  2281                 if [ ".$exists" = . ]; then
  2282                     EDITOR=/tmp/vipw.$$
  2283                     VISUAL="$EDITOR"
  2284                     export EDITOR
  2285                     export VISUAL
  2286                     ( echo "#!/bin/sh"
  2287                       echo "(   echo \"# <OpenPKG prefix=$prefix pkg=openpkg>\""
  2288                       echo "    echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\""
  2289                       echo "    echo \"0          0  1  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\""
  2290                       echo "    echo \"0          0  *  *  0  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\""
  2291                       echo "    echo \"0          0  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\""
  2292                       echo "    echo \"0          *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\""
  2293                       echo "    echo \"0,15,30,45 *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\""
  2294                       echo "    echo \"# </OpenPKG>\""
  2295                       echo ") >>\$1"
  2296                     ) >$EDITOR
  2297                     chmod a+x $EDITOR
  2298                     ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2299                     rm -f $EDITOR
  2300                 fi
  2301                 ;;
  2302             IRIX*/6.* )
  2303                 exists=`crontab -l | grep "$prefix/etc/rc"`
  2304                 if [ ".$exists" = . ]; then
  2305                     ( crontab -l
  2306                       echo "# <OpenPKG prefix=$prefix pkg=openpkg>"
  2307                       echo "# chronological tasks of ${prefix} OpenPKG hierarchy"
  2308                       echo "0          0  1  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly"
  2309                       echo "0          0  *  *  0  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly"
  2310                       echo "0          0  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily"
  2311                       echo "0          *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly"
  2312                       echo "0,15,30,45 *  *  *  *  [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly"
  2313                       echo "# </OpenPKG>"
  2314                     ) | /usr/bin/crontab || exit $?
  2315                 fi
  2316                 ;;
  2317         esac
  2318     fi
  2320     #   remember what OpenPKG RPM version was installed, so we can
  2321     #   correctly upgrade the RPM database in the %post section (see below).
  2322     if [ -d ${prefix}/RPM/DB ]; then
  2323         if [ -x "${prefix}/bin/openpkg" -a -x "${prefix}/libexec/openpkg/rpm" ]; then
  2324             #   OpenPKG 2.0
  2325             rpm="${prefix}/bin/openpkg rpm"
  2326         else
  2327             #   OpenPKG 1.x
  2328             rpm="${prefix}/bin/rpm"
  2329         fi
  2330         rm -f ${prefix}/RPM/DB/.version >/dev/null 2>&1 || true
  2331         $rpm --version |\
  2332             sed -e 's;^;X;' \
  2333                 -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \
  2334                 -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \
  2335                 -e 's;^X.*$;4.0;' \
  2336                 >${prefix}/RPM/DB/.version
  2337     fi
  2339 %post
  2340     #   optional post-processing from "pre" section
  2341     if [ -f %{l_prefix}.pre-post-process.sh ]; then
  2342         sh %{l_prefix}.pre-post-process.sh
  2343         rm -f %{l_prefix}.pre-post-process.sh
  2344     fi
  2346     #   update or initially create OpenPKG UUID configuration
  2347     %{l_prefix}/bin/openpkg uuid update >/dev/null 2>&1 || true
  2349     #   determine new and old OpenPKG RPM version
  2350     V_rpm_new="%{V_rpm}"
  2351     if [ -f %{l_prefix}/RPM/DB/.version ]; then
  2352         V_rpm_old="`cat %{l_prefix}/RPM/DB/.version`"
  2353         rm -f %{l_prefix}/RPM/DB/.version >/dev/null 2>&1 || true
  2354     else
  2355         V_rpm_old="4.0"
  2356     fi
  2358     #   make sure all RPM database files are present and that their
  2359     #   attributes are correct, etc. This is not a database rebuild
  2360     #   operation, so this is fully harmless and can be done always.
  2361     %{l_prefix}/lib/openpkg/rpmdb --quiet --fixate
  2363     #   check RPM database for upgrade requirements
  2364     if [ ".$1" = .2 -a ".$V_rpm_old" != ".$V_rpm_new" ]; then
  2365         #   RPM 4.0/4.1 does not allow concurrent database access, so we
  2366         #   cannot upgrade the database immediately from here (because
  2367         #   we are still running within the execution context of the
  2368         #   old RPM which in turn has the database locked) and instead
  2369         #   have to just drop a note to the administrator about database
  2370         #   upgrading. RPM 4.2 in general allows concurrent database
  2371         #   access, but the whole stuff is too risky here, too.
  2372         ( echo "You are upgrading the OpenPKG bootstrap from a previous"
  2373           echo "RPM $V_rpm_old based version to this RPM $V_rpm_new based"
  2374           echo "version. The RPM database in %{l_prefix}/RPM/DB/ can still"
  2375           echo "be used, but it is strongly recommended to upgrade it as"
  2376           echo "soon as possible to the latest Berkeley-DB format files by"
  2377           echo "executing the command:"
  2378           echo "    \$ %{l_prefix}/bin/openpkg rpm --db-rebuild"
  2379           echo "In case of problems with the RPM database you can always"
  2380           echo "execute the command:"
  2381           echo "    \$ %{l_prefix}/bin/openpkg rpm --db-cleanup"
  2382         ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t warn
  2383     fi
  2385     #   system command overriding support
  2386     #   ATTENTION: THIS BETTER SHOULD BE REPLACED WITH A MORE GENERIC
  2387     #   BUILD COMMAND OVERRIDE SOLUTION!
  2388     if [ ! -d %{l_prefix}/lib/openpkg/override ]; then
  2389         mkdir %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2390     fi
  2391     chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2392     case "`cat %{l_prefix}/etc/openpkg/platform`" in
  2393         *-*-debian* | *-*-ubuntu* )
  2394             #   FIXME: Evil hack to workaround build problems under Debian
  2395             #   (at least 3.1) (and similar platforms) where a Debian
  2396             #   install-info(8) exists which is both API and functionally
  2397             #   incompatible to the de-facto standardized install-info(8)
  2398             #   command from GNU Texinfo.
  2399             if [ ! -f %{l_prefix}/lib/openpkg/override/install-info ]; then
  2400                 ( echo "#!/bin/sh"
  2401                   echo "echo 'OpenPKG: NOTICE: install-info(8) command execution overridden'"
  2402                   echo "exit 0"
  2403                 ) >%{l_prefix}/lib/openpkg/override/install-info
  2404                 chmod 775 %{l_prefix}/lib/openpkg/override/install-info
  2405             fi
  2406             ;;
  2407         *-*-macosx* | *-*-darwin* )
  2408             #   FIXME: Evil hack to workaround the fact that Mac OS X'
  2409             #   linker by default prefers the /usr/lib libraries and does
  2410             #   not honor the -L options the way one would expect it.
  2411             gcc="`%{l_prefix}/lib/openpkg/shtool path gcc`"
  2412             cc="`%{l_prefix}/lib/openpkg/shtool path cc`"
  2413             ld="`%{l_prefix}/lib/openpkg/shtool path ld`"
  2414             if [ ".$gcc" != . -a ! -f %{l_prefix}/lib/openpkg/override/gcc ]; then
  2415                 ( echo "#!/bin/sh"
  2416                   echo "case \" \$* \" in"
  2417                   echo "    *\" -c \"* | *\" -E \"* ) exec $gcc \"\$@\" ;;"
  2418                   echo "    * ) exec $gcc -Wl,-search_paths_first \"\$@\" ;;"
  2419                   echo "esac"
  2420                 ) >%{l_prefix}/lib/openpkg/override/gcc
  2421                 chmod 775 %{l_prefix}/lib/openpkg/override/gcc
  2422             fi
  2423             if [ ".$cc" != . -a ! -f %{l_prefix}/lib/openpkg/override/cc ]; then
  2424                 ( echo "#!/bin/sh"
  2425                   echo "case \" \$* \" in"
  2426                   echo "    *\" -c \"* | *\" -E \"* ) exec $gcc \"\$@\" ;;"
  2427                   echo "    * ) exec $cc -Wl,-search_paths_first \"\$@\" ;;"
  2428                   echo "esac"
  2429                 ) >%{l_prefix}/lib/openpkg/override/cc
  2430                 chmod 775 %{l_prefix}/lib/openpkg/override/cc
  2431             fi
  2432             if [ ".$ld" != . -a ! -f %{l_prefix}/lib/openpkg/override/ld ]; then
  2433                 ( echo "#!/bin/sh"
  2434                   echo "exec $ld -search_paths_first \"\$@\""
  2435                 ) >%{l_prefix}/lib/openpkg/override/ld
  2436                 chmod 775 %{l_prefix}/lib/openpkg/override/ld
  2437             fi
  2438             ;;
  2439     esac
  2441     #   FIXME: hack to workaround problems in environments with too few
  2442     #   development tools. ATTENTION: see one paragraph above.
  2443     if [ ! -d %{l_prefix}/lib/openpkg/fallback ]; then
  2444         mkdir %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2445     fi
  2446     chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2448     #   check for "openpkg" executable from the OpenPKG Community series
  2449     #   print license if not OSS, otherwise register with openpkg.org
  2450     community_version=`%{l_prefix}/bin/openpkg --license 2>/dev/null | \
  2451         sed -e 'q' | egrep '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*-C'`
  2452     if [ ".$community_version" = . ]; then
  2453         ( echo ""
  2454           echo "NOTICE: This OpenPKG bootstrap package is based on an \"openpkg\""
  2455           echo "executable which is covered by the following terms of use:"
  2456           echo "______________________________________________________________________________"
  2457           echo ""
  2458           %{l_prefix}/bin/openpkg --license | sed -e '1d'
  2459         ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t notice
  2460     else
  2461         %{l_prefix}/bin/openpkg register </dev/null >/dev/null 2>&1 || true
  2462     fi
  2464 %preun
  2465     [ ".$1" != .0 ] && exit 0
  2467     #   remove override files
  2468     if [ -d %{l_prefix}/lib/openpkg/override ]; then
  2469         rm -rf %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true
  2470     fi
  2472     #   remove fallback files
  2473     if [ -d %{l_prefix}/lib/openpkg/fallback ]; then
  2474         rm -rf %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true
  2475     fi
  2477     #   remove files which are not RPM controlled
  2478     rm -rf %{l_prefix}/RPM/TMP/* %{l_prefix}/RPM/TMP/.[a-z]* >/dev/null 2>&1 || true
  2479     rm -rf %{l_prefix}/RPM/SRC/* %{l_prefix}/RPM/SRC/.[a-z]* >/dev/null 2>&1 || true
  2480     rm -rf %{l_prefix}/RPM/PKG/* %{l_prefix}/RPM/PKG/.[a-z]* >/dev/null 2>&1 || true
  2481     rm -rf %{l_prefix}/RPM/DB/*  %{l_prefix}/RPM/DB/.[a-z]*  >/dev/null 2>&1 || true
  2483     #   The following code usually would be done in a %postun section.
  2484     #   But because we already had to remove the database in this %preun
  2485     #   section (see the 'rm' commands above) in order to make RPM happy
  2486     #   inside its own removal procedure, RPM would no longer find the
  2487     #   %postun script (because it's recorded in the database files). So
  2488     #   we have to perform the procedure already in this %preun script.
  2489     #   except for the removal of the top-level directory it does not
  2490     #   matter. But the top-level directory can only be removed after
  2491     #   the RPM removal procedure took place, so we play a little delay
  2492     #   trick below.
  2494     #   determine current user
  2495     cusr=`(id -un) 2>/dev/null ||\
  2496           (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
  2497           (whoami) 2>/dev/null ||\
  2498           (who am i | cut "-d " -f1) 2>/dev/null ||\
  2499           echo $LOGNAME`
  2501     #   determine runtime details (for both inside and outside RPM!!)
  2502     user="%{l_musr}"
  2503     group="%{l_mgrp}"
  2504     prefix="%{l_prefix}"
  2505     prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
  2507     #   determine platform id
  2508     s=`(uname -s) 2>/dev/null` || s='Unknown'
  2509     r=`(uname -r) 2>/dev/null` || r='0.0'
  2510     plid="${s}/${r}"
  2512     #   unregister instance in presence file
  2513     presence="/etc/openpkg"
  2514     exists=`cat $presence 2>/dev/null | egrep "^ *${prefix} *\$"`
  2515     if [ ".$exists" != . ]; then
  2516         if [ ".$cusr" != ".root" ]; then
  2517             echo "openpkg:WARNING: skipping unregistering of $prefix in $presence" 1>&2
  2518             echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2519         else
  2520             cp $presence $presence.bak && \
  2521             egrep -v "^ *${prefix} *\$" $presence.bak >$presence
  2522             rm -f $presence.bak >/dev/null 2>&1
  2523             if [ ".`cat $presence`" = . ]; then
  2524                 rm -f $presence >/dev/null 2>&1
  2525             fi
  2526         fi
  2527     fi
  2529     #   remove entry in /etc/shells
  2530     shell="${prefix}/lib/openpkg/bash"
  2531     exists=`cat /etc/shells 2>/dev/null | grep "^$shell"`
  2532     if [ ".$exists" != . ]; then
  2533         if [ ".$cusr" != ".root" ]; then
  2534             echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2
  2535             echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2536         else
  2537             cp /etc/shells /etc/shells.bak && \
  2538             grep -v "^${shell}" /etc/shells.bak >/etc/shells
  2539             rm -f /etc/shells.bak >/dev/null 2>&1
  2540         fi
  2541     fi
  2543     #   remove the hierarchy user/group
  2544     for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \
  2545                "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \
  2546                "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \
  2547                "non-privileged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do
  2548         #   split request into class/usr/uid/grp/gid
  2549         OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS"
  2550         class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5"
  2552         #   check whether user already exists
  2553         exists=`(getent passwd "$usr"; \
  2554                  grep "^$usr:" /etc/passwd; \
  2555                  ypmatch "$usr" passwd; \
  2556                  nismatch "$usr" passwd; \
  2557                  nidump passwd . | grep "^$usr:") 2>/dev/null | \
  2558                  sed -e 'q'`
  2559         if [ ".$exists" != . ]; then
  2560             if [ ".$cusr" != ".root" ]; then
  2561                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  2562                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2563             elif [ ".$usr" = ".root" ]; then
  2564                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2
  2565                 echo "openpkg:WARNING: (would remove system standard user)" 1>&2
  2566             else
  2567                 case "$plid" in
  2568                     FreeBSD/* | NetBSD/* )
  2569                         cp /etc/master.passwd /etc/master.passwd.bak && \
  2570                         grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd
  2571                         ( PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd ) || exit $?
  2572                         rm -f /etc/master.passwd.bak >/dev/null 2>&1
  2573                         ;;
  2574                     Linux/* | SunOS/5.* | UnixWare/* )
  2575                         cp /etc/passwd /etc/passwd.bak && \
  2576                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2577                         ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $?
  2578                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2579                         ;;
  2580                     AIX/* )
  2581                         rmuser -p "${usr}"
  2582                         cp /etc/security/login.cfg /etc/security/login.cfg.bak && \
  2583                         sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\),$shell\\(.*\\)\$;\\1\\2;" \
  2584                             </etc/security/login.cfg.bak >/etc/security/login.cfg && \
  2585                         rm -f /etc/security/login.cfg.bak >/dev/null 2>&1
  2586                         ;;
  2587                     OSF1/V5.* )
  2588                         cp /etc/passwd /etc/passwd.bak && \
  2589                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2590                         ( PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd ) || exit $?
  2591                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2592                         ;;
  2593                     HP-UX/* )
  2594                         cp /etc/passwd /etc/passwd.bak && \
  2595                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2596                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2597                         ;;
  2598                     Darwin/* )
  2599                         niutil -destroy . "/users/${usr}"
  2600                         ;;
  2601                     IRIX*/6.* )
  2602                         cp /etc/passwd /etc/passwd.bak && \
  2603                         grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd
  2604                         if   [ -f /etc/shadow ]
  2605                         then ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $?
  2606                         fi
  2607                         rm -f /etc/passwd.bak >/dev/null 2>&1
  2608                         ;;
  2609                 esac
  2610             fi
  2611         fi
  2613         #   check whether group already exists
  2614         exists=`(getent group "$grp"; \
  2615                 grep "^$grp:" /etc/group; \
  2616                 ypmatch "$grp" group; \
  2617                 nismatch "$grp" group; \
  2618                 nidump group . | grep "^$grp:") 2>/dev/null | \
  2619                 sed -e 'q'`
  2620         if [ ".$exists" != . ]; then
  2621             if [ ".$cusr" != ".root" ]; then
  2622                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  2623                 echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2624             elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then
  2625                 echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2
  2626                 echo "openpkg:WARNING: (would remove system standard group)" 1>&2
  2627             else
  2628                 case "$plid" in
  2629                     Darwin/* )
  2630                         niutil -destroy . "/groups/${grp}"
  2631                         ;;
  2632                     AIX/* )
  2633                         rmgroup "${grp}"
  2634                         ;;
  2635                     * )
  2636                         cp /etc/group /etc/group.bak && \
  2637                         grep -v "^${grp}:" /etc/group.bak >/etc/group
  2638                         rm -f /etc/group.bak >/dev/null 2>&1
  2639                         ;;
  2640                 esac
  2641             fi
  2642         fi
  2643     done
  2645     #   invalidate passwd and group tables from Name Service Cache Daemon to
  2646     #   ensure chown/chgrp works immediately after pwconv on Linux and Solaris
  2647     if [ -x /usr/sbin/nscd ]; then
  2648         /usr/sbin/nscd -i passwd >/dev/null 2>&1 || true
  2649         /usr/sbin/nscd -i group >/dev/null 2>&1 || true
  2650     fi
  2652     #   remove the startup/shutdown transfer scripts
  2653     name=`echo "$prefix" | sed -e 's;/;;g'`
  2654     if [ ".$cusr" != ".root" ]; then
  2655         echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2
  2656         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2657     else
  2658         case "$plid" in
  2659             FreeBSD/* )
  2660                 rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1
  2661                 ;;
  2662             NetBSD/* )
  2663                 rm -f /etc/rc.d/${name} >/dev/null 2>&1
  2664                 ;;
  2665             Linux/* )
  2666                 if [ -f /etc/gentoo-release ]; then
  2667                     /sbin/rc-update del openpkg-${name} >/dev/null 2>&1
  2668                     rm -f /etc/init.d/openpkg-${name}   >/dev/null 2>&1
  2669                 else
  2670                     #   sroot: script root directory
  2671                     #   lroot: link   root directory
  2672                     if [ -f /etc/debian_version ]; then
  2673                         sroot=/etc/init.d
  2674                         lroot=/etc/rc%d.d
  2675                     elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then
  2676                         sroot=/etc/rc.d/init.d
  2677                         lroot=/etc/rc.d/rc%d.d
  2678                     elif [ -f /etc/SuSE-release ]; then
  2679                         sroot=/etc/init.d
  2680                         lroot=/etc/init.d/rc%d.d
  2681                     elif [ -f /etc/slackware-version ]; then
  2682                         sroot=/etc/rc.d
  2683                         lroot=/etc/rc.d/rc%d.d
  2684                         name="rc.${name}"
  2685                     else
  2686                         echo "WARNING: you are not running one of the supported standard" 1>&2
  2687                         echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)."   1>&2
  2688                         echo "WARNING: Guessing the location of the system init scripts!" 1>&2
  2689                         sroot=""
  2690                         lroot=""
  2691                         for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do
  2692                             if [ -d $sr ]; then
  2693                                 sroot="$sr"
  2694                                 break
  2695                             fi
  2696                         done
  2697                         for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do
  2698                             if [ -d $lr ]; then
  2699                                 lroot="`echo $lr | sed -e 's;2;%d;'`"
  2700                                 break
  2701                             fi
  2702                         done
  2703                         if [ ".$sroot" = . -o ".$lroot" = . ]; then
  2704                             echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2
  2705                             exit 1
  2706                         fi
  2707                     fi
  2708                     rm -f ${sroot}/${name} >/dev/null 2>&1
  2709                     for i in 2 3 4 5; do
  2710                         rm -f `echo $lroot | sed -e "s;%d;$i;"`/S99${name} >/dev/null 2>&1
  2711                     done
  2712                     for i in 0 1 6; do
  2713                         rm -f `echo $lroot | sed -e "s;%d;$i;"`/K00${name} >/dev/null 2>&1
  2714                     done
  2715                     if [ -f /etc/slackware-version ]; then
  2716                         for i in 0 1 2 3 4 5 6; do
  2717                             l=`echo $lroot | sed -e "s;%d;$i;"`
  2718                             if [ -d $l ]; then
  2719                                 rmdir $l >/dev/null 2>&1 || true
  2720                             fi
  2721                         done
  2722                     fi
  2723                 fi
  2724                 ;;
  2725             SunOS/5.* )
  2726                 rm -f /etc/init.d/${name} >/dev/null 2>&1
  2727                 rm -f /etc/rc3.d/S99${name} >/dev/null 2>&1
  2728                 rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2729                 rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  2730                 ;;
  2731             UnixWare/* )
  2732                 rm -f /etc/init.d/${name} >/dev/null 2>&1
  2733                 rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1
  2734                 rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2735                 rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1
  2736                 ;;
  2737             AIX/* )
  2738                 rm -f /etc/rc.d/init.d/${name} >/dev/null 2>&1
  2739                 rm -f /etc/rc.d/rc2.d/S99${name} >/dev/null 2>&1
  2740                 ;;
  2741             OSF1/V5.* )
  2742                 rm -f /sbin/init.d/${name} >/dev/null 2>&1
  2743                 rm -f /sbin/rc3.d/S99${name} >/dev/null 2>&1
  2744                 rm -f /sbin/rc0.d/K00${name} >/dev/null 2>&1
  2745                 ;;
  2746             HP-UX/* )
  2747                 rm -f /sbin/init.d/${name} >/dev/null 2>&1
  2748                 rm -f /etc/rc2.d/S900${name} >/dev/null 2>&1
  2749                 rm -f /etc/rc1.d/K100${name} >/dev/null 2>&1
  2750                 ;;
  2751             Darwin/* )
  2752                 cp /etc/hostconfig /etc/hostconfig.bak && \
  2753                 grep -v "^OPENPKG_${name}=" /etc/hostconfig.bak >/etc/hostconfig
  2754                 rm -f /etc/hostconfig.bak >/dev/null 2>&1
  2755                 rm -rf /System/Library/StartupItems/${name} >/dev/null 2>&1
  2756                 ;;
  2757             IRIX*/6.* )
  2758                 rm -f /etc/init.d/${name} >/dev/null 2>&1
  2759                 rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1
  2760                 rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1
  2761                 ;;
  2762         esac
  2763     fi
  2765     #   remove the cron transfer entries
  2766     if [ ".$cusr" != ".root" ]; then
  2767         echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2
  2768         echo "openpkg:WARNING: (would require root-privileges)" 1>&2
  2769     else
  2770         case "$plid" in
  2771             FreeBSD/* | Linux/* | Darwin/* )
  2772                 if [ -f /etc/slackware-version ]; then
  2773                     EDITOR=/tmp/vipw.$$
  2774                     VISUAL="$EDITOR"
  2775                     export EDITOR
  2776                     export VISUAL
  2777                     p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  2778                     ( echo "cp \$1 \$1.bak"
  2779                       echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  2780                       echo "rm -f \$1.bak"
  2781                     ) >$EDITOR
  2782                     chmod a+x $EDITOR
  2783                     ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2784                     rm -f $EDITOR
  2785                 else
  2786                     exists=`grep "<OpenPKG prefix=$prefix pkg=openpkg>" /etc/crontab`
  2787                     if [ ".$exists" != . ]; then
  2788                         p=`echo $prefix | sed -e 's;/;\\\\/;g'`
  2789                         cp /etc/crontab /etc/crontab.bak
  2790                         cat /etc/crontab.bak |\
  2791                         sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\\/OpenPKG>/d" \
  2792                         >/etc/crontab
  2793                         rm -f /etc/crontab.bak >/dev/null 2>&1
  2794                     fi
  2795                 fi
  2796                 ;;
  2797             SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* )
  2798                 EDITOR=/tmp/vipw.$$
  2799                 VISUAL="$EDITOR"
  2800                 export EDITOR
  2801                 export VISUAL
  2802                 p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'`
  2803                 ( echo "cp \$1 \$1.bak"
  2804                   echo "cat \$1.bak | sed -e \"/<OpenPKG prefix=$p pkg=openpkg>/,/<\\\\/OpenPKG>/d\" >\$1"
  2805                   echo "rm -f \$1.bak"
  2806                 ) >$EDITOR
  2807                 chmod a+x $EDITOR
  2808                 ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $?
  2809                 rm -f $EDITOR
  2810                 ;;
  2811             IRIX*/6.* )
  2812                 p=`echo $prefix | sed -e 's;/;\\\\\\/;g'`
  2813                 ( crontab -l |
  2814                   sed -e "/<OpenPKG prefix=$p pkg=openpkg>/,/<\/OpenPKG>/d"
  2815                 ) | /usr/bin/crontab || exit $?
  2816                 ;;
  2817         esac
  2818     fi
  2820     #   delayed removal of top-level directory.
  2821     ( sleep 2
  2822       rm -rf %{l_prefix}/RPM/DB/* %{l_prefix}/RPM/DB/.[a-z]* >/dev/null 2>&1 || true
  2823       rmdir %{l_prefix}/RPM/DB >/dev/null 2>&1 || true
  2824       rmdir %{l_prefix}/RPM >/dev/null 2>&1 || true
  2825       rmdir %{l_prefix} >/dev/null 2>&1 || true
  2826     ) </dev/null >/dev/null 2>/dev/null &

mercurial