openpkg/openpkg.spec

Sun, 29 May 2011 17:12:08 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sun, 29 May 2011 17:12:08 +0200
changeset 345
b7180006bcf1
parent 333
4ecfc2416fd8
child 346
c403d9dd5e0e
permissions
-rw-r--r--

Correct buildconf in embedded miniperl and correct bootstrap script line wrap error.

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

mercurial