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 ################################################################
12 # Copyright (c) 1997-2014 SUSE Linux Products GmbH
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License version 2 or 3 as
16 # published by the Free Software Foundation.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
23 # You should have received a copy of the GNU General Public License
24 # along with this program (see the file COPYING); if not, write to the
25 # Free Software Foundation, Inc.,
26 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28 ################################################################
31 # needed globals variables
34 export BUILD_DIR=${BUILD_DIR:-/usr/lib/build}
35 PATH="$BUILD_DIR:$PATH"
37 export YAST_IS_RUNNING=instsys
39 # slurp in package binary support
40 . "$BUILD_DIR/build-pkg"
42 # need to restore build root owner for non-root builds
47 . $BUILD_DIR/common_functions || exit 1
49 BUILD_IS_RUNNING="$BUILD_ROOT"/not-ready
50 TMPFILE="$BUILD_ROOT"/tmpfile
51 RPMIDFMT="%{NAME}-%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
53 test -x /usr/bin/rpmquery && RPMCHECKOPTS_HOST="--nodigest --nosignature"
55 # should RPMs be installed with --force ?
63 CREATE_BUILD_BINARIES=
65 CACHE_DIR=/var/cache/build
67 test -z "$CONFIG_DIR" && CONFIG_DIR="$BUILD_DIR/configs"
69 while test -n "$1" ; do
79 --create-build-binaries)
81 CREATE_BUILD_BINARIES=true
85 USEUSEDFORBUILD=--useusedforbuild
96 --define|--with|--without)
97 definesnstuff[${#definesnstuff[@]}]="$1";
98 definesnstuff[${#definesnstuff[@]}]="$2";
102 repos[${#repos[@]}]="$2";
119 DLNOSIGNATURE="--nosignature"
123 USEHIGHERDEPS="--usehigherdeps"
144 if test -z "$BUILD_ROOT" ; then
145 echo "Please specify a build root!"
149 BUILD_IS_RUNNING="$BUILD_ROOT"/not-ready
150 TMPFILE="$BUILD_ROOT"/tmpfile
156 if test "$UID" = 0 -a -n "$BUILD_ROOT" -a "$BUILD_ROOT" != / ; then
157 mount -n -tproc none "$BUILD_ROOT/proc"
158 test -e "$BUILD_ROOT/proc/self" || cleanup_and_exit 1 "Could not mount /proc, is this a container with missing capabilities?"
159 mount -n -tdevpts -omode=0620,gid=5 none "$BUILD_ROOT/dev/pts"
164 if test -n "$BUILD_ROOT" -a "$BUILD_ROOT" != / ; then
165 buildroot_umount "/proc/sys/fs/binfmt_misc"
166 buildroot_umount "/proc"
167 buildroot_umount "/sys"
168 buildroot_umount "/dev/pts"
169 buildroot_umount "/dev/shm"
170 buildroot_umount "/mnt"
176 test -z "$1" && set 0
177 if test -n "$2" ; then
178 if test "$1" -ne 0 ; then
184 test "$BUILD_ROOT" = / -a -n "$browner" && chown "$browner" "$BUILD_ROOT"
185 # umount so init_buildsystem can be used standalone
187 # never report a fatal error when the job got killed from outside
188 test "$1" = 4 -a -e "$BUILD_ROOT/exit" && exit 1
193 if test -n "$BUILD_ROOT" -a "$BUILD_ROOT" != / ; then
195 rm -rf -- "$BUILD_ROOT"/* 2> /dev/null || true
196 chattr -a -A -i -R -- "$BUILD_ROOT" 2> /dev/null || true # does not follow symlinks
197 rm -rf -- "$BUILD_ROOT"/*
198 rm -rf -- "$BUILD_ROOT/.build"
199 rm -rf -- "$BUILD_ROOT"/.build.console.*
200 rm -rf -- "$BUILD_ROOT"/.build.hostarch.*
201 rm -rf -- "$BUILD_ROOT"/.build.kernel.*
202 rm -rf -- "$BUILD_ROOT"/.build.initrd.*
203 rm -rf -- "$BUILD_ROOT"/.build.sysroot
204 rm -rf -- "$BUILD_ROOT/.root"
205 rm -rf -- "$BUILD_ROOT/.init_b_cache"
206 test -L "$BUILD_ROOT/.preinstall_image" && rm -f -- "$BUILD_ROOT/.preinstall_image"
207 rm -rf -- "$BUILD_ROOT"/.preinstall_image/*
208 rm -rf -- "$BUILD_ROOT"/.preinstallimage*
212 unsafe_preinstall_check() {
213 # cpio isn't safe so we require bsdtar for VMs. chroot is
214 # unsafe anyways so it's ok for that.
215 if test -n "$PREPARE_VM" ; then
216 echo "Error: setting up a VM requires bsdtar for security reasons."
217 echo "Please install bsdtar."
222 preinstall_image_filter() {
224 test -e "$BUILD_ROOT/.preinstall_image/$PKG" && continue
231 echo "unpacking preinstall image${2:+ $2}"
232 cd "$BUILD_ROOT" || cleanup_and_exit 1
233 if test -x /usr/bin/bsdtar ; then
234 TAR="/usr/bin/bsdtar -P --chroot --numeric-owner -x"
236 unsafe_preinstall_check
239 # pipe output through perl to print a dot every 1000 lines
240 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
241 echo "unpack failed."
242 test -e "$BUILD_ROOT/.preinstallimage.unpack" && cat "$BUILD_ROOT/.preinstallimage.unpack"
245 rm -f "$BUILD_ROOT/.preinstallimage.unpack"
251 echo "preinstalling $PKG..."
252 cd "$BUILD_ROOT" || cleanup_and_exit 1
253 if test -x /usr/bin/bsdtar ; then
254 CPIO="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x -f-"
255 TAR="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x"
257 unsafe_preinstall_check
258 CPIO="cpio --extract --unconditional --preserve-modification-time --make-directories --no-absolute-filenames --quiet"
259 cpio --help 2>/dev/null | grep -q -e --extract-over-symlinks && CPIO="$CPIO --extract-over-symlinks"
266 chroot "$BUILD_ROOT" /sbin/ldconfig 2>/dev/null
267 for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
275 local com file mode arg
277 mkdir -m 755 -p "$BUILD_ROOT"/dev/pts
278 test -d "$BUILD_ROOT"/dev/shm || rm -f "$BUILD_ROOT"/dev/shm
279 mkdir -m 755 -p "$BUILD_ROOT"/dev/shm
280 while read com file mode arg ; do
281 rm -f "$BUILD_ROOT"/dev/$file
282 if test $com = ln ; then
283 ln -s $arg "$BUILD_ROOT"/dev/$file
286 $com -m $mode "$BUILD_ROOT"/dev/$file $arg
291 mknod random 666 c 1 8
292 mknod urandom 644 c 1 9
295 mknod loop-control 600 c 10 237
296 mknod loop0 640 b 7 0
297 mknod loop1 640 b 7 1
298 mknod loop2 640 b 7 2
299 mknod loop3 640 b 7 3
300 ln fd 777 /proc/self/fd
307 # check whether the repo list contains a plain "zypp://". Add all
308 # enabled zypp repos in this case
309 expand_plain_zypp_repo() {
312 for i in "${repos[@]}"; do
313 if test "$i" = "zypp://" ; then
314 for j in $($BUILD_DIR/createzyppdeps --listrepos) ; do
315 r=("${r[@]}" "zypp://$j")
324 create_cache_file() {
326 expand_plain_zypp_repo
327 if ! test -f $CACHE_FILE || ! test -f $CACHE_FILE.id || \
328 test "${repos[*]} ${BUILD_RPMS//:/ /}" != "$(cat $CACHE_FILE.id 2>/dev/null)"; then
331 for SRC in "${repos[@]}" ${BUILD_RPMS//:/ /}; do
332 test -n "$SRC" || SRC=.
333 if test "${SRC#zypp://}" != "$SRC" ; then
334 SRC="/var/cache/zypp/raw/${SRC#zypp://}"
336 if test "$SRC" -nt $CACHE_FILE; then
340 # always rebuild if we have remote repositories and --clean is given
341 if test -n "$CLEAN_BUILD" -a "$SRC" != "${SRC#*://}" -a "${SRC#zypp://}" = "$SRC" ; then
347 if ! test -f $CACHE_FILE.id ; then
348 test -z "$LIST_STATE" && echo initializing $CACHE_FILE ...
350 if test -n "$BUILD_DIST" ; then
351 for i in `queryconfig repotype --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH"` ; do
353 arch|debian|hdlist2|rpm-md) REPOTYPE=$i
355 test -n "$REPOTYPE" && break
357 if test -z "$REPOTYPE"; then
358 BINTYPE=`queryconfig binarytype --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH"`
360 arch) REPOTYPE=arch ;;
361 deb) REPOTYPE=debian ;;
365 if test -z "$REPOTYPE" ; then
366 # check the first init_buildsystem arg, maybe it is a recipe
376 for SRC in "${repos[@]}" -- ${BUILD_RPMS//:/ /}; do
377 if test "$SRC" = '--' ; then
381 test -z "$SRC" && SRC=`pwd`
382 if test "${SRC#http://}" != "$SRC" -o "${SRC#https://}" != "$SRC" -o "${SRC#ftp://}" != "$SRC" -o "${SRC#ftps://}" != "$SRC" ; then
383 # remote repo, cache binary packages
384 mkdir -p "$(getcachedir "$SRC")"
385 if test "$REPOTYPE" = arch ; then
386 set -- $BUILD_DIR/createarchdeps --cachedir="$CACHE_DIR" "$SRC"
387 elif test "$REPOTYPE" = debian ; then
388 set -- $BUILD_DIR/createdebdeps --cachedir="$CACHE_DIR" --archpath "$BUILD_ARCH" "$SRC"
389 elif test "$REPOTYPE" = hdlist2 ; then
390 set -- $BUILD_DIR/createmdkdeps --cachedir="$CACHE_DIR" "$SRC"
392 set -- $BUILD_DIR/createrepomddeps --cachedir="$CACHE_DIR" "$SRC"
394 elif test "${SRC#zypp://}" != "$SRC" ; then
396 set -- $BUILD_DIR/createzyppdeps --cachedir="$CACHE_DIR" "$SRC"
397 elif test ! -e "$SRC" ; then
398 echo "*** $SRC does not exist" >&2
400 elif test -z "$findonly" -a \( -e "$SRC"/suse/setup/descr/packages -o -e "$SRC"/suse/setup/descr/packages.gz \) ; then
401 set -- $BUILD_DIR/createyastdeps "$SRC"
402 elif test -z "$findonly" -a -e "$SRC"/repodata/repomd.xml ; then
403 set -- $BUILD_DIR/createrepomddeps "$SRC"
405 set -- $BUILD_DIR/createdirdeps --oldfile "$CACHE_FILE" "$SRC"
408 "$@" || cleanup_and_exit 1
410 done > $CACHE_FILE.new
412 mv $CACHE_FILE.new $CACHE_FILE
413 echo "${repos[*]} ${BUILD_RPMS//:/ /}" > $CACHE_FILE.id
426 if test "${url:0:7}" == "zypp://" -o "${url:0:7}" == "http://" -o "${url:0:8}" == "https://" -o "${url:0:6}" == "ftp://" -o "${url:0:7}" == "ftps://" ; then
427 cachedir="$(getcachedir "$url")"
428 local name="$(basename "$url")"
429 name=${name/%.pkg.tar.zst/.arch}
430 name=${name/%.pkg.tar.?z/.arch}
431 SRC="$cachedir/$name"
433 echo "Invalid url: $url"
437 local destdir="$cachedir/tmp_$$"
439 if [ ! -f "$BUILD_ROOT"/exit ] ; then
440 echo "downloading $url ... ";
442 $BUILD_DIR/download "$destdir" "$url" || cleanup_and_exit 1
443 local destfile="$destdir/${url##*/}"
444 if test ! -e "$destfile" ; then
445 echo "expected $destfile after download but it's missing" >&2
448 # for rpm check integrity and the signature
451 rpm -K $DLNOSIGNATURE "$destfile" > $destfile.v || { echo "rpm verify failed" >&2; rm -rf "$destdir"; cleanup_and_exit 1; }
452 if grep "NOT OK" $destfile.v; then
459 # if there is such package, didn't mv.
460 mv -n "$destfile" "$SRC" || cleanup_and_exit 1
465 test -z "$*" && return
466 rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
468 echo "$PKG" >> "$BUILD_ROOT"/.init_b_cache/order.manifest
471 #NOTICE: in reorder, you can't print any logs, or it will treate the logs as pacakges outside
472 #Change: If reorder failed because of missing packages, add logic to re-download the missed packages.
473 touch "$BUILD_ROOT"/missedPKG
474 echo "" > "$BUILD_ROOT"/missedPKG
477 #remove exit file, it will create exit file if reorder fail.
478 rm -f "$BUILD_ROOT"/exit
479 #call order operation
480 $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 "$BUILD_ROOT"/missedPKG || touch "$BUILD_ROOT"/exit
482 #order operation OK, exit reorder funciton
483 if [ ! -f "$BUILD_ROOT"/exit ]; then
484 #after reorder again, if reorder is normal, should delete tmp file.
485 rm -f "$BUILD_ROOT"/missedPKG
486 rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
489 #order operation failed!
490 if [ -f "$BUILD_ROOT"/exit ]; then
491 #fail reason: binary not found. To try to download packages again.
492 if test -s "$BUILD_ROOT"/missedPKG; then
493 for line in `cat "$BUILD_ROOT"/missedPKG`; do
494 while read PKG SRC; do
495 if [ "$PKG" = "$line" ]; then
497 # downloadpkg missed packages
498 SRCSUF=${SRC/%.pkg.tar.?z/.arch}
499 #remove the soft link that already existed.
500 rm -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
501 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
504 done < "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
506 #clear file. use it next loop if needed.
507 echo "" > "$BUILD_ROOT"/missedPKG
508 #Other fail reason. Exit!
510 rm -f "$BUILD_ROOT"/missedPKG
511 rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
516 rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
521 for repo in "${repos[@]}" ; do
522 if test "${url:0:${#repo}}" == "$repo" ; then
523 read repoid dummy < <(echo -n "$repo" | md5sum)
524 echo "$CACHE_DIR/$repoid"
530 can_reuse_cached_package() {
531 local cachepkgid pkgid xpkgid
532 test -s "$1" || return 1
533 if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.id" ; then
534 local ep=$(rpm -qp --qf "%{EPOCH}" "'${1}'")
535 if test "$ep" != "(none)"; then
536 RPMIDFMT_EP="%{NAME}-%{EPOCH}:%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
537 pkgid=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "'${1}'"`
539 pkgid=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "'${1}'"`
541 read cachepkgid < "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.id
542 # check if the build time is zero
544 *" 0-"*) xpkgid="${pkgid##* }"; pkgid="${pkgid% *} 0-${xpkgid#*-}" ;;
546 test "$cachepkgid" = "$pkgid" || return 1
555 for arch in $EMULATOR_DEVS; do
556 if test -e $BUILD_DIR/qemu-$arch; then
569 mkdir -p "$BUILD_ROOT"/usr/bin
571 if check_copy_qemu; then
573 for path in $BUILD_DIR/qemu-*; do
574 if file $path | grep -q static; then
575 dest="$BUILD_ROOT/usr/bin/${path##*/}"
576 if [ -f "$path" -a ! -x "$dest" ]; then
577 echo -n " $path" # report copy
578 #echo install -m755 "$path" "$dest"
579 install -m755 "$path" "$dest"
586 for path in /usr/bin/qemu-*; do
587 if file $path | grep -q static; then
588 dest="$BUILD_ROOT/usr/bin/${path##*/}"
589 if [ -f "$path" -a ! -x "$dest" ]; then
590 echo -n " $path" # report copy
591 #echo install -m755 "$path" "$dest"
592 install -m755 "$path" "$dest"
597 if [ -e /usr/sbin/qemu-binfmt-conf.sh \
598 -a ! -e "$BUILD_ROOT"/usr/sbin/qemu-binfmt-conf.sh ]; then
599 echo " /usr/sbin/qemu-binfmt-conf.sh" # report copy
600 mkdir -p "$BUILD_ROOT"/usr/sbin
601 install -m755 /usr/sbin/qemu-binfmt-conf.sh "$BUILD_ROOT"/usr/sbin
607 # Below for backward compatibility when /.build/initvm is not present
609 if [ -n "$PREPARE_VM" ]; then
610 if [ -x /bin/bash-static -a -x /bin/mount-static ]; then
611 echo " /bin/bash-static /bin/mount-static" # report copy
612 mkdir -p "$BUILD_ROOT"/bin
613 install -m755 /bin/bash-static "$BUILD_ROOT"/bin
614 install -m755 /bin/mount-static "$BUILD_ROOT"/bin
624 if test "$BUILD_ROOT" = / ; then
625 browner="$(stat -c %u /)"
628 if test -n "$CLEAN_BUILD" ; then
633 # now test if there was an incomplete run
635 if test -e "$BUILD_IS_RUNNING" ; then
636 echo "It seems that there was an incomplete setup of $BUILD_ROOT."
637 echo "To be sure, we will build it again completely..."
639 echo "Your build system is broken!! Shall I execute"
641 echo " rm -rf -- $BUILD_ROOT/*"
643 echo "y - yes, cleanup the build root"
644 echo "N - No, abort build (default on enter)"
645 echo "c - Continue anyway with this build root"
650 rm -f $BUILD_IS_RUNNING "$BUILD_ROOT"/exit ;;
654 cleanup_and_exit 1 ;;
658 # check for surprises
659 if test -z "$CLEAN_BUILD" -a -n "$BUILD_ROOT" -a "$BUILD_ROOT" != / ; then
663 # umount stuff if mounted
664 if test -n "$BUILD_ROOT" -a "$BUILD_ROOT" != / -a -e "$BUILD_ROOT/proc/self" ; then
669 # store that we start to build the system
671 mkdir -p -- "$BUILD_ROOT" "$BUILD_ROOT/.build" "$BUILD_ROOT/proc" "$BUILD_ROOT/sys" "$BUILD_ROOT/dev/pts" || cleanup_and_exit 4
673 touch $BUILD_IS_RUNNING
675 if test -n "$PREPARE_VM" ; then
676 rm -f "$BUILD_ROOT"/.build/init_buildsystem.data
679 if test -e "$BUILD_ROOT"/.build/init_buildsystem.data ; then
680 # vm continuation, read old config
681 . "$BUILD_ROOT"/.build/init_buildsystem.data
684 # now make sure that all the packages are installed.
686 rm -rf "$BUILD_ROOT/.init_b_cache"
687 mkdir -p "$BUILD_ROOT/.init_b_cache/scripts"
689 if test -z "$RPMLIST" ; then
691 # create rpmdeps file
693 CACHE_FILE="$BUILD_ROOT"/.srcfiles.cache
697 # select and expand packages
699 RPMLIST="$BUILD_ROOT"/.init_b_cache/rpmlist
700 test -z "$LIST_STATE" && echo "expanding package dependencies..."
702 test -z "$PREPARE_VM" || VMOPT=--vm
703 if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD $VMOPT $USEHIGHERDEPS "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR "${PKGS[@]}" > $RPMLIST ; then
704 rm -f $BUILD_IS_RUNNING
709 if test -n "$LIST_STATE" ; then
710 rm -f $BUILD_IS_RUNNING
711 while read PKG SRC ; do
712 test "$PKG" = "preinstall:" && continue
713 test "$PKG" = "runscripts:" && continue
714 test "$PKG" = "cbpreinstall:" && continue
715 test "$PKG" = "vminstall:" && continue
716 test "$PKG" = "dist:" && continue
717 test "$PKG" = "rpmid:" && continue
719 done < "$BUILD_ROOT"/.init_b_cache/rpmlist
720 rm -rf "$BUILD_ROOT/.init_b_cache"
725 # register the QEMU emulator if needed
726 # (we do not need this for the prepare step, as we do not run scripts in this case)
729 if test -z "$PREPARE_VM" ; then
730 if check_use_emulator ; then
731 echo "registering binfmt handlers for cross build"
732 "$BUILD_DIR/$INITVM_NAME"
733 echo 0 > /proc/sys/vm/mmap_min_addr
734 read mmap_min_addr < /proc/sys/vm/mmap_min_addr
735 if test "$mmap_min_addr" != 0 ; then
736 echo "Warning: mmap_min_addr is != 0. If programs fail at mmap this could be the reason."
742 # extract the data from the (generated) rpm list
745 PACKAGES_TO_PREINSTALL=
746 PACKAGES_TO_RUNSCRIPTS=
747 PACKAGES_TO_VMINSTALL=
748 PACKAGES_TO_INSTALLONLY=
749 PACKAGES_TO_NOINSTALL=
751 PREINSTALL_IMAGE_SOURCE=
753 PACKAGES_FROM_PREINSTALLIMAGE=
755 mkdir -p "$BUILD_ROOT"/.init_b_cache/rpms
756 rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download
757 while read PKG SRC ; do
758 if test "$PKG" = "preinstall:" ; then
759 PACKAGES_TO_PREINSTALL=$SRC
762 if test "$PKG" = "vminstall:" ; then
763 PACKAGES_TO_VMINSTALL=$SRC
766 if test "$PKG" = "installonly:" ; then
767 PACKAGES_TO_INSTALLONLY=$SRC
770 if test "$PKG" = "noinstall:" ; then
771 PACKAGES_TO_NOINSTALL=$SRC
774 if test "$PKG" = "preinstallimage:" ; then
775 PREINSTALL_IMAGE=${SRC##*/}
776 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/${SRC##*/}"
779 if test "$PKG" = "preinstallimagesource:" ; then
780 PREINSTALL_IMAGE_SOURCE="$SRC"
783 if test "$PKG" = "runscripts:" ; then
785 PACKAGES_TO_RUNSCRIPTS=$SRC
788 if test "$PKG" = "dist:" ; then
792 if test "$PKG" = "rpmid:" ; then
793 echo "${SRC#*:}" > "$BUILD_ROOT"/.init_b_cache/rpms/${SRC%%:*}.id
796 if test "$PKG" != "${PKG%:}"; then
797 echo "Warning: ignoring unsupported tag '$PKG'" >&2
800 if test "$SRC" = "preinstallimage" ; then
801 PACKAGES_FROM_PREINSTALLIMAGE="$PACKAGES_FROM_PREINSTALLIMAGE $PKG"
802 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
805 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
806 if test "${SRC#/}" = "$SRC" ; then
808 zypp://* | http://* | https://* | ftp://* | ftps://*)
809 echo "$PKG $SRC" >>"$BUILD_ROOT"/.init_b_cache/rpmlist.download
813 echo "unsupported url for '$PKG': $SRC" >&2
818 SRCSUF=${SRC/%.pkg.tar.zst/.arch}
819 SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch}
820 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
823 PACKAGES_TO_ALL="$PACKAGES_TO_INSTALL"
824 PACKAGES_TO_AVAILABLE="$PACKAGES_TO_INSTALL"
826 # subtract noinstall packages from PACKAGES_TO_INSTALL
827 if test -n "$PACKAGES_TO_NOINSTALL" ; then
828 settest=" $PACKAGES_TO_NOINSTALL "
830 for PKG in $PACKAGES_TO_ALL ; do
831 test "$settest" = "${settest/ $PKG /}" && PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
834 # subtract installonly packages from PACKAGES_TO_AVAILABLE
835 if test -n "$PACKAGES_TO_INSTALLONLY" ; then
836 settest=" $PACKAGES_TO_INSTALLONLY "
837 PACKAGES_TO_AVAILABLE=
838 for PKG in $PACKAGES_TO_ALL ; do
839 test "$settest" = "${settest/ $PKG /}" && PACKAGES_TO_AVAILABLE="$PACKAGES_TO_AVAILABLE $PKG"
843 # check if we really can use cached versions for packages on the download list
844 if test -s "$BUILD_ROOT"/.init_b_cache/rpmlist.download ; then
845 echo "calculating packages to download..."
846 rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download2
847 while read PKG SRC ; do
848 cachepkg="${SRC##*/}"
849 cachepkg="${cachepkg/%.pkg.tar.zst/.arch}"
850 cachepkg="${cachepkg/%.pkg.tar.?z/.arch}"
851 if test "$SRC" != "${SRC#zypp://}" ; then
852 # for zypp packages also look in the zypp cache
853 cachedir="/var/cache/zypp/packages/${SRC#zypp://}"
854 cachedir="${cachedir%/*}"
855 if can_reuse_cached_package "$cachedir/$cachepkg" ; then
856 SRCSUF=${SRC/%.pkg.tar.zst/.arch}
857 SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch}
858 ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
862 cachedir="$(getcachedir "$SRC")"
863 if can_reuse_cached_package "$cachedir/$cachepkg" ; then
864 SRCSUF=${SRC/%.pkg.tar.zst/.arch}
865 SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch}
866 ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
869 # not found in cache or cache has different package
870 rm -f "$cachedir/$cachepkg"
871 echo "$PKG $SRC" >>"$BUILD_ROOT"/.init_b_cache/rpmlist.download2
872 done < "$BUILD_ROOT"/.init_b_cache/rpmlist.download
873 rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download
874 test -s "$BUILD_ROOT"/.init_b_cache/rpmlist.download2 && mv "$BUILD_ROOT"/.init_b_cache/rpmlist.download2 "$BUILD_ROOT"/.init_b_cache/rpmlist.download
877 # now do the download of missing packages
878 if test -s "$BUILD_ROOT"/.init_b_cache/rpmlist.download ; then
879 PACKAGES_TO_DOWNLOAD=`cat ${RPMLIST}.download|awk '{print $2}'`
880 progress_setup PACKAGES_TO_DOWNLOAD
881 while read PKG SRC ; do
882 progress_step PACKAGES_TO_DOWNLOAD
884 # downloadpkg modified $SRC, so it has a right name for use
885 SRCSUF=${SRC/%.pkg.tar.zst/.arch}
886 SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch}
887 ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
888 done < "$BUILD_ROOT"/.init_b_cache/rpmlist.download
889 cp "$BUILD_ROOT"/.init_b_cache/rpmlist.download "$BUILD_ROOT"/.init_b_cache/rpmlist_reorder_check.download
890 rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download
895 test -z "$RUNSCRIPTS_SEEN" && PACKAGES_TO_RUNSCRIPTS="$PACKAGES_TO_PREINSTALL"
897 echo "$GUESSED_DIST" > "$BUILD_ROOT"/.guessed_dist
898 test -n "$BUILD_DIST" || BUILD_DIST="$GUESSED_DIST"
902 if test -n "$PREINSTALL_IMAGE" ; then
903 for PKG in $PACKAGES_FROM_PREINSTALLIMAGE ; do
904 # touch the file so that the copying works
905 touch "$BUILD_ROOT"/.init_b_cache/rpms/"$PKG.$PSUF"
912 # test if we need to preinstall
914 if test ! -e "$BUILD_ROOT"/installed-pkg -a ! -e "$BUILD_ROOT"/.build/init_buildsystem.data ; then
915 mkdir -p "$BUILD_ROOT"/etc || cleanup_and_exit 1
916 mkdir -p "$BUILD_ROOT"/proc || cleanup_and_exit 1
917 test -f "$BUILD_ROOT"/etc/HOSTNAME || hostname -f > "$BUILD_ROOT"/etc/HOSTNAME
918 for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
919 : > "$BUILD_ROOT"/.init_b_cache/scripts/$PKG.run
921 PACKAGES_TO_PREINSTALL_FILTERED="$PACKAGES_TO_PREINSTALL"
922 PACKAGES_TO_VMINSTALL_FILTERED="$PACKAGES_TO_VMINSTALL"
923 rm -f "$BUILD_ROOT/.preinstall_image"/*
924 if test -n "$PREINSTALL_IMAGE" ; then
925 preinstall_image "$PREINSTALL_IMAGE" "$PREINSTALL_IMAGE_SOURCE"
926 PACKAGES_TO_PREINSTALL_FILTERED=`preinstall_image_filter $PACKAGES_TO_PREINSTALL_FILTERED`
927 PACKAGES_TO_VMINSTALL_FILTERED=`preinstall_image_filter $PACKAGES_TO_VMINSTALL_FILTERED`
929 PACKAGES_TO_PREINSTALL_FILTERED=`reorder $PACKAGES_TO_PREINSTALL_FILTERED`
930 progress_setup PACKAGES_TO_PREINSTALL_FILTERED
931 for PKG in $PACKAGES_TO_PREINSTALL_FILTERED ; do
932 progress_step PACKAGES_TO_PREINSTALL_FILTERED
933 preinstall ${PKG##*/}
936 if test -n "$PREPARE_VM" ; then
937 PACKAGES_TO_VMINSTALL_FILTERED=`reorder $PACKAGES_TO_VMINSTALL_FILTERED`
938 progress_setup PACKAGES_TO_VMINSTALL_FILTERED
939 for PKG in $PACKAGES_TO_VMINSTALL_FILTERED ; do
940 progress_step PACKAGES_TO_VMINSTALL_FILTERED
941 preinstall ${PKG##*/}
946 if test -w /root ; then
947 test -c "$BUILD_ROOT"/dev/null || create_devs
949 test -e "$BUILD_ROOT"/etc/fstab || touch "$BUILD_ROOT"/etc/fstab
950 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
951 if test -z "$PREPARE_VM" ; then
955 touch "$BUILD_ROOT"/.init_b_cache/preinstall_finished
957 # mark as preinstalled no longer needed
958 rm -rf "$BUILD_ROOT/installed-pkg"
959 mkdir -p "$BUILD_ROOT/installed-pkg"
961 # preinstall was already done
962 if test -z "$PREPARE_VM" ; then
967 if test -n "$PREPARE_VM" ; then
968 echo "copying packages..."
969 for PKG in $PACKAGES_TO_ALL ; do
970 rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
971 cp "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
972 ln -s -f ../$PKG.$PSUF "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF
975 # alreadyinstalled check will not work, but we have to live with that...
976 echo -n 'reordering...'
977 PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
981 echo "PACKAGES_TO_INSTALL='${PACKAGES_TO_INSTALL//"'"/$Q}'" > "$BUILD_ROOT"/.build/init_buildsystem.data
982 echo "PACKAGES_TO_RUNSCRIPTS='${PACKAGES_TO_RUNSCRIPTS//"'"/$Q}'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
983 # needed for continuation in xen/kvm with rpm-x86
984 echo "PACKAGES_TO_PREINSTALL='${PACKAGES_TO_PREINSTALL//"'"/$Q}'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
985 echo "PACKAGES_TO_AVAILABLE='${PACKAGES_TO_AVAILABLE//"'"/$Q}'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
986 echo "PSUF='$PSUF'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
987 rm -f $BUILD_IS_RUNNING
992 # finish preinstall if this is a vm continuation
994 if test -e "$BUILD_ROOT/.build/init_buildsystem.data" -a ! -e "$BUILD_ROOT/.init_b_cache/preinstall_finished" ; then
997 touch "$BUILD_ROOT/.init_b_cache/preinstall_finished"
1002 # create .build.binaries directory if requested
1004 rm -rf "$BUILD_ROOT/.build.binaries"
1005 if test -n "$CREATE_BUILD_BINARIES" ; then
1006 echo "creating .build.binaries directory..."
1007 mkdir -p "$BUILD_ROOT/.build.binaries"
1008 for PKG in $PACKAGES_TO_AVAILABLE ; do
1009 test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue
1010 LPKG=`readlink -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"`
1011 ln "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" 2>/dev/null
1012 test -f "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" && continue
1013 cp "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF"
1019 # reorder packages (already done in vm continuation)
1021 if ! test -e "$BUILD_ROOT"/.build/init_buildsystem.data ; then
1022 echo -n 'reordering...'
1023 PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
1025 echo 'reordering done'
1029 # get list and ids of already installed packages
1031 mkdir -p "$BUILD_ROOT"/.init_b_cache/alreadyinstalled
1032 listinstalled --root "$BUILD_ROOT" --type "$PSUF" --extraname | (
1033 while read id name buildid; do
1034 echo "$buildid" > "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$name"
1038 # do pre-installation work
1042 # delete all packages we don't want
1044 if [ -z "$KEEP_PACKS" ]; then
1045 mkdir -p "$BUILD_ROOT"/.init_b_cache/todelete
1046 for PKG in "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/* ; do
1048 test "$PKG" = "*" && continue
1049 ln "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG "$BUILD_ROOT"/.init_b_cache/todelete/$PKG
1051 for PKG in $PACKAGES_TO_INSTALL; do
1052 rm -f "$BUILD_ROOT"/.init_b_cache/todelete/$PKG
1054 for PKG in "$BUILD_ROOT"/.init_b_cache/todelete/* ; do
1056 test "$PKG" = "*" && continue
1057 echo "deleting $PKG"
1061 rm -rf "$BUILD_ROOT/.init_b_cache/todelete"
1063 rm -rf "$BUILD_ROOT/.init_b_cache/preinstalls"
1064 mkdir -p "$BUILD_ROOT/.init_b_cache/preinstalls"
1065 for PKG in $PACKAGES_TO_PREINSTALL; do
1066 touch "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG"
1069 rm -rf "$BUILD_ROOT/installed-pkg"
1070 mkdir -p "$BUILD_ROOT/installed-pkg"
1072 test -x "$BUILD_ROOT"/sbin/ldconfig && chroot "$BUILD_ROOT" /sbin/ldconfig 2>&1
1074 MAIN_LIST="$PACKAGES_TO_INSTALL"
1075 progress_setup MAIN_LIST
1076 for PKG in $MAIN_LIST ; do
1077 test -f "$BUILD_ROOT"/installed-pkg/$PKG && continue
1078 progress_step MAIN_LIST
1080 if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -a ! -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" ; then
1081 # preinstallimage package, make sure it's in the image
1082 if ! test -e "$BUILD_ROOT"/.preinstall_image/$PKG ; then
1083 echo "Package $PKG is missing from the preinstall image"
1086 read PKG_HDRMD5 PKGID < "$BUILD_ROOT"/.preinstall_image/$PKG
1087 echo "preinstalled ${PKGID%% *}"
1088 echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
1092 # get the hdrmd5 if we want to create a preinstall image
1094 if test -d "$BUILD_ROOT"/.preinstall_image -a ! -e "$BUILD_ROOT"/.preinstall_image/$PKG ; then
1095 PKG_HDRMD5=`perl -I$BUILD_DIR -MBuild -e 'print Build::queryhdrmd5($ARGV[0])' "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF`
1096 test -n "$PKG_HDRMD5" || cleanup_and_exit 1
1099 test -L "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF || continue
1101 # check if we can keep an already installed package
1102 if test "$VERIFY_BUILD_SYSTEM" != true -a -f "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.id -a -f "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG ; then
1103 read PKGID < "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.id
1104 read OLDPKGID < "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG
1105 if test "$PKGID" = "$OLDPKGID" ; then
1106 echo "keeping ${PKGID%% *}"
1107 rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
1108 echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
1109 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > "$BUILD_ROOT"/.preinstall_image/$PKG
1114 # revert use rpm to query pkgid if building rpm package
1115 if test "$PSUF" != "rpm" ; then
1116 PKGID=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" buildid)
1118 ep=$(rpm -qp --qf "%{EPOCH}" "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.$PSUF")
1119 if test "$ep" != "(none)"; then
1120 RPMIDFMT_EP="%{NAME}-%{EPOCH}:%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
1121 PKGID=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.$PSUF"`
1123 PKGID=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.$PSUF"`
1127 if test -f "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG ; then
1128 read OLDPKGID < "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG
1129 if test "$PKGID" != "$OLDPKGID" ; then
1130 echo "deleting unwanted ${OLDPKGID%% *}"
1133 if test "$VERIFY_BUILD_SYSTEM" != true || pkg_verify_installed ; then
1134 echo "keeping ${PKGID%% *}"
1135 echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
1136 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > "$BUILD_ROOT"/.preinstall_image/$PKG
1139 echo "deleting incomplete ${OLDPKGID%% *}"
1142 if test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then
1148 export ADDITIONAL_PARAMS=
1149 if test "$USE_FORCE" = true ; then
1150 export ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --force"
1152 # work around for cross-build installs, we must not overwrite the running rpm
1153 if test "$PKG" = rpm ; then
1154 for i in "$BUILD_ROOT"/.init_b_cache/preinstalls/rpm-x86-* ; do
1155 test -e "$i" && ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --justdb"
1159 if pkg_cumulate ; then
1160 echo "cumulate ${PKGID%% *}"
1164 # install the package
1165 echo "installing ${PKGID%% *}"
1166 if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -ef "$BUILD_ROOT/.init_b_cache/$PKG.$PSUF" ; then
1167 rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
1168 cp "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
1172 rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
1173 echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
1174 test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > "$BUILD_ROOT"/.preinstall_image/$PKG
1178 # do post-installation work
1181 # devices can vanish if devs got uninstalled
1182 test -c "$BUILD_ROOT"/dev/null || create_devs
1184 cd "$BUILD_ROOT" || cleanup_and_exit 1
1189 #init_buildsystem: make /etc/mtab a symlink
1190 #from patch:https://github.com/openSUSE/obs-build/commit/f0e7d37c811dbde49fcd5b9c8779063f4e87cb74
1191 ln -sf ../proc/self/mounts $BUILD_ROOT/etc/mtab
1194 # make sure, that our nis is not present in the chroot system
1196 test -e "$BUILD_ROOT"/etc/nsswitch.conf && {
1197 echo "removing nis flags from $BUILD_ROOT/etc/nsswitch.conf..."
1198 cat "$BUILD_ROOT"/etc/nsswitch.conf | sed -e"s:nis::g" > "$BUILD_ROOT"/etc/nsswitch.conf.tmp
1199 mv "$BUILD_ROOT"/etc/nsswitch.conf.tmp "$BUILD_ROOT"/etc/nsswitch.conf
1203 # create some default directories and files
1205 for DIR in /usr/share/doc/packages \
1206 /usr/X11R6/include/X11/pixmaps \
1207 /usr/X11R6/include/X11/bitmaps ; do
1208 mkdir -p "$BUILD_ROOT"/$DIR
1210 for FILE in /var/run/utmp /var/log/wtmp /etc/fstab ; do
1211 mkdir -p "$BUILD_ROOT"/${FILE%/*}
1212 touch "$BUILD_ROOT"/$FILE
1215 echo now finalizing build dir...
1216 if test -x "$BUILD_ROOT"/sbin/ldconfig ; then
1217 CHROOT_RETURN="`chroot "$BUILD_ROOT" /sbin/ldconfig 2>&1`"
1218 case "$CHROOT_RETURN" in
1220 chroot "$BUILD_ROOT" /sbin/ldconfig
1222 echo chroot "$BUILD_ROOT" /sbin/ldconfig
1224 echo "$CHROOT_RETURN"
1226 echo "Problem with ldconfig. It's better to reinit the build system..."
1233 if test -x "$BUILD_ROOT"/usr/sbin/Check && ! grep -q "/usr/sbin/Check is obsolete" "$BUILD_ROOT"/usr/sbin/Check ; then
1234 chroot "$BUILD_ROOT" /usr/sbin/Check
1237 mkdir -p "$BUILD_ROOT"/var/adm/packages
1238 touch "$BUILD_ROOT"/var/adm/packages
1240 if test -x "$BUILD_ROOT"/sbin/SuSEconfig ; then
1241 if grep norestarts "$BUILD_ROOT"/sbin/SuSEconfig > /dev/null ; then
1242 chroot "$BUILD_ROOT" /sbin/SuSEconfig --norestarts --force
1244 chroot "$BUILD_ROOT" /sbin/SuSEconfig --force
1248 if test -x "$BUILD_ROOT"/usr/X11R6/bin/switch2mesasoft ; then
1249 chroot "$BUILD_ROOT" /usr/X11R6/bin/switch2mesasoft
1252 for PROG in /usr/bin/TeX/texhash /usr/bin/texhash ; do
1253 test -x "$BUILD_ROOT"/$PROG && \
1254 chroot "$BUILD_ROOT" bash -c ". /etc/profile ; $PROG"
1257 if test -e "$BUILD_ROOT"/usr/share/zoneinfo/UTC ; then
1258 for PROG in /usr/sbin/zic /usr/bin/zic /bin/zic /sbin/zic ; do
1259 test -x "$BUILD_ROOT"/$PROG && chroot "$BUILD_ROOT" bash -c "$PROG -l \$(readlink -f /usr/share/zoneinfo/UTC)"
1263 test -e "$BUILD_ROOT"/.build/init_buildsystem.data || HOST=`hostname`
1264 test -e "$BUILD_ROOT"/etc/hosts || echo "127.0.0.1 localhost" > "$BUILD_ROOT"/etc/hosts
1265 if ! grep -F "127.0.0.1 $HOST" "$BUILD_ROOT"/etc/hosts > /dev/null ; then
1266 # this makes a reverse lookup on 127.0.0.1 return the host name,
1267 # which is bad, but 127.0.0.2 does not work on all unix systems
1268 echo "127.0.0.1 $HOST" > "$BUILD_ROOT"/etc/hosts.new
1269 test -f "$BUILD_ROOT"/etc/hosts && cat "$BUILD_ROOT"/etc/hosts >> "$BUILD_ROOT"/etc/hosts.new
1270 mv "$BUILD_ROOT"/etc/hosts.new "$BUILD_ROOT"/etc/hosts
1273 # XXX: still needed?
1274 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
1276 chroot "$BUILD_ROOT" rpm -q --whatprovides rpm >/dev/null 2>&1 # create provides index
1278 rm -f "$BUILD_ROOT"/.rpmmacros "$BUILD_ROOT"/root/.rpmmacros
1279 rm -rf "$BUILD_ROOT/.init_b_cache"
1280 rm -f $BUILD_IS_RUNNING
1285 # vim: set tabstop=8 softtabstop=4 shiftwidth=4 noexpandtab: