diff -r 333964c621f1 -r cb59d6afeb61 openpkg/openpkg.spec --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openpkg/openpkg.spec Tue Jan 06 23:40:39 2009 +0100 @@ -0,0 +1,2827 @@ +## +## openpkg.spec -- OpenPKG RPM Package Specification +## Copyright (c) 2000-2007 OpenPKG Foundation e.V. +## Copyright (c) 2000-2007 Ralf S. Engelschall +## +## Permission to use, copy, modify, and distribute this software for +## any purpose with or without fee is hereby granted, provided that +## the above copyright notice and this permission notice appear in all +## copies. +## +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +## SUCH DAMAGE. +## + +# NOTICE: This OpenPKG RPM specification is _very_ special, because +# it is used both for bootstrapping OpenPKG with its OpenPKG RPM and +# for regular builds of OpenPKG RPM in order to upgrade an existing +# installation. For this it has to interact correctly with the +# "openpkg.boot" script. See the documentation in the file "README" +# and the source of the companion script "openpkg.boot" for details, +# but do not touch anything here until you are 100% sure about what +# you are doing. In short: This script is allowed to use only a very +# restricted subset of the OpenPKG RPM functionality! + +# BUILD REQUIREMENTS: +# o any sh(1) +# o any tar(1) +# o any make(1) +# o any cc(1) + +# the package version/release +%define V_openpkg 20071227 + +# the used software versions +%define V_rpm 4.2.1 +%define V_zlib 1.2.3 +%define V_bzip2 1.0.4 +%define V_beecrypt 4.1.2 +%define V_curl 7.17.1 +%define V_make 3.81 +%define V_gzip 1.3.12 +%define V_gzip_r 1.13 +%define V_patch 2.5.9 +%define V_tar 1.19 +%define V_bash 3.2 +%define V_uuid 1.6.0 +%define V_config 20060923 +%define V_registry 1.1.3 +%define V_perl 5.10.0 +%define V_openssl 0.9.8g +%define V_tools 1.4.5 +%define V_exec 2.0.1-C + +# package information +Name: openpkg +Summary: OpenPKG Bootstrap +URL: http://www.openpkg.org/ +Vendor: OpenPKG +Packager: OpenPKG Foundation e.V. +Distribution: OpenPKG Community +Class: CORE +Group: Bootstrapping +License: MIT/BSD/LGPL/GPL +Version: %{V_openpkg} +Release: %{V_openpkg} + +# list of sources +Source0: ftp://alpha.gnu.org/gnu/patch/patch-%{V_patch}.tar.gz +Source1: ftp://ftp.cwru.edu/pub/bash/bash-%{V_bash}.tar.gz +Source2: ftp://ftp.gnu.org/gnu/make/make-%{V_make}.tar.gz +Source3: ftp://ftp.gnu.org/gnu/tar/tar-%{V_tar}.tar.gz +Source4: ftp://ftp.openpkg.org/sources/CPY/config/config-%{V_config}.tar.gz +Source5: ftp://ftp.openpkg.org/sources/CPY/openpkg-registry/openpkg-registry-%{V_registry}.tar.gz +Source6: ftp://ftp.openpkg.org/sources/CPY/openpkg-tools/openpkg-tools-%{V_tools}.tar.gz +Source7: ftp://ftp.openpkg.org/sources/CPY/openpkg/gzip-%{V_gzip}-openpkg-r%{V_gzip_r}.tar +Source8: ftp://ftp.openpkg.org/sources/CPY/openpkg/gzip-%{V_gzip}.tar +Source9: ftp://ftp.openpkg.org/sources/CPY/openpkg/openpkg-executable-%{V_exec}.tar.gz +Source10: ftp://ftp.openpkg.org/sources/CPY/openpkg/rpm-%{V_rpm}.tar.gz +Source11: ftp://ftp.openpkg.org/sources/CPY/perl/perl-%{V_perl}-mini.tar.gz +Source12: ftp://ftp.openssl.org/source/openssl-%{V_openssl}.tar.gz +Source13: ftp://ftp.ossp.org/pkg/lib/uuid/uuid-%{V_uuid}.tar.gz +Source14: http://curl.haxx.se/download/curl-%{V_curl}.tar.gz +Source15: http://switch.dl.sourceforge.net/beecrypt/beecrypt-%{V_beecrypt}.tar.gz +Source16: http://www.bzip.org/%{V_bzip2}/bzip2-%{V_bzip2}.tar.gz +Source17: http://www.zlib.net/zlib-%{V_zlib}.tar.gz +Source100: bash.patch +Source101: beecrypt.patch +Source102: make.patch +Source103: openssl.patch +Source104: perl.patch +Source105: tar.patch +Source106: rpm.patch.bugfix +Source107: rpm.patch.feature +Source108: rpm.patch.porting +Source109: rpm.patch.regen +Source200: HISTORY +Source201: README +Source202: aux.prereq.sh +Source203: aux.usrgrp.sh +Source204: aux.wrapbin.sh +Source205: aux.wrapsrc.sh +Source206: dot.bash_login +Source207: dot.bashrc +Source208: dot.lsyncrc +Source209: install.sh +Source210: local.README +Source211: lsync +Source212: lsync.8 +Source213: lsync.pod +Source214: man.sh +Source215: openpkg.1 +Source216: openpkg.boot +Source217: openpkg.com.pgp +Source218: openpkg.net.pgp +Source219: openpkg.org.pgp +Source220: openpkg.pod +Source221: openpkg.sh +Source222: pod2man.sh +Source223: rc +Source224: rc.8 +Source225: rc.conf +Source226: rc.func +Source227: rc.openpkg +Source228: rc.pod +Source229: release.8 +Source230: release.pod +Source231: release.sh +Source232: root.README +Source233: rpm-config.8 +Source234: rpm-config.pod +Source235: rpm-config.sh +Source236: rpmdb +Source237: rpmtool +Source238: rpmtool.8 +Source239: rpmtool.pod +Source240: shtool +Source241: uuid.8 +Source242: uuid.pod +Source243: uuid.sh +Source244: rpmmacros +Source245: rpmpopt +Source246: rpmrc + +# build information +Prefix: %{l_prefix} +BuildRoot: %{l_buildroot} +AutoReq: no +AutoReqProv: no +Provides: OpenPKG + +%description + This is the bootstrap package for the RPM-based Unix Software + Package Hierarchy OpenPKG. The RPM Package Manager (RPM) is a + sophisticated and portable package manager for Unix platforms, + which supports automated building, installation, management and + deinstallation of Unix software. RPM was originally designed and + implemented for the RedHat Linux operating system where it manages + every file on the whole system. OpenPKG uses RPM only for managing + the files in a particular filesystem hierarchy dedicated to the + installation of third-party software packages provided by the + OpenPKG project. + + The OpenPKG bootstrap package includes the following software: + RPM %{V_rpm}, ZLib %{V_zlib}, GNU Bzip2 %{V_bzip2}, + GNU Gzip %{V_gzip}, GNU Tar %{V_tar}, GNU Patch %{V_patch}, + GNU Make %{V_make}, GNU Bash %{V_bash}, cURL %{V_curl}, + OSSP uuid %{V_uuid}, BeeCrypt %{V_beecrypt}, + OpenSSL %{V_openssl}, Perl %{V_perl} + +%track + prog openpkg:bash = { + version = %{V_bash} + url = ftp://ftp.cwru.edu/pub/bash/ + regex = bash-(__VER__)\.tar\.gz + } + prog openpkg:bzip2 = { + version = %{V_bzip2} + url = http://www.bzip.org/downloads.html + regex = bzip2-(__VER__)\.tar\.gz + } + prog openpkg:curl = { + version = %{V_curl} + url = http://curl.haxx.se/download/ + regex = curl-(__VER__)\.tar\.gz + } + prog openpkg:gzip = { + comment = "rse: intentionally tracked at gnu.org, although fetched from openpkg.org because of uncompression" + version = %{V_gzip} + url = ftp://ftp.gnu.org/gnu/gzip/ + regex = gzip-(__VER__)\.tar(\.gz)? + } + prog openpkg:gzip_r = { + version = %{V_gzip_r} + url = ftp://ftp.openpkg.org/sources/CPY/openpkg/ + regex = gzip-%{V_gzip}-openpkg-r(__VER__)\.tar + } + prog openpkg:make = { + version = %{V_make} + url = ftp://ftp.gnu.org/gnu/make/ + regex = make-(__VER__)\.tar\.gz + } + prog openpkg:patch = { + disabled + comment = "rse: directory missing after GNU.org security issues" + version = %{V_patch} + url = ftp://alpha.gnu.org/gnu/patch/ + regex = patch-(__VER__)\.tar\.gz + } + prog openpkg:rpm = { + disabled + comment = "rse: we have a .src.rpm extracted .tar.gz, because there is still no tarball for 4.2.1" + version = %{V_rpm} + url = ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.2.x/ + regex = rpm-(4\.2\.\d+)\.tar\.gz + } + prog openpkg:tar = { + version = %{V_tar} + url = ftp://ftp.gnu.org/gnu/tar/ + regex = tar-(__VER__)\.tar\.gz + } + prog openpkg:zlib = { + version = %{V_zlib} + url = http://www.zlib.net/ + regex = zlib-(__VER__)\.tar\.gz + } + prog openpkg:uuid = { + version = %{V_uuid} + url = ftp://ftp.ossp.org/pkg/lib/uuid/ + regex = uuid-(__VER__)\.tar\.gz + } + prog openpkg:config = { + version = %{V_config} + url = ftp://ftp.openpkg.org/sources/CPY/config/ + regex = config-(__VER__)\.tar\.gz + } + prog openpkg:beecrypt = { + version = %{V_beecrypt} + url = http://prdownloads.sourceforge.net/beecrypt/ + regex = beecrypt-(__VER__)\.tar\.gz + } + prog openpkg:registry = { + version = %{V_registry} + url = ftp://ftp.openpkg.org/sources/CPY/openpkg-registry/ + regex = openpkg-registry-(__VER__)\.tar\.gz + } + prog openpkg:perl = { + version = %{V_perl} + url = ftp://ftp.openpkg.org/sources/CPY/perl/ + regex = perl-(__VER__)-mini\.tar\.gz + } + prog openpkg:openssl = { + version = %{V_openssl} + url = ftp://ftp.openssl.org/source/ + regex = openssl-(\d+\.\d+\.\d+[a-z]?)\.tar\.gz + } + prog openpkg:openpkg-tools = { + version = %{V_tools} + url = ftp://ftp.openpkg.org/sources/CPY/openpkg-tools/ + regex = openpkg-tools-(__VER__)\.tar\.gz + } + prog openpkg:openpkg-executable = { + version = %{V_exec} + url = ftp://ftp.openpkg.org/sources/CPY/openpkg/ + regex = openpkg-executable-(__VER__-C)\.tar\.gz + } + +%prep + # skip in bootstrap phase 2 (see openpkg.boot) + [ ".$OPENPKG_BOOT" = .1 ] && exit 0 + + # switch into a temporary build area + rm -rf openpkg-%{version} + mkdir openpkg-%{version} + cd openpkg-%{version} + rm -f .buildenv + touch .buildenv + + # provide a bootstrap alternative to %{SOURCE xxx} because else + # it is not possible to upgrade a newer OpenPKG RPM with an older + # OpenPKG RPM. + echo >>.buildenv 'SOURCE () {' + echo >>.buildenv ' if [ -f "%{_specdir}/$1" ]; then' + echo >>.buildenv ' echo "%{_specdir}/$1"' + echo >>.buildenv ' else' + echo >>.buildenv ' echo "%{_sourcedir}/$1"' + echo >>.buildenv ' fi' + echo >>.buildenv '}' + echo >>.buildenv 'VERBOSE () {' + echo >>.buildenv ' if [ -f "%{_specdir}/rpmtool" ]; then' + echo >>.buildenv ' echo "$*" | sh %{_specdir}/rpmtool msg' + echo >>.buildenv ' else' + echo >>.buildenv ' echo "$*" | sh %{_sourcedir}/rpmtool msg' + echo >>.buildenv ' fi' + echo >>.buildenv '}' + . ./.buildenv + + # display verbosity header + set +x; VERBOSE "PREPARATION: Determine Build Tool Paths"; set -x + + # determine path to shtool + shtool=`SOURCE shtool` + echo "shtool=$shtool" >>./.buildenv + + # determine development tools + # - bootstrapping: %{l_xxx} is set via sed(1) + # - upgrading new: %{l_xxx} is set via rpmmacros + # - upgrading old: %{l_xxx} is not set at all + + # manually make sure tar(1) is available + l_tar=""; export l_tar + [ ".%{?l_tar:set}" = .set ] && l_tar="%{l_tar}" + [ ".%{?use_tar:set}" = .set ] && l_tar="%{use_tar}" + if [ ".$l_tar" = . ]; then + l_tar=`sh $shtool path gtar tar` + if [ ".$l_tar" = . ]; then + echo "openpkg: prerequisite tool \`gtar' or \`tar' not found" + exit 1 + fi + fi + echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv + + # manually make sure make(1) is available + l_make=""; export l_make + [ ".%{?l_make:set}" = .set ] && l_make="%{l_make}" + [ ".%{?use_make:set}" = .set ] && l_make="%{use_make}" + if [ ".$l_make" = . ]; then + l_make=`sh $shtool path gmake make` + if [ ".$l_make" = . ]; then + echo "openpkg: prerequisite tool \`gmake' or \`make' not found" + exit 1 + fi + fi + echo "l_make=\"$l_make\"; export l_make" >>.buildenv + + # manually make sure cc(1) is available + l_cc=""; export l_cc + [ ".%{?l_cc:set}" = .set ] && l_cc="%{l_cc}" + [ ".%{?use_cc:set}" = .set ] && l_cc="%{use_cc}" + if [ ".$l_cc" = . ]; then + l_cc=`sh $shtool path gcc cc` + if [ ".$l_cc" = . ]; then + echo "openpkg: prerequisite tool \`gcc' or \`cc' not found" + exit 1 + fi + fi + echo "l_cc=\"$l_cc\"; export l_cc" >>.buildenv + + # manually make sure ar(1) is available + l_ar=""; export l_ar + [ ".%{?l_ar:set}" = .set ] && l_ar="%{l_ar}" + [ ".%{?use_ar:set}" = .set ] && l_ar="%{use_ar}" + if [ ".$l_ar" = . ]; then + l_ar=`sh $shtool path ar` + if [ ".$l_ar" = . ]; then + echo "openpkg: prerequisite tool \`ar' not found" + exit 1 + fi + fi + echo "l_ar=\"$l_ar\"; export l_ar" >>.buildenv + + # manually make sure ld(1) is available + l_ld=""; export l_ld + [ ".%{?l_ld:set}" = .set ] && l_ld="%{l_ld}" + [ ".%{?use_ld:set}" = .set ] && l_ld="%{use_ld}" + if [ ".$l_ld" = . ]; then + l_ld=`sh $shtool path ld` + if [ ".$l_ld" = . ]; then + echo "openpkg: prerequisite tool \`ld' not found" + exit 1 + fi + fi + echo "l_ld=\"$l_ld\"; export l_ld" >>.buildenv + + # manually make sure as(1) is available + l_as=""; export l_as + [ ".%{?l_as:set}" = .set ] && l_as="%{l_as}" + [ ".%{?use_as:set}" = .set ] && l_as="%{use_as}" + if [ ".$l_as" = . ]; then + l_as=`sh $shtool path as` + if [ ".$l_as" = . ]; then + echo "openpkg: prerequisite tool \`as' not found" + exit 1 + fi + fi + echo "l_as=\"$l_as\"; export l_as" >>.buildenv + + # manually make sure strip(1) is available or use a null replacement + l_strip=""; export l_strip + [ ".%{?l_strip:set}" = .set ] && l_strip="%{l_strip}" + [ ".%{?use_strip:set}" = .set ] && l_strip="%{use_strip}" + if [ ".$l_strip" = . ]; then + l_strip=`sh $shtool path strip ls` + if [ ".$l_strip" = . ]; then + echo "openpkg: prerequisite tool \`strip' not found" + exit 1 + fi + fi + echo "l_strip=\"$l_strip\"; export l_strip" >>.buildenv + + # determine path to aux.usrgrp.sh script + usrgrp=`SOURCE aux.usrgrp.sh` + echo "usrgrp=$usrgrp; export usrgrp" >>./.buildenv + + # display verbosity header + set +x; VERBOSE "PREPARATION: Determine OpenPKG User/Group Name/Id Pairs"; set -x + + # determine user/group name/id pairs + # - bootstrapping: %{l_[smrn]{usr,grp}} is set via sed(1) + # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros + # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all + susr=""; [ ".%{?l_susr:set}" = .set ] && susr="%{l_susr}" + sgrp=""; [ ".%{?l_sgrp:set}" = .set ] && sgrp="%{l_sgrp}" + musr=""; [ ".%{?l_musr:set}" = .set ] && musr="%{l_musr}" + mgrp=""; [ ".%{?l_mgrp:set}" = .set ] && mgrp="%{l_mgrp}" + rusr=""; [ ".%{?l_rusr:set}" = .set ] && rusr="%{l_rusr}" + rgrp=""; [ ".%{?l_rgrp:set}" = .set ] && rgrp="%{l_rgrp}" + nusr=""; [ ".%{?l_nusr:set}" = .set ] && nusr="%{l_nusr}" + ngrp=""; [ ".%{?l_ngrp:set}" = .set ] && ngrp="%{l_ngrp}" + # corresponding ids + suid=""; [ ".%{?l_suid:set}" = .set ] && suid="%{l_suid}" + sgid=""; [ ".%{?l_sgid:set}" = .set ] && sgid="%{l_sgid}" + muid=""; [ ".%{?l_muid:set}" = .set ] && muid="%{l_muid}" + mgid=""; [ ".%{?l_mgid:set}" = .set ] && mgid="%{l_mgid}" + ruid=""; [ ".%{?l_ruid:set}" = .set ] && ruid="%{l_ruid}" + rgid=""; [ ".%{?l_rgid:set}" = .set ] && rgid="%{l_rgid}" + nuid=""; [ ".%{?l_nuid:set}" = .set ] && nuid="%{l_nuid}" + ngid=""; [ ".%{?l_ngid:set}" = .set ] && ngid="%{l_ngid}" + # compat: + usr=""; [ ".%{?l_fsusr:set}" = .set ] && usr="%{l_fsusr}" + grp=""; [ ".%{?l_fsgrp:set}" = .set ] && grp="%{l_fsgrp}" + eval `sh $usrgrp \ + --usr="$usr" --grp="$grp" \ + --susr="$susr" --sgrp="$sgrp" \ + --musr="$musr" --mgrp="$mgrp" \ + --rusr="$rusr" --rgrp="$rgrp" \ + --nusr="$nusr" --ngrp="$ngrp" \ + --suid="$suid" --sgid="$sgid" \ + --muid="$muid" --mgid="$mgid" \ + --ruid="$ruid" --rgid="$rgid" \ + --nuid="$nuid" --ngid="$ngid"` + echo "susr=\"$susr\"; export susr" >>.buildenv + echo "sgrp=\"$sgrp\"; export sgrp" >>.buildenv + echo "musr=\"$musr\"; export musr" >>.buildenv + echo "mgrp=\"$mgrp\"; export mgrp" >>.buildenv + echo "rusr=\"$rusr\"; export rusr" >>.buildenv + echo "rgrp=\"$rgrp\"; export rgrp" >>.buildenv + echo "nusr=\"$nusr\"; export nusr" >>.buildenv + echo "ngrp=\"$ngrp\"; export ngrp" >>.buildenv + echo "suid=\"$suid\"; export suid" >>.buildenv + echo "sgid=\"$sgid\"; export sgid" >>.buildenv + echo "muid=\"$muid\"; export muid" >>.buildenv + echo "mgid=\"$mgid\"; export mgid" >>.buildenv + echo "ruid=\"$ruid\"; export ruid" >>.buildenv + echo "rgid=\"$rgid\"; export rgid" >>.buildenv + echo "nuid=\"$nuid\"; export nuid" >>.buildenv + echo "ngid=\"$ngid\"; export ngid" >>.buildenv + + # display verbosity header + set +x; VERBOSE "PREPARATION: Determine OpenPKG Instance Environment"; set -x + + # determine installation location id + if [ ".%{?l_tag_fmt:set}" = .set ]; then + tag="%{l_tag_fmt}" + else + tag="" + fi + echo "tag=\"$tag\"; export tag" >>.buildenv + + # determine platform id + s=`(uname -s) 2>/dev/null` || s='Unknown' + r=`(uname -r) 2>/dev/null` || r='0.0' + plid="${s}/${r}" + echo "plid=\"$plid\"; export plid" >>.buildenv + + # determine platform-specific build environment + case $plid in + FreeBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + NetBSD/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + Linux/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + SunOS/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;; + UnixWare/*) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;; + AIX/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin" ;; + Darwin/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + OSF1/V5.* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + HP-UX/* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + IRIX*/6.* ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + * ) l_build_path="/bin:/sbin:/usr/bin:/usr/sbin" ;; + esac + case $plid in + FreeBSD/* ) l_build_ldlp="/lib:/usr/lib" ;; + NetBSD/* ) l_build_ldlp="/lib:/usr/lib" ;; + Linux/* ) l_build_ldlp="/lib:/usr/lib" ;; + SunOS/* ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;; + UnixWare/*) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;; + AIX/* ) l_build_ldlp="/usr/lib:/usr/ccs/lib" ;; + Darwin/* ) l_build_ldlp="/usr/lib" ;; + OSF1/V5.* ) l_build_ldlp="/usr/lib" ;; + HP-UX/* ) l_build_ldlp="/usr/lib" ;; + IRIX*/6.* ) l_build_ldlp="/usr/lib" ;; + * ) l_build_ldlp="/usr/lib" ;; + esac + case $plid in + * ) l_build_ulim=":" ;; + esac + echo "l_build_path=\"$l_build_path\"; export l_build_path" >>.buildenv + echo "l_build_ldlp=\"$l_build_ldlp\"; export l_build_ldlp" >>.buildenv + echo "l_build_ulim=\"$l_build_ulim\"; export l_build_ulim" >>.buildenv + + # display verbosity header + set +x; VERBOSE "PREPARATION: Build GNU gzip (Compression Tool)"; set -x + + # bootstrap GNU zip tool + ${l_tar} xf `SOURCE gzip-%{V_gzip}.tar` 2>/dev/null || true + ${l_tar} xf `SOURCE gzip-%{V_gzip}-openpkg-r%{V_gzip_r}.tar` 2>/dev/null || true + ( cd gzip-%{V_gzip} + echo "ac_cv_prog_cc_g=no" >config.cache + case $plid in + Darwin/* ) echo "gzip_cv_assembler=no" >>config.cache ;; + esac + sh $shtool subst -e 's/futimens/gzip_&/' gzip.c lib/utimens.[ch] + CC="${l_cc}" \ + GREP="grep" \ + ./configure \ + --cache-file=./config.cache + ${l_make} || exit $? + ( mv gzip ..; ${l_make} clean || true; mv ../gzip . ) || exit $? + ) || exit $? + l_gzip="`pwd`/gzip-%{V_gzip}/gzip"; export l_gzip + echo "l_gzip=\"$l_gzip\"; export l_gzip" >>.buildenv + + # display verbosity header + set +x; VERBOSE "PREPARATION: Unpack GNU configuration guessing utilities"; set -x + + # unpack GNU config.guess + ${l_gzip} -dc `SOURCE config-%{V_config}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + + # display verbosity header + set +x; VERBOSE "PREPARATION: Build GNU patch (Source Patching Tool)"; set -x + + # bootstrap GNU patch tool + ${l_gzip} -dc `SOURCE patch-%{V_patch}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ( cd patch-%{V_patch} + chmod u+w config.guess config.sub >/dev/null 2>&1 || true + cp ../config/config.guess . + cp ../config/config.sub . + ( echo 'ac_cv_func_setmode=${ac_cv_func_setmode=no}' + echo 'ac_cv_prog_cc_g=no' + false=`sh $shtool path false` + echo "ac_cv_path_ed_PROGRAM=\${ac_cv_path_ed_PROGRAM=$false}" + ) >config.cache + CC="${l_cc}" \ + ./configure \ + --cache-file=./config.cache \ + --disable-largefile + ${l_make} || exit $? + ( mv patch ..; ${l_make} clean || true; mv ../patch . ) || exit $? + ) || exit $? + l_patch="`pwd`/patch-%{V_patch}/patch"; export l_patch + echo "l_patch=\"$l_patch\"; export l_patch" >>.buildenv + + # display verbosity header + set +x; VERBOSE "BUILD: Build GNU tar (Archiving Tool)"; set -x + + # build GNU tar tool + ${l_gzip} -dc `SOURCE tar-%{V_tar}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ( cd tar-%{V_tar} + ${l_patch} -p0 <`SOURCE tar.patch` + ( echo 'am_cv_func_iconv=no' + echo 'am_cv_lib_iconv=no' + echo 'ac_cv_lib_iconv_iconv=no' + echo 'ac_cv_header_iconv_h=no' + echo 'ac_cv_type_iconv_t=no' + ) >config.cache + CC="${l_cc}" \ + MAKEINFO="true" \ + GREP="grep" \ + ./configure \ + --cache-file=./config.cache \ + --prefix=%{l_prefix} \ + --disable-nls + ${l_make} || exit $? + ( mv src/tar ..; ${l_make} clean || true; mv ../tar . ) || exit $? + ) || exit $? + l_tar="`pwd`/tar-%{V_tar}/tar"; export l_tar + echo "l_tar=\"$l_tar\"; export l_tar" >>.buildenv + + # display verbosity header + set +x; VERBOSE "PREPARATION: Unpack Distribution Tarballs"; set -x + + # unpack distribution tarballs + ${l_gzip} -dc `SOURCE rpm-%{V_rpm}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE zlib-%{V_zlib}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE bzip2-%{V_bzip2}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE curl-%{V_curl}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE make-%{V_make}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE bash-%{V_bash}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE uuid-%{V_uuid}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE beecrypt-%{V_beecrypt}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE openpkg-registry-%{V_registry}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE perl-%{V_perl}-mini.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE openssl-%{V_openssl}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE openpkg-tools-%{V_tools}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + ${l_gzip} -dc `SOURCE openpkg-executable-%{V_exec}.tar.gz` | ${l_tar} xf - 2>/dev/null || true + + # update config.guess/config.sub + for dir in rpm-%{V_rpm} rpm-%{V_rpm}/popt beecrypt-%{V_beecrypt} \ + curl-%{V_curl} make-%{V_make} bash-%{V_bash}/support; do + chmod u+w $dir/config.guess $dir/config.sub >/dev/null 2>&1 || true + cp config/config.guess $dir/ + cp config/config.sub $dir/ + done + + # display verbosity header + set +x; VERBOSE "PREPARATION: Apply OpenPKG Patches to Distributions"; set -x + + # apply OpenPKG patches to distribution trees + ( cd rpm-%{V_rpm} + sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.bugfix` | ${l_patch} -p0 + sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.feature` | ${l_patch} -p0 + sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.porting` | ${l_patch} -p0 + sed -e "s;@l_prefix@;%{l_prefix};g" <`SOURCE rpm.patch.regen` | ${l_patch} -p0 + rm -rf db/docs # just reduce disk size of source tree + ) || exit $? + ( cd make-%{V_make} + ${l_patch} -p0 <`SOURCE make.patch` + ) || exit $? + ( cd bash-%{V_bash} + ${l_patch} -p0 <`SOURCE bash.patch` + sleep 1 + touch y.tab.[ch] + touch configure config.h.in + ) || exit $? + ( cd beecrypt-%{V_beecrypt} + ${l_patch} -p0 <`SOURCE beecrypt.patch` + ) || exit $? + ( cd perl-%{V_perl} + ${l_patch} -p0 <`SOURCE perl.patch` + ) || exit $? + ( cd openssl-%{V_openssl} + ${l_patch} -p0 <`SOURCE openssl.patch` + ) || exit $? + + # display verbosity header + set +x; VERBOSE "PREPARATION: Build GNU make (Build Tool)"; set -x + + # bootstrap GNU make tool + ( cd make-%{V_make} + CC="${l_cc}" \ + ./configure \ + --without-libiconv-prefix \ + --without-libintl-prefix \ + --disable-nls \ + --disable-largefile + ${l_make} + ( mv make ..; ${l_make} clean || true; mv ../make . ) || exit $? + ) || exit $? + l_make="`pwd`/make-%{V_make}/make"; export l_make + echo "l_make=\"$l_make\"; export l_make" >>.buildenv + +%build + # skip in bootstrap phase 2 (see openpkg.boot) + [ ".$OPENPKG_BOOT" = .1 ] && exit 0 + + # switch into a temporary build area + cd openpkg-%{version} + . ./.buildenv + + # display verbosity header + set +x; VERBOSE "BUILD: Build GNU bash (Bourne-Again Shell)"; set -x + + # build GNU bash tool + ( cd bash-%{V_bash} + sh $shtool subst \ + -e 's;@l_openpkg_release@;OpenPKG;' \ + version.c + ( # force disabled wide-character support + echo "ac_cv_header_wchar_h=no" + echo "ac_cv_header_wctype_h=no" + echo "ac_cv_func_mbsrtowcs=no" + # force disabled internationalization support + echo "ac_cv_header_libintl_h=no" + echo "ac_cv_func_gettext=no" + echo "ac_cv_func_textdomain=no" + echo "ac_cv_func_bindtextdomain=no" + echo "ac_cv_lib_intl_bindtextdomain=no" + # disable building with debug symbols + echo "ac_cv_prog_cc_g=no" + ) >config.cache + AUTOCONF="true" \ + CC="${l_cc}" + ./configure \ + --cache-file=./config.cache \ + --prefix=%{l_prefix} \ + --without-curses \ + --without-gnu-malloc \ + --disable-nls + ${l_make} || exit $? + ( mv bash ..; ${l_make} clean || true; mv ../bash . ) || exit $? + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build GNU bzip2 (Compression Library)"; set -x + + # build BZIP2 library + ( cd bzip2-%{V_bzip2} + ${l_make} CC="${l_cc}" CFLAGS="-O" libbz2.a bzip2 || exit $? + ( echo "# libbz2.la - a libtool library file" + echo "# Generated by ltmain.sh - GNU libtool x.x.x" + echo "dlname=''" + echo "library_names=''" + echo "old_library='libbz2.a'" + echo "dependency_libs=''" + echo "current=0" + echo "age=0" + echo "revision=0" + echo "installed=no" + echo "dlopen=''" + echo "dlpreopen=''" + echo "libdir='%{l_prefix}'" + ) >libbz2.la + ln -s . .libs + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build Zlib (Compression Library)"; set -x + + # build ZLIB library + ( cd zlib-%{V_zlib} + CC="${l_cc}" CFLAGS="-O" ./configure + ${l_make} CC="${l_cc}" libz.a || exit $? # intentionally do not pass CFLAGS here + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build OSSP uuid (UUID Generation Tool)"; set -x + + # build OSSP uuid tool + ( cd uuid-%{V_uuid} + CC="${l_cc}" \ + CFLAGS="-O" \ + GREP="grep" \ + ./configure \ + --prefix=%{l_prefix} \ + --disable-shared + ${l_make} || exit $? + ( mv uuid ..; ${l_make} clean || true; mv ../uuid . ) || exit $? + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build Perl (Programming Language)"; set -x + + # build Perl tool + ( cd perl-%{V_perl} + chmod -R u+w . + sh $shtool subst \ + -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;' \ + -e 's;package=perl5;package=perl;' \ + Configure + sh $shtool subst \ + -e 's; */usr/local/lib;;' \ + hints/freebsd.sh hints/netbsd.sh + libdirs="" + for dir in %{l_prefix}/lib /lib64 /usr/lib64 /lib /usr/lib /usr/ccs/lib; do + [ -d $dir ] && libdirs="$libdirs $dir" + done + ./Configure \ + -d -e -s \ + -Dprefix=%{l_prefix} \ + -Dvendorprefix=%{l_prefix} \ + -Dinstallprefix=%{l_prefix} \ + -Dinstallstyle="lib/perl5" \ + -Dman1dir=%{l_prefix}/man/man1 \ + -Dman3dir=%{l_prefix}/man/man3 \ + -Dcc="${l_cc}" -Uoptimize \ + -Dlocincpth="%{l_prefix}/include" \ + -Dloclibpth="%{l_prefix}/lib" \ + -Dldflags="-L""%{l_prefix}/lib" \ + -Dlibpth="$libdirs" \ + -Dglibpth="$libdirs" \ + -Dscriptdir="%{l_prefix}/bin" \ + -Uinstallusrbinperl \ + -Adefine:useshrplib='false' \ + -Ui_malloc -Ui_iconv -Ui_db + ${l_make} miniperl || exit $? + rm -f *.o >/dev/null 2>&1 || true + ) || exit $? + l_perl="`pwd`/perl-%{V_perl}/miniperl"; export l_perl + echo "l_perl=\"$l_perl\"; export l_perl" >>.buildenv + + # display verbosity header + set +x; VERBOSE "BUILD: Build OpenSSL (Crypography and SSL/TLS Toolkit)"; set -x + + # build OpenSSL toolkit + ( cd openssl-%{V_openssl} + sh $shtool subst \ + -e 's;-m486;-march=i486;g' \ + -e 's;BN_LLONG *;;' \ + Configure + sh $shtool subst \ + -e 's;test "$OSTYPE" = msdosdjgpp;true;' \ + util/point.sh + sh $shtool subst \ + -e "1s;^.*\$;#!$l_perl;" \ + Configure `find . -name "*.pl" -print` + opts="" + case `sh $shtool platform -n -L -S "" -C "+" -F "%-%"` in + *-solaris* ) opts="-lnsl -lsocket" ;; + esac + case `sh $shtool platform -n -L -S "" -C "+" -F "%-%"` in + amd64-* ) opts="$opts -fPIC" ;; + ia64-* ) opts="$opts -fPIC" ;; + sparc64-freebsd* ) opts="$opts -fPIC" ;; + esac + CC="${l_cc}" \ + PERL="${l_perl}" \ + ./config \ + --prefix=%{l_prefix} \ + no-asm no-shared no-dso \ + no-zlib no-idea no-threads no-krb5 no-hw \ + $opts + ${l_make} CC="${l_cc}" build_libs build_apps || exit $? + ( mkdir lib; cd lib; ln -s ../lib*.a . ) || exit $? + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build cURL (URL Fetching Tool)"; set -x + + # build cURL tool + ( cd curl-%{V_curl} + sh $shtool subst \ + -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \ + configure + ( echo 'ac_cv_header_openssl_engine_h=no' + echo 'lt_cv_prog_compiler_c_o_F77=no' + echo 'lt_cv_sys_max_cmd_len=100' + ) >config.cache + CC="${l_cc}" \ + CFLAGS="-I`pwd`/../zlib-%{V_zlib}" \ + CPPFLAGS="-I`pwd`/../zlib-%{V_zlib}" \ + LDFLAGS="-L`pwd`/../zlib-%{V_zlib}" \ + GREP="grep" \ + ./configure \ + --cache-file=./config.cache \ + --without-libidn \ + --disable-shared \ + --disable-thread \ + --disable-ipv6 \ + --disable-ldap \ + --with-zlib=`pwd`/../zlib-%{V_zlib} \ + --with-ssl=`pwd`/../openssl-%{V_openssl} \ + --with-ca-bundle=%{l_prefix}/etc/openpkg/openpkg.x509 + ${l_make} || exit $? + ( mv src/curl ..; ${l_make} clean || true; mv ../curl ./src ) || exit $? + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build BeeCrypt (Cryptography Library)"; set -x + + # build BeeCrypt library + ( cd beecrypt-%{V_beecrypt} + sh $shtool subst \ + -e 's;^[ ][ ]*#;#;' \ + aes.c base64.c blowfish.c entropy.c fips186.c fips186.h md5.c \ + md5.h mp.c mtprng.c mtprng.h sha1.c sha1.h sha256.c sha256.h timestamp.c + sh $shtool subst \ + -e 's;cppglue\.lo;;g' \ + -e 's;cppglue\.cxx;;g' \ + -e '/^CXX = /s;@CXX@;@CC@;g' \ + Makefile.in + sh $shtool subst \ + -e '/LINENO: error: C[+]* preprocessor/{N;N;N;N;s/.*/:/;}' \ + configure + ( echo 'ac_cv_have_dev_dsp=no' + echo 'ac_cv_have_dev_audio=no' + echo 'ac_cv_func_gettimeofday=yes' + echo 'bc_cv_as_noexecstack=no' + ) >config.cache + CC="${l_cc}" \ + CFLAGS="-O" \ + ./configure \ + --cache-file=./config.cache \ + --prefix=%{l_prefix} \ + --without-cplusplus \ + --without-java \ + --without-python \ + --with-cpu=none \ + --with-arch=none \ + --disable-threads \ + --disable-shared + ${l_make} || exit $? + cp .libs/libbeecrypt.a . + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build RPM (RPM Package Manager)"; set -x + + # build RPM + ( br=`pwd` + cd rpm-%{V_rpm} + + # remove object files accidentally distributed with the RPM tarball + rm -f db/build_unix/*.o + rm -f db/build_unix/*.lo + + # remove embedded zlib (we are linking with an external one) + rm -rf zlib + + # kill Linux-based preconfigured DB header, to allow the Makefiles to + # symlink to it the header that is configured for the current system. + rm -f rpmdb/db.h + + # make sure we do not trigger Autoconf/Automake tools + touch configure + touch config.h.in + + # disable running of any Autoconf/Automake tools + ACLOCAL=true + AUTOCONF=true + AUTOMAKE=true + AUTOHEADER=true + MAKEINFO=true + AMTAR=true + export ACLOCAL AUTOMAKE AUTOHEADER MAKEINFO AMTAR + + # cheat GNU Autoconf + ( echo 'ac_cv_path_MSGFMT=:' + echo 'ac_cv_path_GMSGFMT=:' + echo 'ac_cv_path_XGETTEXT=:' + echo 'ac_cv_path_MSGMERGE=:' + echo "ac_cv_path_MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'" + echo "ac_cv_path___MKDIR='%{l_prefix}/lib/openpkg/shtool mkdir -f -p -m 755'" + echo "ac_cv_path___PYTHON=true" + echo "ac_cv_path___DOXYGEN=true" + echo "acl_cv_rpath=no" + echo "ac_cv_header_getopt_h=no" + ) >config.cache + + # provide platform identification + os_name=`(uname -s) 2>/dev/null` || os_name='Unknown' + os_name=`echo "${os_name}" |\ + sed -e 's;[^a-zA-Z0-9];;g' |\ + tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + + # set build tool flags + CC="${l_cc}" + CPPFLAGS="-DOPENPKG -DOPENPKG_${os_name} -I$br/zlib-%{V_zlib} -I$br/bzip2-%{V_bzip2} -I$br/beecrypt-%{V_beecrypt}" + CFLAGS="$CPPFLAGS" + LDFLAGS="-L$br/zlib-%{V_zlib} -L$br/bzip2-%{V_bzip2} -L$br/beecrypt-%{V_beecrypt}" + LIBS="$LDFLAGS -lz -lbz2 -lbeecrypt" + case $os_name in + SUNOS* ) LIBS="$LIBS -lresolv" ;; + IRIX* ) LIBS="$LIBS -lgen" ;; + esac + export CC CPPFLAGS CFLAGS LDFLAGS LIBS + + # adjust for BeeCrypt 4.0 + sh $shtool subst \ + -e 's;beecrypt\.api\.h;beecrypt.h;g' \ + rpmio/rpmio_internal.h + sh $shtool subst \ + -e 's;\(rsavrfy(\)\(&dig->rsa_pk\);\1\2.n, \2.e;g' \ + lib/signature.c + + # configure the package + sh ./configure \ + --cache-file=./config.cache \ + --prefix=%{l_prefix} \ + --with-db \ + --with-glob \ + --without-python \ + --without-apidocs \ + --disable-shared \ + --disable-rpath \ + --disable-nls + + # build the package + ${l_make} + ) || exit $? + + # display verbosity header + set +x; VERBOSE "BUILD: Build OpenPKG Frontend (Set-UID Wrapper)"; set -x + + # build "openpkg" executable + ( cd openpkg-executable-%{V_exec} + ${l_make} \ + CC="${l_cc}" \ + OPENPKG_PREFIX="%{l_prefix}" \ + OPENPKG_SUSR="%{l_susr}" \ + OPENPKG_MUSR="%{l_musr}" + ) || exit $? + +%install + # skip in bootstrap phase 2 (see openpkg.boot) + [ ".$OPENPKG_BOOT" = .1 ] && exit 0 + + # switch into a temporary build area + cd openpkg-%{version} + . ./.buildenv + + # display verbosity header + set +x; VERBOSE "INSTALL: Create Installation Filesystem Hierarchy"; set -x + + # create installation hierarchy + rm -rf $RPM_BUILD_ROOT + sh $shtool mkdir -f -p -m 755 $RPM_BUILD_ROOT%{l_prefix} + for dir in bin etc include info lib libexec man sbin share var cgi pub local; do + test -d $RPM_BUILD_ROOT%{l_prefix}/$dir || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/$dir + done + for i in 1 2 3 4 5 6 7 8 9; do + test -d $RPM_BUILD_ROOT%{l_prefix}/man/man$i || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/man/man$i + test -d $RPM_BUILD_ROOT%{l_prefix}/man/cat$i || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/man/cat$i + done + for dir in PKG bin etc include info lib man sbin; do + test -d $RPM_BUILD_ROOT%{l_prefix}/local/$dir || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/local/$dir + done + for i in 1 2 3 4 5 6 7 8 9; do + test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/man$i + test -d $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/local/man/cat$i + done + test -d $RPM_BUILD_ROOT%{l_prefix}/RPM || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM + for dir in SRC PKG DB TMP; do + test -d $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/RPM/$dir + done + mkdir $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg + mkdir $RPM_BUILD_ROOT%{l_prefix}/include/openpkg + + # display verbosity header + set +x; VERBOSE "INSTALL: Installation of RPM"; set -x + + # install RPM into installation hierarchy + ( cd rpm-%{V_rpm} + DESTDIR="$RPM_BUILD_ROOT" + export DESTDIR + ${l_make} install + ) || exit $? + + # display verbosity header + set +x; VERBOSE "INSTALL: Install Additional Files"; set -x + + # add additional development files + cp rpm-%{V_rpm}/misc/glob.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/ + cp zlib-%{V_zlib}/zlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/ + cp zlib-%{V_zlib}/zconf.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/ + cp zlib-%{V_zlib}/libz.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmz.a + cp bzip2-%{V_bzip2}/bzlib.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/ + cp bzip2-%{V_bzip2}/libbz2.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbz2.a + cp beecrypt-%{V_beecrypt}/beecrypt.h $RPM_BUILD_ROOT%{l_prefix}/include/rpm/ + cp beecrypt-%{V_beecrypt}/libbeecrypt.a $RPM_BUILD_ROOT%{l_prefix}/lib/librpmbeecrypt.a + + # display verbosity header + set +x; VERBOSE "INSTALL: Post-Adjust Installation"; set -x + + # post-adjust RPM installation (namespace-clean POPT inclusion) + mv $RPM_BUILD_ROOT%{l_prefix}/lib/libpopt.a \ + $RPM_BUILD_ROOT%{l_prefix}/lib/librpmpopt.a + mv $RPM_BUILD_ROOT%{l_prefix}/include/popt.h \ + $RPM_BUILD_ROOT%{l_prefix}/include/rpm/popt.h + + # move C API into custom locations + mv $RPM_BUILD_ROOT%{l_prefix}/include/rpm \ + $RPM_BUILD_ROOT%{l_prefix}/include/openpkg/rpm + mv $RPM_BUILD_ROOT%{l_prefix}/lib/librpm* \ + $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/ + + # move rpm tool to custom location + mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm + mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm.8 \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm.8 + + # move rpm2cpio tool to custom location + mv $RPM_BUILD_ROOT%{l_prefix}/bin/rpm2cpio \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio + mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpm2cpio.8 \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm2cpio.8 + + # replace symlinks with hardlinks + for entry in rpme:rpmi rpmt:rpmb rpmu:rpmi rpmv:rpmq; do + eval `echo $entry | sed -e 's/^\(.*\):\(.*\)$/dst=\1; src=\2/'` + rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst + ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$src \ + $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$dst + done + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/rpmbuild + ln $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmb \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild + mv $RPM_BUILD_ROOT%{l_prefix}/man/man8/rpmbuild.8 \ + $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpmbuild.8 + + # display verbosity header + set +x; VERBOSE "INSTALL: Stripping Down Installation"; set -x + + # strip RPM installation + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/* \ + $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/* >/dev/null 2>&1 || true + for dir in man/ja man/pl man/ru man/sk src; do + rm -rf $RPM_BUILD_ROOT%{l_prefix}/$dir >/dev/null 2>&1 || true + done + rm -rf $RPM_BUILD_ROOT/var >/dev/null 2>&1 || true + for file in rpme rpmi rpmsign rpmu rpmverify rpmquery gendiff; do + rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/$file >/dev/null 2>&1 || true + done + rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/* >/dev/null 2>&1 || true + rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man1/* >/dev/null 2>&1 || true + rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man3/* >/dev/null 2>&1 || true + rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmpopt >/dev/null 2>&1 || true + rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/rpmrc >/dev/null 2>&1 || true + rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/lib*.la >/dev/null 2>&1 || true + rm -rf $RPM_BUILD_ROOT%{l_prefix}/var/lib >/dev/null 2>&1 || true + for file in \ + u_pkg.sh vpkg-provides.sh vpkg-provides2.sh rpmdiff.cgi rpmdiff \ + perl.prov perl.req mkinstalldirs magic.prov magic.req http.req \ + getpo.sh get_magic.pl find-provides find-requires \ + find-requires.perl find-req.pl find-provides.perl \ + find-prov.pl find-lang.sh cpanflute convertrpmrc.sh check-prereqs \ + rpmputtext rpmgettext brp-compress brp-redhat brp-sparc64-linux \ + brp-strip brp-strip-shared brp-strip-comment-note rpmrc \ + config.guess config.sub check-files; do + rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/$file >/dev/null 2>&1 || true + done + + # display verbosity header + set +x; VERBOSE "INSTALL: Install Additional Tools"; set -x + + # install lsync tool + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE lsync` \ + >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE dot.lsyncrc` \ + >$RPM_BUILD_ROOT%{l_prefix}/local/.lsyncrc + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE lsync.8` \ + >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/lsync.8 + + # install rpm-config tool + ( l_prefix="%{l_prefix}" + l_cc="%{l_cc}" + l_cflags="" + l_cppflags="-DOPENPKG -I${l_prefix}/include/openpkg/rpm -I${l_prefix}/include/openpkg" + l_ldflags="-L${l_prefix}/lib/openpkg" + l_libs="-lrpmbuild -lrpm -lrpmio -lrpmdb -lrpmpopt -lrpmbeecrypt -lrpmbz2 -lrpmz" + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + -e "s:@l_cc@:$l_cc:g" \ + -e "s:@l_cflags@:$l_cflags:g" \ + -e "s:@l_cppflags@:$l_cppflags:g" \ + -e "s:@l_ldflags@:$l_ldflags:g" \ + -e "s:@l_libs@:$l_libs:g" \ + -e "s:@l_version@:%{V_rpm}:g" \ + <`SOURCE rpm-config.sh` \ + >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config + ) || exit $? + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config + sed -e "s:RPM_VERSION:%{V_rpm}:g" \ + <`SOURCE rpm-config.8` \ + >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm-config.8 + + # install OpenPKG registry commands + ( cd openpkg-registry-%{V_registry} + mv $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm \ + $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpm + sed -e "s;@l_prefix@;%{l_prefix};g" \ + rpm.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm + chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rpm + sed -e "s;@l_prefix@;%{l_prefix};g" \ + register.sh >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register + chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register + cp register.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/register.8 + ) || exit $? + + # install OpenPKG Tool Chain command subset + ( cd openpkg-tools-%{V_tools} + cp cmd/curl.sh $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/curl.sh + cp cmd/build.pl $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl + chmod 644 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.pl + cp cmd/build.8 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/build.8 + ) || exit $? + + # install RPM extension + ( cd rpm-%{V_rpm} + cp file/file $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/file + ) || exit $? + ( cd perl-%{V_perl} + cp miniperl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/miniperl + ) || exit $? + ( cd openssl-%{V_openssl} + cp apps/openssl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openssl + ) || exit $? + ( cd curl-%{V_curl} + cp src/curl $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/curl + ) || exit $? + ( cd bzip2-%{V_bzip2} + cp bzip2 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2 + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bzip2 + ) || exit $? + ( cd gzip-%{V_gzip} + cp gzip $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/gzip + ) || exit $? + ( cd patch-%{V_patch} + cp patch $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/patch + ) || exit $? + ( cd tar-%{V_tar} + cp tar $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/tar + ) || exit $? + ( cd bash-%{V_bash} + cp bash $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/bash + ) || exit $? + ( cd uuid-%{V_uuid} + cp uuid $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/uuid + ) || exit $? + sed -e "s;@l_prefix@;%{l_prefix};g" \ + -e "s;@l_musr@;%{l_musr};g" \ + -e "s;@l_mgrp@;%{l_mgrp};g" \ + <`SOURCE uuid.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid + sed -e "s;@l_prefix@;%{l_prefix};g" \ + <`SOURCE uuid.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/uuid.8 + sed -e "s;@l_prefix@;%{l_prefix};g" \ + <`SOURCE release.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release + sed -e "s;@l_prefix@;%{l_prefix};g" \ + <`SOURCE release.8` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/release.8 + sed -e "s;@l_prefix@;%{l_prefix};g" \ + -e "s;@l_musr@;%{l_musr};g" \ + -e "s;@l_mgrp@;%{l_mgrp};g" \ + <`SOURCE rpmdb` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmdb + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE rpmtool` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmtool + + # install OpenPKG tool chain execution frontend and execution wrapper + cp openpkg-executable-%{V_exec}/openpkg $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg + ${l_strip} $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg + chmod 4775 $RPM_BUILD_ROOT%{l_prefix}/bin/openpkg + sed -e "s;@l_prefix@;%{l_prefix};g" \ + <`SOURCE openpkg.sh` >$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg + chmod 755 $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/openpkg + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE openpkg.1` \ + >$RPM_BUILD_ROOT%{l_prefix}/man/man1/openpkg.1 + + # install more OpenPKG tool chain commands + sed -e "s;@l_prefix@;%{l_prefix};g" \ + <`SOURCE install.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/install + sed -e "s;@l_prefix@;%{l_prefix};g" \ + <`SOURCE man.sh` >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/man + + # install an own copy of shtool + cp $shtool $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool + chmod a+x $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/shtool + + # display verbosity header + set +x; VERBOSE "INSTALL: Install Configuration Files"; set -x + + # install a few README files + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE root.README` \ + >$RPM_BUILD_ROOT%{l_prefix}/README + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE local.README` \ + >$RPM_BUILD_ROOT%{l_prefix}/local/README + + # install Bash environment + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE dot.bashrc` \ + >$RPM_BUILD_ROOT%{l_prefix}/.bashrc + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE dot.bash_login` \ + >$RPM_BUILD_ROOT%{l_prefix}/.bash_login + + # install Run-Command files + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + -e "s:@l_susr@:%{l_susr}:g" \ + -e "s:@l_musr@:%{l_musr}:g" \ + <`SOURCE rc` \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/rc + chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE rc.conf` \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf + chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.conf + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE rc.func` \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.func + chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.func + mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + -e "s:@l_musr@:%{l_musr}:g" \ + <`SOURCE rc.openpkg` \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg + chmod 755 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/rc.openpkg + ( echo "#!/bin/sh" + echo "exec %{l_prefix}/etc/rc \${1+\"\$@\"}" + ) >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc + chmod 755 $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc + ln $RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc \ + $RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rc + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE rc.8` \ + >$RPM_BUILD_ROOT%{l_prefix}/libexec/openpkg/rc.8 + + # create configuration directory + test -d $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg || \ + mkdir $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg + + # install platform identification file + sh $shtool platform -n -L -S "" -C "+" -F "%-any-%" \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform + chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/platform + + # install UUID configuration file (ghost) + touch $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid + chmod 644 $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/uuid + + # install registry configuration files (ghost) + touch \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.conf \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util + chmod 644 \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.conf \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.prep \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.tran \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/register.util + + # install default managers configuration file + ( echo "##" + echo "## managers -- OpenPKG Instance Managers" + echo "##" + echo "" + echo "%{l_susr}" + echo "%{l_musr}" + echo "" + ) >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/managers + + # install overriding RPM configuration files + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE rpmpopt` \ + >>$RPM_BUILD_ROOT%{l_prefix}/lib/openpkg/rpmpopt + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + <`SOURCE rpmrc` \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmrc + sed -e "s:@l_prefix@:%{l_prefix}:g" \ + -e "s:@l_prefix_static@:%{l_prefix}:g" \ + -e "s;@l_build_path@;$l_build_path;g" \ + -e "s;@l_build_ldlp@;$l_build_ldlp;g" \ + -e "s;@l_build_ulim@;$l_build_ulim;g" \ + -e "s:@TAG@:$tag:g" \ + -e "s:@SUSR@:$susr:g" \ + -e "s:@SGRP@:$sgrp:g" \ + -e "s:@MUSR@:$musr:g" \ + -e "s:@MGRP@:$mgrp:g" \ + -e "s:@RUSR@:$rusr:g" \ + -e "s:@RGRP@:$rgrp:g" \ + -e "s:@NUSR@:$nusr:g" \ + -e "s:@NGRP@:$ngrp:g" \ + <`SOURCE rpmmacros` \ + >$RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/rpmmacros + cp `SOURCE openpkg.org.pgp` \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.org.pgp + cp `SOURCE openpkg.com.pgp` \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.com.pgp + cp `SOURCE openpkg.net.pgp` \ + $RPM_BUILD_ROOT%{l_prefix}/etc/openpkg/openpkg.net.pgp + + # display verbosity header + set +x; VERBOSE "INSTALL: Done. Thank you for flying OpenPKG..."; set -x + +%files + %defattr(-,%{?l_musr}%{!?l_musr:%{l_fsusr}},%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}}) + %{l_prefix}/README + %config(noreplace) %{l_prefix}/.bashrc + %config(noreplace) %{l_prefix}/.bash_login + %dir %{l_prefix}/RPM + %dir %{l_prefix}/RPM/SRC + %dir %{l_prefix}/RPM/PKG + %dir %{l_prefix}/RPM/DB + %dir %{l_prefix}/RPM/TMP + %dir %{l_prefix}/cgi + %dir %{l_prefix}/bin + %attr(4755,%{l_susr},%{l_mgrp}) %{l_prefix}/bin/openpkg + %dir %{l_prefix}/etc + %{l_prefix}/etc/rc + %config(noreplace) %{l_prefix}/etc/rc.conf + %{l_prefix}/etc/rc.func + %dir %{l_prefix}/etc/rc.d + %{l_prefix}/etc/rc.d/rc.openpkg + %dir %{l_prefix}/etc/openpkg + %ghost %{l_prefix}/etc/openpkg/uuid + %config %{l_prefix}/etc/openpkg/platform + %config %{l_prefix}/etc/openpkg/rpmmacros + %config %{l_prefix}/etc/openpkg/rpmrc + %ghost %{l_prefix}/etc/openpkg/register.conf + %ghost %{l_prefix}/etc/openpkg/register.prep + %ghost %{l_prefix}/etc/openpkg/register.tran + %ghost %{l_prefix}/etc/openpkg/register.util + %config %attr(664,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/openpkg/managers + %{l_prefix}/etc/openpkg/openpkg.org.pgp + %{l_prefix}/etc/openpkg/openpkg.com.pgp + %{l_prefix}/etc/openpkg/openpkg.net.pgp + %dir %{l_prefix}/include + %dir %{l_prefix}/include/openpkg + %dir %{l_prefix}/include/openpkg/rpm + %{l_prefix}/include/openpkg/rpm/argv.h + %{l_prefix}/include/openpkg/rpm/beecrypt.h + %{l_prefix}/include/openpkg/rpm/bzlib.h + %{l_prefix}/include/openpkg/rpm/db.h + %{l_prefix}/include/openpkg/rpm/fts.h + %{l_prefix}/include/openpkg/rpm/glob.h + %{l_prefix}/include/openpkg/rpm/hdrinline.h + %{l_prefix}/include/openpkg/rpm/header.h + %{l_prefix}/include/openpkg/rpm/misc.h + %{l_prefix}/include/openpkg/rpm/popt.h + %{l_prefix}/include/openpkg/rpm/rpmal.h + %{l_prefix}/include/openpkg/rpm/rpmbuild.h + %{l_prefix}/include/openpkg/rpm/rpmcli.h + %{l_prefix}/include/openpkg/rpm/rpmdb.h + %{l_prefix}/include/openpkg/rpm/rpmds.h + %{l_prefix}/include/openpkg/rpm/rpmerr.h + %{l_prefix}/include/openpkg/rpm/rpmfc.h + %{l_prefix}/include/openpkg/rpm/rpmfi.h + %{l_prefix}/include/openpkg/rpm/rpmfile.h + %{l_prefix}/include/openpkg/rpm/rpmhash.h + %{l_prefix}/include/openpkg/rpm/rpmio.h + %{l_prefix}/include/openpkg/rpm/rpmlib.h + %{l_prefix}/include/openpkg/rpm/rpmlog.h + %{l_prefix}/include/openpkg/rpm/rpmmacro.h + %{l_prefix}/include/openpkg/rpm/rpmmessages.h + %{l_prefix}/include/openpkg/rpm/rpmpgp.h + %{l_prefix}/include/openpkg/rpm/rpmps.h + %{l_prefix}/include/openpkg/rpm/rpmspec.h + %{l_prefix}/include/openpkg/rpm/rpmsw.h + %{l_prefix}/include/openpkg/rpm/rpmte.h + %{l_prefix}/include/openpkg/rpm/rpmts.h + %{l_prefix}/include/openpkg/rpm/rpmurl.h + %{l_prefix}/include/openpkg/rpm/stringbuf.h + %{l_prefix}/include/openpkg/rpm/ugid.h + %{l_prefix}/include/openpkg/rpm/zconf.h + %{l_prefix}/include/openpkg/rpm/zlib.h + %dir %{l_prefix}/info + %dir %{l_prefix}/lib + %dir %{l_prefix}/lib/openpkg + %{l_prefix}/lib/openpkg/bash + %{l_prefix}/lib/openpkg/bzip2 + %{l_prefix}/lib/openpkg/curl + %{l_prefix}/lib/openpkg/file + %{l_prefix}/lib/openpkg/gzip + %{l_prefix}/lib/openpkg/librpm.a + %{l_prefix}/lib/openpkg/librpmbeecrypt.a + %{l_prefix}/lib/openpkg/librpmbuild.a + %{l_prefix}/lib/openpkg/librpmbz2.a + %{l_prefix}/lib/openpkg/librpmdb.a + %{l_prefix}/lib/openpkg/librpmio.a + %{l_prefix}/lib/openpkg/librpmpopt.a + %{l_prefix}/lib/openpkg/librpmz.a + %{l_prefix}/lib/openpkg/macros + %{l_prefix}/lib/openpkg/magic + %{l_prefix}/lib/openpkg/magic.mgc + %{l_prefix}/lib/openpkg/magic.mime + %{l_prefix}/lib/openpkg/magic.mime.mgc + %{l_prefix}/lib/openpkg/miniperl + %{l_prefix}/lib/openpkg/openpkg + %{l_prefix}/lib/openpkg/openssl + %{l_prefix}/lib/openpkg/patch + %{l_prefix}/lib/openpkg/rc + %{l_prefix}/lib/openpkg/rpm + %{l_prefix}/lib/openpkg/rpmb + %{l_prefix}/lib/openpkg/rpmd + %{l_prefix}/lib/openpkg/rpmdb + %{l_prefix}/lib/openpkg/rpmdb_dump + %{l_prefix}/lib/openpkg/rpmdb_load + %{l_prefix}/lib/openpkg/rpmdb_verify + %{l_prefix}/lib/openpkg/rpme + %{l_prefix}/lib/openpkg/rpmi + %{l_prefix}/lib/openpkg/rpmk + %{l_prefix}/lib/openpkg/rpmpopt + %{l_prefix}/lib/openpkg/rpmq + %{l_prefix}/lib/openpkg/rpmt + %{l_prefix}/lib/openpkg/rpmtool + %{l_prefix}/lib/openpkg/rpmu + %{l_prefix}/lib/openpkg/rpmv + %{l_prefix}/lib/openpkg/shtool + %{l_prefix}/lib/openpkg/tar + %{l_prefix}/lib/openpkg/uuid + %dir %{l_prefix}/libexec + %dir %{l_prefix}/libexec/openpkg + %{l_prefix}/libexec/openpkg/build.8 + %{l_prefix}/libexec/openpkg/build.pl + %{l_prefix}/libexec/openpkg/curl.sh + %{l_prefix}/libexec/openpkg/install + %{l_prefix}/libexec/openpkg/lsync + %{l_prefix}/libexec/openpkg/lsync.8 + %{l_prefix}/libexec/openpkg/man + %{l_prefix}/libexec/openpkg/rc + %{l_prefix}/libexec/openpkg/rc.8 + %{l_prefix}/libexec/openpkg/register + %{l_prefix}/libexec/openpkg/register.8 + %{l_prefix}/libexec/openpkg/release + %{l_prefix}/libexec/openpkg/release.8 + %{l_prefix}/libexec/openpkg/rpm + %{l_prefix}/libexec/openpkg/rpm-config + %{l_prefix}/libexec/openpkg/rpm-config.8 + %{l_prefix}/libexec/openpkg/rpm.8 + %{l_prefix}/libexec/openpkg/rpm2cpio + %{l_prefix}/libexec/openpkg/rpm2cpio.8 + %{l_prefix}/libexec/openpkg/rpmbuild + %{l_prefix}/libexec/openpkg/rpmbuild.8 + %{l_prefix}/libexec/openpkg/uuid + %{l_prefix}/libexec/openpkg/uuid.8 + %dir %{l_prefix}/man + %dir %{l_prefix}/man/man1 + %dir %{l_prefix}/man/man2 + %dir %{l_prefix}/man/man3 + %dir %{l_prefix}/man/man4 + %dir %{l_prefix}/man/man5 + %dir %{l_prefix}/man/man6 + %dir %{l_prefix}/man/man7 + %dir %{l_prefix}/man/man8 + %dir %{l_prefix}/man/man9 + %dir %{l_prefix}/man/cat1 + %dir %{l_prefix}/man/cat2 + %dir %{l_prefix}/man/cat3 + %dir %{l_prefix}/man/cat4 + %dir %{l_prefix}/man/cat5 + %dir %{l_prefix}/man/cat6 + %dir %{l_prefix}/man/cat7 + %dir %{l_prefix}/man/cat8 + %dir %{l_prefix}/man/cat9 + %{l_prefix}/man/man1/openpkg.1 + %dir %{l_prefix}/sbin + %dir %{l_prefix}/pub + %dir %{l_prefix}/share + %dir %{l_prefix}/var + %dir %{l_prefix}/local + %{l_prefix}/local/README + %{l_prefix}/local/.lsyncrc + %dir %{l_prefix}/local/PKG + %dir %{l_prefix}/local/bin + %dir %{l_prefix}/local/etc + %dir %{l_prefix}/local/include + %dir %{l_prefix}/local/info + %dir %{l_prefix}/local/lib + %dir %{l_prefix}/local/man + %dir %{l_prefix}/local/man/man1 + %dir %{l_prefix}/local/man/man2 + %dir %{l_prefix}/local/man/man3 + %dir %{l_prefix}/local/man/man4 + %dir %{l_prefix}/local/man/man5 + %dir %{l_prefix}/local/man/man6 + %dir %{l_prefix}/local/man/man7 + %dir %{l_prefix}/local/man/man8 + %dir %{l_prefix}/local/man/man9 + %dir %{l_prefix}/local/man/cat1 + %dir %{l_prefix}/local/man/cat2 + %dir %{l_prefix}/local/man/cat3 + %dir %{l_prefix}/local/man/cat4 + %dir %{l_prefix}/local/man/cat5 + %dir %{l_prefix}/local/man/cat6 + %dir %{l_prefix}/local/man/cat7 + %dir %{l_prefix}/local/man/cat8 + %dir %{l_prefix}/local/man/cat9 + %dir %{l_prefix}/local/sbin + +%clean + # skip in bootstrap phase 2 (see openpkg.boot) + [ ".$OPENPKG_BOOT" = .1 ] && exit 0 + + # cleanup build area + rm -rf openpkg-%{version} >/dev/null 2>&1 || true + + # cleanup installation area + rm -rf $RPM_BUILD_ROOT >/dev/null 2>&1 || true + +%pre + # always performed for upgrades and because it doesn't harm! + # [ ".$1" != .1 ] && exit 0 + + # this procedure is only usable with root privileges + # (for non-root installations it is not required at all) + cusr=`(id -un) 2>/dev/null ||\ + (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\ + (whoami) 2>/dev/null ||\ + (who am i | cut "-d " -f1) 2>/dev/null ||\ + echo $LOGNAME` + + # determine runtime details (for both inside and outside RPM!!) + # - bootstrapping: $xxx is set from aux.wrapbin.sh + # - upgrading new: %{l_[smrn]{usr,grp}} is set via rpmmacros + # - upgrading old: %{l_[smrn]{usr,grp}} is not set at all + [ ".$susr" = . ] && susr="%{?l_susr}%{!?l_susr:root}" + [ ".$sgrp" = . ] && sgrp="%{?l_sgrp}%{!?l_sgrp:wheel}" + [ ".$musr" = . ] && musr="%{?l_musr}%{!?l_musr:%{l_fsusr}}" + [ ".$mgrp" = . ] && mgrp="%{?l_mgrp}%{!?l_mgrp:%{l_fsgrp}}" + [ ".$rusr" = . ] && rusr="%{?l_rusr}%{!?l_rusr:%{l_fsusr}-r}" + [ ".$rgrp" = . ] && rgrp="%{?l_rgrp}%{!?l_rgrp:%{l_fsgrp}-r}" + [ ".$nusr" = . ] && nusr="%{?l_nusr}%{!?l_nusr:%{l_fsusr}-n}" + [ ".$ngrp" = . ] && ngrp="%{?l_ngrp}%{!?l_ngrp:%{l_fsgrp}-n}" + [ ".$suid" = . ] && suid="%{?l_suid}" + [ ".$sgid" = . ] && sgid="%{?l_sgid}" + [ ".$muid" = . ] && muid="%{?l_muid}" + [ ".$mgid" = . ] && mgid="%{?l_mgid}" + [ ".$ruid" = . ] && ruid="%{?l_ruid}" + [ ".$rgid" = . ] && rgid="%{?l_rgid}" + [ ".$nuid" = . ] && nuid="%{?l_nuid}" + [ ".$ngid" = . ] && ngid="%{?l_ngid}" + + # if any of these optional params are not used we won't have a + # corresponding macro either, so make use of one conditionally + [ ".$suid" = . ] && [ ".%{?l_suid:set}" = .set ] && suid="%{?l_suid}" + [ ".$sgid" = . ] && [ ".%{?l_sgid:set}" = .set ] && sgid="%{?l_sgid}" + [ ".$muid" = . ] && [ ".%{?l_muid:set}" = .set ] && muid="%{?l_muid}" + [ ".$mgid" = . ] && [ ".%{?l_mgid:set}" = .set ] && mgid="%{?l_mgid}" + [ ".$ruid" = . ] && [ ".%{?l_ruid:set}" = .set ] && ruid="%{?l_ruid}" + [ ".$rgid" = . ] && [ ".%{?l_rgid:set}" = .set ] && rgid="%{?l_rgid}" + [ ".$nuid" = . ] && [ ".%{?l_nuid:set}" = .set ] && nuid="%{?l_nuid}" + [ ".$ngid" = . ] && [ ".%{?l_ngid:set}" = .set ] && ngid="%{?l_ngid}" + + # determine prefix + [ ".$prefix" = . ] && prefix="%{l_prefix}" + prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'` + + # register instance in presence file + presence="/etc/openpkg" + exists=`cat $presence 2>/dev/null | egrep "^ *${prefix} *\$"` + if [ ".$exists" = . ]; then + ( umask 022 + echo "${prefix}" >>$presence + ) 2>/dev/null || true + fi + + # determine user/group ids + for class in s m r n; do + eval "xusr=\"\$${class}usr\"" + eval "xgrp=\"\$${class}grp\"" + eval "xuid=\"\$${class}uid\"" + eval "xgid=\"\$${class}gid\"" + if [ ".$xuid" = . ]; then + xuid=`(getent passwd "${xusr}"; \ + grep "^${xusr}:" /etc/passwd; \ + ypmatch "${xusr}" passwd; \ + nismatch "${xusr}" passwd; \ + nidump passwd . | grep "^${xusr}:") 2>/dev/null | \ + sed -e 'q' | awk -F: '{ print $3; }'` + if [ ".$xuid" = . ]; then + # seek for a reasonably uid/gid pair + xuid=1000 + ok=0 + while [ ".$ok" = .0 ]; do + eval "u_exists=\$u_exists_$xuid" + if [ ".$u_exists" = . ]; then + u_exists=`(getent passwd; cat /etc/passwd; ypcat passwd; niscat passwd; nidump passwd .) 2>/dev/null |\ + grep "^[^:]*:[^:]*:$xuid:"` + fi + eval "g_exists=\$g_exists_$xuid" + if [ ".$g_exists" = . ]; then + g_exists=`(getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null |\ + grep "^[^:]*:[^:]*:$xuid:"` + fi + if [ ".$u_exists" = . -a ".$g_exists" = . ]; then + ok=1 + break + fi + xuid=`expr $xuid + 1` + done + eval "u_exists_$xuid=yes" + eval "g_exists_$xuid=yes" + fi + fi + if [ ".$xgid" = . ]; then + xgid=`(getent group "${xgrp}"; \ + grep "^${xgrp}:" /etc/group; \ + ypmatch "${xgrp}" group; \ + nismatch "${xgrp}" group; \ + nidump group . | grep "^${xgrp}:") 2>/dev/null | \ + sed -e 'q' | awk -F: '{ print $3; }'` + if [ ".$xgid" = . ]; then + xgid="$xuid" + fi + fi + eval "${class}uid=\"$xuid\"" + eval "${class}gid=\"$xgid\"" + done + + # determine platform id + s=`(uname -s) 2>/dev/null` || s='Unknown' + r=`(uname -r) 2>/dev/null` || r='0.0' + plid="${s}/${r}" + + # add entry to /etc/shells + shell="${prefix}/lib/openpkg/bash" + if [ -f /etc/shells ]; then + exists=`cat /etc/shells 2>/dev/null | grep "^$shell"` + if [ ".$exists" = . ]; then + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping addition of $shell to /etc/shells" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + echo "${shell}" >>/etc/shells + fi + fi + fi + + # clear pending deferred actions + rm -f %{l_prefix}.pre-group-process.sh %{l_prefix}.pre-post-process.sh >/dev/null 2>&1 + + # create the hierarchy user/group + for req in "superuser:${susr}:${suid}:${sgrp}:${sgid}" \ + "management:${musr}:${muid}:${mgrp}:${mgid}" \ + "restricted:${rusr}:${ruid}:${rgrp}:${rgid}" \ + "non-privileged:${nusr}:${nuid}:${ngrp}:${ngid}"; do + # split request into class/usr/uid/grp/gid + OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS" + class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5" + + # check whether user already exists + exists=`(getent passwd "$usr"; \ + grep "^$usr:" /etc/passwd; \ + ypmatch "$usr" passwd; \ + nismatch "$usr" passwd; \ + nidump passwd . | grep "^$usr:") 2>/dev/null | \ + sed -e 'q'` + if [ ".$exists" = . ]; then + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping creation of OpenPKG $class user $usr" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + # add entry to passwd database + realname="${prefix} OpenPKG ($class)" + case "$plid" in + FreeBSD/* | NetBSD/* ) + file=/etc/master.passwd + entry="${usr}:*:${uid}:${gid}::0:0:${realname}:${prefix}:${shell}" + update="(PATH=\$PATH:/usr/sbin; pwd_mkdb -p /etc/master.passwd)" + ;; + Linux/* ) + file=/etc/passwd + entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}" + update="(PATH=\$PATH:/usr/sbin; pwconv)" + ;; + SunOS/5.* | UnixWare/* ) + file=/etc/passwd + entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}" + update="(PATH=\$PATH:/usr/sbin; pwconv)" + ;; + AIX/* ) + # intentionally do nothing here + : + ;; + OSF1/V5.* ) + file=/etc/passwd + entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}" + update="(PATH=\$PATH:/usr/sbin; mkpasswd /etc/passwd)" + ;; + HP-UX/* ) + file=/etc/passwd + entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}" + update=":" + ;; + Darwin/* ) + # intentionally do nothing here + : + ;; + IRIX*/6.* ) + file=/etc/passwd + entry="${usr}:*:${uid}:${gid}:${realname}:${prefix}:${shell}" + if [ -f /etc/shadow ] + then update="(PATH=\$PATH:/sbin; pwconv)" + else update=":" + fi + ;; + esac + case "$plid" in + Darwin/* ) + niutil -create . "/users/${usr}" + niutil -createprop . "/users/${usr}" passwd "*" + niutil -createprop . "/users/${usr}" uid "${uid}" + niutil -createprop . "/users/${usr}" gid "${gid}" + niutil -createprop . "/users/${usr}" realname "${realname}" + niutil -createprop . "/users/${usr}" home "${prefix}" + niutil -createprop . "/users/${usr}" shell "${shell}" + ;; + AIX/* ) + mkuser id="${uid}" gecos="${realname}" home="${prefix}" "${usr}" + cp /etc/security/login.cfg /etc/security/login.cfg.bak && \ + sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\) *\$;\\1,$shell;" \ + /etc/security/login.cfg && \ + rm -f /etc/security/login.cfg.bak >/dev/null 2>&1 + # defer both the setting of the primary group and the shell, + # as they do not exist at this stage of processing. + echo "chuser pgrp=\"${grp}\" \"${usr}\"" >>%{l_prefix}.pre-group-process.sh + echo "chuser shell=\"${shell}\" \"${usr}\"" >>%{l_prefix}.pre-post-process.sh + ;; + * ) + cp $file $file.bak && \ + (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file + rm -f $file.bak >/dev/null 2>&1 + eval $update + [ $? -ne 0 ] && exit $? + ;; + esac + fi + fi + + # check whether group already exists + exists=`(getent group "$grp"; \ + grep "^$grp:" /etc/group; \ + ypmatch "$grp" group; \ + nismatch "$grp" group; \ + nidump group . | grep "^$grp:") 2>/dev/null | \ + sed -e 'q'` + if [ ".$exists" = . ]; then + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping creation of OpenPKG $class group $grp" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + case "$plid" in + Darwin/* ) + niutil -create . "/groups/${grp}" + niutil -createprop . "/groups/${grp}" gid "${gid}" + niutil -createprop . "/groups/${grp}" users "${usr}" + ;; + AIX/* ) + mkgroup id="${gid}" users="${usr}" "${grp}" + ;; + * ) + # add entry to group database + file=/etc/group + entry="${grp}:*:${gid}:${usr}" + cp $file $file.bak && \ + (grep -v '^+:' $file.bak; echo $entry; grep '^+:' $file.bak) >$file + rm -f $file.bak >/dev/null 2>&1 + ;; + esac + fi + fi + done + + # optional group processing (deferred adjustment of primary group) + if [ -f %{l_prefix}.pre-group-process.sh ]; then + sh %{l_prefix}.pre-group-process.sh + rm -f %{l_prefix}.pre-group-process.sh + fi + + # invalidate passwd and group tables from Name Service Cache Daemon to + # ensure chown/chgrp works immediately after pwconv on Linux and Solaris + if [ -x /usr/sbin/nscd ]; then + /usr/sbin/nscd -i passwd >/dev/null 2>&1 || true + /usr/sbin/nscd -i group >/dev/null 2>&1 || true + fi + + # create the startup/shutdown transfer script + name=`echo "$prefix" | sed -e 's;/;;g'` + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping creation of system run-command hooks" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + case "$plid" in + FreeBSD/* ) + if [ ! -f /etc/rc.d/openpkg-${name} ]; then + # install transfer script + rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1 + ( echo "#!/bin/sh" + echo "##" + echo "## openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "# PROVIDE: openpkg-${name}" + echo "# REQUIRE: LOGIN" + echo "# KEYWORD: shutdown" + echo "" + echo ". /etc/rc.subr" + echo "" + echo "name=\"openpkg_${name}\"" + echo "start_cmd=\"openpkg_rc_all start\"" + echo "stop_cmd=\"openpkg_rc_all stop\"" + echo "restart_cmd=\"openpkg_rc_all stop start\"" + echo "" + echo "openpkg_rc_all () {" + echo " if [ -f ${prefix}/etc/rc ]; then" + echo " ${prefix}/etc/rc all \"\$@\"" + echo " fi" + echo "}" + echo "" + echo "load_rc_config \$name" + echo "run_rc_command \"\$1\"" + echo "" + ) >/etc/rc.d/openpkg-${name} + chmod 755 /etc/rc.d/openpkg-${name} + fi + ;; + NetBSD/* ) + if [ ! -f /etc/rc.d/${name} ]; then + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "## PROVIDE: ${name}" + echo "## REQUIRE: DAEMON LOGIN NETWORK SERVERS" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo " restart ) exec ${prefix}/etc/rc all stop start ;;" + echo " status ) ;;" + echo "esac" + ) >/etc/rc.d/${name} + chmod 755 /etc/rc.d/${name} + fi + ;; + Linux/* ) + if [ -f /etc/gentoo-release ]; then + if [ ! -f /etc/init.d/openpkg-${name} ]; then + # install transfer script + ( echo "#!/sbin/runscript" + echo "##" + echo "## openpkg-${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "depend() {" + echo " after *" + echo "}" + echo "" + echo "checkconfig() {" + echo " [ -f ${prefix}/etc/rc ] || return 1" + echo " case $1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo " esac" + echo "}" + echo "" + echo "start() {" + echo " checkconfig || return 1" + echo " ebegin "Starting OpenPKG ${prefix} hierarchy"" + echo " exec ${prefix}/etc/rc all start" + echo " eend 0" + echo "}" + echo "" + echo "stop() {" + echo " checkconfig || return 1" + echo " ebegin "Stopping OpenPKG ${prefix} hierarchy"" + echo " exec ${prefix}/etc/rc all stop" + echo " eend 0" + echo "}" + ) >/etc/init.d/openpkg-${name} + chmod 755 /etc/init.d/openpkg-${name} + /sbin/rc-update add openpkg-${name} default + fi + else + # sroot: script root directory + # lroot: link root directory + if [ -f /etc/debian_version ]; then + sroot=/etc/init.d + lroot=/etc/rc%d.d + elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then + sroot=/etc/rc.d/init.d + lroot=/etc/rc.d/rc%d.d + elif [ -f /etc/SuSE-release ]; then + sroot=/etc/init.d + lroot=/etc/init.d/rc%d.d + elif [ -f /etc/slackware-version ]; then + sroot=/etc/rc.d + lroot=/etc/rc.d/rc%d.d + name="rc.${name}" + for i in 0 1 2 3 4 5 6; do + l=`echo $lroot | sed -e "s;%d;$i;"` + if [ ! -d $l ]; then + mkdir $l 2>&1 || true + fi + done + else + echo "WARNING: you are not running one of the supported standard" 1>&2 + echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)." 1>&2 + echo "WARNING: Guessing the location of the system init scripts!" 1>&2 + sroot="" + lroot="" + for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do + if [ -d $sr ]; then + sroot="$sr" + break + fi + done + for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do + if [ -d $lr ]; then + lroot="`echo $lr | sed -e 's;2;%d;'`" + break + fi + done + if [ ".$sroot" = . -o ".$lroot" = . ]; then + echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2 + exit 1 + fi + fi + if [ ! -f $sroot/${name} ]; then + # install transfer script + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo "esac" + ) >$sroot/${name} + chmod 755 $sroot/${name} + # create corresponding symbolic links + for i in 2 3 4 5; do + ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/S99${name} + done + for i in 0 1 6; do + ln -s $sroot/${name} `echo $lroot | sed -e "s;%d;$i;"`/K00${name} + done + fi + fi + ;; + SunOS/5.* ) + if [ ! -f /etc/init.d/${name} ]; then + # install transfer script + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo "esac" + ) >/etc/init.d/${name} + chmod 755 /etc/init.d/${name} + # create corresponding symbolic links + ( cd /etc + ln init.d/${name} rc3.d/S99${name} + ln init.d/${name} rc0.d/K00${name} + ln init.d/${name} rc1.d/K00${name} + ) || exit $? + fi + ;; + UnixWare/* ) + if [ ! -f /etc/init.d/${name} ]; then + # install transfer script + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo "esac" + ) >/etc/init.d/${name} + chmod 755 /etc/init.d/${name} + # create corresponding symbolic links + ( cd /etc + ln init.d/${name} rc2.d/S99${name} + ln init.d/${name} rc0.d/K00${name} + ln init.d/${name} rc1.d/K00${name} + ) || exit $? + fi + ;; + AIX/* ) + if [ ! -f /etc/rc.d/init.d/${name} ]; then + # install transfer script + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo "esac" + ) >/etc/rc.d/init.d/${name} + chmod 755 /etc/rc.d/init.d/${name} + # create corresponding symbolic links + ( cd /etc/rc.d + ln -s ../init.d/${name} rc2.d/S99${name} + ) || exit $? + fi + ;; + OSF1/V5.* ) + if [ ! -f /sbin/init.d/${name} ]; then + # install transfer script + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo "esac" + ) >/sbin/init.d/${name} + chmod 755 /sbin/init.d/${name} + # create corresponding symbolic links + ( cd /sbin + ln -s ../init.d/${name} rc3.d/S99${name} + ln -s ../init.d/${name} rc0.d/K00${name} + ) || exit $? + fi + ;; + HP-UX/* ) + if [ ! -f /sbin/init.d/${name} ]; then + # install transfer script + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo "esac" + ) >/sbin/init.d/${name} + chmod 755 /sbin/init.d/${name} + # create corresponding symbolic links + ( cd /sbin + ln -s ../init.d/${name} rc2.d/S900${name} + ln -s ../init.d/${name} rc1.d/K100${name} + ) || exit $? + fi + ;; + Darwin/* ) + darwin_rc_dir="/System/Library/StartupItems/${name}" + if [ ! -d ${darwin_rc_dir} ]; then + mkdir ${darwin_rc_dir} + fi + + # make sure hierarchy is activated in /etc/hostconfig + # FIXME: cs: simple and bad code here without any detection of existing entries + echo "OPENPKG_${name}=-YES-" >>/etc/hostconfig + + # install transfer script + if [ ! -f ${darwin_rc_dir}/${name} ]; then + rm -f ${darwin_rc_dir}/${name} >/dev/null 2>&1 + ( echo "#!/bin/sh" + echo "##" + echo "## ${darwin_rc_dir}/${name}" + echo "## -- startup transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "" + echo ". /etc/rc.common" + echo "" + echo "if [ \"\${OPENPKG_${name}:=-NO-}\" = \"-YES-\" ]; then" + echo " ConsoleMessage \"OpenPKG ${prefix} hierarchy\"" + echo " ${prefix}/etc/rc all start" + echo "fi" + ) >${darwin_rc_dir}/${name} + chmod 755 ${darwin_rc_dir}/${name} + fi + # install startup parameter list + if [ ! -f ${darwin_rc_dir}/StartupParameters.plist ]; then + rm -f ${darwin_rc_dir}/StartupParameters.plist >/dev/null 2>&1 + ( echo "{" + echo " Description = \"OpenPKG ${prefix} hierarchy\";" + echo " Provides = (\"OpenPKG ${prefix}\");" + echo " Requires = (\"Disks\", \"Network Configuration\", \"Resolver\");" + echo " Uses = (\"Cron\");" + echo " OrderPreference = \"Last\";" + echo " Messages =" + echo " {" + echo " start = \"Starting OpenPKG ${prefix} hierarchy\";" + echo " stop = \"Stopping OpenPKG ${prefix} hierarchy\";" + echo " };" + echo "}" + ) >${darwin_rc_dir}/StartupParameters.plist + chmod 644 ${darwin_rc_dir}/StartupParameters.plist + fi + ;; + IRIX*/6.* ) + if [ ! -f /etc/init.d/${name} ]; then + # install transfer script + ( echo "#!/bin/sh" + echo "##" + echo "## ${name} -- startup/shutdown transfer script for OpenPKG ${prefix} hierarchy" + echo "##" + echo "" + echo "[ ! -f ${prefix}/etc/rc ] && exit 0" + echo "case \$1 in" + echo " start ) exec ${prefix}/etc/rc all start ;;" + echo " stop ) exec ${prefix}/etc/rc all stop ;;" + echo "esac" + ) >/etc/init.d/${name} + chmod 755 /etc/init.d/${name} + # create corresponding links + ( cd /etc + ln -f init.d/${name} rc2.d/S99${name} + ln -f init.d/${name} rc0.d/K00${name} + ) || exit $? + fi + ;; + esac + fi + + # create the cron transfer entries + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping creation of system cron hooks" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + case "$plid" in + FreeBSD/* | Linux/* | Darwin/* ) + if [ -f /etc/slackware-version ]; then + exists=`crontab -l | grep "$prefix/etc/rc"` + if [ ".$exists" = . ]; then + EDITOR=/tmp/vipw.$$ + VISUAL="$EDITOR" + export EDITOR + export VISUAL + ( echo "#!/bin/sh" + echo "( echo \"# \"" + echo " echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\"" + echo " echo \"0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\"" + echo " echo \"0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\"" + echo " echo \"0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\"" + echo " echo \"0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\"" + echo " echo \"0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\"" + echo " echo \"# \"" + echo ") >>\$1" + ) >$EDITOR + chmod a+x $EDITOR + ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $? + rm -f $EDITOR + fi + else + exists=`grep "$prefix/etc/rc" /etc/crontab` + if [ ".$exists" = . ]; then + ( echo "# " + echo "# chronological tasks of ${prefix} OpenPKG hierarchy" + echo "0 0 1 * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly" + echo "0 0 * * 0 root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly" + echo "0 0 * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily" + echo "0 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly" + echo "*/15 * * * * root [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly" + echo "# " + ) >>/etc/crontab + fi + fi + ;; + SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* ) + exists=`crontab -l | grep "$prefix/etc/rc"` + if [ ".$exists" = . ]; then + EDITOR=/tmp/vipw.$$ + VISUAL="$EDITOR" + export EDITOR + export VISUAL + ( echo "#!/bin/sh" + echo "( echo \"# \"" + echo " echo \"# chronological tasks of ${prefix} OpenPKG hierarchy\"" + echo " echo \"0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly\"" + echo " echo \"0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly\"" + echo " echo \"0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily\"" + echo " echo \"0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly\"" + echo " echo \"0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly\"" + echo " echo \"# \"" + echo ") >>\$1" + ) >$EDITOR + chmod a+x $EDITOR + ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $? + rm -f $EDITOR + fi + ;; + IRIX*/6.* ) + exists=`crontab -l | grep "$prefix/etc/rc"` + if [ ".$exists" = . ]; then + ( crontab -l + echo "# " + echo "# chronological tasks of ${prefix} OpenPKG hierarchy" + echo "0 0 1 * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all monthly" + echo "0 0 * * 0 [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all weekly" + echo "0 0 * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all daily" + echo "0 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all hourly" + echo "0,15,30,45 * * * * [ -f ${prefix}/etc/rc ] && ${prefix}/etc/rc all quarterly" + echo "# " + ) | /usr/bin/crontab || exit $? + fi + ;; + esac + fi + + # remember what OpenPKG RPM version was installed, so we can + # correctly upgrade the RPM database in the %post section (see below). + if [ -d ${prefix}/RPM/DB ]; then + if [ -x "${prefix}/bin/openpkg" -a -x "${prefix}/libexec/openpkg/rpm" ]; then + # OpenPKG 2.0 + rpm="${prefix}/bin/openpkg rpm" + else + # OpenPKG 1.x + rpm="${prefix}/bin/rpm" + fi + rm -f ${prefix}/RPM/DB/.version >/dev/null 2>&1 || true + $rpm --version |\ + sed -e 's;^;X;' \ + -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \ + -e 's;^X[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$;\1;' \ + -e 's;^X.*$;4.0;' \ + >${prefix}/RPM/DB/.version + fi + +%post + # optional post-processing from "pre" section + if [ -f %{l_prefix}.pre-post-process.sh ]; then + sh %{l_prefix}.pre-post-process.sh + rm -f %{l_prefix}.pre-post-process.sh + fi + + # update or initially create OpenPKG UUID configuration + %{l_prefix}/bin/openpkg uuid update >/dev/null 2>&1 || true + + # determine new and old OpenPKG RPM version + V_rpm_new="%{V_rpm}" + if [ -f %{l_prefix}/RPM/DB/.version ]; then + V_rpm_old="`cat %{l_prefix}/RPM/DB/.version`" + rm -f %{l_prefix}/RPM/DB/.version >/dev/null 2>&1 || true + else + V_rpm_old="4.0" + fi + + # make sure all RPM database files are present and that their + # attributes are correct, etc. This is not a database rebuild + # operation, so this is fully harmless and can be done always. + %{l_prefix}/lib/openpkg/rpmdb --quiet --fixate + + # check RPM database for upgrade requirements + if [ ".$1" = .2 -a ".$V_rpm_old" != ".$V_rpm_new" ]; then + # RPM 4.0/4.1 does not allow concurrent database access, so we + # cannot upgrade the database immediately from here (because + # we are still running within the execution context of the + # old RPM which in turn has the database locked) and instead + # have to just drop a note to the administrator about database + # upgrading. RPM 4.2 in general allows concurrent database + # access, but the whole stuff is too risky here, too. + ( echo "You are upgrading the OpenPKG bootstrap from a previous" + echo "RPM $V_rpm_old based version to this RPM $V_rpm_new based" + echo "version. The RPM database in %{l_prefix}/RPM/DB/ can still" + echo "be used, but it is strongly recommended to upgrade it as" + echo "soon as possible to the latest Berkeley-DB format files by" + echo "executing the command:" + echo " \$ %{l_prefix}/bin/openpkg rpm --db-rebuild" + echo "In case of problems with the RPM database you can always" + echo "execute the command:" + echo " \$ %{l_prefix}/bin/openpkg rpm --db-cleanup" + ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t warn + fi + + # system command overriding support + # ATTENTION: THIS BETTER SHOULD BE REPLACED WITH A MORE GENERIC + # BUILD COMMAND OVERRIDE SOLUTION! + if [ ! -d %{l_prefix}/lib/openpkg/override ]; then + mkdir %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true + fi + chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true + case "`cat %{l_prefix}/etc/openpkg/platform`" in + *-*-debian* | *-*-ubuntu* ) + # FIXME: Evil hack to workaround build problems under Debian + # (at least 3.1) (and similar platforms) where a Debian + # install-info(8) exists which is both API and functionally + # incompatible to the de-facto standardized install-info(8) + # command from GNU Texinfo. + if [ ! -f %{l_prefix}/lib/openpkg/override/install-info ]; then + ( echo "#!/bin/sh" + echo "echo 'OpenPKG: NOTICE: install-info(8) command execution overridden'" + echo "exit 0" + ) >%{l_prefix}/lib/openpkg/override/install-info + chmod 775 %{l_prefix}/lib/openpkg/override/install-info + fi + ;; + *-*-macosx* | *-*-darwin* ) + # FIXME: Evil hack to workaround the fact that Mac OS X' + # linker by default prefers the /usr/lib libraries and does + # not honor the -L options the way one would expect it. + gcc="`%{l_prefix}/lib/openpkg/shtool path gcc`" + cc="`%{l_prefix}/lib/openpkg/shtool path cc`" + ld="`%{l_prefix}/lib/openpkg/shtool path ld`" + if [ ".$gcc" != . -a ! -f %{l_prefix}/lib/openpkg/override/gcc ]; then + ( echo "#!/bin/sh" + echo "case \" \$* \" in" + echo " *\" -c \"* | *\" -E \"* ) exec $gcc \"\$@\" ;;" + echo " * ) exec $gcc -Wl,-search_paths_first \"\$@\" ;;" + echo "esac" + ) >%{l_prefix}/lib/openpkg/override/gcc + chmod 775 %{l_prefix}/lib/openpkg/override/gcc + fi + if [ ".$cc" != . -a ! -f %{l_prefix}/lib/openpkg/override/cc ]; then + ( echo "#!/bin/sh" + echo "case \" \$* \" in" + echo " *\" -c \"* | *\" -E \"* ) exec $gcc \"\$@\" ;;" + echo " * ) exec $cc -Wl,-search_paths_first \"\$@\" ;;" + echo "esac" + ) >%{l_prefix}/lib/openpkg/override/cc + chmod 775 %{l_prefix}/lib/openpkg/override/cc + fi + if [ ".$ld" != . -a ! -f %{l_prefix}/lib/openpkg/override/ld ]; then + ( echo "#!/bin/sh" + echo "exec $ld -search_paths_first \"\$@\"" + ) >%{l_prefix}/lib/openpkg/override/ld + chmod 775 %{l_prefix}/lib/openpkg/override/ld + fi + ;; + esac + + # FIXME: hack to workaround problems in environments with too few + # development tools. ATTENTION: see one paragraph above. + if [ ! -d %{l_prefix}/lib/openpkg/fallback ]; then + mkdir %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true + fi + chown %{l_musr}:%{l_mgrp} %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true + + # check for "openpkg" executable from the OpenPKG Community series + # print license if not OSS, otherwise register with openpkg.org + community_version=`%{l_prefix}/bin/openpkg --license 2>/dev/null | \ + sed -e 'q' | egrep '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*-C'` + if [ ".$community_version" = . ]; then + ( echo "" + echo "NOTICE: This OpenPKG bootstrap package is based on an \"openpkg\"" + echo "executable which is covered by the following terms of use:" + echo "______________________________________________________________________________" + echo "" + %{l_prefix}/bin/openpkg --license | sed -e '1d' + ) | %{l_prefix}/lib/openpkg/rpmtool msg -b -t notice + else + %{l_prefix}/bin/openpkg register /dev/null 2>&1 || true + fi + +%preun + [ ".$1" != .0 ] && exit 0 + + # remove override files + if [ -d %{l_prefix}/lib/openpkg/override ]; then + rm -rf %{l_prefix}/lib/openpkg/override >/dev/null 2>&1 || true + fi + + # remove fallback files + if [ -d %{l_prefix}/lib/openpkg/fallback ]; then + rm -rf %{l_prefix}/lib/openpkg/fallback >/dev/null 2>&1 || true + fi + + # remove files which are not RPM controlled + rm -rf %{l_prefix}/RPM/TMP/* %{l_prefix}/RPM/TMP/.[a-z]* >/dev/null 2>&1 || true + rm -rf %{l_prefix}/RPM/SRC/* %{l_prefix}/RPM/SRC/.[a-z]* >/dev/null 2>&1 || true + rm -rf %{l_prefix}/RPM/PKG/* %{l_prefix}/RPM/PKG/.[a-z]* >/dev/null 2>&1 || true + rm -rf %{l_prefix}/RPM/DB/* %{l_prefix}/RPM/DB/.[a-z]* >/dev/null 2>&1 || true + + # The following code usually would be done in a %postun section. + # But because we already had to remove the database in this %preun + # section (see the 'rm' commands above) in order to make RPM happy + # inside its own removal procedure, RPM would no longer find the + # %postun script (because it's recorded in the database files). So + # we have to perform the procedure already in this %preun script. + # except for the removal of the top-level directory it does not + # matter. But the top-level directory can only be removed after + # the RPM removal procedure took place, so we play a little delay + # trick below. + + # determine current user + cusr=`(id -un) 2>/dev/null ||\ + (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\ + (whoami) 2>/dev/null ||\ + (who am i | cut "-d " -f1) 2>/dev/null ||\ + echo $LOGNAME` + + # determine runtime details (for both inside and outside RPM!!) + user="%{l_musr}" + group="%{l_mgrp}" + prefix="%{l_prefix}" + prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'` + + # determine platform id + s=`(uname -s) 2>/dev/null` || s='Unknown' + r=`(uname -r) 2>/dev/null` || r='0.0' + plid="${s}/${r}" + + # unregister instance in presence file + presence="/etc/openpkg" + exists=`cat $presence 2>/dev/null | egrep "^ *${prefix} *\$"` + if [ ".$exists" != . ]; then + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping unregistering of $prefix in $presence" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + cp $presence $presence.bak && \ + egrep -v "^ *${prefix} *\$" $presence.bak >$presence + rm -f $presence.bak >/dev/null 2>&1 + if [ ".`cat $presence`" = . ]; then + rm -f $presence >/dev/null 2>&1 + fi + fi + fi + + # remove entry in /etc/shells + shell="${prefix}/lib/openpkg/bash" + exists=`cat /etc/shells 2>/dev/null | grep "^$shell"` + if [ ".$exists" != . ]; then + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping deletion of $shell from /etc/shells" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + cp /etc/shells /etc/shells.bak && \ + grep -v "^${shell}" /etc/shells.bak >/etc/shells + rm -f /etc/shells.bak >/dev/null 2>&1 + fi + fi + + # remove the hierarchy user/group + for req in "super-user:%{l_susr}:%{l_suid}:%{l_sgrp}:%{l_sgid}" \ + "management:%{l_musr}:%{l_muid}:%{l_mgrp}:%{l_mgid}" \ + "restricted:%{l_rusr}:%{l_ruid}:%{l_rgrp}:%{l_rgid}" \ + "non-privileged:%{l_nusr}:%{l_nuid}:%{l_ngrp}:%{l_ngid}"; do + # split request into class/usr/uid/grp/gid + OIFS="$IFS"; IFS=":"; set -- $req; IFS="$OIFS" + class="$1"; usr="$2"; uid="$3"; grp="$4"; gid="$5" + + # check whether user already exists + exists=`(getent passwd "$usr"; \ + grep "^$usr:" /etc/passwd; \ + ypmatch "$usr" passwd; \ + nismatch "$usr" passwd; \ + nidump passwd . | grep "^$usr:") 2>/dev/null | \ + sed -e 'q'` + if [ ".$exists" != . ]; then + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + elif [ ".$usr" = ".root" ]; then + echo "openpkg:WARNING: skipping deletion of OpenPKG $class user $usr" 1>&2 + echo "openpkg:WARNING: (would remove system standard user)" 1>&2 + else + case "$plid" in + FreeBSD/* | NetBSD/* ) + cp /etc/master.passwd /etc/master.passwd.bak && \ + grep -v "^${usr}:" /etc/master.passwd.bak >/etc/master.passwd + ( PATH="$PATH:/usr/sbin"; pwd_mkdb -p /etc/master.passwd ) || exit $? + rm -f /etc/master.passwd.bak >/dev/null 2>&1 + ;; + Linux/* | SunOS/5.* | UnixWare/* ) + cp /etc/passwd /etc/passwd.bak && \ + grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd + ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $? + rm -f /etc/passwd.bak >/dev/null 2>&1 + ;; + AIX/* ) + rmuser -p "${usr}" + cp /etc/security/login.cfg /etc/security/login.cfg.bak && \ + sed -e "/^usw:/,/^[^ ]/s;\\( *shells =.*\\),$shell\\(.*\\)\$;\\1\\2;" \ + /etc/security/login.cfg && \ + rm -f /etc/security/login.cfg.bak >/dev/null 2>&1 + ;; + OSF1/V5.* ) + cp /etc/passwd /etc/passwd.bak && \ + grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd + ( PATH="$PATH:/usr/sbin"; mkpasswd /etc/passwd ) || exit $? + rm -f /etc/passwd.bak >/dev/null 2>&1 + ;; + HP-UX/* ) + cp /etc/passwd /etc/passwd.bak && \ + grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd + rm -f /etc/passwd.bak >/dev/null 2>&1 + ;; + Darwin/* ) + niutil -destroy . "/users/${usr}" + ;; + IRIX*/6.* ) + cp /etc/passwd /etc/passwd.bak && \ + grep -v "^${usr}:" /etc/passwd.bak >/etc/passwd + if [ -f /etc/shadow ] + then ( PATH="$PATH:/usr/sbin"; pwconv ) || exit $? + fi + rm -f /etc/passwd.bak >/dev/null 2>&1 + ;; + esac + fi + fi + + # check whether group already exists + exists=`(getent group "$grp"; \ + grep "^$grp:" /etc/group; \ + ypmatch "$grp" group; \ + nismatch "$grp" group; \ + nidump group . | grep "^$grp:") 2>/dev/null | \ + sed -e 'q'` + if [ ".$exists" != . ]; then + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + elif [ ".$usr" = ".root" ] || [ ".$grp" = ".root" ] || [ ".$grp" = ".wheel" ]; then + echo "openpkg:WARNING: skipping deletion of OpenPKG $class group $grp" 1>&2 + echo "openpkg:WARNING: (would remove system standard group)" 1>&2 + else + case "$plid" in + Darwin/* ) + niutil -destroy . "/groups/${grp}" + ;; + AIX/* ) + rmgroup "${grp}" + ;; + * ) + cp /etc/group /etc/group.bak && \ + grep -v "^${grp}:" /etc/group.bak >/etc/group + rm -f /etc/group.bak >/dev/null 2>&1 + ;; + esac + fi + fi + done + + # invalidate passwd and group tables from Name Service Cache Daemon to + # ensure chown/chgrp works immediately after pwconv on Linux and Solaris + if [ -x /usr/sbin/nscd ]; then + /usr/sbin/nscd -i passwd >/dev/null 2>&1 || true + /usr/sbin/nscd -i group >/dev/null 2>&1 || true + fi + + # remove the startup/shutdown transfer scripts + name=`echo "$prefix" | sed -e 's;/;;g'` + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping deletion of system run-command hooks" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + case "$plid" in + FreeBSD/* ) + rm -f /etc/rc.d/openpkg-${name} >/dev/null 2>&1 + ;; + NetBSD/* ) + rm -f /etc/rc.d/${name} >/dev/null 2>&1 + ;; + Linux/* ) + if [ -f /etc/gentoo-release ]; then + /sbin/rc-update del openpkg-${name} >/dev/null 2>&1 + rm -f /etc/init.d/openpkg-${name} >/dev/null 2>&1 + else + # sroot: script root directory + # lroot: link root directory + if [ -f /etc/debian_version ]; then + sroot=/etc/init.d + lroot=/etc/rc%d.d + elif [ -f /etc/redhat-release -o -f /etc/mandrake-release ]; then + sroot=/etc/rc.d/init.d + lroot=/etc/rc.d/rc%d.d + elif [ -f /etc/SuSE-release ]; then + sroot=/etc/init.d + lroot=/etc/init.d/rc%d.d + elif [ -f /etc/slackware-version ]; then + sroot=/etc/rc.d + lroot=/etc/rc.d/rc%d.d + name="rc.${name}" + else + echo "WARNING: you are not running one of the supported standard" 1>&2 + echo "WARNING: Linux platforms (Debian, RedHat, Mandrake, SuSE, Gentoo)." 1>&2 + echo "WARNING: Guessing the location of the system init scripts!" 1>&2 + sroot="" + lroot="" + for sr in /etc/rc.d/init.d /etc/init.d /sbin/init.d; do + if [ -d $sr ]; then + sroot="$sr" + break + fi + done + for lr in /etc/rc.d/rc2.d /etc/rc2.d /sbin/init.d/rc2.d; do + if [ -d $lr ]; then + lroot="`echo $lr | sed -e 's;2;%d;'`" + break + fi + done + if [ ".$sroot" = . -o ".$lroot" = . ]; then + echo "ERROR: Failed to guess the location of the system init scripts!" 1>&2 + exit 1 + fi + fi + rm -f ${sroot}/${name} >/dev/null 2>&1 + for i in 2 3 4 5; do + rm -f `echo $lroot | sed -e "s;%d;$i;"`/S99${name} >/dev/null 2>&1 + done + for i in 0 1 6; do + rm -f `echo $lroot | sed -e "s;%d;$i;"`/K00${name} >/dev/null 2>&1 + done + if [ -f /etc/slackware-version ]; then + for i in 0 1 2 3 4 5 6; do + l=`echo $lroot | sed -e "s;%d;$i;"` + if [ -d $l ]; then + rmdir $l >/dev/null 2>&1 || true + fi + done + fi + fi + ;; + SunOS/5.* ) + rm -f /etc/init.d/${name} >/dev/null 2>&1 + rm -f /etc/rc3.d/S99${name} >/dev/null 2>&1 + rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1 + rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1 + ;; + UnixWare/* ) + rm -f /etc/init.d/${name} >/dev/null 2>&1 + rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1 + rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1 + rm -f /etc/rc1.d/K00${name} >/dev/null 2>&1 + ;; + AIX/* ) + rm -f /etc/rc.d/init.d/${name} >/dev/null 2>&1 + rm -f /etc/rc.d/rc2.d/S99${name} >/dev/null 2>&1 + ;; + OSF1/V5.* ) + rm -f /sbin/init.d/${name} >/dev/null 2>&1 + rm -f /sbin/rc3.d/S99${name} >/dev/null 2>&1 + rm -f /sbin/rc0.d/K00${name} >/dev/null 2>&1 + ;; + HP-UX/* ) + rm -f /sbin/init.d/${name} >/dev/null 2>&1 + rm -f /etc/rc2.d/S900${name} >/dev/null 2>&1 + rm -f /etc/rc1.d/K100${name} >/dev/null 2>&1 + ;; + Darwin/* ) + cp /etc/hostconfig /etc/hostconfig.bak && \ + grep -v "^OPENPKG_${name}=" /etc/hostconfig.bak >/etc/hostconfig + rm -f /etc/hostconfig.bak >/dev/null 2>&1 + rm -rf /System/Library/StartupItems/${name} >/dev/null 2>&1 + ;; + IRIX*/6.* ) + rm -f /etc/init.d/${name} >/dev/null 2>&1 + rm -f /etc/rc2.d/S99${name} >/dev/null 2>&1 + rm -f /etc/rc0.d/K00${name} >/dev/null 2>&1 + ;; + esac + fi + + # remove the cron transfer entries + if [ ".$cusr" != ".root" ]; then + echo "openpkg:WARNING: skipping deletion of system cron hooks" 1>&2 + echo "openpkg:WARNING: (would require root-privileges)" 1>&2 + else + case "$plid" in + FreeBSD/* | Linux/* | Darwin/* ) + if [ -f /etc/slackware-version ]; then + EDITOR=/tmp/vipw.$$ + VISUAL="$EDITOR" + export EDITOR + export VISUAL + p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'` + ( echo "cp \$1 \$1.bak" + echo "cat \$1.bak | sed -e \"//,/<\\\\/OpenPKG>/d\" >\$1" + echo "rm -f \$1.bak" + ) >$EDITOR + chmod a+x $EDITOR + ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $? + rm -f $EDITOR + else + exists=`grep "" /etc/crontab` + if [ ".$exists" != . ]; then + p=`echo $prefix | sed -e 's;/;\\\\/;g'` + cp /etc/crontab /etc/crontab.bak + cat /etc/crontab.bak |\ + sed -e "//,/<\\/OpenPKG>/d" \ + >/etc/crontab + rm -f /etc/crontab.bak >/dev/null 2>&1 + fi + fi + ;; + SunOS/5.* | OSF1/V5.* | NetBSD/* | HP-UX/* | UnixWare/* | AIX/* ) + EDITOR=/tmp/vipw.$$ + VISUAL="$EDITOR" + export EDITOR + export VISUAL + p=`echo $prefix | sed -e 's;/;\\\\\\\\/;g'` + ( echo "cp \$1 \$1.bak" + echo "cat \$1.bak | sed -e \"//,/<\\\\/OpenPKG>/d\" >\$1" + echo "rm -f \$1.bak" + ) >$EDITOR + chmod a+x $EDITOR + ( PATH="$PATH:/usr/bin"; crontab -e ) || exit $? + rm -f $EDITOR + ;; + IRIX*/6.* ) + p=`echo $prefix | sed -e 's;/;\\\\\\/;g'` + ( crontab -l | + sed -e "//,/<\/OpenPKG>/d" + ) | /usr/bin/crontab || exit $? + ;; + esac + fi + + # delayed removal of top-level directory. + ( sleep 2 + rm -rf %{l_prefix}/RPM/DB/* %{l_prefix}/RPM/DB/.[a-z]* >/dev/null 2>&1 || true + rmdir %{l_prefix}/RPM/DB >/dev/null 2>&1 || true + rmdir %{l_prefix}/RPM >/dev/null 2>&1 || true + rmdir %{l_prefix} >/dev/null 2>&1 || true + ) /dev/null 2>/dev/null & +