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"
41 CREATE_BUILD_BINARIES=
43 while test -n "$1" ; do
49 --create-build-binaries)
51 CREATE_BUILD_BINARIES=true
55 USEUSEDFORBUILD=--useusedforbuild
66 --define|--with|--without)
67 definesnstuff[${#definesnstuff[@]}]="$1";
68 definesnstuff[${#definesnstuff[@]}]="$2";
72 repos[${#repos[@]}]="$2";
97 [ "$BUILD_ROOT" != / ] || chown $browner $BUILD_ROOT
98 # umount so init_buildsystem can be used standalone
99 # XXX: use stat -f /dev/pts/ -c %T to check whether it's mounted and not suppress errors then?
100 umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true
101 umount -n $BUILD_ROOT/proc 2> /dev/null || true
102 umount -n $BUILD_ROOT/dev/pts 2> /dev/null || true
103 umount -n $BUILD_ROOT/mnt 2> /dev/null || true
109 test -n "$BUILD_ROOT" && {
110 umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true
111 umount -n $BUILD_ROOT/proc 2> /dev/null || true
112 umount -n $BUILD_ROOT/dev/pts 2> /dev/null || true
113 umount -n $BUILD_ROOT/mnt 2> /dev/null || true
114 rm -rf -- $BUILD_ROOT/*
115 rm -rf -- $BUILD_ROOT/.build
116 rm -rf -- $BUILD_ROOT/.root
117 rm -rf -- $BUILD_ROOT/.init_b_cache
118 mkdir -p $BUILD_ROOT/proc
119 mkdir -p $BUILD_ROOT/dev/pts
120 if [ "$UID" = '0' ]; then
121 mount -n -tproc none $BUILD_ROOT/proc
122 mount -n -tdevpts none $BUILD_ROOT/dev/pts
130 echo "preinstalling $1..."
131 cd $BUILD_ROOT || cleanup_and_exit 1
132 if test -x /usr/bin/bsdtar ; then
133 CPIO="/usr/bin/bsdtar --chroot -o --numeric-owner -x -f-"
134 TAR="/usr/bin/bsdtar --chroot -o --numeric-owner -x"
136 # cpio isn't safe so we require bsdtar for VMs. chroot is
137 # unsafe anyways so it's ok for that.
138 if [ -n "$PREPARE_VM" ]; then
139 echo "Error: setting up a VM requires bsdtar for security reasons."
140 echo "Please install bsdtar"
143 CPIO="cpio --extract --unconditional --preserve-modification-time --make-directories --no-absolute-filenames --quiet"
146 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" ; then
147 PAYLOADDECOMPRESS=cat
148 case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm"` in
149 lzma) rpm --showrc | grep PayloadIsLzma > /dev/null || PAYLOADDECOMPRESS="lzma -d" ;;
150 xz) rpm --showrc | grep PayloadIsXz > /dev/null || PAYLOADDECOMPRESS="xz -d" ;;
152 if test "$PAYLOADDECOMPRESS" = "lzma -d" ; then
153 if ! lzma </dev/null >/dev/null 2>&1 ; then
154 test -f "$BUILD_DIR/lzmadec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/lzmadec.sh"
157 if test "$PAYLOADDECOMPRESS" = "xz -d" ; then
158 if ! xz </dev/null >/dev/null 2>&1 ; then
159 test -f "$BUILD_DIR/xzdec.sh" && PAYLOADDECOMPRESS="bash $BUILD_DIR/xzdec.sh"
162 if test "$PAYLOADDECOMPRESS" = cat ; then
163 rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $CPIO
165 rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" | $PAYLOADDECOMPRESS | $CPIO
167 if test -e ".init_b_cache/scripts/$1.run" ; then
168 rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > ".init_b_cache/scripts/$1.pre"
169 rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$1.rpm" > ".init_b_cache/scripts/$1.post"
170 echo -n '(none)' > .init_b_cache/scripts/.none
171 cmp -s ".init_b_cache/scripts/$1.pre" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$1.pre"
172 cmp -s ".init_b_cache/scripts/$1.post" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$1.post"
173 rm -f .init_b_cache/scripts/.none
175 elif test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" ; then
176 ar x "$BUILD_ROOT/.init_b_cache/rpms/$1.deb" control.tar.gz data.tar.gz
177 mkdir -p .init_b_cache/scripts/control
178 $TAR -C .init_b_cache/scripts/control -z -f control.tar.gz
179 $TAR -z -f data.tar.gz
180 if test -e ".init_b_cache/scripts/$1.run" ; then
181 test -e .init_b_cache/scripts/control/preinst && mv .init_b_cache/scripts/control/preinst ".init_b_cache/scripts/$1.pre"
182 test -e .init_b_cache/scripts/control/postinst && mv .init_b_cache/scripts/control/postinst ".init_b_cache/scripts/$1.post"
184 rm -rf .init_b_cache/scripts/control control.tar.gz data.tar.gz
185 elif test -e "$BUILD_ROOT/.init_b_cache/rpms/$1.arch" ; then
186 $TAR -z -f "$BUILD_ROOT/.init_b_cache/rpms/$1.arch"
187 if test -f .INSTALL ; then
188 cat .INSTALL > ".init_b_cache/scripts/$1.post"
189 echo 'type post_install >/dev/null 2>&1 && post_install' >> ".init_b_cache/scripts/$1.post"
191 rm -f .PKGINFO .INSTALL
193 echo "warning: package $1 does not exist"
199 chroot $BUILD_ROOT /sbin/ldconfig 2>/dev/null
200 for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
201 if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
202 echo "running $PKG preinstall script"
203 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then
204 chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0
206 chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install < /dev/null
208 rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre"
210 if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
211 echo "running $PKG postinstall script"
212 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" ; then
213 chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1
215 chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' < /dev/null
217 rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
225 if test $PSUF = rpm ; then
226 echo initializing rpm db...
227 if ! test -e $BUILD_ROOT/usr/lib/rpm/cpuinfo.yaml; then
228 # rpm v5 does not have initdb
229 chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1
231 # hack: add nofsync to db config to speed up install
232 mkdir -p $BUILD_ROOT/root
233 echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/.rpmmacros
234 echo '%__dbi_perms perms=0644 nofsync' > $BUILD_ROOT/root/.rpmmacros
235 elif test $PSUF = deb ; then
236 # force dpkg into database to make epoch test work
237 if ! test "$BUILD_ROOT/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_ROOT/.init_b_cache/dpkg.deb" ; then
238 rm -f $BUILD_ROOT/.init_b_cache/dpkg.deb
239 cp $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb $BUILD_ROOT/.init_b_cache/dpkg.deb || cleanup_and_exit 1
241 chroot $BUILD_ROOT dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1
242 elif test $PSUF = arch ; then
243 mkdir -p $BUILD_ROOT/var/lib/pacman/sync
244 touch $BUILD_ROOT/var/lib/pacman/sync/core.db
245 touch $BUILD_ROOT/var/lib/pacman/sync/extra.db
246 touch $BUILD_ROOT/var/lib/pacman/sync/community.db
252 test -z "$*" && return
253 rm -f $BUILD_ROOT/.init_b_cache/order.manifest
255 echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest
257 $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms
258 rm -f $BUILD_ROOT/.init_b_cache/order.manifest
263 local com file mode arg
265 mkdir -m 755 -p $BUILD_ROOT/dev/pts
266 test -f $BUILD_ROOT/dev/shm && rm -f $BUILD_ROOT/dev/shm
267 mkdir -m 755 -p $BUILD_ROOT/dev/shm
268 while read com file mode arg ; do
269 rm -f $BUILD_ROOT/dev/$file
270 if test $com = ln ; then
271 ln -s $arg $BUILD_ROOT/dev/$file
274 $com -m $mode $BUILD_ROOT/dev/$file $arg
279 mknod random 666 c 1 8
280 mknod urandom 644 c 1 9
283 mknod loop0 640 b 7 0
284 mknod loop1 640 b 7 1
285 mknod loop2 640 b 7 2
286 mknod loop3 640 b 7 3
287 ln fd 777 /proc/self/fd
294 # check whether the repo list contains a plain "zypp://". Add all
295 # enabled zypp repos in this case
296 maybe_add_all_zypp_repos()
300 for i in "${repos[@]}"; do
301 if [ "$i" = "zypp://" ]; then
303 j="${j#/etc/zypp/repos.d/}"
304 r=("${r[@]}" "zypp://${j%.repo}")
305 done < <(grep -l enabled=1 /etc/zypp/repos.d/*.repo)
313 validate_cache_file()
316 maybe_add_all_zypp_repos
317 if ! test -f $CACHE_FILE || ! test -f $CACHE_FILE.id || \
318 test "${repos[*]} ${BUILD_RPMS//:/ /}" != "$(cat $CACHE_FILE.id 2>/dev/null)"; then
321 for SRC in "${repos[@]}" ${BUILD_RPMS//:/ /}; do
322 test -n "$SRC" || SRC=.
323 if [ "${SRC#zypp://}" != "$SRC" ]; then
324 SRC="/var/cache/zypp/raw" # XXX can't use name here as we'd need to parse the file
326 if test "$SRC" -nt $CACHE_FILE; then
332 if ! test -f $CACHE_FILE.id ; then
333 test -z "$LIST_STATE" && echo initializing $CACHE_FILE ...
334 for SRC in "${repos[@]}" -- ${BUILD_RPMS//:/ /}; do
335 if test "$SRC" = '--' ; then
339 test -z "$SRC" && SRC=`pwd`
340 if [ "${SRC#zypp://}" != "$SRC" ]; then
341 set -- $BUILD_DIR/createrepomddeps "$SRC"
342 elif [ "${SRC#http://}" != "$SRC" -o "${SRC#https://}" != "$SRC" -o "${SRC#ftp://}" != "$SRC" -o "${SRC#ftps://}" != "$SRC" ]; then
343 mkdir -p "$(getcachedir "$SRC")"
344 set -- $BUILD_DIR/createrepomddeps --cachedir="$CACHE_DIR" "$SRC"
345 elif [ "${SRC#arch@http://}" != "$SRC" -o "${SRC#arch@https://}" != "$SRC" -o "${SRC#arch@ftp://}" != "$SRC" -o "${SRC#arch@ftps://}" != "$SRC" ]; then
346 mkdir -p "$(getcachedir "$SRC")"
347 set -- $BUILD_DIR/createrepomddeps --cachedir="$CACHE_DIR" "$SRC"
348 elif [ ! -e "$SRC" ]; then
349 echo "*** $SRC does not exist" >&2
351 elif [ -z "$findonly" -a -e "$SRC"/suse/setup/descr/packages -o -e "$SRC"/suse/setup/descr/packages.gz ]; then
352 set -- $BUILD_DIR/createyastdeps "$SRC"
353 elif [ -z "$findonly" -a -e "$SRC"/repodata/repomd.xml ]; then
354 set -- $BUILD_DIR/createrepomddeps "$SRC"
356 set -- $BUILD_DIR/createrpmdeps "$SRC"
359 "$@" || cleanup_and_exit 1
361 done > $CACHE_FILE.new
363 mv $CACHE_FILE.new $CACHE_FILE
364 echo "${repos[*]} ${BUILD_RPMS//:/ /}" > $CACHE_FILE.id
369 # Copy qemu static binaries for cross-build emulation mode.
370 # Preferentially install from $BUILD_DIR (potentially provided by build
371 # server) in preference to build worker's /usr/bin (fallback).
372 # If initvm is available it will be in $BUILD_DIR; otherwise prepare to
373 # fall back to initscript_qemu_vm shell script with corresponding static
374 # bash and mount programs.
381 for arch in $EMULATOR_DEVS; do
382 if test -e $BUILD_DIR/qemu-$arch; then
395 mkdir -p $BUILD_ROOT/usr/bin
397 if check_copy_qemu; then
399 for path in $BUILD_DIR/qemu-*; do
400 if file $path | grep -q static; then
401 dest="$BUILD_ROOT/usr/bin/${path##*/}"
402 if [ -f "$path" -a ! -x "$dest" ]; then
403 echo -n " $path" # report copy
404 #echo install -m755 "$path" "$dest"
405 install -m755 "$path" "$dest"
412 for path in /usr/bin/qemu-*; do
413 if file $path | grep -q static; then
414 dest="$BUILD_ROOT/usr/bin/${path##*/}"
415 if [ -f "$path" -a ! -x "$dest" ]; then
416 echo -n " $path" # report copy
417 #echo install -m755 "$path" "$dest"
418 install -m755 "$path" "$dest"
423 if [ -e /usr/sbin/qemu-binfmt-conf.sh \
424 -a ! -e $BUILD_ROOT/usr/sbin/qemu-binfmt-conf.sh ]; then
425 echo " /usr/sbin/qemu-binfmt-conf.sh" # report copy
426 mkdir -p $BUILD_ROOT/usr/sbin
427 install -m755 /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin
433 # Below for backward compatibility when /.build/initvm is not present
435 if [ -n "$PREPARE_VM" ]; then
436 if [ -x /bin/bash-static -a -x /bin/mount-static ]; then
437 echo " /bin/bash-static /bin/mount-static" # report copy
438 mkdir -p $BUILD_ROOT/bin
439 install -m755 /bin/bash-static $BUILD_ROOT/bin
440 install -m755 /bin/mount-static $BUILD_ROOT/bin
445 check_binfmt_registered()
448 for arch in $EMULATOR_DEVS; do
449 if test -e /proc/sys/fs/binfmt_misc/$arch; then
467 if [ "${url:0:7}" == "zypp://" ] ; then
468 cachedir="/var/cache/zypp/packages/"
469 SRC="$cachedir${url#zypp://}"
470 mkdir -p "${SRC%/*}" || cleanup_and_exit 1
471 elif [ "${url:0:7}" == "http://" -o "${url:0:8}" == "https://" -o "${url:0:6}" == "ftp://" -o "${url:0:7}" == "ftps://" ] ; then
472 cachedir="$(getcachedir "$url")"
473 local name="$(basename "$url")"
474 name=${name/%.pkg.tar.?z/.arch}
475 SRC="$cachedir/$name"
477 echo "Invalid url: $url"
481 if [ ! -e "$SRC" ]; then
482 local destdir="$cachedir/tmp"
484 echo "downloading $url ... ";
485 $BUILD_DIR/download "$destdir" "$url" || cleanup_and_exit 1
486 local destfile="$destdir/${url##*/}"
487 if [ ! -e "$destfile" ]; then
488 echo "expected $destfile after download but it's missing" >&2
493 rpm -K "$destfile" > $destfile.v || { echo "rpm verify failed" >&2; rm -rf "$destdir"; cleanup_and_exit 1; }
494 if grep "NOT OK" $destfile.v; then
501 mv "$destfile" "$SRC" || cleanup_and_exit 1
509 *.pkg.tar.?z) url="arch@$url" ;;
511 for repo in "${repos[@]}" ; do
512 if [ "${url:0:${#repo}}" == "$repo" -o "${url:0:${#repo}}" == "$repo" ] ; then
513 read repoid dummy < <(echo -n "$repo" | md5sum)
514 echo "$CACHE_DIR/$repoid"
523 local name=$(basename $url)
524 local cachedir=$(getcachedir $url)
525 local destfile="$cachedir/$name"
533 if [ "$BUILD_ROOT" = / ]; then
534 browner="$(stat -c %U /)"
537 if [ -n "$CLEAN_BUILD" ]; then
542 # now test if there was an incomplete run
544 if test -e $BUILD_IS_RUNNING ; then
545 echo It seems that there was an incomplete setup of $BUILD_ROOT.
546 echo To be sure, we will build it again completely...
547 umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true
548 umount -n $BUILD_ROOT/proc 2> /dev/null
549 umount -n $BUILD_ROOT/dev/pts 2> /dev/null
550 umount -n $BUILD_ROOT/mnt 2> /dev/null
551 echo "Your build system is broken!! Shall I execute"
553 echo " rm -rf -- $BUILD_ROOT/*"
555 echo "y - yes, cleanup the build root"
556 echo "N - No, abort build (default on enter)"
557 echo "c - Continue anyway with this build root"
561 c|C) rm -f $BUILD_IS_RUNNING ;;
562 y|Y) clean_build_root ;;
563 *) cleanup_and_exit 1 ;;
568 # store that we start to build system
571 mkdir -p $BUILD_ROOT/.build
572 touch $BUILD_IS_RUNNING
574 if test -n "$PREPARE_VM" ; then
575 rm -f $BUILD_ROOT/.build/init_buildsystem.data
577 if test -e $BUILD_ROOT/.build/init_buildsystem.data ; then
579 . $BUILD_ROOT/.build/init_buildsystem.data
580 if ! test -e $BUILD_ROOT/.init_b_cache/preinstall_finished ; then
584 touch $BUILD_ROOT/.init_b_cache/preinstall_finished
588 # now make sure that all the packages are installed.
590 rm -rf $BUILD_ROOT/.init_b_cache
591 mkdir -p $BUILD_ROOT/.init_b_cache/scripts
593 if test -z "$RPMLIST" ; then
595 # create rpmdeps file
597 CACHE_FILE=$BUILD_ROOT/.srcfiles.cache
601 # select and expand packages
603 RPMLIST=$BUILD_ROOT/.init_b_cache/rpmlist
604 test -z "$LIST_STATE" && echo "expanding package dependencies..."
605 if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $BUILD_DIR/configs "${PKGS[@]}" > $RPMLIST ; then
606 rm -f $BUILD_IS_RUNNING
611 if test -n "$LIST_STATE" ; then
612 rm -f $BUILD_IS_RUNNING
613 while read PKG SRC ; do
614 test "$PKG" = "preinstall:" && continue
615 test "$PKG" = "runscripts:" && continue
616 test "$PKG" = "cbpreinstall:" && continue
617 test "$PKG" = "vminstall:" && continue
618 test "$PKG" = "dist:" && continue
619 test "$PKG" = "rpmid:" && continue
621 done < $BUILD_ROOT/.init_b_cache/rpmlist
622 rm -rf $BUILD_ROOT/.init_b_cache
627 # copy the QEMU emulator
629 if check_use_emulator; then
631 if [ -z "$PREPARE_VM" ]; then
632 if ! check_binfmt_registered; then
633 echo "registering binfmt handlers"
634 if [ -x "$BUILD_DIR/initvm" -a -e "$BUILD_DIR/qemu-reg" ]; then
636 elif [ -x /usr/sbin/qemu-binfmt-conf.sh ]; then
637 /usr/sbin/qemu-binfmt-conf.sh
639 echo "Warning: could not register binfmt handlers"
642 if [ -n "$PREPARE_VM" ]; then
643 echo 0 > /proc/sys/vm/mmap_min_addr
645 read mmap_min_addr < /proc/sys/vm/mmap_min_addr
646 if [ "$mmap_min_addr" != 0 ]; then
647 echo "Warning: mmap_min_addr is != 0. If programs fail at mmap this could be the reason"
653 PACKAGES_TO_PREINSTALL=
654 PACKAGES_TO_RUNSCRIPTS=
655 PACKAGES_TO_VMINSTALL=
656 PACKAGES_TO_CBPREINSTALL=
657 PACKAGES_TO_CBINSTALL=
660 mkdir -p $BUILD_ROOT/.init_b_cache/rpms
661 while read PKG SRC ; do
662 if test "$PKG" = "preinstall:" ; then
663 PACKAGES_TO_PREINSTALL=$SRC
666 if test "$PKG" = "vminstall:" ; then
667 PACKAGES_TO_VMINSTALL=$SRC
670 # these additional preinstall / install values are only set for
671 # emulated "CrossBuild" setups - thus CB(pre)install
672 if test "$PKG" = "cbpreinstall:" ; then
673 if is_emulator_arch ; then
674 PACKAGES_TO_CBPREINSTALL=$SRC
678 if test "$PKG" = "cbinstall:" ; then
679 if is_emulator_arch ; then
680 PACKAGES_TO_CBINSTALL=$SRC
684 if test "$PKG" = "runscripts:" ; then
686 PACKAGES_TO_RUNSCRIPTS=$SRC
689 if test "$PKG" = "dist:" ; then
693 if test "$PKG" = "rpmid:" ; then
694 echo "${SRC#*:}" > $BUILD_ROOT/.init_b_cache/rpms/${SRC%%:*}.id
697 if test "$PKG" != "${PKG%:}"; then
698 echo "Warning: ignoring unsupported tag '$PKG'" >&2
701 if [ "${SRC#/}" = "$SRC" ]; then
704 zypp://* | http://* | https://* | ftp://* | ftps://*)
708 echo "unsupported url for '$PKG': $url" >&2
712 # downloadpkg modified $SRC, so it has a right name for use
714 SRCSUF=${SRC/%.pkg.tar.?z/.arch}
715 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
716 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
719 test -n "$PACKAGES_TO_CBPREINSTALL" && echo "cbpreinstall: $PACKAGES_TO_CBPREINSTALL"
720 test -n "$PACKAGES_TO_CBINSTALL" && echo "cbinstall : $PACKAGES_TO_CBINSTALL"
722 test -z "$RUNSCRIPTS_SEEN" && PACKAGES_TO_RUNSCRIPTS="$PACKAGES_TO_PREINSTALL"
724 echo "$GUESSED_DIST" > $BUILD_ROOT/.guessed_dist
725 test -n "$BUILD_DIST" || BUILD_DIST="$GUESSED_DIST"
726 DIST_TYPE=`gettype --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH"`
732 # auto detect from packages
734 test -L $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb && PSUF=deb
735 test -L $BUILD_ROOT/.init_b_cache/rpms/pacman.arch && PSUF=arch
741 # now test if there is already a build dir.
743 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
744 mkdir -p $BUILD_ROOT/var/lib/rpm || cleanup_and_exit 1
745 mkdir -p $BUILD_ROOT/usr/src/packages/SOURCES || cleanup_and_exit 1
746 mkdir -p $BUILD_ROOT/etc || cleanup_and_exit 1
747 mkdir -p $BUILD_ROOT/proc || cleanup_and_exit 1
748 test -f $BUILD_ROOT/etc/HOSTNAME || hostname -f > $BUILD_ROOT/etc/HOSTNAME
749 if test $PSUF = deb ; then
750 mkdir -p $BUILD_ROOT/var/lib/dpkg
751 mkdir -p $BUILD_ROOT/var/log
752 mkdir -p $BUILD_ROOT/etc/default
753 :> $BUILD_ROOT/var/lib/dpkg/status
754 :> $BUILD_ROOT/var/lib/dpkg/available
755 :> $BUILD_ROOT/var/log/dpkg.log
756 :> $BUILD_ROOT/etc/ld.so.conf
757 :> $BUILD_ROOT/etc/default/rcS
759 for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
760 : > $BUILD_ROOT/.init_b_cache/scripts/$PKG.run
762 progress_setup PACKAGES_TO_PREINSTALL
763 for PKG in $PACKAGES_TO_PREINSTALL ; do
764 progress_step PACKAGES_TO_PREINSTALL
765 preinstall ${PKG##*/}
767 if test -n "$PREPARE_VM" ; then
768 progress_setup PACKAGES_TO_VMINSTALL
769 for PKG in $PACKAGES_TO_VMINSTALL ; do
770 progress_step PACKAGES_TO_VMINSTALL
771 preinstall ${PKG##*/}
774 # add cbpreinstall if cross HOST != TARGET
775 progress_setup PACKAGES_TO_CBPREINSTALL
776 for PKG in $PACKAGES_TO_CBPREINSTALL ; do
777 progress_step PACKAGES_TO_CBPREINSTALL
778 preinstall ${PKG##*/}
780 if [ -w /root ]; then
781 test -c $BUILD_ROOT/dev/null || create_devs
783 test -e $BUILD_ROOT/etc/fstab || touch $BUILD_ROOT/etc/fstab
784 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
785 if test -z "$PREPARE_VM" ; then
788 touch $BUILD_ROOT/.init_b_cache/preinstall_finished
792 if test -n "$PREPARE_VM" ; then
793 echo "copying packages..."
794 for PKG in $PACKAGES_TO_INSTALL ; do
795 rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
796 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
797 ln -s -f ../$PKG.$PSUF $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF
800 # alreadyinstalled check will not work, but we have to live with
802 echo -n 'reordering...'
803 PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
806 echo "PACKAGES_TO_INSTALL='${PACKAGES_TO_INSTALL//"'"/$Q}'" > $BUILD_ROOT/.build/init_buildsystem.data
807 echo "PACKAGES_TO_RUNSCRIPTS='${PACKAGES_TO_RUNSCRIPTS//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
808 # needed for continuation in xen/kvm with rpm-x86
809 echo "PACKAGES_TO_PREINSTALL='${PACKAGES_TO_PREINSTALL//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
810 echo "PACKAGES_TO_CBPREINSTALL='${PACKAGES_TO_CBPREINSTALL//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
811 echo "PSUF='$PSUF'" >> $BUILD_ROOT/.build/init_buildsystem.data
812 rm -f $BUILD_IS_RUNNING
816 mkdir -p $BUILD_ROOT/proc
817 mkdir -p $BUILD_ROOT/dev/pts
818 mount -n -tproc none $BUILD_ROOT/proc 2>/dev/null || true
819 mount -n -tdevpts none $BUILD_ROOT/dev/pts 2>/dev/null || true
822 # create .build.binaries directory if requested
824 rm -rf $BUILD_ROOT/.build.binaries
825 if test -n "$CREATE_BUILD_BINARIES" ; then
826 echo "creating .build.binaries directory..."
827 mkdir -p "$BUILD_ROOT/.build.binaries"
828 for PKG in $PACKAGES_TO_INSTALL ; do
829 test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue
830 LPKG=`readlink -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"`
831 ln "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" 2>/dev/null
832 test -f "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" && continue
833 cp "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF"
839 # get list and ids of already installed rpms
841 mkdir -p $BUILD_ROOT/.init_b_cache/alreadyinstalled
842 if test -f $BUILD_ROOT/var/lib/rpm/packages.rpm -o -f $BUILD_ROOT/var/lib/rpm/Packages ; then
843 chroot $BUILD_ROOT rpm -qa --qf "%{NAME} $RPMIDFMT" | (
845 echo "$ii" > "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$pp"
851 # reorder packages (already done in vm continuation)
853 if ! test -e $BUILD_ROOT/.build/init_buildsystem.data ; then
854 echo -n 'reordering...'
855 PACKAGES_TO_INSTALL_FIRST=`reorder $PACKAGES_TO_INSTALL_FIRST`
856 PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
862 chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | \
866 r*failed:\ No\ such\ file\ or\ directory) ;;
867 error:\ failed\ to\ stat\ *:\ No\ such\ file\ or\ directory) ;;
868 error:\ *scriptlet\ failed*)
870 echo "re-try deleting $PKG using --noscripts"
871 chroot $BUILD_ROOT rpm --nodeps --noscripts -e $PKG || true
879 # delete all packages we don't want
881 mkdir -p $BUILD_ROOT/.init_b_cache/todelete
882 for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do
884 test "$PKG" = "*" && continue
885 ln $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG $BUILD_ROOT/.init_b_cache/todelete/$PKG
887 for PKG in $PACKAGES_TO_INSTALL_FIRST $PACKAGES_TO_INSTALL $PACKAGES_TO_CBINSTALL ; do
888 rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG
890 for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do
892 test "$PKG" = "*" && continue
897 rm -rf $BUILD_ROOT/.init_b_cache/todelete
899 rm -rf $BUILD_ROOT/.init_b_cache/preinstalls
900 mkdir -p $BUILD_ROOT/.init_b_cache/preinstalls
901 for PKG in $PACKAGES_TO_PREINSTALL $PACKAGES_TO_CBPREINSTALL; do
902 touch "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG"
905 rm -rf $BUILD_ROOT/installed-pkg
906 mkdir -p $BUILD_ROOT/installed-pkg
910 # on Fedora 10 rpmbuild is in a separate package so we need something else to
912 test -x $BUILD_ROOT/usr/bin/rpmsign && RPMCHECKOPTS="--nodigest --nosignature"
913 test -x /usr/bin/rpmsign && RPMCHECKOPTS_HOST="--nodigest --nosignature"
915 MAIN_LIST="$PACKAGES_TO_INSTALL_FIRST $PACKAGES_TO_INSTALL $PACKAGES_TO_CBINSTALL"
916 progress_setup MAIN_LIST
917 for PKG in $PACKAGES_TO_INSTALL_FIRST RUN_LDCONFIG $PACKAGES_TO_INSTALL $PACKAGES_TO_CBINSTALL; do
920 test -x $BUILD_ROOT/sbin/ldconfig && chroot $BUILD_ROOT /sbin/ldconfig 2>&1
924 progress_step MAIN_LIST
926 test -f $BUILD_ROOT/installed-pkg/$PKG && continue
928 if test $PSUF = deb ; then
929 # debian world, install deb files
930 test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb || continue
931 if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.deb" -ef "$BUILD_ROOT/.init_b_cache/$PKG.deb" ; then
932 rm -f $BUILD_ROOT/.init_b_cache/$PKG.deb
933 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb $BUILD_ROOT/.init_b_cache/$PKG.deb || cleanup_and_exit 1
935 PKGID=`readlink $BUILD_ROOT/.init_b_cache/rpms/$PKG.deb`
937 PKGID="${PKGID%.deb}"
938 echo "installing ${PKGID%_*}"
939 ( chroot $BUILD_ROOT dpkg --install --force all .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \
940 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'
942 echo "$PKGID debian" > $BUILD_ROOT/installed-pkg/$PKG
943 # ugly workaround for upstart system. some packages (procps) try
944 # to start a service in their configure phase. As we don't have
945 # a running upstart, we just link the start binary to /bin/true
946 if test -e "$BUILD_ROOT/sbin/start"; then
947 if test "$BUILD_ROOT/sbin/start" -ef "$BUILD_ROOT/sbin/initctl" ; then
948 echo "linking /sbin/start to /bin/true"
949 mv "$BUILD_ROOT/sbin/start" "$BUILD_ROOT/sbin/start.disabled"
950 ln -s "/bin/true" "$BUILD_ROOT/sbin/start"
953 # another workaround, see bug bnc#733699
954 rm -f "$BUILD_ROOT/var/run/init.upgraded"
958 if test $PSUF = arch ; then
959 test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF || continue
960 if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -ef "$BUILD_ROOT/.init_b_cache/$PKG.$PSUF" ; then
961 rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
962 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
964 PKGID=`readlink $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF`
966 PKGID="${PKGID/%.pkg.tar.?z/.arch}"
967 PKGID="${PKGID%.$PSUF}"
968 echo "installing ${PKGID%_*}"
969 # -d -d disables deps checking
970 ( chroot $BUILD_ROOT pacman -Uf -d -d --noconfirm .init_b_cache/$PKG.$PSUF 2>&1 || touch $BUILD_ROOT/exit ) | \
971 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'
973 echo "$PKGID $PSUF" > $BUILD_ROOT/installed-pkg/$PKG
977 test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm || continue
979 if test -f $BUILD_ROOT/.init_b_cache/rpms/$PKG.id -a -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then
980 read PKGID < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id
981 read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG
982 if test "$PKGID" = "$OLDPKGID" ; then
983 #echo "keeping ${PKGID%% *}"
984 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
989 PKGID=`rpm -qp --qf "$RPMIDFMT" $RPMCHECKOPTS_HOST $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm`
991 if test -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then
992 read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG
993 if test "$PKGID" != "$OLDPKGID" ; then
994 echo deleting unwanted ${OLDPKGID%% *}
996 elif test "$VERIFY_BUILD_SYSTEM" = true ; then
997 chroot $BUILD_ROOT rpm --verify $PKG 2>&1 | tee $TMPFILE
998 if grep ^missing $TMPFILE > /dev/null ; then
999 echo deleting incomplete ${PKGID%% *}
1002 #echo "keeping ${PKGID%% *}"
1003 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1007 #echo "keeping ${PKGID%% *}"
1008 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1011 if test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then
1013 # call for rpm-4.x and not rpm-devel
1014 test -z "${PKG##rpm-[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
1015 # also exec for exchanged rpm ! naming is rpm-x86-<target>-<ver>
1016 test -z "${PKG##rpm-x86-*[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
1019 export ADDITIONAL_PARAMS=
1020 if test "$USE_FORCE" = true ; then
1021 export ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --force"
1023 # work around for cross-build installs, we must not overwrite the running rpm
1024 if test "$PKG" = rpm ; then
1025 for i in $BUILD_ROOT/.init_b_cache/preinstalls/rpm-x86-* ; do
1026 test -e "$i" && ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --justdb"
1029 echo "installing ${PKGID%% *}"
1030 if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" -ef "$BUILD_ROOT/.init_b_cache/$PKG.rpm" ; then
1031 rm -f $BUILD_ROOT/.init_b_cache/$PKG.rpm
1032 cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm $BUILD_ROOT/.init_b_cache/$PKG.rpm || cleanup_and_exit 1
1034 ( chroot $BUILD_ROOT rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \
1035 $ADDITIONAL_PARAMS .init_b_cache/$PKG.rpm 2>&1 || \
1036 touch $BUILD_ROOT/exit ) | \
1037 grep -v "^warning:.*saved as.*rpmorig$"
1038 # delete link so package is only installed once
1039 rm -f $BUILD_ROOT/.init_b_cache/$PKG.rpm
1041 echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
1045 if test $PSUF = deb ; then
1046 echo "configure all installed packages..."
1047 # configure all packages after complete installation, not for each package like rpm does
1048 # We need to run this twice, because of cyclic dependencies as it does not succeed on most
1049 # debian based distros in the first attempt.
1050 if ! chroot $BUILD_ROOT dpkg --configure --pending 2>&1; then
1051 echo "first configure attempt failed, trying again..."
1052 chroot $BUILD_ROOT dpkg --configure --pending 2>&1 || touch $BUILD_ROOT/exit
1056 # devices can vanish if devs got uninstalled
1057 test -c $BUILD_ROOT/dev/null || create_devs
1059 cd $BUILD_ROOT || cleanup_and_exit 1
1064 rm -f $BUILD_ROOT/etc/mtab
1065 cp /proc/mounts $BUILD_ROOT/etc/mtab
1066 chmod 644 $BUILD_ROOT/etc/mtab
1069 # to be sure, path is set correctly, we have to source /etc/profile before
1073 #rm -f $BUILD_ROOT/bin/rpm.sh
1074 #cp $BUILD_LIBDIR/lib/rpm.sh $BUILD_ROOT/bin/rpm.sh
1075 #chmod 755 $BUILD_ROOT/bin/rpm.sh
1076 #test -f $BUILD_ROOT/bin/rpm -a ! -L $BUILD_ROOT/bin/rpm && \
1077 # mv $BUILD_ROOT/bin/rpm $BUILD_ROOT/bin/rpm.bin
1078 #rm -f $BUILD_ROOT/bin/rpm
1079 #ln -s rpm.sh $BUILD_ROOT/bin/rpm
1082 # some packages use uname -r to decide which kernel is used to build for.
1083 # this does not work in autobuild always. Here is a wrapper script, that
1084 # gets Version from kernel sources.
1087 #rm -f $BUILD_ROOT/bin/uname.sh
1088 #cp -v $BUILD_LIBDIR/lib/uname.sh $BUILD_ROOT/bin/uname.sh
1089 #chmod 755 $BUILD_ROOT/bin/uname.sh
1090 #test -f $BUILD_ROOT/bin/uname -a ! -L $BUILD_ROOT/bin/uname && \
1091 # mv $BUILD_ROOT/bin/uname $BUILD_ROOT/bin/uname.bin
1092 #rm -f $BUILD_ROOT/bin/uname
1093 #ln -s uname.sh $BUILD_ROOT/bin/uname
1096 # some distributions have a /etc/rpmrc or /etc/rpm/macros and some not.
1097 # make sure, that it is setup correctly.
1100 #rm -f $BUILD_ROOT/etc/rpmrc
1101 #if test -e $BUILD_LIBDIR/lib/rpmrc.$BUILD_BASENAME ; then
1102 # cp -v $BUILD_LIBDIR/lib/rpmrc.$BUILD_BASENAME $BUILD_ROOT/etc/rpmrc
1103 #elif test -e $BUILD_LIBDIR/lib/rpmrc ; then
1104 # cp -v $BUILD_LIBDIR/lib/rpmrc $BUILD_ROOT/etc/rpmrc
1108 #rm -f $BUILD_ROOT/etc/rpm/macros $BUILD_ROOT/etc/rpm/suse_macros
1109 #mkdir -p $BUILD_ROOT/etc/rpm
1110 #if test -e $BUILD_LIBDIR/lib/macros.$BUILD_BASENAME ; then
1111 # cp -v $BUILD_LIBDIR/lib/macros.$BUILD_BASENAME $BUILD_ROOT/etc/rpm/macros
1112 # cp -v $BUILD_LIBDIR/lib/macros.$BUILD_BASENAME $BUILD_ROOT/etc/rpm/suse_macros
1113 #elif test -e $BUILD_LIBDIR/lib/macros ; then
1114 # cp -v $BUILD_LIBDIR/lib/macros $BUILD_ROOT/etc/rpm/macros
1115 # cp -v $BUILD_LIBDIR/lib/macros $BUILD_ROOT/etc/rpm/suse_macros
1119 # make sure, that our nis is not present in the chroot system
1121 test -e $BUILD_ROOT/etc/nsswitch.conf && {
1122 echo removing nis flags from $BUILD_ROOT/etc/nsswitch.conf...
1123 cat $BUILD_ROOT/etc/nsswitch.conf | sed -e"s:nis::g" > \
1124 $BUILD_ROOT/etc/nsswitch.conf.tmp
1125 mv $BUILD_ROOT/etc/nsswitch.conf.tmp $BUILD_ROOT/etc/nsswitch.conf
1129 # creating some default directories
1130 for DIR in /usr/share/doc/packages \
1131 /usr/X11R6/include/X11/pixmaps \
1132 /usr/X11R6/include/X11/bitmaps ; do
1133 mkdir -p $BUILD_ROOT/$DIR
1136 for FILE in /var/run/utmp /var/log/wtmp /etc/fstab ; do
1137 mkdir -p $BUILD_ROOT/${FILE%/*}
1138 touch $BUILD_ROOT/$FILE
1141 echo now finalizing build dir...
1142 CHROOT_RETURN="`chroot $BUILD_ROOT /sbin/ldconfig 2>&1`"
1143 case "$CHROOT_RETURN" in
1145 chroot $BUILD_ROOT /sbin/ldconfig
1147 echo chroot $BUILD_ROOT /sbin/ldconfig
1149 echo "$CHROOT_RETURN"
1151 echo "Problem with ldconfig. It's better to reinit the build system..."
1156 test -x $BUILD_ROOT/usr/sbin/Check && chroot $BUILD_ROOT /usr/sbin/Check
1158 mkdir -p $BUILD_ROOT/var/adm/packages
1159 touch $BUILD_ROOT/var/adm/packages
1160 if test -x $BUILD_ROOT/sbin/SuSEconfig ; then
1161 if grep norestarts $BUILD_ROOT/sbin/SuSEconfig > /dev/null ; then
1162 chroot $BUILD_ROOT /sbin/SuSEconfig --norestarts --force
1164 chroot $BUILD_ROOT /sbin/SuSEconfig --force
1168 if test -x $BUILD_ROOT/usr/X11R6/bin/switch2mesasoft ; then
1169 chroot $BUILD_ROOT /usr/X11R6/bin/switch2mesasoft
1172 for PROG in /usr/bin/TeX/texhash /usr/bin/texhash ; do
1173 test -x $BUILD_ROOT/$PROG && \
1174 chroot $BUILD_ROOT bash -c ". /etc/profile ; $PROG"
1177 if test -e $BUILD_ROOT/usr/share/zoneinfo/UTC ; then
1178 chroot $BUILD_ROOT zic -l UTC
1181 test -e $BUILD_ROOT/.build/init_buildsystem.data || HOST=`hostname`
1182 test -e $BUILD_ROOT/etc/hosts || echo "127.0.0.1 localhost" > $BUILD_ROOT/etc/hosts
1183 if ! grep -F "127.0.0.1 $HOST" $BUILD_ROOT/etc/hosts > /dev/null ; then
1184 # this makes a reverse lookup on 127.0.0.1 return the host name,
1185 # which is bad, but 127.0.0.2 does not work on all unix systems
1186 echo "127.0.0.1 $HOST" > $BUILD_ROOT/etc/hosts.new
1187 test -f $BUILD_ROOT/etc/hosts && cat $BUILD_ROOT/etc/hosts >> $BUILD_ROOT/etc/hosts.new
1188 mv $BUILD_ROOT/etc/hosts.new $BUILD_ROOT/etc/hosts
1191 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
1192 echo "initializing rpm db..."
1193 chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1
1194 # create provides index
1195 chroot $BUILD_ROOT rpm -q --whatprovides rpm >/dev/null 2>&1
1198 # create modules.dep in kvm/xen
1199 # This can not work, until we use the native repository kernel
1200 #if [ $BUILD_ROOT = "/" -a -x /sbin/depmod ]; then
1204 rm -f $BUILD_ROOT/.rpmmacros $BUILD_ROOT/root/.rpmmacros
1205 rm -rf $BUILD_ROOT/.init_b_cache
1206 rm -f $BUILD_IS_RUNNING