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