openpkg/openpkg.boot

changeset 428
f880f219c566
parent 13
cb59d6afeb61
child 447
129b16fdb811
equal deleted inserted replaced
0:bdddab3fb43c 1:939fcd9a9af8
1 #!/bin/sh 1 #!/bin/sh
2 ## 2 ##
3 ## openpkg.boot -- OpenPKG bootstrap procedure (look Ma, without hands ;) 3 ## openpkg.boot -- OpenPKG bootstrap procedure (look Ma, without hands ;)
4 ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/> 4 ## Copyright (c) 2000-2012 OpenPKG GmbH <http://openpkg.com/>
5 ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/> 5 ##
6 ## 6 ## This software is property of the OpenPKG GmbH, DE MUC HRB 160208.
7 ## Permission to use, copy, modify, and distribute this software for 7 ## All rights reserved. Licenses which grant limited permission to use,
8 ## any purpose with or without fee is hereby granted, provided that 8 ## copy, modify and distribute this software are available from the
9 ## the above copyright notice and this permission notice appear in all 9 ## OpenPKG GmbH.
10 ## copies. 10 ##
11 ## 11 ## THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
12 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
13 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 12 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 13 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR 14 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
16 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 15 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 16 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 # command line parameters (defaults) 44 # command line parameters (defaults)
46 help=0 45 help=0
47 verbose='' 46 verbose=''
48 prefix='' 47 prefix=''
49 tag='' 48 tag=''
49 stack=''
50 unprivileged=no
50 usr=''; grp='' 51 usr=''; grp=''
51 susr=''; sgrp='' 52 susr=''; sgrp=''
52 musr=''; mgrp='' 53 musr=''; mgrp=''
53 rusr=''; rgrp='' 54 rusr=''; rgrp=''
54 nusr=''; ngrp='' 55 nusr=''; ngrp=''
69 case $opt in 70 case $opt in
70 -h | --help ) help=1 ;; 71 -h | --help ) help=1 ;;
71 -v | --verbose ) verbose=v ;; 72 -v | --verbose ) verbose=v ;;
72 --prefix=* ) prefix=$arg ;; 73 --prefix=* ) prefix=$arg ;;
73 --tag=* ) tag=$arg ;; 74 --tag=* ) tag=$arg ;;
75 --stack=* ) stack=$arg ;;
76 --unprivileged ) unprivileged=yes ;;
74 --usr=* | --user=* ) usr=$arg ;; 77 --usr=* | --user=* ) usr=$arg ;;
75 --grp=* | --group=* ) grp=$arg ;; 78 --grp=* | --group=* ) grp=$arg ;;
76 --susr=* ) susr=$arg ;; 79 --susr=* ) susr=$arg ;;
77 --sgrp=* ) sgrp=$arg ;; 80 --sgrp=* ) sgrp=$arg ;;
78 --musr=* ) musr=$arg ;; 81 --musr=* ) musr=$arg ;;
104 help=1 107 help=1
105 fi 108 fi
106 if [ ".$help" = .1 ]; then 109 if [ ".$help" = .1 ]; then
107 echo "Usage: sh $me" 2>&1 110 echo "Usage: sh $me" 2>&1
108 echo " [--prefix=<prefix>] [--tag=<str>]" 2>&1 111 echo " [--prefix=<prefix>] [--tag=<str>]" 2>&1
112 echo " [--stack=<name-or-url>] [--unprivileged]" 2>&1
109 echo " [--user=<usr>] [--group=<grp>]" 2>&1 113 echo " [--user=<usr>] [--group=<grp>]" 2>&1
110 echo " [--{s,m,r,n}usr=<usr>] [--{s,m,r,n}grp=<grp>]" 2>&1 114 echo " [--{s,m,r,n}usr=<usr>] [--{s,m,r,n}grp=<grp>]" 2>&1
111 echo " [--{s,m,r,n}uid=<uid>] [--{s,m,r,n}gid=<gid>]" 2>&1 115 echo " [--{s,m,r,n}uid=<uid>] [--{s,m,r,n}gid=<gid>]" 2>&1
112 echo " [--use_tar=<tar>] [--use_make=<make>] [--use_cc=<cc>]" 2>&1 116 echo " [--use_tar=<tar>] [--use_make=<make>] [--use_cc=<cc>]" 2>&1
113 echo " [--use_ar=<ar>] [--use_ld=<ld>] [--use_as=<as>] [--use_strip=<strip>]" 2>&1 117 echo " [--use_ar=<ar>] [--use_ld=<ld>] [--use_as=<as>] [--use_strip=<strip>]" 2>&1
114 echo " [-t|--tar] [-h|--help] [-v|--version]" 2>&1 118 echo " [-t|--tar] [-h|--help] [-v|--version]" 2>&1
115 exit 1 119 exit 1
116 fi 120 fi
117 121
122 # special support for environments with only a single
123 # fully unprivileged user account (the current user)
124 if [ ".$unprivileged" = .yes ]; then
125 # determine current user/group
126 cusr=`(id -un) 2>/dev/null ||\
127 (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
128 (whoami) 2>/dev/null ||\
129 (who am i | cut "-d " -f1) 2>/dev/null ||\
130 echo $LOGNAME`
131 cgid=`(id -g $cusr) 2>/dev/null ||\
132 ((getent passwd "${cusr}"; grep "^${cusr}:" /etc/passwd; ypmatch "${cusr}" passwd; nismatch "${cusr}" passwd; nidump passwd . | grep "^${cusr}:") 2>/dev/null |\
133 sed -n -e '1p' | awk -F: '{ print $4; }')`
134 cgrp=`(id -gn $cusr) 2>/dev/null ||\
135 ((getent group; cat /etc/group; ypcat group; niscat group; nidump group .) 2>/dev/null | grep "^[^:]*:[^:]*:${cgid}:" |\
136 sed -n -e '1p' | awk -F: '{ print $1; }')`
137 [ ".$cgrp" = . ] && cgrp="$cusr"
138
139 # set all other user/group variants to current user/group
140 for who in s m r n; do
141 for what in usr grp; do
142 eval "${who}${what}=\"\$c${what}\""
143 done
144 done
145 fi
146
118 # determine missing parameters 147 # determine missing parameters
119 eval `sh aux.usrgrp.sh \ 148 eval `sh etc.usrgrp.sh \
120 --usr="$usr" --grp="$grp" \ 149 --usr="$usr" --grp="$grp" \
121 --susr="$susr" --sgrp="$sgrp" \ 150 --susr="$susr" --sgrp="$sgrp" \
122 --musr="$musr" --mgrp="$mgrp" \ 151 --musr="$musr" --mgrp="$mgrp" \
123 --rusr="$rusr" --rgrp="$rgrp" \ 152 --rusr="$rusr" --rgrp="$rgrp" \
124 --nusr="$nusr" --ngrp="$ngrp" \ 153 --nusr="$nusr" --ngrp="$ngrp" \
139 ## determine package information 168 ## determine package information
140 ## 169 ##
141 170
142 name="openpkg" 171 name="openpkg"
143 spec="$name.spec" 172 spec="$name.spec"
144 version=`grep V_openpkg $spec | sed -e 'q' | awk '{ printf("%s", $3); }'` 173 version=`grep '^Version:' $spec | sed -e 'q' | awk '{ printf("%s", $2); }'`
145 release="$version" 174 release=`grep '^Release:' $spec | sed -e 'q' | awk '{ printf("%s", $2); }'`
146 175
147 ## 176 ##
148 ## display headline 177 ## display headline
149 ## 178 ##
150 179
156 ## optionally roll just a bootstrap source package 185 ## optionally roll just a bootstrap source package
157 ## 186 ##
158 187
159 if [ ".$bs" = .1 ]; then 188 if [ ".$bs" = .1 ]; then
160 srcdir=. 189 srcdir=.
161 if [ -d ../../dst ]; then 190 if [ -d ../dst ]; then
191 dstdir=../dst
192 elif [ -d ../../dst/openpkg ]; then
162 dstdir=../../dst/openpkg 193 dstdir=../../dst/openpkg
163 else 194 else
164 dstdir=. 195 dstdir=.
165 fi 196 fi
166 tmpdir="/tmp/$me.$$.d" 197 tmpdir="/tmp/$me.$$.d"
167 if [ -d ../PKG/SRC ]; then 198 if [ -d ../pkg ]; then
168 pkgdir=../PKG/SRC 199 pkgdir=../pkg
169 elif [ -d ../PKG ]; then 200 elif [ -d ../../pkg/openpkg ]; then
170 pkgdir=../PKG 201 pkgdir=../../pkg/openpkg
171 elif [ -d ../../PKG/SRC ]; then
172 pkgdir=../../PKG/SRC
173 elif [ -d ../../PKG ]; then
174 pkgdir=../../PKG
175 elif [ -d ../../pkg/src ]; then
176 pkgdir=../../pkg/src
177 elif [ -d ../../pkg ]; then
178 pkgdir=../../pkg
179 else 202 else
180 pkgdir=.. 203 pkgdir=..
181 fi 204 fi
182 echo "** rolling source bootstrap package:" 205 echo "** rolling source bootstrap package:"
183 echo " $pkgdir/$name-$version-$release.src.sh" 206 echo " $pkgdir/$name-$version-$release.src.sh"
194 ) >$tmpdir/.sh 217 ) >$tmpdir/.sh
195 sh $tmpdir/.sh 218 sh $tmpdir/.sh
196 rm -f $tmpdir/.sh 219 rm -f $tmpdir/.sh
197 l_version="$release" 220 l_version="$release"
198 l_release=`sh ./release.sh -r "${l_version}" -F "%t"` 221 l_release=`sh ./release.sh -r "${l_version}" -F "%t"`
199 sed <$srcdir/aux.wrapsrc.sh >$tmpdir/openpkg.boot.tmp \ 222 sed <$srcdir/etc.wrapsrc.sh >$tmpdir/openpkg.boot.tmp \
200 -e "s;@l_dir@;$name-$version-$release.src;" \ 223 -e "s;@l_dir@;$name-$version-$release.src;" \
201 -e "s;@l_release@;$l_release;" \ 224 -e "s;@l_release@;$l_release;" \
202 -e "s;@l_version@;$l_version;" 225 -e "s;@l_version@;$l_version;"
203 echo . | awk '{ 226 echo . | awk '{
204 for (i = 0; i < 8192; i++) { 227 for (i = 0; i < 8192; i++) {
216 ## 239 ##
217 ## determine distribution directory 240 ## determine distribution directory
218 ## 241 ##
219 242
220 V_rpm=`grep V_rpm $spec | sed -e 'q' | awk '{ printf("%s", $3); }'` 243 V_rpm=`grep V_rpm $spec | sed -e 'q' | awk '{ printf("%s", $3); }'`
221 if [ -f "../../dst/openpkg/rpm-${V_rpm}.tar.gz" ]; then 244 if [ -d ../dst ]; then
222 distdir="`cd ../../dst/openpkg; pwd`" # developer only 245 distdir="`cd ../dst; pwd`"
246 elif [ -d ../../dst/openpkg ]; then
247 distdir="`cd ../../dst/openpkg; pwd`"
223 else 248 else
224 distdir="`pwd`" 249 distdir="`pwd`"
225 fi 250 fi
226 echo "++ distribution directory: $distdir" 251 echo "++ distribution directory: $distdir"
227 252
228 ## 253 ##
229 ## perform prerequisite checks 254 ## perform prerequisite checks
230 ## 255 ##
231 256
232 sh ./aux.prereq.sh source || exit $? 257 sh ./etc.prereq.sh source || exit $?
233 258
234 ## 259 ##
235 ## find reasonable run-time paths and tools 260 ## find reasonable run-time paths and tools
236 ## 261 ##
237 262
238 # find reasonable temporary directory 263 # find reasonable temporary directory
239 tmpdir="${TMPDIR-/tmp}" 264 if [ -d ../tmp ]; then
265 tmpdir="`cd ../tmp; pwd`"
266 else
267 tmpdir="${TMPDIR-/tmp}"
268 fi
240 269
241 # find reasonable safe program path 270 # find reasonable safe program path
242 test ".$PATH" = . && PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin" 271 test ".$PATH" = . && PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin"
243 for dir in /usr/ccs/bin /usr/xpg4/bin; do 272 for dir in /usr/ccs/bin /usr/xpg4/bin; do
244 test -d $dir && PATH="$PATH:$dir" 273 test -d $dir && PATH="$PATH:$dir"
262 echo "_sourcedir=$distdir" 291 echo "_sourcedir=$distdir"
263 echo "_tmppath=$tmpdir" 292 echo "_tmppath=$tmpdir"
264 echo "_builddir=$tmpdir" 293 echo "_builddir=$tmpdir"
265 echo "l_prefix=$prefix" 294 echo "l_prefix=$prefix"
266 echo "l_tag_fmt=\"$tag\"" 295 echo "l_tag_fmt=\"$tag\""
267 echo "l_buildroot=$tmpdir/$name-$version-root" 296 echo "l_stack=$stack"
297 echo "l_buildroot=$tmpdir/$name-$version-$release-buildroot"
268 echo "l_susr=$susr" 298 echo "l_susr=$susr"
269 echo "l_sgrp=$sgrp" 299 echo "l_sgrp=$sgrp"
270 echo "l_musr=$musr" 300 echo "l_musr=$musr"
271 echo "l_mgrp=$mgrp" 301 echo "l_mgrp=$mgrp"
272 echo "l_rusr=$rusr" 302 echo "l_rusr=$rusr"
279 echo "l_mgid=$mgid" 309 echo "l_mgid=$mgid"
280 echo "l_ruid=$ruid" 310 echo "l_ruid=$ruid"
281 echo "l_rgid=$rgid" 311 echo "l_rgid=$rgid"
282 echo "l_nuid=$nuid" 312 echo "l_nuid=$nuid"
283 echo "l_ngid=$ngid" 313 echo "l_ngid=$ngid"
314 echo "l_unprivileged=$unprivileged"
284 echo "use_tar=$use_tar" 315 echo "use_tar=$use_tar"
285 echo "use_make=$use_make" 316 echo "use_make=$use_make"
286 echo "use_cc=$use_cc" 317 echo "use_cc=$use_cc"
287 echo "use_ar=$use_ar" 318 echo "use_ar=$use_ar"
288 echo "use_ld=$use_ld" 319 echo "use_ld=$use_ld"
339 runscript build 370 runscript build
340 runscript install 371 runscript install
341 372
342 ## 373 ##
343 ## adjust build environment so that the installed 374 ## adjust build environment so that the installed
344 ## "rpm" is actually useable, although it still resides in 375 ## "rpm" is actually usable, although it still resides in
345 ## the temporary location instead of the real location. 376 ## the temporary location instead of the real location.
346 ## 377 ##
347 378
348 # suck in prolog in order to get variables from the spec file 379 # suck in prolog in order to get variables from the spec file
349 cwd=`pwd` 380 cwd=`pwd`
352 383
353 # suck in buildenv script in order to get musr/mgrp 384 # suck in buildenv script in order to get musr/mgrp
354 . $tmpdir/openpkg-*/.buildenv 385 . $tmpdir/openpkg-*/.buildenv
355 386
356 # create a custom "rpm" command 387 # create a custom "rpm" command
388 # (and direct it to an adjusted macro set)
357 echo "++ creating custom RPM command" 389 echo "++ creating custom RPM command"
358 rm -f $tmpdir/rpm >/dev/null 2>&1 390 rm -f $tmpdir/rpm >/dev/null 2>&1
359 rmdir $tmpdir/rpm >/dev/null 2>&1 391 rmdir $tmpdir/rpm >/dev/null 2>&1
360 if [ -d "$tmpdir/rpm" ]; then 392 if [ -d "$tmpdir/rpm" ]; then
361 echo "$0:ERROR: directory $tmpdir/rpm exists, cannot create file with same name" 393 echo "$0:ERROR: directory $tmpdir/rpm exists, cannot create file with same name"
365 echo "$0:ERROR: file $tmpdir/rpm exists, cannot override" 397 echo "$0:ERROR: file $tmpdir/rpm exists, cannot override"
366 exit 1 398 exit 1
367 fi 399 fi
368 ( echo "#!/bin/sh" 400 ( echo "#!/bin/sh"
369 echo "exec $RPM_BUILD_ROOT$prefix/lib/openpkg/rpm \\" 401 echo "exec $RPM_BUILD_ROOT$prefix/lib/openpkg/rpm \\"
370 echo " --rcfile \"$tmpdir/rpm.1\" \\" 402 echo " --macros \"$tmpdir/rpm.1:$tmpdir/rpm.2:$tmpdir/rpm.3\" \\"
371 echo " --define \"__platform $RPM_BUILD_ROOT$prefix/etc/openpkg/platform\" \\" 403 echo " --rpmpopt \"$tmpdir/rpm.4:$tmpdir/rpm.5\" \\"
404 echo " --rpmlua \"$tmpdir/rpm.6\" \\"
372 echo " \"\$@\"" 405 echo " \"\$@\""
373 ) >$tmpdir/rpm 406 ) >$tmpdir/rpm
374 chmod a+x $tmpdir/rpm 407 chmod a+x $tmpdir/rpm
375 408
376 # direct our own "rpm" tool to adjusted macro sets
377 sed <`SOURCE rpmrc` >$tmpdir/rpm.1 \
378 -e "s;^\\(macrofiles:\\) .*;\\1 $tmpdir/rpm.2:$tmpdir/rpm.3;"
379
380 # use an adjusted vendor macro set 409 # use an adjusted vendor macro set
381 sed <$RPM_BUILD_ROOT$prefix/lib/openpkg/macros >$tmpdir/rpm.2 \ 410 rm -f $tmpdir/rpm.1 >/dev/null 2>&1
411 sed <$RPM_BUILD_ROOT$prefix/lib/openpkg/rpmmacros >$tmpdir/rpm.1 \
382 -e "s;$prefix;$RPM_BUILD_ROOT$prefix;g" 412 -e "s;$prefix;$RPM_BUILD_ROOT$prefix;g"
383 413
384 # override the vendor macro set 414 # override the vendor macro set
385 sed <`SOURCE rpmmacros` >$tmpdir/rpm.3 \ 415 rm -f $tmpdir/rpm.2 >/dev/null 2>&1
416 sed <`SOURCE rpmmacros` >$tmpdir/rpm.2 \
386 -e "s;@SUSR@;$susr;" \ 417 -e "s;@SUSR@;$susr;" \
387 -e "s;@SGRP@;$sgrp;" \ 418 -e "s;@SGRP@;$sgrp;" \
388 -e "s;@MUSR@;$musr;" \ 419 -e "s;@MUSR@;$musr;" \
389 -e "s;@MGRP@;$mgrp;" \ 420 -e "s;@MGRP@;$mgrp;" \
390 -e "s;@RUSR@;$rusr;" \ 421 -e "s;@RUSR@;$rusr;" \
391 -e "s;@RGRP@;$rgrp;" \ 422 -e "s;@RGRP@;$rgrp;" \
392 -e "s;@NUSR@;$nusr;" \ 423 -e "s;@NUSR@;$nusr;" \
393 -e "s;@NGRP@;$ngrp;" \ 424 -e "s;@NGRP@;$ngrp;" \
394 -e "s;@TAG@;$tag;" \ 425 -e "s;@TAG@;$tag;" \
426 -e "s;@l_unprivileged@;$unprivileged;" \
395 -e "s;\\(%{l_prefix}/lib/openpkg/rpmtool\\);%{l_bash} \\1;g" \ 427 -e "s;\\(%{l_prefix}/lib/openpkg/rpmtool\\);%{l_bash} \\1;g" \
396 -e "s;@l_prefix_static@;$prefix;g" \ 428 -e "s;@l_prefix_static@;$prefix;g" \
397 -e "s;@l_prefix@;$RPM_BUILD_ROOT$prefix;g" \ 429 -e "s;@l_prefix@;$RPM_BUILD_ROOT$prefix;g" \
398 -e "s;%l_prefix\\([^_]\\);%l_prefix_INTERNAL\\1;g" \ 430 -e "s;^%l_prefix\\([^_]\\);%l_prefix_INTERNAL\\1;g" \
399 -e "s;%{l_prefix};%{l_prefix_INTERNAL};g" \ 431 -e "s;%{l_prefix};%{l_prefix_INTERNAL};g" \
400 -e "s;^\\(%_specdir *\\).*;\\1 `pwd`;" \ 432 -e "s;^\\(%_specdir *\\).*;\\1 `pwd`;" \
401 -e "s;^\\(%_sourcedir *\\).*;\\1 $distdir;" \ 433 -e "s;^\\(%_sourcedir *\\).*;\\1 $distdir;" \
402 -e "s;^\\(%_builddir *\\).*;\\1 $tmpdir;" \ 434 -e "s;^\\(%_builddir *\\).*;\\1 $tmpdir;" \
403 -e "s;^\\(%_tmppath *\\).*;\\1 $tmpdir;" \ 435 -e "s;^\\(%_tmppath *\\).*;\\1 $tmpdir;" \
404 -e "s;^\\(%_buildshell *\\).*;\\1 env -i OPENPKG_BOOT=1 %{l_build_shell_cmd} %{l_build_shell_opt};" \ 436 -e "s;^\\(%_buildshell *\\).*;\\1 env -i OPENPKG_BOOT=1 %{l_build_shell_cmd} %{l_build_shell_opt};" \
405 -e "s;@l_build_path@;/bin:/sbin:/usr/bin:/usr/sbin;g" \ 437 -e "s;@l_build_path@;/bin:/sbin:/usr/bin:/usr/sbin;g" \
406 -e "s;@l_build_ldlp@;/usr/lib;g" \ 438 -e "s;@l_build_ldlp@;/usr/lib;g" \
407 -e "s;@l_build_ulim@;:;g" 439 -e "s;@l_build_ulim@;:;g"
408 echo "%l_prefix $prefix" >>$tmpdir/rpm.3 440
409 441 # provide some special overrides
410 # use an own $HOME/.popt in order to make sure the "rpm" 442 rm -f $tmpdir/rpm.3 >/dev/null 2>&1
411 # tool is able to execute its sub-tools "rpm<x>". 443 ( echo "%l_prefix $prefix"
412 V_rpm=`grep V_rpm $spec | sed -e 'q' | awk '{ printf("%s", $3); }'` 444 echo "%l_rpm $tmpdir/rpm"
413 sed <$RPM_BUILD_ROOT$prefix/lib/openpkg/rpmpopt >$tmpdir/.popt \ 445 echo "%__spec_install_pre %{nil}"
414 -e "s;^\\(rpm.*exec.*\\)\\(rpm[bdieukvq]*\\);\\1$RPM_BUILD_ROOT$prefix/lib/openpkg/\\2;" 446 echo "%__spec_clean_body %{nil}"
415 447 echo "%__platform $RPM_BUILD_ROOT$prefix/etc/openpkg/platform"
416 # activate the .popt file 448 echo "%_integrity_spec_cfg $RPM_BUILD_ROOT$prefix/etc/openpkg/license.d/BOOT"
417 HOME=$tmpdir 449 echo "%_integrity_proc_lua $RPM_BUILD_ROOT$prefix/lib/openpkg/license.lua"
418 export HOME 450 echo "%_integrity_pkey_pgp $RPM_BUILD_ROOT$prefix/etc/openpkg/openpkg.com.pgp"
451 ) >$tmpdir/rpm.3
452
453 # use an adjusted vendor POPT config
454 rm -f $tmpdir/rpm.4 >/dev/null 2>&1
455 sed <$RPM_BUILD_ROOT$prefix/lib/openpkg/rpmpopt >$tmpdir/rpm.4 \
456 -e "s;$prefix;$RPM_BUILD_ROOT$prefix;g"
457
458 # override the vendor POPT config
459 rm -f $tmpdir/rpm.5 >/dev/null 2>&1
460 sed <$RPM_BUILD_ROOT$prefix/etc/openpkg/rpmpopt >$tmpdir/rpm.5 \
461 -e "s;@l_prefix@;$RPM_BUILD_ROOT$prefix;g"
462
463 # use an adjusted vendor RPM Lua script
464 rm -f $tmpdir/rpm.6 >/dev/null 2>&1
465 sed <$RPM_BUILD_ROOT$prefix/etc/openpkg/rpmlua >$tmpdir/rpm.6 \
466 -e "s;@l_prefix@;$RPM_BUILD_ROOT$prefix;g"
419 467
420 ## 468 ##
421 ## now initialize the RPM database under the temporary install location 469 ## now initialize the RPM database under the temporary install location
422 ## 470 ##
423 471
448 ## would install into the real location, but does not actually install 496 ## would install into the real location, but does not actually install
449 ## anything. But as a side-effect, the database is now correct. 497 ## anything. But as a side-effect, the database is now correct.
450 ## 498 ##
451 499
452 echo "++ overwriting RPM installation by installing via RPM itself" 500 echo "++ overwriting RPM installation by installing via RPM itself"
453 $tmpdir/rpm --install --justdb --force --noscripts --notriggers --ignoresize \ 501 $tmpdir/rpm --install --justdb --replacepkgs --replacefiles --oldpackage --noscripts --notriggers --ignoresize \
454 $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm 502 $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm
455 503
456 ## Puhhhh!!! what a tricky bootstrapping procedure. But now we are 504 ## Puhhhh!!! what a tricky bootstrapping procedure. But now we are
457 ## mostly finished. All we finally have to do is to roll a bootstrap 505 ## mostly finished. All we finally have to do is to roll a bootstrap
458 ## tarball in addition to the binary RPM and save the stuff in a 506 ## tarball in addition to the binary RPM and save the stuff in a
460 508
461 v="$version-$release" 509 v="$version-$release"
462 t="`$tmpdir/rpm --eval '%{l_platform -p}-%{l_tag}'`" 510 t="`$tmpdir/rpm --eval '%{l_platform -p}-%{l_tag}'`"
463 511
464 # find a reasonable destination directory for packages 512 # find a reasonable destination directory for packages
465 if [ -d ../PKG/BIN ]; then 513 if [ -d ../pkg ]; then
466 dstdir=../PKG/BIN 514 pkgdir=../pkg
467 elif [ -d ../PKG ]; then 515 elif [ -d ../../pkg/openpkg ]; then
468 dstdir=../PKG 516 pkgdir=../../pkg/openpkg
469 elif [ -d ../../PKG/BIN ]; then
470 dstdir=../../PKG/BIN
471 elif [ -d ../../PKG ]; then
472 dstdir=../../PKG
473 else 517 else
474 dstdir=.. 518 pkgdir=..
475 fi 519 fi
476 520
477 # create Source-RPM file 521 # create Source-RPM file
478 echo "++ creating bootstrap source RPM file" 522 echo "++ creating bootstrap source RPM file"
479 $tmpdir/rpm -bs --nodeps $spec 523 $tmpdir/rpm -bs --nodeps --define "_srcrpmdir $pkgdir" $spec
480 cp $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.src.rpm $dstdir/
481 rm -f $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.src.rpm
482 524
483 # create Binary-RPM file 525 # create Binary-RPM file
526 # (notice that there might be a discrepancy in the platform
527 # identification, so we have to copy the source via wildcard)
484 echo "++ creating bootstrap binary RPM file" 528 echo "++ creating bootstrap binary RPM file"
485 cp $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.$t.rpm $dstdir/ 529 cp $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm $pkgdir/openpkg-$v.$t.rpm
486 rm -f $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-$v.$t.rpm 530 rm -f $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm
487 531
488 # create Binary-Bootstrap file 532 # create Binary-Bootstrap file
489 echo "++ creating bootstrap binary shell script" 533 echo "++ creating bootstrap binary shell script"
490 files=`cat $spec |\ 534 files=`cat $spec |\
491 sed -e '1,/%files/d' -e '/%clean/,$d' |\ 535 sed -e '1,/%files/d' -e '/%clean/,$d' |\
492 grep -v '^ *$' | grep -v '%defattr' |\ 536 grep -v '^ *$' | grep -v '%defattr' |\
493 sed -e 's;%config(noreplace) *;;' -e 's;%config *;;' -e 's;%ghost *;;' -e 's;%attr([^)]*) *;;' \ 537 sed -e 's;%config(noreplace) *;;' -e 's;%config *;;' -e 's;%ghost *;;' -e 's;%attr([^)]*) *;;' \
494 -e 's;%dir *;;' -e 's;%{l_prefix}/;;' -e 's;^ *;;' -e "s;%{V_rpm};${V_rpm};"` 538 -e 's;%dir *;;' -e 's;%{l_prefix}/;;' -e 's;^ *;;' -e "s;%{V_rpm};${V_rpm};"`
539 rm -f $RPM_BUILD_ROOT$prefix/RPM/DB/__db.[0-9]*
495 db_files="" 540 db_files=""
496 for db_file in \ 541 for db_file in \
497 `$RPM_BUILD_ROOT$prefix/lib/openpkg/bash \ 542 `$RPM_BUILD_ROOT$prefix/lib/openpkg/bash \
498 $RPM_BUILD_ROOT$prefix/lib/openpkg/rpmdb \ 543 $RPM_BUILD_ROOT$prefix/lib/openpkg/rpmdb \
499 --prefix=$RPM_BUILD_ROOT$prefix \ 544 --prefix=$RPM_BUILD_ROOT$prefix \
500 --dbpath=$RPM_BUILD_ROOT$prefix/RPM/DB \ 545 --dbpath=$RPM_BUILD_ROOT$prefix/RPM/DB \
501 --list --quiet`; do 546 --rpm=$tmpdir/rpm \
547 --list --quiet` VERSION; do
502 db_files="$db_files RPM/DB/$db_file" 548 db_files="$db_files RPM/DB/$db_file"
503 done 549 done
504 chmod 644 $RPM_BUILD_ROOT$prefix/RPM/DB/* 550 chmod 644 $RPM_BUILD_ROOT$prefix/RPM/DB/*
505 files="$files $db_files" 551 files="$files $db_files"
506 ( cd $RPM_BUILD_ROOT$prefix 552 ( cd $RPM_BUILD_ROOT$prefix
531 -e 's;%{![?]l_\([^:}]*\):\([^}]*\)};${\1-\2};g' \ 577 -e 's;%{![?]l_\([^:}]*\):\([^}]*\)};${\1-\2};g' \
532 -e 's;%{[?]l_\([^:}]*\)};${\1+""};g' \ 578 -e 's;%{[?]l_\([^:}]*\)};${\1+""};g' \
533 -e 's;%{![?]l_\([^:}]*\)};${\1-""};g' \ 579 -e 's;%{![?]l_\([^:}]*\)};${\1-""};g' \
534 -e 's;%{l_\([^}]*\)};${\1};g' \ 580 -e 's;%{l_\([^}]*\)};${\1};g' \
535 >$tmpdir/rpm.post 581 >$tmpdir/rpm.post
536 sed <`SOURCE aux.wrapbin.sh` \ 582 sed <`SOURCE etc.wrapbin.sh` \
537 -e "s;@SUSR@;$susr;" -e "s;@SGRP@;$sgrp;" \ 583 -e "s;@SUSR@;$susr;" -e "s;@SGRP@;$sgrp;" \
538 -e "s;@MUSR@;$musr;" -e "s;@MGRP@;$mgrp;" \ 584 -e "s;@MUSR@;$musr;" -e "s;@MGRP@;$mgrp;" \
539 -e "s;@RUSR@;$rusr;" -e "s;@RGRP@;$rgrp;" \ 585 -e "s;@RUSR@;$rusr;" -e "s;@RGRP@;$rgrp;" \
540 -e "s;@NUSR@;$nusr;" -e "s;@NGRP@;$ngrp;" \ 586 -e "s;@NUSR@;$nusr;" -e "s;@NGRP@;$ngrp;" \
541 -e "s;@SUID@;$suid;" -e "s;@SGID@;$sgid;" \ 587 -e "s;@SUID@;$suid;" -e "s;@SGID@;$sgid;" \
544 -e "s;@NUID@;$nuid;" -e "s;@NGID@;$ngid;" \ 590 -e "s;@NUID@;$nuid;" -e "s;@NGID@;$ngid;" \
545 -e "s;@l_prefix@;$prefix;" \ 591 -e "s;@l_prefix@;$prefix;" \
546 -e "s;@l_platform@;$l_platform;" \ 592 -e "s;@l_platform@;$l_platform;" \
547 -e "s;@l_release@;$l_release;" \ 593 -e "s;@l_release@;$l_release;" \
548 -e "s;@l_version@;$l_version;" \ 594 -e "s;@l_version@;$l_version;" \
595 -e "s;@l_unprivileged@;$unprivileged;" \
549 -e "/^@PRE@/r $tmpdir/rpm.pre" \ 596 -e "/^@PRE@/r $tmpdir/rpm.pre" \
550 -e "/^@POST@/r $tmpdir/rpm.post" |\ 597 -e "/^@POST@/r $tmpdir/rpm.post" |\
551 sed -e '/^@PRE@/d' -e '/^@POST@/d' >$tmpdir/openpkg.boot.tmp 598 sed -e '/^@PRE@/d' -e '/^@POST@/d' >$tmpdir/openpkg.boot.tmp
552 echo . | awk '{ 599 echo . | awk '{
553 for (i = 0; i < 8192; i++) { 600 for (i = 0; i < 8192; i++) {
554 printf(" "); 601 printf(" ");
555 } 602 }
556 }' >>$tmpdir/openpkg.boot.tmp 603 }' >>$tmpdir/openpkg.boot.tmp
557 rm -f $dstdir/openpkg-$v.$t.sh 604 rm -f $pkgdir/openpkg-$v.$t.sh
558 dd if=$tmpdir/openpkg.boot.tmp bs=8192 count=8 \ 605 dd if=$tmpdir/openpkg.boot.tmp bs=8192 count=8 \
559 of=$dstdir/openpkg-$v.$t.sh 2>/dev/null 606 of=$pkgdir/openpkg-$v.$t.sh 2>/dev/null
560 rm -f $tmpdir/openpkg.boot.tmp 607 rm -f $tmpdir/openpkg.boot.tmp
561 ( cd $RPM_BUILD_ROOT$prefix 608 ( cd $RPM_BUILD_ROOT$prefix
562 $RPM_BUILD_ROOT$prefix/lib/openpkg/tar --no-recursion -cf - \ 609 $RPM_BUILD_ROOT$prefix/lib/openpkg/tar --no-recursion -cf - \
563 openpkg.tar openpkg.bzip2 openpkg.tar.bz2 610 openpkg.tar openpkg.bzip2 openpkg.tar.bz2
564 ) >>$dstdir/openpkg-$v.$t.sh 611 ) >>$pkgdir/openpkg-$v.$t.sh
565 612
566 # cleanup 613 # cleanup
567 echo "++ cleaning up" 614 echo "++ cleaning up"
568 cp `SOURCE rpmtool` $tmpdir/rpmtool 615 cp `SOURCE rpmtool` $tmpdir/rpmtool
569 rm -rf $RPM_BUILD_ROOT 616 rm -rf $RPM_BUILD_ROOT
570 rm -rf $tmpdir/$name-$version 617 rm -rf $tmpdir/$name-$version
571 rm -f $tmpdir/rpm $tmpdir/rpm.[123] $tmpdir/.popt $tmpdir/rpm.pre $tmpdir/rpm.post 618 rm -f $tmpdir/rpm $tmpdir/rpm.[123456] $tmpdir/rpm.pre $tmpdir/rpm.post
572 rm -f $prolog 619 rm -f $prolog
573 620
574 # final hint about results 621 # final hint about results
575 echo "++ resulting OpenPKG bootstrap package files:" 622 echo "++ resulting OpenPKG Framework bootstrap package files:"
576 (cd $dstdir; ls -l openpkg-$v.$t.sh openpkg-$v.$t.rpm openpkg-$v.src.rpm) 623 (cd $pkgdir; ls -l openpkg-$v.$t.sh openpkg-$v.$t.rpm openpkg-$v.src.rpm)
577 set +x 624 set +x
578 ( echo "You have successfully built the OpenPKG Package from scratch" 625 ( echo "You have successfully built the OpenPKG Framework from scratch"
579 echo "for prefix $prefix on target platform $l_platform. The input" 626 echo "for prefix $prefix on target platform $l_platform. The input"
580 echo "was the OpenPKG Source Bootstrap Package in file:" 627 echo "was the OpenPKG Framework Source Bootstrap Package in file:"
581 echo "" 628 echo ""
582 echo " openpkg-$v.src.sh" 629 echo " openpkg-$v.src.sh"
583 echo "" 630 echo ""
584 echo "The results are the following three files:" 631 echo "The results are the following three files:"
585 echo "" 632 echo ""
586 echo " openpkg-$v.src.rpm" 633 echo " openpkg-$v.src.rpm"
587 echo " openpkg-$v.$t.rpm" 634 echo " openpkg-$v.$t.rpm"
588 echo " openpkg-$v.$t.sh" 635 echo " openpkg-$v.$t.sh"
589 echo "" 636 echo ""
590 echo "The first result file is the OpenPKG Source RPM Package," 637 echo "The first result file is the OpenPKG Framework Source RPM Package,"
591 echo "containing just the same contents than the OpenPKG Source" 638 echo "containing just the same contents than the OpenPKG Framework Source"
592 echo "Bootstrap Package, but now in RPM format. Optionally use this" 639 echo "Bootstrap Package, but now in RPM format. Optionally use this after"
593 echo "after the installation of the OpenPKG Binary Bootstrap Package" 640 echo "the installation of the OpenPKG Framework Binary Bootstrap Package"
594 echo "if you want to rebuild from source again (but then with RPM" 641 echo "if you want to rebuild from source again (but then with RPM"
595 echo "available)." 642 echo "available)."
596 echo "" 643 echo ""
597 echo "The second result file is the OpenPKG Binary RPM Package," 644 echo "The second result file is the OpenPKG Framework Binary RPM Package,"
598 echo "containing the installation files in RPM format for the OpenPKG" 645 echo "containing the installation files in RPM format for the OpenPKG"
599 echo "instance $prefix. Optionally use this after the installation of" 646 echo "instance $prefix. Optionally use this after the installation of"
600 echo "the OpenPKG Binary Bootstrap Package if you want (usually for" 647 echo "the OpenPKG Framework Binary Bootstrap Package if you want (usually"
601 echo "fixing something) to reinstall (but then with RPM available)." 648 echo "for fixing something) to reinstall (but then with RPM available)."
602 echo "" 649 echo ""
603 echo "The third result file is the OpenPKG Binary Bootstrap Package," 650 echo "The third result file is the OpenPKG Framework Binary Bootstrap"
604 echo "containing the installation files as a self-extracting shell" 651 echo "Package, containing the installation files as a self-extracting"
605 echo "script for the OpenPKG instance $prefix. Use this in YOUR NEXT" 652 echo "shell script for the OpenPKG instance $prefix. Use this in YOUR"
606 echo "STEP to initially create the OpenPKG instance from scratch." 653 echo "NEXT STEP to initially create the OpenPKG instance from scratch."
607 echo "Hence, proceed now by running the following command:" 654 echo "Hence, proceed now by running the following command:"
608 echo "" 655 echo ""
609 cusr=`(id -un) 2>/dev/null ||\ 656 cusr=`(id -un) 2>/dev/null ||\
610 (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\ 657 (id | sed -e 's;^[^(]*(\([^)]*\)).*;\1;') 2>/dev/null ||\
611 (whoami) 2>/dev/null ||\ 658 (whoami) 2>/dev/null ||\

mercurial