openpkg/openpkg.boot

changeset 447
129b16fdb811
parent 428
f880f219c566
child 450
061d2617f42f
equal deleted inserted replaced
1:939fcd9a9af8 2:cf68cacdd3e2
30 # subset of the RPM functionality), followed by a second round over 30 # subset of the RPM functionality), followed by a second round over
31 # openpkg.spec with the real (and then existing) OpenPKG RPM tool. 31 # openpkg.spec with the real (and then existing) OpenPKG RPM tool.
32 # Also keep in mind that lots of tricks are played here in order to 32 # Also keep in mind that lots of tricks are played here in order to
33 # perform all the steps without having to touch the real installation 33 # perform all the steps without having to touch the real installation
34 # location. That is the whole procedure can (and should) be performed 34 # location. That is the whole procedure can (and should) be performed
35 # by a non-privileged user and no access to the real installation 35 # by a nonprivileged user and no access to the real installation
36 # location filesystem location. 36 # location filesystem location.
37 37
38 me="openpkg.boot" 38 me="openpkg.boot"
39 39
40 ## 40 ##
255 ## 255 ##
256 256
257 sh ./etc.prereq.sh source || exit $? 257 sh ./etc.prereq.sh source || exit $?
258 258
259 ## 259 ##
260 ## find reasonable run-time paths and tools 260 ## find reasonable runtime paths and tools
261 ## 261 ##
262 262
263 # find reasonable temporary directory 263 # find reasonable temporary directory
264 if [ -d ../tmp ]; then 264 if [ -d ../tmp ]; then
265 tmpdir="`cd ../tmp; pwd`" 265 tmpdir="`cd ../tmp; pwd`"
341 echo "umask 022" 341 echo "umask 022"
342 echo "cd \$RPM_BUILD_DIR" 342 echo "cd \$RPM_BUILD_DIR"
343 ) | sed -e 's;%{\([^}]*\)};${\1};g' >$prolog 343 ) | sed -e 's;%{\([^}]*\)};${\1};g' >$prolog
344 344
345 # install package via RPM spec file by faking a 345 # install package via RPM spec file by faking a
346 # sufficiently enough RPM run-time environment 346 # sufficiently enough RPM runtime environment
347 runscript () { 347 runscript () {
348 step=$1 348 step=$1
349 script="$tmpdir/openpkg.boot.$step.sh" 349 script="$tmpdir/openpkg.boot.$step.sh"
350 echo ". $prolog" >$script 350 echo ". $prolog" >$script
351 sed -e "/^%$step/,/^%/ p" -e 'd' <$spec | \ 351 sed -e "/^%$step/,/^%/ p" -e 'd' <$spec | \
359 -e 's;%{\([^}]*\)};${\1};g' >>$script 359 -e 's;%{\([^}]*\)};${\1};g' >>$script
360 echo "++ executing(%$step): sh $script" 360 echo "++ executing(%$step): sh $script"
361 sh $script 361 sh $script
362 if [ $? -ne 0 ]; then 362 if [ $? -ne 0 ]; then
363 rm -f $script 363 rm -f $script
364 echo "$0:ERROR: script returned non-null value" 364 echo "$0:ERROR: script returned nonnull value"
365 exit 1 365 exit 1
366 fi 366 fi
367 rm -f $script 367 rm -f $script
368 } 368 }
369 runscript prep 369 runscript prep
476 --dbpath=$RPM_BUILD_ROOT$prefix/RPM/DB \ 476 --dbpath=$RPM_BUILD_ROOT$prefix/RPM/DB \
477 --rpm=$tmpdir/rpm \ 477 --rpm=$tmpdir/rpm \
478 --build --quiet 478 --build --quiet
479 479
480 ## 480 ##
481 ## now turn over and re-iterate over the RPM spec, but this time 481 ## now turn over and reiterate over the RPM spec, but this time
482 ## with the real RPM tool. 482 ## with the real RPM tool.
483 ## 483 ##
484 484
485 echo "++ re-iterating over RPM specification procedures" 485 echo "++ reiterating over RPM specification procedures"
486 $tmpdir/rpm -bb $spec 486 $tmpdir/rpm -bb $spec
487 487
488 ## 488 ##
489 ## and finally overwrite the installation again, but this time by 489 ## and finally overwrite the installation again, but this time by
490 ## installing officially through the "rpm" tool. This way we achieve 490 ## installing officially through the "rpm" tool. This way we achieve
492 ## just have to make sure the package is relocated while installing. 492 ## just have to make sure the package is relocated while installing.
493 ## For this we could use --prefix=$RPM_BUILD_ROOT$prefix, but this 493 ## For this we could use --prefix=$RPM_BUILD_ROOT$prefix, but this
494 ## would create an incorrect filelist for "rpm" in the database. 494 ## would create an incorrect filelist for "rpm" in the database.
495 ## Instead we use the --justdb option which means "rpm" behaves as it 495 ## Instead we use the --justdb option which means "rpm" behaves as it
496 ## would install into the real location, but does not actually install 496 ## would install into the real location, but does not actually install
497 ## anything. But as a side-effect, the database is now correct. 497 ## anything. But as a side effect, the database is now correct.
498 ## 498 ##
499 499
500 echo "++ overwriting RPM installation by installing via RPM itself" 500 echo "++ overwriting RPM installation by installing via RPM itself"
501 $tmpdir/rpm --install --justdb --replacepkgs --replacefiles --oldpackage --noscripts --notriggers --ignoresize \ 501 $tmpdir/rpm --install --justdb --replacepkgs --replacefiles --oldpackage --noscripts --notriggers --ignoresize \
502 $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm 502 $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm
516 pkgdir=../../pkg/openpkg 516 pkgdir=../../pkg/openpkg
517 else 517 else
518 pkgdir=.. 518 pkgdir=..
519 fi 519 fi
520 520
521 # create Source-RPM file 521 # create Source RPM file
522 echo "++ creating bootstrap source RPM file" 522 echo "++ creating bootstrap source RPM file"
523 $tmpdir/rpm -bs --nodeps --define "_srcrpmdir $pkgdir" $spec 523 $tmpdir/rpm -bs --nodeps --define "_srcrpmdir $pkgdir" $spec
524 524
525 # create Binary-RPM file 525 # create Binary RPM file
526 # (notice that there might be a discrepancy in the platform 526 # (notice that there might be a discrepancy in the platform
527 # identification, so we have to copy the source via wildcard) 527 # identification, so we have to copy the source via wildcard)
528 echo "++ creating bootstrap binary RPM file" 528 echo "++ creating bootstrap binary RPM file"
529 cp $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm $pkgdir/openpkg-$v.$t.rpm 529 cp $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm $pkgdir/openpkg-$v.$t.rpm
530 rm -f $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm 530 rm -f $RPM_BUILD_ROOT$prefix/RPM/PKG/openpkg-*.rpm
531 531
532 # create Binary-Bootstrap file 532 # create binary bootstrap file
533 echo "++ creating bootstrap binary shell script" 533 echo "++ creating bootstrap binary shell script"
534 files=`cat $spec |\ 534 files=`cat $spec |\
535 sed -e '1,/%files/d' -e '/%clean/,$d' |\ 535 sed -e '1,/%files/d' -e '/%clean/,$d' |\
536 grep -v '^ *$' | grep -v '%defattr' |\ 536 grep -v '^ *$' | grep -v '%defattr' |\
537 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([^)]*) *;;' \

mercurial