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