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