2 # Script to create a complete system to build packages in a chroot
3 # environment. This script ensures, that all packages given as
4 # parameter are installed. All other packges will be deleted.
6 # BUILD_ROOT here the packages will be installed/deleted
7 # BUILD_RPMS here we get our packages to install
8 # BUILD_ARCH path of the architectures we try
10 # (c) 1997-2005 SuSE GmbH Nuernberg, Germany
13 # needed globals variables
16 export YAST_IS_RUNNING="instsys"
17 export DEBIAN_FRONTEND=noninteractive
18 export DEBIAN_PRIORITY=critical
19 export BUILD_DIR=${BUILD_DIR:-/usr/lib/build}
20 # need to restore build root owner for non-root builds
25 . $BUILD_DIR/common_functions || exit 1
27 # should RPMs be installed with --force ?
30 BUILD_IS_RUNNING=$BUILD_ROOT/not-ready
31 TMPFILE=$BUILD_ROOT/tmpfile
32 #buildhost removed so that id can be generated from repo files
33 #RPMIDFMT="%{NAME}-%{VERSION}-%{RELEASE} %{BUILDHOST}-%{BUILDTIME}\n"
34 RPMIDFMT="%{NAME}-%{VERSION}-%{RELEASE} %{BUILDTIME}\n"
43 CREATE_BUILD_BINARIES=
45 while test -n "$1" ; do
59 --create-build-binaries)
61 CREATE_BUILD_BINARIES=true
65 USEUSEDFORBUILD=--useusedforbuild
76 --define|--with|--without)
77 definesnstuff[${#definesnstuff[@]}]="$1";
78 definesnstuff[${#definesnstuff[@]}]="$2";
82 repos[${#repos[@]}]="$2";
111 test "$BUILD_ROOT" = / -a -n "$browner" && chown "$browner" "$BUILD_ROOT"
112 # umount so init_buildsystem can be used standalone
113 # XXX: use stat -f /dev/pts/ -c %T to check whether it's mounted and not suppress errors then?
114 umount -n "$BUILD_ROOT/proc/sys/fs/binfmt_misc" 2> /dev/null || true
115 umount -n "$BUILD_ROOT/proc" 2> /dev/null || true
116 umount -n "$BUILD_ROOT/dev/pts" 2> /dev/null || true
117 umount -n "$BUILD_ROOT/mnt" 2> /dev/null || true
123 test -n "$BUILD_ROOT" && {
124 umount -n "$BUILD_ROOT/proc/sys/fs/binfmt_misc" 2> /dev/null || true
125 umount -n "$BUILD_ROOT/proc" 2> /dev/null || true
126 umount -n "$BUILD_ROOT/dev/pts" 2> /dev/null || true
127 umount -n "$BUILD_ROOT/mnt" 2> /dev/null || true
128 rm -rf -- "$BUILD_ROOT"/*
129 rm -rf -- "$BUILD_ROOT/.build"
130 rm -rf -- "$BUILD_ROOT/.root"
131 rm -rf -- "$BUILD_ROOT/.init_b_cache"
132 rm -rf -- "$BUILD_ROOT/.preinstall_image/*"
133 rm -rf -- "$BUILD_ROOT/.preinstallimage"*
134 mkdir -p "$BUILD_ROOT/proc"
135 mkdir -p "$BUILD_ROOT/dev/pts"
136 if [ "$UID" = '0' ]; then
137 mount -n -tproc none "$BUILD_ROOT/proc"
138 mount -n -tdevpts none "$BUILD_ROOT/dev/pts"
144 unsafe_preinstall_check()
146 # cpio isn't safe so we require bsdtar for VMs. chroot is
147 # unsafe anyways so it's ok for that.
148 if test -n "$PREPARE_VM" ; then
149 echo "Error: setting up a VM requires bsdtar for security reasons."
150 echo "Please install bsdtar."
155 preinstall_image_filter()
158 test -e "$BUILD_ROOT/.preinstall_image/$PKG" && continue
166 if test -n "$2" ; then
167 echo "unpacking preinstall image $2"
169 echo "unpacking preinstall image"
171 cd $BUILD_ROOT || cleanup_and_exit 1
172 if test -x /usr/bin/bsdtar ; then
173 TAR="/usr/bin/bsdtar -P --chroot --numeric-owner -x"
175 unsafe_preinstall_check
178 # pipe output through perl to print a dot every 1000 lines
179 if ! $TAR -z --exclude .build --exclude .init_b_cache -f "$BUILD_ROOT/.init_b_cache/rpms/$1" -v > >(tee "$BUILD_ROOT/.preinstallimage.unpack" | perl -e '$|=1; my $done=0; $done++ % 1000 or print "." while <STDIN>; print "\n";') 2>&1 ; then
180 echo "unpack failed."
181 test -e "$BUILD_ROOT/.preinstallimage.unpack" && cat "$BUILD_ROOT/.preinstallimage.unpack"
184 rm -f "$BUILD_ROOT/.preinstallimage.unpack"
190 echo "preinstalling $1..."
191 cd $BUILD_ROOT || cleanup_and_exit 1
192 if test -x /usr/bin/bsdtar ; then
193 CPIO="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x -f-"
194 TAR="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x"
196 unsafe_preinstall_check
197 CPIO="cpio --extract --unconditional --preserve-modification-time --make-directories --no-absolute-filenames --quiet"
200 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" ; then
201 PAYLOADDECOMPRESS=cat
202 case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm"` in
203 lzma) rpm --showrc | grep PayloadIsLzma > /dev/null || PAYLOADDECOMPRESS="lzma -d" ;;
204 xz) rpm --showrc | grep PayloadIsXz > /dev/null || PAYLOADDECOMPRESS="xz -d" ;;
206 if test "$PAYLOADDECOMPRESS" = "lzma -d" ; then
207 if ! lzma </dev/null >/dev/null 2>&1 ; then
208 test -f "$BUILD_DIR/lzmadec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/lzmadec.sh"
211 if test "$PAYLOADDECOMPRESS" = "xz -d" ; then
212 if ! xz </dev/null >/dev/null 2>&1 ; then
213 test -f "$BUILD_DIR/xzdec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/xzdec.sh"
216 if test "$PAYLOADDECOMPRESS" = cat ; then
217 rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $CPIO
219 rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $PAYLOADDECOMPRESS | $CPIO
221 if test -e ".init_b_cache/scripts/$1.run" ; then
222 rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > ".init_b_cache/scripts/$1.pre"
223 rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > ".init_b_cache/scripts/$1.post"
224 echo -n '(none)' > .init_b_cache/scripts/.none
225 cmp -s ".init_b_cache/scripts/$1.pre" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$1.pre"
226 cmp -s ".init_b_cache/scripts/$1.post" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$1.post"
227 rm -f .init_b_cache/scripts/.none
229 elif test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" ; then
230 ar x "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" control.tar.gz data.tar.gz
231 mkdir -p .init_b_cache/scripts/control
232 $TAR -C .init_b_cache/scripts/control -z -f control.tar.gz
233 $TAR -z -f data.tar.gz
234 if test -e ".init_b_cache/scripts/$1.run" ; then
235 test -e .init_b_cache/scripts/control/preinst && mv .init_b_cache/scripts/control/preinst ".init_b_cache/scripts/$1.pre"
236 test -e .init_b_cache/scripts/control/postinst && mv .init_b_cache/scripts/control/postinst ".init_b_cache/scripts/$1.post"
238 rm -rf .init_b_cache/scripts/control control.tar.gz data.tar.gz
239 elif test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.arch" ; then
240 $TAR -z -f "$BUILD_ROOT/.init_b_cache/rpms/$1.arch"
241 if test -f .INSTALL ; then
242 cat .INSTALL > ".init_b_cache/scripts/$1.post"
243 echo 'type post_install >/dev/null 2>&1 && post_install' >> ".init_b_cache/scripts/$1.post"
245 rm -f .PKGINFO .INSTALL
247 echo "warning: package $1 does not exist"
253 chroot $BUILD_ROOT /sbin/ldconfig 2>/dev/null
254 for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
255 if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
256 echo "running $PKG preinstall script"
257 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then
258 chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0
260 chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install < /dev/null
262 rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre"
264 if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
265 echo "running $PKG postinstall script"
266 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then
267 chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1
269 chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' < /dev/null
271 rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
279 if test $PSUF = rpm ; then
280 echo initializing rpm db...
281 if ! test -e $BUILD_ROOT/usr/lib/rpm/cpuinfo.yaml; then
282 # rpm v5 does not have initdb
283 chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1
285 # hack: add nofsync to db config to speed up install
286 mkdir -p $BUILD_ROOT/root
287 echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/.rpmmacros
288 echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/root/.rpmmacros
289 elif test $PSUF = deb ; then
290 # force dpkg into database to make epoch test work
291 if ! test "$BUILD_ROOT/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_ROOT/.init_b_cache/dpkg.deb" ; then
292 rm -f $BUILD_ROOT/.init_b_cache/dpkg.deb
293 cp $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb $BUILD_ROOT/.init_b_cache/dpkg.deb || cleanup_and_exit 1
295 chroot $BUILD_ROOT dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1
296 elif test $PSUF = arch ; then
297 mkdir -p $BUILD_ROOT/var/lib/pacman/sync
298 touch $BUILD_ROOT/var/lib/pacman/sync/core.db
299 touch $BUILD_ROOT/var/lib/pacman/sync/extra.db
300 touch $BUILD_ROOT/var/lib/pacman/sync/community.db
306 test -z "$*" && return
307 rm -f $BUILD_ROOT/.init_b_cache/order.manifest
309 echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest
311 $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms || touch $BUILD_ROOT/exit
312 rm -f $BUILD_ROOT/.init_b_cache/order.manifest
317 local com file mode arg
319 mkdir -m 755 -p $BUILD_ROOT/dev/pts
320 test -f $BUILD_ROOT/dev/shm && rm -f $BUILD_ROOT/dev/shm
321 mkdir -m 755 -p $BUILD_ROOT/dev/shm
322 while read com file mode arg ; do
323 rm -f $BUILD_ROOT/dev/$file
324 if test $com = ln ; then
325 ln -s $arg $BUILD_ROOT/dev/$file
328 $com -m $mode $BUILD_ROOT/dev/$file $arg
333 mknod random 666 c 1 8
334 mknod urandom 644 c 1 9
337 mknod loop0 640 b 7 0
338 mknod loop1 640 b 7 1
339 mknod loop2 640 b 7 2
340 mknod loop3 640 b 7 3
341 ln fd 777 /proc/self/fd
348 # check whether the repo list contains a plain "zypp://". Add all
349 # enabled zypp repos in this case
350 maybe_add_all_zypp_repos()
354 for i in "${repos[@]}"; do
355 if [ "$i" = "zypp://" ]; then
357 j="${j#/etc/zypp/repos.d/}"
358 r=("${r[@]}" "zypp://${j%.repo}")
359 done < <(grep -l enabled=1 /etc/zypp/repos.d/*.repo)
367 validate_cache_file()
370 maybe_add_all_zypp_repos
371 if ! test -f $CACHE_FILE || ! test -f $CACHE_FILE.id || \
372 test "${repos[*]} ${BUILD_RPMS//:/ /}" != "$(cat $CACHE_FILE.id 2>/dev/null)"; then
375 for SRC in "${repos[@]}" ${BUILD_RPMS//:/ /}; do
376 test -n "$SRC" || SRC=.
377 if [ "${SRC#zypp://}" != "$SRC" ]; then
378 SRC="/var/cache/zypp/raw" # XXX can't use name here as we'd need to parse the file
380 if test "$SRC" -nt $CACHE_FILE; then
384 # always rebuild if we have remote repositories and --clean is given
385 if test -n "$CLEAN_BUILD" -a "$SRC" != "${SRC#*://}" ; then
391 if ! test -f $CACHE_FILE.id ; then
392 test -z "$LIST_STATE" && echo initializing $CACHE_FILE ...
393 for SRC in "${repos[@]}" -- ${BUILD_RPMS//:/ /}; do
394 if test "$SRC" = '--' ; then
398 test -z "$SRC" && SRC=`pwd`
399 if [ "${SRC#zypp://}" != "$SRC" ]; then
400 set -- $BUILD_DIR/createrepomddeps "$SRC"
401 elif [ "${SRC#http://}" != "$SRC" -o "${SRC#https://}" != "$SRC" -o "${SRC#ftp://}" != "$SRC" -o "${SRC#ftps://}" != "$SRC" ]; then
402 mkdir -p "$(getcachedir "$SRC")"
403 set -- $BUILD_DIR/createrepomddeps --cachedir="$CACHE_DIR" "$SRC"
404 elif [ "${SRC#arch@http://}" != "$SRC" -o "${SRC#arch@https://}" != "$SRC" -o "${SRC#arch@ftp://}" != "$SRC" -o "${SRC#arch@ftps://}" != "$SRC" ]; then
405 mkdir -p "$(getcachedir "$SRC")"
406 set -- $BUILD_DIR/createrepomddeps --cachedir="$CACHE_DIR" "$SRC"
407 elif [ ! -e "$SRC" ]; then
408 echo "*** $SRC does not exist" >&2
410 elif [ -z "$findonly" -a \( -e "$SRC"/suse/setup/descr/packages -o -e "$SRC"/suse/setup/descr/packages.gz \) ]; then
411 set -- $BUILD_DIR/createyastdeps "$SRC"
412 elif [ -z "$findonly" -a -e "$SRC"/repodata/repomd.xml ]; then
413 set -- $BUILD_DIR/createrepomddeps "$SRC"
415 set -- $BUILD_DIR/createrpmdeps "$SRC"
418 "$@" || cleanup_and_exit 1
420 done > $CACHE_FILE.new
422 mv $CACHE_FILE.new $CACHE_FILE
423 echo "${repos[*]} ${BUILD_RPMS//:/ /}" > $CACHE_FILE.id
428 # Copy qemu static binaries for cross-build emulation mode.
429 # Preferentially install from $BUILD_DIR (potentially provided by build
430 # server) in preference to build worker's /usr/bin (fallback).
431 # If initvm is available it will be in $BUILD_DIR; otherwise prepare to
432 # fall back to initscript_qemu_vm shell script with corresponding static
433 # bash and mount programs.
440 for arch in $EMULATOR_DEVS; do
441 if test -e $BUILD_DIR/qemu-$arch; then
454 mkdir -p $BUILD_ROOT/usr/bin
456 if check_copy_qemu; then
458 for path in $BUILD_DIR/qemu-*; do
459 if file $path | grep -q static; then
460 dest="$BUILD_ROOT/usr/bin/${path##*/}"
461 if [ -f "$path" -a ! -x "$dest" ]; then
462 echo -n " $path" # report copy
463 #echo install -m755 "$path" "$dest"
464 install -m755 "$path" "$dest"
471 for path in /usr/bin/qemu-*; do
472 if file $path | grep -q static; then
473 dest="$BUILD_ROOT/usr/bin/${path##*/}"
474 if [ -f "$path" -a ! -x "$dest" ]; then
475 echo -n " $path" # report copy
476 #echo install -m755 "$path" "$dest"
477 install -m755 "$path" "$dest"
482 if [ -e /usr/sbin/qemu-binfmt-conf.sh \
483 -a ! -e $BUILD_ROOT/usr/sbin/qemu-binfmt-conf.sh ]; then
484 echo " /usr/sbin/qemu-binfmt-conf.sh" # report copy
485 mkdir -p $BUILD_ROOT/usr/sbin
486 install -m755 /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin
492 # Below for backward compatibility when /.build/initvm is not present
494 if [ -n "$PREPARE_VM" ]; then
495 if [ -x /bin/bash-static -a -x /bin/mount-static ]; then
496 echo " /bin/bash-static /bin/mount-static" # report copy
497 mkdir -p $BUILD_ROOT/bin
498 install -m755 /bin/bash-static $BUILD_ROOT/bin
499 install -m755 /bin/mount-static $BUILD_ROOT/bin
504 check_binfmt_registered()
507 for arch in $EMULATOR_DEVS; do
508 if test -e /proc/sys/fs/binfmt_misc/$arch; then
526 if [ "${url:0:7}" == "zypp://" ] ; then
527 cachedir="/var/cache/zypp/packages/"
528 SRC="$cachedir${url#zypp://}"
529 mkdir -p "${SRC%/*}" || cleanup_and_exit 1
530 elif [ "${url:0:7}" == "http://" -o "${url:0:8}" == "https://" -o "${url:0:6}" == "ftp://" -o "${url:0:7}" == "ftps://" ] ; then
531 cachedir="$(getcachedir "$url")"
532 local name="$(basename "$url")"
533 name=${name/%.pkg.tar.?z/.arch}
534 SRC="$cachedir/$name"
536 echo "Invalid url: $url"
540 local destdir="$cachedir/tmp"
542 echo "downloading $url ... ";
543 $BUILD_DIR/download "$destdir" "$url" || cleanup_and_exit 1
544 local destfile="$destdir/${url##*/}"
545 if [ ! -e "$destfile" ]; then
546 echo "expected $destfile after download but it's missing" >&2
551 rpm -K "$destfile" > $destfile.v || { echo "rpm verify failed" >&2; rm -rf "$destdir"; cleanup_and_exit 1; }
552 if grep "NOT OK" $destfile.v; then
559 mv "$destfile" "$SRC" || cleanup_and_exit 1
568 echo "/var/cache/zypp/packages/${url%/*}"
571 *.pkg.tar.?z) url="arch@$url" ;;
573 for repo in "${repos[@]}" ; do
574 if [ "${url:0:${#repo}}" == "$repo" -o "${url:0:${#repo}}" == "$repo" ] ; then
575 read repoid dummy < <(echo -n "$repo" | md5sum)
576 echo "$CACHE_DIR/$repoid"
585 local name=$(basename $url)
586 local cachedir=$(getcachedir $url)
587 local destfile="$cachedir/$name"
595 if [ "$BUILD_ROOT" = / ]; then
596 browner="$(stat -c %u /)"
599 if [ -n "$CLEAN_BUILD" ]; then
604 # now test if there was an incomplete run
606 if test -e $BUILD_IS_RUNNING ; then
607 echo It seems that there was an incomplete setup of $BUILD_ROOT.
608 echo To be sure, we will build it again completely...
609 umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true
610 umount -n $BUILD_ROOT/proc 2> /dev/null
611 umount -n $BUILD_ROOT/dev/pts 2> /dev/null
612 umount -n $BUILD_ROOT/mnt 2> /dev/null
613 echo "Your build system is broken!! Shall I execute"
615 echo " rm -rf -- $BUILD_ROOT/*"
617 echo "y - yes, cleanup the build root"
618 echo "N - No, abort build (default on enter)"
619 echo "c - Continue anyway with this build root"
623 c|C) rm -f $BUILD_IS_RUNNING ;;
624 y|Y) clean_build_root ;;
625 *) cleanup_and_exit 1 ;;
630 # store that we start to build system
633 mkdir -p $BUILD_ROOT/.build
634 touch $BUILD_IS_RUNNING
636 if test -n "$PREPARE_VM" ; then
637 rm -f $BUILD_ROOT/.build/init_buildsystem.data
639 if test -e $BUILD_ROOT/.build/init_buildsystem.data ; then
641 . $BUILD_ROOT/.build/init_buildsystem.data
642 if ! test -e $BUILD_ROOT/.init_b_cache/preinstall_finished ; then
646 touch $BUILD_ROOT/.init_b_cache/preinstall_finished
650 # now make sure that all the packages are installed.
652 rm -rf "$BUILD_ROOT/.init_b_cache"
653 mkdir -p "$BUILD_ROOT/.init_b_cache/scripts"
655 if test -z "$RPMLIST" ; then
657 # create rpmdeps file
659 CACHE_FILE=$BUILD_ROOT/.srcfiles.cache
663 # select and expand packages
665 RPMLIST=$BUILD_ROOT/.init_b_cache/rpmlist
666 test -z "$LIST_STATE" && echo "expanding package dependencies..."
667 if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR "${PKGS[@]}" > $RPMLIST ; then
668 rm -f $BUILD_IS_RUNNING
673 if test -n "$LIST_STATE" ; then
674 rm -f $BUILD_IS_RUNNING
675 while read PKG SRC ; do
676 test "$PKG" = "preinstall:" && continue
677 test "$PKG" = "runscripts:" && continue
678 test "$PKG" = "cbpreinstall:" && continue
679 test "$PKG" = "vminstall:" && continue
680 test "$PKG" = "dist:" && continue
681 test "$PKG" = "rpmid:" && continue
683 done < $BUILD_ROOT/.init_b_cache/rpmlist
684 rm -rf "$BUILD_ROOT/.init_b_cache"
689 # copy the QEMU emulator
691 if check_use_emulator; then
692 [ -n "$USE_SYSTEM_QEMU" ] && copy_qemu
693 if [ -z "$PREPARE_VM" ]; then
694 if ! check_binfmt_registered; then
695 echo "registering binfmt handlers"
697 if [ -x "$BUILD_DIR/initvm" -a -e "$BUILD_DIR/qemu-reg" ]; then
699 elif [ -x /usr/sbin/qemu-binfmt-conf.sh ]; then
700 [ -e /proc/sys/fs/binfmt_misc ] || mount -n binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
701 /usr/sbin/qemu-binfmt-conf.sh
703 echo "Warning: could not register binfmt handlers. Neither build-initvm nor /usr/sbin/qemu-binfmt-conf.sh exist"
706 if [ -n "$PREPARE_VM" ]; then
707 echo 0 > /proc/sys/vm/mmap_min_addr
709 read mmap_min_addr < /proc/sys/vm/mmap_min_addr
710 if [ "$mmap_min_addr" != 0 ]; then
711 echo "Warning: mmap_min_addr is != 0. If programs fail at mmap this could be the reason"
717 PACKAGES_TO_PREINSTALL=
718 PACKAGES_TO_RUNSCRIPTS=
719 PACKAGES_TO_VMINSTALL=
720 PACKAGES_TO_CBPREINSTALL=
721 PACKAGES_TO_CBINSTALL=
723 PREINSTALL_IMAGE_SOURCE=
725 PACKAGES_FROM_PREINSTALLIMAGE=
727 mkdir -p $BUILD_ROOT/.init_b_cache/rpms
728 rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download
729 while read PKG SRC ; do
730 if test "$PKG" = "preinstall:" ; then
731 PACKAGES_TO_PREINSTALL=$SRC
734 if test "$PKG" = "vminstall:" ; then
735 PACKAGES_TO_VMINSTALL=$SRC
738 if test "$PKG" = "preinstallimage:" ; then
739 PREINSTALL_IMAGE=${SRC##*/}
740 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/${SRC##*/}"
743 if test "$PKG" = "preinstallimagesource:" ; then
744 PREINSTALL_IMAGE_SOURCE="$SRC"
747 # these additional preinstall / install values are only set for
748 # emulated "CrossBuild" setups - thus CB(pre)install
749 if test "$PKG" = "cbpreinstall:" ; then
750 if is_emulator_arch ; then
751 PACKAGES_TO_CBPREINSTALL=$SRC
755 if test "$PKG" = "cbinstall:" ; then
756 if is_emulator_arch ; then
757 PACKAGES_TO_CBINSTALL=$SRC
761 if test "$PKG" = "runscripts:" ; then
763 PACKAGES_TO_RUNSCRIPTS=$SRC
766 if test "$PKG" = "dist:" ; then
770 if test "$PKG" = "rpmid:" ; then
771 echo "${SRC#*:}" > $BUILD_ROOT/.init_b_cache/rpms/${SRC%%:*}.id
774 if test "$PKG" != "${PKG%:}"; then
775 echo "Warning: ignoring unsupported tag '$PKG'" >&2
778 if test "$SRC" = "preinstallimage" ; then
779 PACKAGES_FROM_PREINSTALLIMAGE="$PACKAGES_FROM_PREINSTALLIMAGE $PKG"
780 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
783 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
784 if [ "${SRC#/}" = "$SRC" ]; then
786 zypp://* | http://* | https://* | ftp://* | ftps://*)
787 echo "$PKG $SRC" >>$BUILD_ROOT/.init_b_cache/rpmlist.download
791 echo "unsupported url for '$PKG': $SRC" >&2
796 SRCSUF=${SRC/%.pkg.tar.?z/.arch}
797 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
800 # check if we really can use cached versions for packages on the download list
801 if test -s $BUILD_ROOT/.init_b_cache/rpmlist.download ; then
802 rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download2
803 while read PKG SRC ; do
804 cachepkg="${SRC##*/}"
805 cachepkg="${cachepkg/%.pkg.tar.?z/.arch}"
806 cachedir="$(getcachedir "$SRC")"
807 if test -s "$cachedir/$cachepkg" ; then
808 if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.id" -a "${SRC%.rpm}" != "$SRC" ; then
809 PKGID=`rpm -qp --qf "$RPMIDFMT" $RPMCHECKOPTS_HOST "$cachedir/$cachepkg"`
810 read cachepkgid < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id
811 if test "$cachepkgid" = "$PKGID" ; then
812 SRC="$cachedir/$cachepkg"
814 rm -f "$cachedir/$cachepkg"
817 $SRC="$cachedir/$cachepkg"
820 if test "${SRC#/}" = "$SRC" ; then
821 echo "$PKG $SRC" >>$BUILD_ROOT/.init_b_cache/rpmlist.download2
823 SRCSUF=${SRC/%.pkg.tar.?z/.arch}
824 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
826 done < $BUILD_ROOT/.init_b_cache/rpmlist.download
827 rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download
828 test -s $BUILD_ROOT/.init_b_cache/rpmlist.download2 && mv $BUILD_ROOT/.init_b_cache/rpmlist.download2 $BUILD_ROOT/.init_b_cache/rpmlist.download
831 # now do the download of missing packages
832 if test -s $BUILD_ROOT/.init_b_cache/rpmlist.download ; then
833 PACKAGES_TO_DOWNLOAD=`cat ${RPMLIST}.download|awk '{print $2}'`
834 progress_setup PACKAGES_TO_DOWNLOAD
835 while read PKG SRC ; do
836 progress_step PACKAGES_TO_DOWNLOAD
838 # downloadpkg modified $SRC, so it has a right name for use
839 SRCSUF=${SRC/%.pkg.tar.?z/.arch}
840 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
841 done < $BUILD_ROOT/.init_b_cache/rpmlist.download
842 rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download
846 test -n "$PACKAGES_TO_CBPREINSTALL" && echo "cbpreinstall: $PACKAGES_TO_CBPREINSTALL"
847 test -n "$PACKAGES_TO_CBINSTALL" && echo "cbinstall : $PACKAGES_TO_CBINSTALL"
849 test -z "$RUNSCRIPTS_SEEN" && PACKAGES_TO_RUNSCRIPTS="$PACKAGES_TO_PREINSTALL"
851 echo "$GUESSED_DIST" > $BUILD_ROOT/.guessed_dist
852 test -n "$BUILD_DIST" || BUILD_DIST="$GUESSED_DIST"
853 PSUF=`gettype --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH"`
856 # auto detect from packages
857 if test -n "$PREINSTALL_IMAGE" ; then
858 echo "cannot autodetect build type when using a preinstall image" >&2
862 test -e $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb && PSUF=deb
863 test -e $BUILD_ROOT/.init_b_cache/rpms/pacman.arch && PSUF=arch
867 if test -n "$PREINSTALL_IMAGE" ; then
868 for PKG in $PACKAGES_FROM_PREINSTALLIMAGE ; do
869 # touch the file so that the copying works
870 touch $BUILD_ROOT/.init_b_cache/rpms/"$PKG.$PSUF"
877 # now test if there is already a build dir.
879 if test ! -f $BUILD_ROOT/var/lib/rpm/packages.rpm -a ! -f $BUILD_ROOT/var/lib/rpm/Packages -a ! -e $BUILD_ROOT/.build/init_buildsystem.data ; then
880 mkdir -p $BUILD_ROOT/var/lib/rpm || cleanup_and_exit 1
881 mkdir -p $BUILD_ROOT/usr/src/packages/SOURCES || cleanup_and_exit 1
882 mkdir -p $BUILD_ROOT/etc || cleanup_and_exit 1
883 mkdir -p $BUILD_ROOT/proc || cleanup_and_exit 1
884 test -f $BUILD_ROOT/etc/HOSTNAME || hostname -f > $BUILD_ROOT/etc/HOSTNAME
885 if test $PSUF = deb ; then
886 mkdir -p $BUILD_ROOT/var/lib/dpkg
887 mkdir -p $BUILD_ROOT/var/log
888 mkdir -p $BUILD_ROOT/etc/default
889 :> $BUILD_ROOT/var/lib/dpkg/status
890 :> $BUILD_ROOT/var/lib/dpkg/available
891 :> $BUILD_ROOT/var/log/dpkg.log
892 :> $BUILD_ROOT/etc/ld.so.conf
893 :> $BUILD_ROOT/etc/default/rcS
895 for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
896 : > $BUILD_ROOT/.init_b_cache/scripts/$PKG.run
898 PACKAGES_TO_PREINSTALL_FILTERED="$PACKAGES_TO_PREINSTALL"
899 PACKAGES_TO_VMINSTALL_FILTERED="$PACKAGES_TO_VMINSTALL"
900 PACKAGES_TO_CBPREINSTALL_FILTERED="$PACKAGES_TO_CBPREINSTALL"
901 rm -f "$BUILD_ROOT/.preinstall_image"/*
902 if test -n "$PREINSTALL_IMAGE" ; then
903 preinstall_image "$PREINSTALL_IMAGE" "$PREINSTALL_IMAGE_SOURCE"
904 PACKAGES_TO_PREINSTALL_FILTERED=`preinstall_image_filter $PACKAGES_TO_PREINSTALL_FILTERED`
905 PACKAGES_TO_VMINSTALL_FILTERED=`preinstall_image_filter $PACKAGES_TO_VMINSTALL_FILTERED`
906 PACKAGES_TO_CBPREINSTALL_FILTERED=`preinstall_image_filter $PACKAGES_TO_VMINSTALL_FILTERED`
908 PACKAGES_TO_PREINSTALL_FILTERED=`reorder $PACKAGES_TO_PREINSTALL_FILTERED`
909 progress_setup PACKAGES_TO_PREINSTALL_FILTERED
910 for PKG in $PACKAGES_TO_PREINSTALL_FILTERED ; do
911 progress_step PACKAGES_TO_PREINSTALL_FILTERED
912 preinstall ${PKG##*/}
915 if test -n "$PREPARE_VM" ; then
916 PACKAGES_TO_VMINSTALL_FILTERED=`reorder $PACKAGES_TO_VMINSTALL_FILTERED`
917 progress_setup PACKAGES_TO_VMINSTALL_FILTERED
918 for PKG in $PACKAGES_TO_VMINSTALL_FILTERED ; do
919 progress_step PACKAGES_TO_VMINSTALL_FILTERED
920 preinstall ${PKG##*/}
923 # add cbpreinstall if cross HOST != TARGET
924 PACKAGES_TO_CBINSTALL_FILTERED=`reorder $PACKAGES_TO_CBINSTALL_FILTERED`
925 progress_setup PACKAGES_TO_CBPREINSTALL_FILTERED
926 for PKG in $PACKAGES_TO_CBPREINSTALL_FILTERED ; do
927 progress_step PACKAGES_TO_CBPREINSTALL_FILTERED
928 preinstall ${PKG##*/}
932 if [ -w /root ]; then
933 test -c $BUILD_ROOT/dev/null || create_devs
935 test -e $BUILD_ROOT/etc/fstab || touch $BUILD_ROOT/etc/fstab
936 test ! -e $BUILD_ROOT/etc/ld.so.conf -a -e $BUILD_ROOT/etc/ld.so.conf.in && cp $BUILD_ROOT/etc/ld.so.conf.in $BUILD_ROOT/etc/ld.so.conf
937 if test -z "$PREPARE_VM" ; then
940 touch $BUILD_ROOT/.init_b_cache/preinstall_finished
944 if test -n "$PREPARE_VM" ; then
945 echo "copying packages..."
946 for PKG in $PACKAGES_TO_INSTALL ; do
947 rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
948 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
949 ln -s -f ../$PKG.$PSUF $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF
952 # alreadyinstalled check will not work, but we have to live with that...
953 echo -n 'reordering...'
954 PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
958 echo "PACKAGES_TO_INSTALL='${PACKAGES_TO_INSTALL//"'"/$Q}'" > $BUILD_ROOT/.build/init_buildsystem.data
959 echo "PACKAGES_TO_RUNSCRIPTS='${PACKAGES_TO_RUNSCRIPTS//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
960 # needed for continuation in xen/kvm with rpm-x86
961 echo "PACKAGES_TO_PREINSTALL='${PACKAGES_TO_PREINSTALL//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
962 echo "PACKAGES_TO_CBPREINSTALL='${PACKAGES_TO_CBPREINSTALL//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
963 echo "PSUF='$PSUF'" >> $BUILD_ROOT/.build/init_buildsystem.data
964 rm -f $BUILD_IS_RUNNING
968 mkdir -p $BUILD_ROOT/proc
969 mkdir -p $BUILD_ROOT/dev/pts
970 mount -n -tproc none $BUILD_ROOT/proc 2>/dev/null || true
971 mount -n -tdevpts none $BUILD_ROOT/dev/pts 2>/dev/null || true
974 # create .build.binaries directory if requested
976 rm -rf "$BUILD_ROOT/.build.binaries"
977 if test -n "$CREATE_BUILD_BINARIES" ; then
978 echo "creating .build.binaries directory..."
979 mkdir -p "$BUILD_ROOT/.build.binaries"
980 for PKG in $PACKAGES_TO_INSTALL ; do
981 test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue
982 LPKG=`readlink -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"`
983 ln "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" 2>/dev/null
984 test -f "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" && continue
985 cp "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF"
991 # get list and ids of already installed rpms
993 mkdir -p $BUILD_ROOT/.init_b_cache/alreadyinstalled
994 if test -f $BUILD_ROOT/var/lib/rpm/packages.rpm -o -f $BUILD_ROOT/var/lib/rpm/Packages ; then
995 chroot $BUILD_ROOT rpm -qa --qf "%{NAME} $RPMIDFMT" | (
997 echo "$ii" > "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$pp"
1003 # reorder packages (already done in vm continuation)
1005 if ! test -e $BUILD_ROOT/.build/init_buildsystem.data ; then
1006 echo -n 'reordering...'
1007 PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
1014 chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | \
1018 r*failed:\ No\ such\ file\ or\ directory) ;;
1019 error:\ failed\ to\ stat\ *:\ No\ such\ file\ or\ directory) ;;
1020 error:\ *scriptlet\ failed*)
1022 echo "re-try deleting $PKG using --noscripts"
1023 chroot $BUILD_ROOT rpm --nodeps --noscripts -e $PKG || true
1031 # delete all packages we don't want
1033 if [ -z "$KEEP_PACKS" ]; then
1034 mkdir -p $BUILD_ROOT/.init_b_cache/todelete
1035 for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do
1037 test "$PKG" = "*" && continue
1038 ln $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG $BUILD_ROOT/.init_b_cache/todelete/$PKG
1040 for PKG in $PACKAGES_TO_INSTALL $PACKAGES_TO_CBINSTALL ; do
1041 rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG
1043 for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do
1045 test "$PKG" = "*" && continue
1046 echo "deleting $PKG"
1050 rm -rf "$BUILD_ROOT/.init_b_cache/todelete"
1053 rm -rf "$BUILD_ROOT/.init_b_cache/preinstalls"
1054 mkdir -p "$BUILD_ROOT/.init_b_cache/preinstalls"
1055 for PKG in $PACKAGES_TO_PREINSTALL $PACKAGES_TO_CBPREINSTALL; do
1056 touch "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG"
1059 rm -rf "$BUILD_ROOT/installed-pkg"
1060 mkdir -p "$BUILD_ROOT/installed-pkg"
1064 # on Fedora 10 rpmbuild is in a separate package so we need something else to
1066 test -x $BUILD_ROOT/usr/bin/rpmquery && RPMCHECKOPTS="--nodigest --nosignature"
1067 test -x /usr/bin/rpmquery && RPMCHECKOPTS_HOST="--nodigest --nosignature"
1069 test -x $BUILD_ROOT/sbin/ldconfig && chroot $BUILD_ROOT /sbin/ldconfig 2>&1
1071 typeset -ri suse_version=$(chroot $BUILD_ROOT rpm --eval '%{?suse_version}' 2>/dev/null)
1072 typeset -i num cumulate=-1
1073 typeset -a CUMULATED_LIST=()
1074 typeset -a CUMULATED_PIDS=()
1075 typeset -a CUMULATED_HMD5=()
1078 if ((suse_version > 1220)) ; then
1082 MAIN_LIST="$PACKAGES_TO_INSTALL $PACKAGES_TO_CBINSTALL"
1083 test -n "$DO_CUMULATE" && MAIN_LIST="$MAIN_LIST CUMULATED"
1084 progress_setup MAIN_LIST
1085 for PKG in $MAIN_LIST; do
1086 test -f $BUILD_ROOT/installed-pkg/$PKG && continue
1087 progress_step MAIN_LIST
1092 # Use the features of rpm which are reordering the list of packages to
1093 # satisfy dependencies and the final execution of the %posttrans scriplets
1095 echo "now installing cumulated packages"
1096 ((cumulate < 0)) && continue
1097 exec 4>$BUILD_ROOT/.init_b_cache/manifest
1098 for ((num=0; num<=cumulate; num++)) ; do
1099 echo ${CUMULATED_LIST[$num]} 1>&4
1100 PKG=${CUMULATED_LIST[$num]##*/}
1101 test "$BUILD_ROOT/.init_b_cache/rpms/$PKG" -ef "$BUILD_ROOT/${CUMULATED_LIST[$num]}" && continue
1102 rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]}
1103 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG $BUILD_ROOT/${CUMULATED_LIST[$num]} || cleanup_and_exit 1
1106 chroot $BUILD_ROOT rpm --ignorearch --nodeps -Uh --oldpackage --ignoresize --verbose $RPMCHECKOPTS \
1107 $ADDITIONAL_PARAMS .init_b_cache/manifest 2>&1 || touch $BUILD_ROOT/exit
1108 for ((num=0; num<=cumulate; num++)) ; do
1109 rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]}
1111 rm -f .init_b_cache/manifest
1113 for ((num=0; num<=cumulate; num++)) ; do
1114 PKG=${CUMULATED_LIST[$num]##*/}
1115 echo "${CUMULATED_PIDS[$num]}" > $BUILD_ROOT/installed-pkg/${PKG%.rpm}
1116 test -n "${CUMULATED_HMD5[$num]}" || continue
1117 echo "${CUMULATED_HMD5[$num]} ${CUMULATED_PIDS[$num]}" > $BUILD_ROOT/.preinstall_image/${PKG%.rpm}
1126 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -a ! -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" ; then
1127 # preinstallimage package, make sure it's in the image
1128 if ! test -e $BUILD_ROOT/.preinstall_image/$PKG ; then
1129 echo "Package $PKG is missing from the preinstall image"
1132 read PKG_HDRMD5 PKGID < $BUILD_ROOT/.preinstall_image/$PKG
1133 echo "preinstalled ${PKGID%% *}"
1134 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1138 if test -d $BUILD_ROOT/.preinstall_image ; then
1139 if ! test -e $BUILD_ROOT/.preinstall_image/$PKG ; then
1140 PKG_HDRMD5=`perl -I$BUILD_DIR -MBuild -e 'print Build::queryhdrmd5($ARGV[0])' $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF`
1141 test -n "$PKG_HDRMD5" || cleanup_and_exit 1
1144 test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF || continue
1146 if test $PSUF = deb ; then
1147 # debian world, install deb files
1148 if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.deb" -ef "$BUILD_ROOT/.init_b_cache/$PKG.deb" ; then
1149 rm -f $BUILD_ROOT/.init_b_cache/$PKG.deb
1150 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb $BUILD_ROOT/.init_b_cache/$PKG.deb || cleanup_and_exit 1
1152 PKGID=`readlink $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb`
1153 PKGID="${PKGID##*/}"
1154 PKGID="${PKGID%.deb} debian"
1155 echo "installing ${PKGID%% *}"
1156 ( chroot $BUILD_ROOT dpkg --install --force all .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \
1157 perl -ne '$|=1;/^(Configuration file|Installing new config file|Selecting previously deselected|\(Reading database|Unpacking |Setting up|Creating config file|Preparing to replace dpkg)/||/^$/||print'
1159 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1160 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
1161 # ugly workaround for upstart system. some packages (procps) try
1162 # to start a service in their configure phase. As we don't have
1163 # a running upstart, we just link the start binary to /bin/true
1164 if test -e "$BUILD_ROOT/sbin/start"; then
1165 if test "$BUILD_ROOT/sbin/start" -ef "$BUILD_ROOT/sbin/initctl" ; then
1166 echo "linking /sbin/start to /bin/true"
1167 mv "$BUILD_ROOT/sbin/start" "$BUILD_ROOT/sbin/start.disabled"
1168 ln -s "/bin/true" "$BUILD_ROOT/sbin/start"
1171 # another workaround, see bug bnc#733699
1172 rm -f "$BUILD_ROOT/var/run/init.upgraded"
1176 if test $PSUF = arch ; then
1177 if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -ef "$BUILD_ROOT/.init_b_cache/$PKG.$PSUF" ; then
1178 rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
1179 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
1181 PKGID=`readlink $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF`
1182 PKGID="${PKGID##*/}"
1183 PKGID="${PKGID/%.pkg.tar.?z/.arch}"
1184 PKGID="${PKGID%.arch} arch"
1185 echo "installing ${PKGID%% *}"
1186 # -d -d disables deps checking
1187 ( chroot $BUILD_ROOT pacman -Uf -d -d --noconfirm .init_b_cache/$PKG.$PSUF 2>&1 || touch $BUILD_ROOT/exit ) | \
1188 perl -ne '$|=1;/^(warning: could not get filesystem information for |loading packages|looking for inter-conflicts|Targets |Total Installed Size: |Net Upgrade Size: |Proceed with installation|checking package integrity|loading package files|checking available disk space|installing |upgrading |warning:.*is up to date -- reinstalling|Optional dependencies for| )/||/^$/||print'
1190 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1191 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
1195 if test -f $BUILD_ROOT/.init_b_cache/rpms/$PKG.id -a -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then
1196 read PKGID < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id
1197 read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG
1198 if test "$PKGID" = "$OLDPKGID" ; then
1199 #echo "keeping ${PKGID%% *}"
1200 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1201 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
1206 PKGID=`rpm -qp --qf "$RPMIDFMT" $RPMCHECKOPTS_HOST $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm`
1208 if test -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then
1209 read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG
1210 if test "$PKGID" != "$OLDPKGID" ; then
1211 echo deleting unwanted ${OLDPKGID%% *}
1213 elif test "$VERIFY_BUILD_SYSTEM" = true ; then
1214 chroot $BUILD_ROOT rpm --verify $PKG 2>&1 | tee $TMPFILE
1215 if grep ^missing $TMPFILE > /dev/null ; then
1216 echo deleting incomplete ${PKGID%% *}
1219 #echo "keeping ${PKGID%% *}"
1220 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1221 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
1225 #echo "keeping ${PKGID%% *}"
1226 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1227 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
1230 if test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then
1232 # call for rpm-4.x and not rpm-devel
1233 test -z "${PKG##rpm-[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
1234 # also exec for exchanged rpm ! naming is rpm-x86-<target>-<ver>
1235 test -z "${PKG##rpm-x86-*[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
1238 export ADDITIONAL_PARAMS=
1239 if test "$USE_FORCE" = true ; then
1240 export ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --force"
1242 # FIXME: work around for cross-build installs, we must not overwrite the running rpm
1243 if test "$PKG" = rpm ; then
1244 for i in $BUILD_ROOT/.init_b_cache/preinstalls/rpm-x86-* ; do
1245 test -e "$i" && ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --justdb"
1248 if test -n "$DO_CUMULATE" -a "$ADDITIONAL_PARAMS" = "${ADDITIONAL_PARAMS%--justdb}"; then
1249 echo "cumulate ${PKGID%% *}"
1251 CUMULATED_LIST[$cumulate]=".init_b_cache/$PKG.rpm"
1252 CUMULATED_PIDS[$cumulate]="$PKGID"
1253 CUMULATED_HMD5[$cumulate]="$PKG_HDRMD5"
1256 echo "installing ${PKGID%% *}"
1257 if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" -ef "$BUILD_ROOT/.init_b_cache/$PKG.rpm" ; then
1258 rm -f $BUILD_ROOT/.init_b_cache/$PKG.rpm
1259 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm $BUILD_ROOT/.init_b_cache/$PKG.rpm || cleanup_and_exit 1
1261 ( chroot $BUILD_ROOT rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \
1262 $ADDITIONAL_PARAMS .init_b_cache/$PKG.rpm 2>&1 || \
1263 touch $BUILD_ROOT/exit ) | \
1264 grep -v "^warning:.*saved as.*rpmorig$"
1265 # delete link so package is only installed once
1266 rm -f $BUILD_ROOT/.init_b_cache/$PKG.rpm
1268 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1269 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
1273 if test $PSUF = deb ; then
1274 echo "configuring all installed packages..."
1275 # configure all packages after complete installation, not for each package like rpm does
1276 # We need to run this twice, because of cyclic dependencies as it does not succeed on most
1277 # debian based distros in the first attempt.
1278 if ! chroot $BUILD_ROOT dpkg --configure --pending 2>&1; then
1279 echo "first configure attempt failed, trying again..."
1280 chroot $BUILD_ROOT dpkg --configure --pending 2>&1 || touch $BUILD_ROOT/exit
1284 # devices can vanish if devs got uninstalled
1285 test -c $BUILD_ROOT/dev/null || create_devs
1287 cd $BUILD_ROOT || cleanup_and_exit 1
1292 rm -f $BUILD_ROOT/etc/mtab
1293 cp /proc/mounts $BUILD_ROOT/etc/mtab
1294 chmod 644 $BUILD_ROOT/etc/mtab
1297 # to be sure, path is set correctly, we have to source /etc/profile before
1301 #rm -f $BUILD_ROOT/bin/rpm.sh
1302 #cp $BUILD_LIBDIR/lib/rpm.sh $BUILD_ROOT/bin/rpm.sh
1303 #chmod 755 $BUILD_ROOT/bin/rpm.sh
1304 #test -f $BUILD_ROOT/bin/rpm -a ! -L $BUILD_ROOT/bin/rpm && \
1305 # mv $BUILD_ROOT/bin/rpm $BUILD_ROOT/bin/rpm.bin
1306 #rm -f $BUILD_ROOT/bin/rpm
1307 #ln -s rpm.sh $BUILD_ROOT/bin/rpm
1310 # some packages use uname -r to decide which kernel is used to build for.
1311 # this does not work in autobuild always. Here is a wrapper script, that
1312 # gets Version from kernel sources.
1315 #rm -f $BUILD_ROOT/bin/uname.sh
1316 #cp -v $BUILD_LIBDIR/lib/uname.sh $BUILD_ROOT/bin/uname.sh
1317 #chmod 755 $BUILD_ROOT/bin/uname.sh
1318 #test -f $BUILD_ROOT/bin/uname -a ! -L $BUILD_ROOT/bin/uname && \
1319 # mv $BUILD_ROOT/bin/uname $BUILD_ROOT/bin/uname.bin
1320 #rm -f $BUILD_ROOT/bin/uname
1321 #ln -s uname.sh $BUILD_ROOT/bin/uname
1324 # some distributions have a /etc/rpmrc or /etc/rpm/macros and some not.
1325 # make sure, that it is setup correctly.
1328 #rm -f $BUILD_ROOT/etc/rpmrc
1329 #if test -e $BUILD_LIBDIR/lib/rpmrc.$BUILD_BASENAME ; then
1330 # cp -v $BUILD_LIBDIR/lib/rpmrc.$BUILD_BASENAME $BUILD_ROOT/etc/rpmrc
1331 #elif test -e $BUILD_LIBDIR/lib/rpmrc ; then
1332 # cp -v $BUILD_LIBDIR/lib/rpmrc $BUILD_ROOT/etc/rpmrc
1336 #rm -f $BUILD_ROOT/etc/rpm/macros $BUILD_ROOT/etc/rpm/suse_macros
1337 #mkdir -p $BUILD_ROOT/etc/rpm
1338 #if test -e $BUILD_LIBDIR/lib/macros.$BUILD_BASENAME ; then
1339 # cp -v $BUILD_LIBDIR/lib/macros.$BUILD_BASENAME $BUILD_ROOT/etc/rpm/macros
1340 # cp -v $BUILD_LIBDIR/lib/macros.$BUILD_BASENAME $BUILD_ROOT/etc/rpm/suse_macros
1341 #elif test -e $BUILD_LIBDIR/lib/macros ; then
1342 # cp -v $BUILD_LIBDIR/lib/macros $BUILD_ROOT/etc/rpm/macros
1343 # cp -v $BUILD_LIBDIR/lib/macros $BUILD_ROOT/etc/rpm/suse_macros
1347 # make sure, that our nis is not present in the chroot system
1349 test -e $BUILD_ROOT/etc/nsswitch.conf && {
1350 echo removing nis flags from $BUILD_ROOT/etc/nsswitch.conf...
1351 cat $BUILD_ROOT/etc/nsswitch.conf | sed -e"s:nis::g" > \
1352 $BUILD_ROOT/etc/nsswitch.conf.tmp
1353 mv $BUILD_ROOT/etc/nsswitch.conf.tmp $BUILD_ROOT/etc/nsswitch.conf
1357 # creating some default directories
1358 for DIR in /usr/share/doc/packages \
1359 /usr/X11R6/include/X11/pixmaps \
1360 /usr/X11R6/include/X11/bitmaps ; do
1361 mkdir -p $BUILD_ROOT/$DIR
1364 for FILE in /var/run/utmp /var/log/wtmp /etc/fstab ; do
1365 mkdir -p $BUILD_ROOT/${FILE%/*}
1366 touch $BUILD_ROOT/$FILE
1369 echo now finalizing build dir...
1370 if test -x $BUILD_ROOT/sbin/ldconfig ; then
1371 CHROOT_RETURN="`chroot $BUILD_ROOT /sbin/ldconfig 2>&1`"
1372 case "$CHROOT_RETURN" in
1374 chroot $BUILD_ROOT /sbin/ldconfig
1376 echo chroot $BUILD_ROOT /sbin/ldconfig
1378 echo "$CHROOT_RETURN"
1380 echo "Problem with ldconfig. It's better to reinit the build system..."
1386 test -x $BUILD_ROOT/usr/sbin/Check && chroot $BUILD_ROOT /usr/sbin/Check
1388 mkdir -p $BUILD_ROOT/var/adm/packages
1389 touch $BUILD_ROOT/var/adm/packages
1390 if test -x $BUILD_ROOT/sbin/SuSEconfig ; then
1391 if grep norestarts $BUILD_ROOT/sbin/SuSEconfig > /dev/null ; then
1392 chroot $BUILD_ROOT /sbin/SuSEconfig --norestarts --force
1394 chroot $BUILD_ROOT /sbin/SuSEconfig --force
1398 if test -x $BUILD_ROOT/usr/X11R6/bin/switch2mesasoft ; then
1399 chroot $BUILD_ROOT /usr/X11R6/bin/switch2mesasoft
1402 for PROG in /usr/bin/TeX/texhash /usr/bin/texhash ; do
1403 test -x $BUILD_ROOT/$PROG && \
1404 chroot $BUILD_ROOT bash -c ". /etc/profile ; $PROG"
1407 if test -e $BUILD_ROOT/usr/share/zoneinfo/UTC ; then
1408 for PROG in /usr/sbin/zic /usr/bin/zic /bin/zic /sbin/zic ; do
1409 test -x $BUILD_ROOT/$PROG && chroot $BUILD_ROOT $PROG -l UTC
1413 test -e $BUILD_ROOT/.build/init_buildsystem.data || HOST=`hostname`
1414 test -e $BUILD_ROOT/etc/hosts || echo "127.0.0.1 localhost" > $BUILD_ROOT/etc/hosts
1415 if ! grep -F "127.0.0.1 $HOST" $BUILD_ROOT/etc/hosts > /dev/null ; then
1416 # this makes a reverse lookup on 127.0.0.1 return the host name,
1417 # which is bad, but 127.0.0.2 does not work on all unix systems
1418 echo "127.0.0.1 $HOST" > $BUILD_ROOT/etc/hosts.new
1419 test -f $BUILD_ROOT/etc/hosts && cat $BUILD_ROOT/etc/hosts >> $BUILD_ROOT/etc/hosts.new
1420 mv $BUILD_ROOT/etc/hosts.new $BUILD_ROOT/etc/hosts
1423 if test -x $BUILD_ROOT/bin/rpm -a ! -f $BUILD_ROOT/var/lib/rpm/packages.rpm -a ! -f $BUILD_ROOT/var/lib/rpm/Packages ; then
1424 echo "initializing rpm db..."
1425 chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1
1426 # create provides index
1427 chroot $BUILD_ROOT rpm -q --whatprovides rpm >/dev/null 2>&1
1430 # create modules.dep in kvm/xen
1431 # This can not work, until we use the native repository kernel
1432 #if [ $BUILD_ROOT = "/" -a -x /sbin/depmod ]; then
1436 rm -f $BUILD_ROOT/.rpmmacros $BUILD_ROOT/root/.rpmmacros
1437 rm -rf "$BUILD_ROOT/.init_b_cache"
1438 rm -f $BUILD_IS_RUNNING