Fix bugs when username including backslash 56/173556/1
authorjingui.ren <jingui.ren@samsung.com>
Thu, 22 Mar 2018 08:18:06 +0000 (16:18 +0800)
committerjingui.ren <jingui.ren@samsung.com>
Thu, 22 Mar 2018 08:18:06 +0000 (16:18 +0800)
Change-Id: Ib489d11174f67acf04c6c622fc41c2243e596198

build
build-pkg-arch
build-pkg-deb
build-pkg-rpm
createdirdeps
init_buildsystem

diff --git a/build b/build
index 6a7599d..c02e12b 100755 (executable)
--- a/build
+++ b/build
@@ -369,15 +369,15 @@ usage () {
 cleanup_and_exit () {
     trap EXIT
     test -z "$1" && set 0
-       rm -f $BUILD_ROOT/.repo.config
-    rm -f $BUILD_ROOT/exit
+       rm -f "$BUILD_ROOT"/.repo.config
+    rm -f "$BUILD_ROOT"/exit
     if test "$1" -eq 1 -a -x /bin/df ; then
         echo
         echo "$HOST failed \"build $RECIPEFILE\" at `date --utc`."
         echo
         # okay, it failed, but maybe because disk space?
-       if df $BUILD_ROOT 2>/dev/null | grep -q "100%"; then
-            df $BUILD_ROOT 2>/dev/null
+       if df "$BUILD_ROOT" 2>/dev/null | grep -q "100%"; then
+            df "$BUILD_ROOT" 2>/dev/null
             echo
             echo "$HOST ran out of disk space. Please try again."
             echo
@@ -386,21 +386,21 @@ cleanup_and_exit () {
     fi
     if test -n "$RUNNING_IN_VM" ; then
        echo "$1" >  /.build/_exitcode
-       test -n "$browner" && chown "$browner" $BUILD_ROOT
+       test -n "$browner" && chown "$browner" "$BUILD_ROOT"
        vm_shutdown "$1"
     else
-       umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true
-       umount -n $BUILD_ROOT/proc 2>/dev/null || true
+       umount -n "$BUILD_ROOT"/proc/sys/fs/binfmt_misc 2> /dev/null || true
+       umount -n "$BUILD_ROOT"/proc 2>/dev/null || true
     while true
     do
-            umount -n $BUILD_ROOT/dev/pts 2>/dev/null
+            umount -n "$BUILD_ROOT"/dev/pts 2>/dev/null
             if test $? -ne 0; then
                     break
             fi
     done
-       umount -n $BUILD_ROOT/dev/shm 2>/dev/null || true
-       umount -n $BUILD_ROOT/sys 2>/dev/null || true
-       test -n "$VM_IMAGE" -a "$VM_IMAGE" != 1 && umount $BUILD_ROOT 2>/dev/null || true
+       umount -n "$BUILD_ROOT"/dev/shm 2>/dev/null || true
+       umount -n "$BUILD_ROOT"/sys 2>/dev/null || true
+       test -n "$VM_IMAGE" -a "$VM_IMAGE" != 1 && umount "$BUILD_ROOT" 2>/dev/null || true
        test -n "$VM_TYPE" && vm_cleanup
     fi
     exit $1
@@ -431,17 +431,17 @@ toshellscript() {
 
 setupccache() {
     if test -n "$CCACHE" ; then
-       if mkdir -p $BUILD_ROOT/var/lib/build/ccache/bin; then
-           for i in $(ls $BUILD_ROOT/usr/bin | grep -E '^(cc|gcc|[cg][+][+])([-]?[234][.]?[0-9])*$'); do
+       if mkdir -p "$BUILD_ROOT"/var/lib/build/ccache/bin; then
+           for i in $(ls "$BUILD_ROOT"/usr/bin | grep -E '^(cc|gcc|[cg][+][+])([-]?[234][.]?[0-9])*$'); do
 #                ln -sf /usr/bin/ccache $BUILD_ROOT/var/lib/build/ccache/bin/$i
-               rm -f $BUILD_ROOT/var/lib/build/ccache/bin/$i
-               test -e $BUILD_ROOT/usr/bin/$i || continue
-               echo '#! /bin/sh' > $BUILD_ROOT/var/lib/build/ccache/bin/$i
-               echo "test -e /usr/bin/$i || exit 1" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i
-               echo 'export PATH=/usr/lib/icecc/bin:/opt/icecream/bin:/usr/bin:$PATH' >> $BUILD_ROOT/var/lib/build/ccache/bin/$i
-               echo "ccache $i \"\$@\"" >> $BUILD_ROOT/var/lib/build/ccache/bin/$i
-               chmod 755 $BUILD_ROOT/var/lib/build/ccache/bin/$i
-               echo "Installed ccache wrapper as $BUILD_ROOT/var/lib/build/ccache/bin/$i"
+               rm -f "$BUILD_ROOT"/var/lib/build/ccache/bin/$i
+               test -e "$BUILD_ROOT"/usr/bin/$i || continue
+               echo '#! /bin/sh' > "$BUILD_ROOT"/var/lib/build/ccache/bin/$i
+               echo "test -e /usr/bin/$i || exit 1" >> "$BUILD_ROOT"/var/lib/build/ccache/bin/$i
+               echo 'export PATH=/usr/lib/icecc/bin:/opt/icecream/bin:/usr/bin:$PATH' >> "$BUILD_ROOT"/var/lib/build/ccache/bin/$i
+               echo "ccache $i \"\$@\"" >> "$BUILD_ROOT"/var/lib/build/ccache/bin/$i
+               chmod 755 "$BUILD_ROOT"/var/lib/build/ccache/bin/$i
+               echo "Installed ccache wrapper as '$BUILD_ROOT'/var/lib/build/ccache/bin/$i"
            done
        fi
        mkdir -p "$BUILD_ROOT/.ccache"
@@ -477,8 +477,8 @@ setupicecream() {
        echo 'export CCACHE_PATH=/usr/lib/icecc/bin:/opt/icecream/bin' > "$BUILD_ROOT"/etc/profile.d/build_icecream.sh
     fi
 
-    local icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT$icecreamdir/*.tar.{bz2,gz}`)
-    icecc_vers=${icecc_vers//$BUILD_ROOT/}
+    local icecc_vers=(`shopt -s nullglob; echo "$BUILD_ROOT"$icecreamdir/*.tar.{bz2,gz}`)
+    icecc_vers=${icecc_vers//"$BUILD_ROOT"/}
 
     # XXX use changelog like autobuild does instead?
     # only run create-env if compiler or glibc changed
@@ -502,9 +502,9 @@ setupicecream() {
            return 1
        fi
         echo "creating new env in '$icecreamdir'"
-       chroot $BUILD_ROOT bash -c "cd $icecreamdir; $createenv" || cleanup_and_exit 1
-       icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/$icecreamdir/*.tar.{bz2,gz}`)
-       icecc_vers=${icecc_vers//$BUILD_ROOT/}
+       chroot "$BUILD_ROOT" bash -c "cd $icecreamdir; $createenv" || cleanup_and_exit 1
+       icecc_vers=(`shopt -s nullglob; echo "$BUILD_ROOT"/$icecreamdir/*.tar.{bz2,gz}`)
+       icecc_vers=${icecc_vers//"$BUILD_ROOT"/}
        echo "created icecream environment $icecc_vers"
     else
        echo "reusing existing icecream environment $icecc_vers"
@@ -549,16 +549,16 @@ create_baselibs() {
     if test "$BUILDTYPE" == dsc ; then
        pkgs=($DEBS)
     else # spec and kiwi
-       if test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs.conf ; then
+       if test -e "$BUILD_ROOT"$TOPDIR/SOURCES/baselibs.conf ; then
            BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs.conf"
        fi
-       if test -e $BUILD_ROOT/usr/lib/build/baselibs_global.conf; then
+       if test -e "$BUILD_ROOT"/usr/lib/build/baselibs_global.conf; then
            BASELIBS_GLOBAL="-c /usr/lib/build/baselibs_global.conf"
        fi
        pkgs=($RPMS)
     fi
 
-    mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
+    mount -n -tproc none "$BUILD_ROOT"/proc 2> /dev/null
     # don't use -R as extracted sources, build root etc might be below $TOPDIR
     chown "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT$TOPDIR"/* "$BUILD_ROOT$TOPDIR"/RPMS/* || true
 
@@ -567,8 +567,8 @@ create_baselibs() {
     # $BUILD_DIR is set to /.build when using a vm. So we need to
     # hardcode /usr/lib/build instead of $BUILD_DIR to prefer
     # mkbaselibs from the distro.
-    if test -f $BUILD_ROOT$mkbaselibs; then
-       if test -z "$BASELIBS_CFG" -a -e $BUILD_ROOT/usr/lib/build/baselibs.conf ; then
+    if test -f "$BUILD_ROOT"$mkbaselibs; then
+       if test -z "$BASELIBS_CFG" -a -e "$BUILD_ROOT"/usr/lib/build/baselibs.conf ; then
            BASELIBS_CFG="-c /usr/lib/build/baselibs.conf"
        fi
     else
@@ -581,27 +581,28 @@ create_baselibs() {
        mkbaselibs="/.mkbaselibs/mkbaselibs"
        rm -rf "$BUILD_ROOT/.mkbaselibs"
        mkdir -p "$BUILD_ROOT/.mkbaselibs"
-       cp -f $BUILD_DIR/mkbaselibs $BUILD_ROOT/.mkbaselibs/
+       cp -f $BUILD_DIR/mkbaselibs "$BUILD_ROOT"/.mkbaselibs/
        if test "$BUILDTYPE" == "dsc" ; then
-           cp -f $BUILD_DIR/baselibs_global-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf
-           cp -f $BUILD_ROOT$TOPDIR/SOURCES/baselibs-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs-deb.conf
+           cp -f $BUILD_DIR/baselibs_global-deb.conf "$BUILD_ROOT"/.mkbaselibs/baselibs_g.conf
+           cp -f "$BUILD_ROOT"$TOPDIR/SOURCES/baselibs-deb.conf "$BUILD_ROOT"/.mkbaselibs/baselibs-deb.conf
            BASELIBS_CFG="-c /.mkbaselibs/baselibs-deb.conf"
        else
-           cp -f $BUILD_DIR/baselibs_global.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf
+           cp -f $BUILD_DIR/baselibs_global.conf "$BUILD_ROOT"/.mkbaselibs/baselibs_g.conf
            if test -z "$BASELIBS_CFG" -a -e $BUILD_DIR/baselibs.conf; then
-               cp -f $BUILD_DIR/baselibs.conf $BUILD_ROOT/.mkbaselibs/baselibs.conf
+               cp -f $BUILD_DIR/baselibs.conf "$BUILD_ROOT"/.mkbaselibs/baselibs.conf
                BASELIBS_CFG="-c /.mkbaselibs/baselibs.conf"
            fi
        fi
-       if test -e $BUILD_ROOT/.mkbaselibs/baselibs_g.conf; then
+       if test -e "$BUILD_ROOT"/.mkbaselibs/baselibs_g.conf; then
            BASELIBS_GLOBAL="-c /.mkbaselibs/baselibs_g.conf"
        fi
     fi
     echo "... creating baselibs$whichone"
+    pkgs_origin=(`echo ${pkgs[*]} | sed 's/\"//g'`)
     while read line
     do
-       chroot $BUILD_ROOT su -c "$mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $line" - $BUILD_USER || cleanup_and_exit 1
-    done < <(IFS=$'\n'; echo "${pkgs[*]#$BUILD_ROOT}" | xargs -n 1024)
+       chroot "$BUILD_ROOT" su -c "$mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $line" - $BUILD_USER || cleanup_and_exit 1
+    done < <(IFS=$'\n'; echo "${pkgs_origin[*]#$BUILD_ROOT}" | xargs -n 1024)
     rm -rf "$BUILD_ROOT/.mkbaselibs"
 }
 
@@ -639,13 +640,13 @@ mkdir_build_root() {
     test "$BUILD_ROOT" != / && BUILD_ROOT="${BUILD_ROOT%/}"
     if test -d "$BUILD_ROOT" ; then
        # check if it is owned by root
-       if test -z "$RUNNING_IN_VM" -a \! -O "$BUILD_ROOT" -a "`stat -c %u $BUILD_ROOT`" -ne 0 ; then
+       if test -z "$RUNNING_IN_VM" -a \! -O "$BUILD_ROOT" -a "`stat -c %u "$BUILD_ROOT"`" -ne 0 ; then
            echo "BUILD_ROOT=$BUILD_ROOT must be owned by root. Exit..."
            cleanup_and_exit 1
        fi
     else
        test "$BUILD_ROOT" != "${BUILD_ROOT%/*}" && mkdir -p "${BUILD_ROOT%/*}"
-       if ! mkdir $BUILD_ROOT ; then
+       if ! mkdir "$BUILD_ROOT" ; then
            echo "can not create BUILD_ROOT=$BUILD_ROOT. Exit..."
            cleanup_and_exit 1
        fi
@@ -668,7 +669,7 @@ copy_overlay() {
     if test -d "$OVERLAY"; then
        pushd $OVERLAY
        echo "Copying overlay to BUILD_ROOT"
-       tar -cpf - . | (cd $BUILD_ROOT ; tar -xvf -)
+       tar -cpf - . | (cd "$BUILD_ROOT" ; tar -xvf -)
        popd
     else
        echo "OVERLAY ($OVERLAY) is no directory - skipping"
@@ -679,11 +680,11 @@ run_rsync() {
     if test -n "$RSYNCDEST" ; then
        if test -d "$RSYNCSRC" ; then
            if ! test -d "$BUILD_ROOT/$RSYNCDEST" ; then
-               echo "ATTENTION! Creating missing target directory ($BUILD_ROOT/$RSYNCDEST)."
-               mkdir -p $BUILD_ROOT/$RSYNCDEST
+               echo "ATTENTION! Creating missing target directory ("$BUILD_ROOT"/$RSYNCDEST)."
+               mkdir -p "$BUILD_ROOT"/$RSYNCDEST
            fi
            echo "Running rsync ..."
-           rsync -av $RSYNCSRC/* $BUILD_ROOT/$RSYNCDEST/
+           rsync -av $RSYNCSRC/* "$BUILD_ROOT"/$RSYNCDEST/
            chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT/$RSYNCDEST"
            RSYNCDONE=true
            echo "... done"
@@ -699,18 +700,18 @@ hide_passwords()
 {
     local i j
     r=()
-    rm -f $BUILD_ROOT/.repo.config
+    rm -f "$BUILD_ROOT"/.repo.config
     for i in "${repos[@]}"; do
         if [ "$i" == "--repo" -o "$i" == "--repository" ]; then
             r=("${r[@]}" "$i")
         else
-            echo $i |grep -E "^http[s]?:\/\/[^\/]*\/?" >/dev/null && echo $i >> $BUILD_ROOT/.repo.config
+            echo $i |grep -E "^http[s]?:\/\/[^\/]*\/?" >/dev/null && echo $i >> "$BUILD_ROOT"/.repo.config
             j=$(echo $i | sed -e "s#://[^@]*@#://#")
             r=("${r[@]}" "$j")
         fi
     done
     repos=("${r[@]}")
-    echo ${repos[@]}
+#    echo ${repos[@]}
 }
 
 #### main ####
@@ -996,7 +997,7 @@ if test -n "$KILL" ; then
     if test -n "$VM_TYPE" ; then
         vm_kill
     else
-       if ! $BUILD_DIR/killchroot -s 9 $BUILD_ROOT ; then
+       if ! $BUILD_DIR/killchroot -s 9 "$BUILD_ROOT" ; then
            echo "could not kill build in $BUILD_ROOT"
            cleanup_and_exit 1
        fi
@@ -1051,14 +1052,14 @@ if test "$BUILD_ROOT" = / ; then
     browner="$(stat -c %u /)"
 fi
 
-rm -f $BUILD_ROOT/exit
+rm -f "$BUILD_ROOT"/exit
 
 if test -w /root ; then
-    mkdir -p $BUILD_ROOT/proc
-    mkdir -p $BUILD_ROOT/sys
-    mkdir -p $BUILD_ROOT/dev/pts
-    mount -n -tproc none $BUILD_ROOT/proc || true
-    mount -n -tdevpts -omode=0620,gid=5 none $BUILD_ROOT/dev/pts
+    mkdir -p "$BUILD_ROOT"/proc
+    mkdir -p "$BUILD_ROOT"/sys
+    mkdir -p "$BUILD_ROOT"/dev/pts
+    mount -n -tproc none "$BUILD_ROOT"/proc || true
+    mount -n -tdevpts -omode=0620,gid=5 none "$BUILD_ROOT"/dev/pts
 fi
 
 if test -z "$VM_IMAGE" -a -z "$LOGFILE" ; then
@@ -1155,14 +1156,14 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
 
     # we need to do this before the vm is started
     if test -n "$CHANGELOG" -a -z "$RUNNING_IN_VM" ; then
-       rm -f $BUILD_ROOT/.build-changelog
+       rm -f "$BUILD_ROOT"/.build-changelog
        case $RECIPEFILE in
            *.dsc) CFFORMAT=debian ;;
            *) CFFORMAT=rpm ;;
        esac
        echo "running changelog2spec --target $CFFORMAT --file $MYSRCDIR/$RECIPEFILE"
-       if ! $BUILD_DIR/changelog2spec --target $CFFORMAT --file "$MYSRCDIR/$RECIPEFILE" > $BUILD_ROOT/.build-changelog ; then
-           rm -f $BUILD_ROOT/.build-changelog
+       if ! $BUILD_DIR/changelog2spec --target $CFFORMAT --file "$MYSRCDIR/$RECIPEFILE" > "$BUILD_ROOT"/.build-changelog ; then
+           rm -f "$BUILD_ROOT"/.build-changelog
        fi
     fi
 
@@ -1177,9 +1178,9 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
        # create legacy .buildenv file
        #
        test -z "$INCARNATION" && INCARNATION=0
-       echo "BUILD_INCARNATION=$INCARNATION" > $BUILD_ROOT/.buildenv
+       echo "BUILD_INCARNATION=$INCARNATION" > "$BUILD_ROOT"/.buildenv
        CREATE_BUILD_BINARIES=
-       test "$BUILDTYPE" = preinstallimage && mkdir -p $BUILD_ROOT/.preinstall_image
+       test "$BUILDTYPE" = preinstallimage && mkdir -p "$BUILD_ROOT"/.preinstall_image
        egrep '^#[       ]*needsbinariesforbuild[       ]*$' >/dev/null <$MYSRCDIR/$RECIPEFILE && CREATE_BUILD_BINARIES=--create-build-binaries
        test "$BUILDTYPE" = mock && CREATE_BUILD_BINARIES=--create-build-binaries
        test "$BUILDTYPE" = debootstrap && CREATE_BUILD_BINARIES=--create-build-binaries
@@ -1193,16 +1194,16 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
         TIME_INSTALL=$(( `date +%s` - $start_time ))
         unset start_time
        # arbitrary limit of 10MB
-       if test $((`stat -f -c "%a*%S/1024/1024" $BUILD_ROOT`)) -lt 10; then
+       if test $((`stat -f -c "%a*%S/1024/1024" "$BUILD_ROOT"`)) -lt 10; then
             # ensure that old stat is not failing (RHEL4)
-            if df $BUILD_ROOT 2>/dev/null | grep -q "100%"; then
-               df -h $BUILD_ROOT
+            if df "$BUILD_ROOT" 2>/dev/null | grep -q "100%"; then
+               df -h "$BUILD_ROOT"
                echo "build does not work on a completely full filesystem"
                cleanup_and_exit 1
            fi
        fi
-       mount -n -tproc none $BUILD_ROOT/proc || true
-       mount -n -tdevpts -omode=0620,gid=5 none $BUILD_ROOT/dev/pts
+       mount -n -tproc none "$BUILD_ROOT"/proc || true
+       mount -n -tdevpts -omode=0620,gid=5 none "$BUILD_ROOT"/dev/pts
 
        copy_oldpackages
     fi
@@ -1214,25 +1215,25 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
     fi
 
     if test -z "$BUILD_DIST" -a -e "$BUILD_ROOT/.guessed_dist" ; then
-       read BUILD_DIST < $BUILD_ROOT/.guessed_dist
+       read BUILD_DIST < "$BUILD_ROOT"/.guessed_dist
     fi
 
     #
     # install dummy sign program if needed
     #
-    test -f $BUILD_ROOT/usr/bin/sign_installed && mv $BUILD_ROOT/usr/bin/sign_installed $BUILD_ROOT/usr/bin/sign
+    test -f "$BUILD_ROOT"/usr/bin/sign_installed && mv "$BUILD_ROOT"/usr/bin/sign_installed "$BUILD_ROOT"/usr/bin/sign
     if test -n "$SIGNDUMMY" ; then
-       test -f $BUILD_ROOT/usr/bin/sign && mv $BUILD_ROOT/usr/bin/sign $BUILD_ROOT/usr/bin/sign_installed
-       cp $BUILD_DIR/signdummy $BUILD_ROOT/usr/bin/sign
-       chmod 755 $BUILD_ROOT/usr/bin/sign
+       test -f "$BUILD_ROOT"/usr/bin/sign && mv "$BUILD_ROOT"/usr/bin/sign "$BUILD_ROOT"/usr/bin/sign_installed
+       cp "$BUILD_DIR"/signdummy "$BUILD_ROOT"/usr/bin/sign
+       chmod 755 "$BUILD_ROOT"/usr/bin/sign
     fi
 
     #
     # check if we want to build with the abuild user
     #
     BUILD_USER=abuild
-    if test -x $BUILD_ROOT/bin/rpm ; then
-       SUSE_VERSION=`chroot $BUILD_ROOT /bin/rpm --eval '%{?suse_version}' 2>/dev/null`
+    if test -x "$BUILD_ROOT"/bin/rpm ; then
+       SUSE_VERSION=`chroot "$BUILD_ROOT" /bin/rpm --eval '%{?suse_version}' 2>/dev/null`
        test -n "$SUSE_VERSION" -a "${SUSE_VERSION:-0}" -le 1020 && BUILD_USER=root
     fi
     if test "$BUILD_USER" = abuild ; then
@@ -1250,52 +1251,52 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
 
     # fixup passwd/group
     if test $BUILD_USER = abuild ; then
-       if ! egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then
-           echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_ROOT/etc/passwd
-           echo 'abuild:*:::::::' >>$BUILD_ROOT/etc/shadow # This is needed on Mandriva 2009
-           echo 'abuild:*::' >>$BUILD_ROOT/etc/gshadow # This is needed on Ubuntu
-           echo "abuild:x:${ABUILD_GID}:" >>$BUILD_ROOT/etc/group
-           mkdir -p $BUILD_ROOT/home/abuild
-           chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/home/abuild
+       if ! egrep '^abuild:' >/dev/null <"$BUILD_ROOT"/etc/passwd ; then
+           echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>"$BUILD_ROOT"/etc/passwd
+           echo 'abuild:*:::::::' >>"$BUILD_ROOT"/etc/shadow # This is needed on Mandriva 2009
+           echo 'abuild:*::' >>"$BUILD_ROOT"/etc/gshadow # This is needed on Ubuntu
+           echo "abuild:x:${ABUILD_GID}:" >>"$BUILD_ROOT"/etc/group
+           mkdir -p "$BUILD_ROOT"/home/abuild
+           chown "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT"/home/abuild
        else
-           if ! egrep "^abuild:x?:${ABUILD_UID}:${ABUILD_GID}" >/dev/null <$BUILD_ROOT/etc/passwd ; then
-                   sed -i '/^abuild:/d' $BUILD_ROOT/etc/passwd
-                   sed -i '/^abuild:/d' $BUILD_ROOT/etc/group
-                   echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_ROOT/etc/passwd
-                   echo "abuild:x:${ABUILD_GID}:" >>$BUILD_ROOT/etc/group
-                   chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/home/abuild -R
+           if ! egrep "^abuild:x?:${ABUILD_UID}:${ABUILD_GID}" >/dev/null <"$BUILD_ROOT"/etc/passwd ; then
+                   sed -i '/^abuild:/d' "$BUILD_ROOT"/etc/passwd
+                   sed -i '/^abuild:/d' "$BUILD_ROOT"/etc/group
+                   echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>"$BUILD_ROOT"/etc/passwd
+                   echo "abuild:x:${ABUILD_GID}:" >>"$BUILD_ROOT"/etc/group
+                   chown "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT"/home/abuild -R
            fi
        fi
-       if test -f $BUILD_ROOT/etc/shadow ; then
-           sed -i -e "s@^root::@root:*:@" $BUILD_ROOT/etc/shadow
+       if test -f "$BUILD_ROOT"/etc/shadow ; then
+           sed -i -e "s@^root::@root:*:@" "$BUILD_ROOT"/etc/shadow
        fi
-       if test -f $BUILD_ROOT/etc/gshadow ; then
-           sed -i -e "s@^root::@root:*:@" $BUILD_ROOT/etc/gshadow
+       if test -f "$BUILD_ROOT"/etc/gshadow ; then
+           sed -i -e "s@^root::@root:*:@" "$BUILD_ROOT"/etc/gshadow
        fi
        BUILD_USER_ABUILD_USED=true
     else
        # building as root
        ABUILD_UID=0
        ABUILD_GID=0
-       if egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then
+       if egrep '^abuild:' >/dev/null <"$BUILD_ROOT"/etc/passwd ; then
            rm -rf "$BUILD_ROOT/home/abuild"
-           sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/passwd
-           sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/group
-           if test -f $BUILD_ROOT/etc/shadow ; then
-               sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/shadow
+           sed -i -e '/^abuild:/d' "$BUILD_ROOT"/etc/passwd
+           sed -i -e '/^abuild:/d' "$BUILD_ROOT"/etc/group
+           if test -f "$BUILD_ROOT"/etc/shadow ; then
+               sed -i -e '/^abuild:/d' "$BUILD_ROOT"/etc/shadow
            fi
-           if test -f $BUILD_ROOT/etc/gshadow ; then
-               sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/gshadow
+           if test -f "$BUILD_ROOT"/etc/gshadow ; then
+               sed -i -e '/^abuild:/d' "$BUILD_ROOT"/etc/gshadow
            fi
        fi
     fi
 
-    mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
-    mount -n -tdevpts -omode=0620,gid=5 none $BUILD_ROOT/dev/pts 2> /dev/null
+    mount -n -tproc none "$BUILD_ROOT"/proc 2> /dev/null
+    mount -n -tdevpts -omode=0620,gid=5 none "$BUILD_ROOT"/dev/pts 2> /dev/null
     # needed for POSIX semaphores
-    test -d $BUILD_ROOT/dev/shm || rm -f $BUILD_ROOT/dev/shm
-    mkdir -p $BUILD_ROOT/dev/shm
-    mount -n -ttmpfs none $BUILD_ROOT/dev/shm 2> /dev/null
+    test -d "$BUILD_ROOT"/dev/shm || rm -f "$BUILD_ROOT"/dev/shm
+    mkdir -p "$BUILD_ROOT"/dev/shm
+    mount -n -ttmpfs none "$BUILD_ROOT"/dev/shm 2> /dev/null
 
     if test -n "$RUNNING_IN_VM" ; then
         if test -x /sbin/ip ; then
@@ -1356,16 +1357,16 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
 
     # fill build directories with sources. Also sets TOPDIR
     recipe_setup
-    
+
     # strip prefix from autogenerated files of source services.
-    for i in $BUILD_ROOT$TOPDIR/SOURCES/_service\:* ; do
+    for i in "$BUILD_ROOT"$TOPDIR/SOURCES/_service\:* ; do
         mv "$i" "${i%/*}/${i##*:}"
     done
     RECIPEFILE="${RECIPEFILE##*:}"
 
     # create .build.packages link
-    rm -f $BUILD_ROOT/.build.packages
-    ln -s ${TOPDIR#/} $BUILD_ROOT/.build.packages
+    rm -f "$BUILD_ROOT"/.build.packages
+    ln -s ${TOPDIR#/} "$BUILD_ROOT"/.build.packages
 
     # nasty hack to prevent rpath on known paths
     # FIXME: do this only for suse
@@ -1373,21 +1374,21 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
        echo "export SUSE_IGNORED_RPATHS=/etc/ld.so.conf" > "$BUILD_ROOT/etc/profile.d/buildsystem.sh"
     fi
 
-    cd $BUILD_ROOT$TOPDIR/SOURCES || cleanup_and_exit 1
+    cd "$BUILD_ROOT"$TOPDIR/SOURCES || cleanup_and_exit 1
     for i in *.obscpio ; do
        test -e "$i" || continue
        echo "Unpacking $i ..."
-       echo "#!/bin/sh -e" > $BUILD_ROOT/.unpack.command
-       shellquote cd "$TOPDIR/SOURCES" >> $BUILD_ROOT/.unpack.command
-       echo >> $BUILD_ROOT/.unpack.command
-       echo -n 'cpio --extract --owner="'$BUILD_USER'" --unconditional --preserve-modification-time --make-directories <' >> $BUILD_ROOT/.unpack.command
-       shellquote "$i" >> $BUILD_ROOT/.unpack.command
-       echo >> $BUILD_ROOT/.unpack.command
-       shellquote rm -f "$i" >> $BUILD_ROOT/.unpack.command
-       echo >> $BUILD_ROOT/.unpack.command
-       chmod 0755 $BUILD_ROOT/.unpack.command
-       chroot $BUILD_ROOT su -c /.unpack.command - $BUILD_USER
-       rm -f $BUILD_ROOT/.unpack.command
+       echo "#!/bin/sh -e" > "$BUILD_ROOT"/.unpack.command
+       shellquote cd "$TOPDIR/SOURCES" >> "$BUILD_ROOT"/.unpack.command
+       echo >> "$BUILD_ROOT"/.unpack.command
+       echo -n 'cpio --extract --owner="'$BUILD_USER'" --unconditional --preserve-modification-time --make-directories <' >> "$BUILD_ROOT"/.unpack.command
+       shellquote "$i" >> "$BUILD_ROOT"/.unpack.command
+       echo >> "$BUILD_ROOT"/.unpack.command
+       shellquote rm -f "$i" >> "$BUILD_ROOT"/.unpack.command
+       echo >> "$BUILD_ROOT"/.unpack.command
+       chmod 0755 "$BUILD_ROOT"/.unpack.command
+       chroot "$BUILD_ROOT" su -c /.unpack.command - $BUILD_USER
+       rm -f "$BUILD_ROOT"/.unpack.command
     done
 
     if  test -e _service; then
@@ -1396,7 +1397,7 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
     fi
 
     # get rid of old src dir, it is no longer needed and just wastes space
-    test "$MYSRCDIR" = $BUILD_ROOT/.build-srcdir && rm -rf "$MYSRCDIR"
+    test "$MYSRCDIR" = "$BUILD_ROOT"/.build-srcdir && rm -rf "$MYSRCDIR"
 
     # patch recipes
     recipe_prepare
@@ -1438,31 +1439,29 @@ if test -n "$RUNNING_IN_VM" -a -n "$DO_STATISTICS" ; then
     touch /.build/_statistics.exit
 fi
 
-RPMS=`find $BUILD_ROOT/$TOPDIR/RPMS -type f -name "*.rpm" 2>/dev/null || true`
-DEBS=`find $BUILD_ROOT/$TOPDIR/DEBS -type f -name "*.deb" 2>/dev/null || true`
-
+RPMS=`find "$BUILD_ROOT"/$TOPDIR/RPMS -type f -name "*.rpm" 2>/dev/null | sed 's/.*/\"&\"/g' || true`
+DEBS=`find "$BUILD_ROOT"/$TOPDIR/DEBS -type f -name "*.deb" 2>/dev/null | sed 's/.*/\"&\"/g' || true`
 if test -n "$RPMS" -a -n "$BUILD_USER_ABUILD_USED" ; then
     recipe_check_file_owners
 fi
-
 if test -n "$RPMS" -a -d "$BUILD_ROOT/usr/lib/build/checks" ; then
     export DO_RPM_REMOVE=true
     # find package name
     export PNAME=
-    for SRPM in $BUILD_ROOT/$TOPDIR/SRPMS/*src.rpm ; do
+    for SRPM in "$BUILD_ROOT"/$TOPDIR/SRPMS/*src.rpm ; do
        test -f "$SRPM" && PNAME=`rpm --nodigest --nosignature -qp --qf "%{NAME}" $SRPM`
     done
-    mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null
-    for CHECKSCRIPT in $BUILD_ROOT/usr/lib/build/checks/* ; do
+    mount -n -tproc none "$BUILD_ROOT"/proc 2> /dev/null
+    for CHECKSCRIPT in "$BUILD_ROOT"/usr/lib/build/checks/* ; do
        echo "... running ${CHECKSCRIPT##*/}"
        $CHECKSCRIPT || cleanup_and_exit 1
     done
-    umount -n $BUILD_ROOT/proc 2>/dev/null || true
+    umount -n "$BUILD_ROOT"/proc 2>/dev/null || true
 fi
 
 # checkscripts may have deleted some binaries
-RPMS=`find $BUILD_ROOT/$TOPDIR/RPMS -type f -name "*.rpm" 2>/dev/null || true`
-DEBS=`find $BUILD_ROOT/$TOPDIR/DEBS -type f -name "*.deb" 2>/dev/null || true`
+RPMS=`find "$BUILD_ROOT"/$TOPDIR/RPMS -type f -name "*.rpm" 2>/dev/null | sed 's/.*/\"&\"/g' || true`
+DEBS=`find "$BUILD_ROOT"/$TOPDIR/DEBS -type f -name "*.deb" 2>/dev/null | sed 's/.*/\"&\"/g' || true`
 
 if test -n "$RPMS" -a "$DO_CHECKS" != false ; then
     recipe_run_rpmlint
@@ -1479,15 +1478,13 @@ exitcode=0
 if test -n "$RPMS" -a -d "$BUILD_ROOT/.build.oldpackages" ; then
     recipe_compare_oldpackages
     # no need to create deltas if the build is the same
-    if test ! -e $BUILD_ROOT/.build/.same_result_marker ; then
-       recipe_create_deltarpms
+    if test ! -e "$BUILD_ROOT"/.build/.same_result_marker ; then
+    recipe_create_deltarpms
     fi
 fi
-
 if test -n "$RUNNING_IN_VM" ; then
     vm_wrapup_build $(recipe_resultdirs) OTHER
 fi
-
 echo
 echo "$HOST finished \"build $RECIPEFILE\" at `date --utc`."
 echo
index 2dc321d..be5dac5 100644 (file)
 ################################################################
 
 pkg_initdb_arch() {
-    mkdir -p $BUILD_ROOT/var/lib/pacman/sync
-    touch $BUILD_ROOT/var/lib/pacman/sync/core.db
-    touch $BUILD_ROOT/var/lib/pacman/sync/extra.db
-    touch $BUILD_ROOT/var/lib/pacman/sync/community.db
+    mkdir -p "$BUILD_ROOT"/var/lib/pacman/sync
+    touch "$BUILD_ROOT"/var/lib/pacman/sync/core.db
+    touch "$BUILD_ROOT"/var/lib/pacman/sync/extra.db
+    touch "$BUILD_ROOT"/var/lib/pacman/sync/community.db
 }
 
 pkg_prepare_arch() {
@@ -33,7 +33,7 @@ pkg_prepare_arch() {
 }
 
 pkg_erase_arch() {
-    ( cd $BUILD_ROOT && chroot $BUILD_ROOT pacman -R -n -d -d --noconfirm $PKG 2>&1 || touch $BUILD_ROOT/exit ) | \
+    ( cd "$BUILD_ROOT" && chroot "$BUILD_ROOT" pacman -R -n -d -d --noconfirm $PKG 2>&1 || touch "$BUILD_ROOT"/exit ) | \
        perl -ne '$|=1;/^(Total Removed Size: |Packages \(\d+\):|:: Do you want to remove these packages|deleting |removing |    )/||/^$/||print'
 }
 
@@ -48,9 +48,9 @@ pkg_cumulate_arch() {
 pkg_install_arch() {
     # Pacman can't handle chroot
     # https://bbs.archlinux.org/viewtopic.php?id=129661
-    (cd $BUILD_ROOT/etc && sed -i "s/^CheckSpace/#CheckSpace/g" pacman.conf)
+    (cd "$BUILD_ROOT"/etc && sed -i "s/^CheckSpace/#CheckSpace/g" pacman.conf)
     # -d -d disables deps checking
-    ( cd $BUILD_ROOT && chroot $BUILD_ROOT pacman -U --force -d -d --noconfirm .init_b_cache/$PKG.$PSUF 2>&1 || touch $BUILD_ROOT/exit ) | \
+    ( cd "$BUILD_ROOT" && chroot "$BUILD_ROOT" pacman -U --force -d -d --noconfirm .init_b_cache/$PKG.$PSUF 2>&1 || touch "$BUILD_ROOT"/exit ) | \
        perl -ne '$|=1;/^(warning: could not get filesystem information for |loading packages|looking for inter-conflicts|looking for conflicting packages|Targets |Total Installed Size: |Net Upgrade Size: |Proceed with installation|checking package integrity|loading package files|checking for file conflicts|checking keyring|Packages \(\d+\)|:: Proceed with installation|:: Processing package changes|checking available disk space|installing |upgrading |warning:.*is up to date -- reinstalling|Optional dependencies for|    )/||/^$/||print'
 }
 
@@ -68,9 +68,9 @@ pkg_preinstall_arch() {
 }
 
 pkg_runscripts_arch() {
-    if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
+    if test -e "'$BUILD_ROOT'/.init_b_cache/scripts/$PKG.post" ; then
        echo "running $PKG postinstall script"
-       ( cd $BUILD_ROOT && chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" < /dev/null )
+       ( cd "$BUILD_ROOT" && chroot "$BUILD_ROOT" ".init_b_cache/scripts/$PKG.post" < /dev/null )
        rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
     fi
 }
index 2465204..2ee0f95 100644 (file)
@@ -41,24 +41,24 @@ deb_chroot ()
 }
 
 deb_setup() {
-    mkdir -p $BUILD_ROOT/var/lib/dpkg
-    mkdir -p $BUILD_ROOT/var/log
-    mkdir -p $BUILD_ROOT/etc/default
-    :>> $BUILD_ROOT/var/lib/dpkg/status
-    :>> $BUILD_ROOT/var/lib/dpkg/available
-    :>> $BUILD_ROOT/var/log/dpkg.log
-    :>> $BUILD_ROOT/etc/ld.so.conf
-    :>> $BUILD_ROOT/etc/default/rcS
+    mkdir -p $"BUILD_ROOT"/var/lib/dpkg
+    mkdir -p $"BUILD_ROOT"/var/log
+    mkdir -p $"BUILD_ROOT"/etc/default
+    :>> $"BUILD_ROOT"/var/lib/dpkg/status
+    :>> $"BUILD_ROOT"/var/lib/dpkg/available
+    :>> $"BUILD_ROOT"/var/log/dpkg.log
+    :>> $"BUILD_ROOT"/etc/ld.so.conf
+    :>> $"BUILD_ROOT"/etc/default/rcS
 }
 
 pkg_initdb_deb() {
     deb_setup
     # force dpkg into database to make epoch test work
-    if ! test "$BUILD_ROOT/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_ROOT/.init_b_cache/dpkg.deb" ; then
-       rm -f $BUILD_ROOT/.init_b_cache/dpkg.deb
-       cp $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb $BUILD_ROOT/.init_b_cache/dpkg.deb || cleanup_and_exit 1
+    if ! test "'$BUILD_ROOT'/.init_b_cache/rpms/dpkg.deb" -ef "'$BUILD_ROOT'/.init_b_cache/dpkg.deb" ; then
+       rm -f $"BUILD_ROOT"/.init_b_cache/dpkg.deb
+       cp $"BUILD_ROOT"/.init_b_cache/rpms/dpkg.deb $"BUILD_ROOT"/.init_b_cache/dpkg.deb || cleanup_and_exit 1
     fi
-    deb_chroot $BUILD_ROOT dpkg --install --force-depends .init_b_cache/dpkg.deb >/dev/null 2>&1
+    deb_chroot $"BUILD_ROOT" dpkg --install --force-depends .init_b_cache/dpkg.deb >/dev/null 2>&1
 }
 
 pkg_prepare_deb() {
@@ -66,7 +66,7 @@ pkg_prepare_deb() {
 }
 
 pkg_install_deb() {
-    ( deb_chroot $BUILD_ROOT dpkg --install --force-depends .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \
+    ( deb_chroot $"BUILD_ROOT" dpkg --install --force-depends .init_b_cache/$PKG.deb 2>&1 || touch $"BUILD_ROOT"/exit ) | \
        perl -ne '$|=1;/^(Configuration file|Installing new config file|Selecting previously deselected|Selecting previously unselected|\(Reading database|Unpacking |Setting up|Creating config file|Preparing to replace dpkg|Preparing to unpack )/||/^$/||print'
     # ugly workaround for upstart system. some packages (procps) try
     # to start a service in their configure phase. As we don't have
@@ -83,12 +83,12 @@ pkg_install_deb() {
 }
 
 pkg_erase_deb() {
-    deb_chroot $BUILD_ROOT dpkg --purge --force-depends $PKG 2>&1 | {
+    deb_chroot "$BUILD_ROOT" dpkg --purge --force-depends $PKG 2>&1 | {
       local retry
       while read line; do
           case "$line" in
               subprocess\ installed\ *script\ returned\ error\ exit\ status*)
-                 chroot $BUILD_ROOT rm -f /var/lib/dpkg/info/$PKG.{pre,post}rm
+                 chroot "$BUILD_ROOT" rm -f /var/lib/dpkg/info/$PKG.{pre,post}rm
                  retry=1
               ;;
               *) echo "$line" ;;
@@ -96,7 +96,7 @@ pkg_erase_deb() {
       done
       if test -n "$retry"; then
           echo "re-try deleting $PKG without post/pre remove scripts"
-          deb_chroot $BUILD_ROOT dpkg --purge --force-depends $PKG 2>&1 || touch $BUILD_ROOT/exit
+          deb_chroot "$BUILD_ROOT" dpkg --purge --force-depends $PKG 2>&1 || touch "$BUILD_ROOT"/exit
       fi
     } | perl -ne '$|=1;/^(\(Reading database|Removing |Purging configuration files for )/||/^$/||print'
 }
@@ -114,9 +114,9 @@ pkg_finalize_deb() {
     # configure all packages after complete installation, not for each package like rpm does
     # We need to run this twice, because of cyclic dependencies as it does not succeed on most
     # debian based distros in the first attempt.
-    if ! deb_chroot $BUILD_ROOT dpkg --configure --pending  2>&1; then
+    if ! deb_chroot "$BUILD_ROOT" dpkg --configure --pending  2>&1; then
          echo "first configure attempt failed, trying again..."
-         deb_chroot $BUILD_ROOT dpkg --configure --pending  2>&1 || cleanup_and_exit 1
+         deb_chroot "$BUILD_ROOT" dpkg --configure --pending  2>&1 || cleanup_and_exit 1
     fi
 }
 
@@ -137,18 +137,18 @@ pkg_preinstall_deb() {
 }
 
 pkg_runscripts_deb() {
-    if ! test -e $BUILD_ROOT/var/lib/dpkg/status ; then
+    if ! test -e "$BUILD_ROOT"/var/lib/dpkg/status ; then
        deb_setup
     fi
     if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
        echo "running $PKG preinstall script"
-       deb_chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install \
+       deb_chroot "$BUILD_ROOT" ".init_b_cache/scripts/$PKG.pre" install \
                   < /dev/null
        rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre"
     fi
     if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
        echo "running $PKG postinstall script"
-       deb_chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' \
+       deb_chroot "$BUILD_ROOT" ".init_b_cache/scripts/$PKG.post" configure '' \
                   < /dev/null
        rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
     fi
index 8b9f7a2..2c385cc 100644 (file)
 
 pkg_initdb_rpm() {
     echo "initializing rpm db..."
-    mkdir -p $BUILD_ROOT/var/lib/rpm
+    mkdir -p "$BUILD_ROOT"/var/lib/rpm
     # rpm v5 does not have initdb
-    if ! test -e $BUILD_ROOT/usr/lib/rpm/cpuinfo.yaml ; then
-       if test -x $BUILD_ROOT/usr/bin/rpmdb ; then
-           chroot $BUILD_ROOT /usr/bin/rpmdb --initdb || cleanup_and_exit 1
+    if ! test -e "$BUILD_ROOT"/usr/lib/rpm/cpuinfo.yaml ; then
+       if test -x "$BUILD_ROOT"/usr/bin/rpmdb ; then
+           chroot "$BUILD_ROOT" /usr/bin/rpmdb --initdb || cleanup_and_exit 1
        else
-           chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1
+           chroot "$BUILD_ROOT" rpm --initdb || cleanup_and_exit 1
        fi
     fi
     # hack: add nofsync to db config to speed up install
-    mkdir -p $BUILD_ROOT/root
-    DBI_OTHER=`chroot $BUILD_ROOT rpm --eval '%{?__dbi_other}'`
-    echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_ROOT/.rpmmacros
-    echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_ROOT/root/.rpmmacros
+    mkdir -p "$BUILD_ROOT"/root
+    DBI_OTHER=`chroot "$BUILD_ROOT" rpm --eval '%{?__dbi_other}'`
+    echo "%__dbi_other $DBI_OTHER nofsync" > "$BUILD_ROOT"/.rpmmacros
+    echo "%__dbi_other $DBI_OTHER nofsync" > "$BUILD_ROOT"/root/.rpmmacros
 }
 
 pkg_prepare_rpm() {
@@ -46,7 +46,7 @@ pkg_prepare_rpm() {
 }
 
 pkg_erase_rpm() {
-    chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | {
+    chroot "$BUILD_ROOT" rpm --nodeps -e $PKG 2>&1 | {
        local retry
        while read line; do
            case "$line" in
@@ -61,7 +61,7 @@ pkg_erase_rpm() {
        done
        if test -n "$retry" ; then
            echo "re-try deleting $PKG using --noscripts"
-           chroot $BUILD_ROOT rpm --nodeps --noscripts -e $PKG || true
+           chroot "$BUILD_ROOT" rpm --nodeps --noscripts -e $PKG || true
        fi
     }
 }
@@ -70,7 +70,7 @@ rpm_set_checkopts() {
     RPMCHECKOPTS=
     # on Fedora 10 rpmbuild is in a separate package so we need something else to
     # detect rpm4
-    test -x $BUILD_ROOT/usr/bin/rpmquery && RPMCHECKOPTS="--nodigest --nosignature"
+    test -x "$BUILD_ROOT"/usr/bin/rpmquery && RPMCHECKOPTS="--nodigest --nosignature"
 }
 
 rpm_init_cumulate() {
@@ -79,14 +79,14 @@ rpm_init_cumulate() {
     CUMULATED_PIDS=()
     CUMULATED_HMD5=()
     DO_CUMULATE=
-    typeset -ri suse_version=$(chroot $BUILD_ROOT rpm --eval '%{?suse_version}' 2>/dev/null)
-    if ((suse_version > 1220)) ; then 
+    typeset -ri suse_version=$(chroot "$BUILD_ROOT" rpm --eval '%{?suse_version}' 2>/dev/null)
+    if ((suse_version > 1220)) ; then
        DO_CUMULATE=true
     fi
 }
 
 pkg_verify_installed_rpm() {
-    chroot $BUILD_ROOT rpm --verify $PKG 2>&1 | tee $TMPFILE
+    chroot "$BUILD_ROOT" rpm --verify $PKG 2>&1 | tee $TMPFILE
     if grep ^missing $TMPFILE > /dev/null ; then
        return 1
     fi
@@ -97,7 +97,7 @@ pkg_cumulate_rpm() {
     test "$DO_CUMULATE" = true || return 1
     # work around for cross-build installs, we must not overwrite the running rpm
     if test "$PKG" = rpm ; then
-       for i in $BUILD_ROOT/.init_b_cache/preinstalls/rpm-x86-* ; do
+       for i in "$BUILD_ROOT"/.init_b_cache/preinstalls/rpm-x86-* ; do
            test -e "$i" && return 1
        done
     fi
@@ -109,9 +109,9 @@ pkg_cumulate_rpm() {
 }
 
 pkg_install_rpm() {
-    ( cd $BUILD_ROOT && chroot $BUILD_ROOT rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \
+    ( cd "$BUILD_ROOT" && chroot "$BUILD_ROOT" rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \
                $ADDITIONAL_PARAMS .init_b_cache/$PKG.rpm 2>&1 || \
-         touch $BUILD_ROOT/exit ) | \
+         touch "$BUILD_ROOT"/exit ) | \
              grep -v "^warning:.*saved as.*rpmorig$"
 }
 
@@ -122,28 +122,28 @@ pkg_finalize_rpm() {
            echo ${CUMULATED_LIST[$num]}
            PKG=${CUMULATED_LIST[$num]##*/}
            test "$BUILD_ROOT/.init_b_cache/rpms/$PKG" -ef "$BUILD_ROOT/${CUMULATED_LIST[$num]}" && continue
-           rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]}
-           cp $BUILD_ROOT/.init_b_cache/rpms/$PKG $BUILD_ROOT/${CUMULATED_LIST[$num]} || cleanup_and_exit 1
-       done > $BUILD_ROOT/.init_b_cache/manifest
-       ( cd $BUILD_ROOT && chroot $BUILD_ROOT rpm --ignorearch --nodeps -Uh --oldpackage --ignoresize --verbose $RPMCHECKOPTS \
-               $ADDITIONAL_PARAMS .init_b_cache/manifest 2>&1 || touch $BUILD_ROOT/exit )
+           rm -f "$BUILD_ROOT"/${CUMULATED_LIST[$num]}
+           cp "$BUILD_ROOT"/.init_b_cache/rpms/$PKG "$BUILD_ROOT"/${CUMULATED_LIST[$num]} || cleanup_and_exit 1
+       done > "$BUILD_ROOT"/.init_b_cache/manifest
+       ( cd "$BUILD_ROOT" && chroot "$BUILD_ROOT" rpm --ignorearch --nodeps -Uh --oldpackage --ignoresize --verbose $RPMCHECKOPTS \
+               $ADDITIONAL_PARAMS .init_b_cache/manifest 2>&1 || touch "$BUILD_ROOT"/exit )
        for ((num=0; num<=cumulate; num++)) ; do
-           rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]}
+           rm -f "$BUILD_ROOT"/${CUMULATED_LIST[$num]}
        done
-       rm -f $BUILD_ROOT/.init_b_cache/manifest
+       rm -f "$BUILD_ROOT"/.init_b_cache/manifest
        check_exit
        for ((num=0; num<=cumulate; num++)) ; do
            PKG=${CUMULATED_LIST[$num]##*/}
-           echo "${CUMULATED_PIDS[$num]}" > $BUILD_ROOT/installed-pkg/${PKG%.rpm}
+           echo "${CUMULATED_PIDS[$num]}" > "$BUILD_ROOT"/installed-pkg/${PKG%.rpm}
            test -n "${CUMULATED_HMD5[$num]}" || continue
-           echo "${CUMULATED_HMD5[$num]} ${CUMULATED_PIDS[$num]}" > $BUILD_ROOT/.preinstall_image/${PKG%.rpm}
+           echo "${CUMULATED_HMD5[$num]} ${CUMULATED_PIDS[$num]}" > "$BUILD_ROOT"/.preinstall_image/${PKG%.rpm}
        done
     fi
 }
 
 pkg_preinstall_rpm() {
     PAYLOADDECOMPRESS=cat
-    case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm"` in
+    case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.rpm"` in
        lzma) rpm --showrc | egrep 'PayloadIsLzma|_lzma' > /dev/null || PAYLOADDECOMPRESS="lzma -d" ;;
        xz) rpm --showrc | egrep 'PayloadIsXz|_xz' > /dev/null || PAYLOADDECOMPRESS="xz -d" ;;
     esac
@@ -163,8 +163,8 @@ pkg_preinstall_rpm() {
        rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" | $PAYLOADDECOMPRESS | $CPIO
     fi
     if test -e ".init_b_cache/scripts/$PKG.run" ; then
-       rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.pre"
-       rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.post"
+       rpm -qp --nodigest --nosignature --qf "%{PREIN}" "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.pre"
+       rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.post"
        echo -n '(none)' > .init_b_cache/scripts/.none
        cmp -s ".init_b_cache/scripts/$PKG.pre" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.pre"
        cmp -s ".init_b_cache/scripts/$PKG.post" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.post"
@@ -173,21 +173,21 @@ pkg_preinstall_rpm() {
     # hack for rpm erasures
     if test -d "$BUILD_ROOT/installed-pkg" ; then
        # call for rpm-4.x and not rpm-devel
-        test -z "${PKG##rpm-[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
+        test -z "${PKG##rpm-[0-9]*}" && chroot "$BUILD_ROOT" rpm --rebuilddb
         # also exec for exchanged rpm !  naming is rpm-x86-<target>-<ver>
-        test -z "${PKG##rpm-x86-*[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
+        test -z "${PKG##rpm-x86-*[0-9]*}" && chroot "$BUILD_ROOT" rpm --rebuilddb
     fi
 }
 
 pkg_runscripts_rpm() {
     if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then
        echo "running $PKG preinstall script"
-       (cd $BUILD_ROOT && chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0)
+       (cd "$BUILD_ROOT" && chroot "$BUILD_ROOT" sh ".init_b_cache/scripts/$PKG.pre" 0)
        rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre"
     fi
     if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then
        echo "running $PKG postinstall script"
-       (cd $BUILD_ROOT && chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1)
+       (cd "$BUILD_ROOT" && chroot "$BUILD_ROOT" sh ".init_b_cache/scripts/$PKG.post" 1)
        rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post"
     fi
 }
index 49bf09e..c38a4dc 100755 (executable)
@@ -59,7 +59,7 @@ if (defined($oldfile) && open(F, '<', $oldfile)) {
 my %seen;
 
 for my $dir (@ARGV) {
-  my $cmd = "find $dir -follow -type f \\( -name \"*.rpm\" -o -name \"*.deb\" -o -name \"*.pkg.tar.gz\" -o -name \"*.pkg.tar.xz\" \\) -a ! -name \"*src.rpm\" -printf '\%T@/\%s/\%i \%p\\n'";
+  my $cmd = "find '$dir' -follow -type f \\( -name \"*.rpm\" -o -name \"*.deb\" -o -name \"*.pkg.tar.gz\" -o -name \"*.pkg.tar.xz\" \\) -a ! -name \"*src.rpm\" -printf '\%T@/\%s/\%i \%p\\n'";
   open(F, '-|', $cmd) or next;
   while (<F>) {
     chomp;
index e8e2c52..5149b29 100755 (executable)
@@ -46,8 +46,8 @@ repos=()
 
 . $BUILD_DIR/common_functions || exit 1
 
-BUILD_IS_RUNNING=$BUILD_ROOT/not-ready
-TMPFILE=$BUILD_ROOT/tmpfile
+BUILD_IS_RUNNING="$BUILD_ROOT"/not-ready
+TMPFILE="$BUILD_ROOT"/tmpfile
 RPMIDFMT="%{NAME}-%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
 RPMCHECKOPTS_HOST=
 test -x /usr/bin/rpmquery && RPMCHECKOPTS_HOST="--nodigest --nosignature"
@@ -146,8 +146,8 @@ if test -z "$BUILD_ROOT" ; then
     exit 1
 fi
 
-BUILD_IS_RUNNING=$BUILD_ROOT/not-ready
-TMPFILE=$BUILD_ROOT/tmpfile
+BUILD_IS_RUNNING="$BUILD_ROOT"/not-ready
+TMPFILE="$BUILD_ROOT"/tmpfile
 
 #
 # needed functions
@@ -211,7 +211,7 @@ preinstall_image_filter() {
 preinstall_image() {
     check_exit
     echo "unpacking preinstall image${2:+ $2}"
-    cd $BUILD_ROOT || cleanup_and_exit 1
+    cd "$BUILD_ROOT" || cleanup_and_exit 1
     if test -x /usr/bin/bsdtar ; then
        TAR="/usr/bin/bsdtar -P --chroot --numeric-owner -x"
     else
@@ -231,7 +231,7 @@ preinstall() {
     local PKG="$1"
     check_exit
     echo "preinstalling $PKG..."
-    cd $BUILD_ROOT || cleanup_and_exit 1
+    cd "$BUILD_ROOT" || cleanup_and_exit 1
     if test -x /usr/bin/bsdtar ; then
        CPIO="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x -f-"
        TAR="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x"
@@ -245,7 +245,7 @@ preinstall() {
 }
 
 run_pkg_scripts() {
-    chroot $BUILD_ROOT /sbin/ldconfig 2>/dev/null
+    chroot "$BUILD_ROOT" /sbin/ldconfig 2>/dev/null
     for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
        pkg_runscripts
        check_exit
@@ -254,27 +254,27 @@ run_pkg_scripts() {
 
 reorder() {
     test -z "$*" && return
-    rm -f $BUILD_ROOT/.init_b_cache/order.manifest
+    rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
     for PKG in "$@" ; do
-       echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest
+       echo "$PKG" >> "$BUILD_ROOT"/.init_b_cache/order.manifest
     done
-    $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
-    rm -f $BUILD_ROOT/.init_b_cache/order.manifest
+    $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
+    rm -f "$BUILD_ROOT"/.init_b_cache/order.manifest
 }
 
 create_devs() {
     local com file mode arg
 
-    mkdir -m 755 -p $BUILD_ROOT/dev/pts
-    test -d $BUILD_ROOT/dev/shm || rm -f $BUILD_ROOT/dev/shm
-    mkdir -m 755 -p $BUILD_ROOT/dev/shm
+    mkdir -m 755 -p "$BUILD_ROOT"/dev/pts
+    test -d "$BUILD_ROOT"/dev/shm || rm -f "$BUILD_ROOT"/dev/shm
+    mkdir -m 755 -p "$BUILD_ROOT"/dev/shm
     while read com file mode arg ; do
-       rm -f $BUILD_ROOT/dev/$file
+       rm -f "$BUILD_ROOT"/dev/$file
        if test $com = ln ; then
-           ln -s $arg $BUILD_ROOT/dev/$file
+           ln -s $arg "$BUILD_ROOT"/dev/$file
            continue
        fi
-       $com -m $mode $BUILD_ROOT/dev/$file $arg
+       $com -m $mode "$BUILD_ROOT"/dev/$file $arg
     done << DEVLIST
        mknod null    666 c 1 3
        mknod zero    666 c 1 5
@@ -463,14 +463,14 @@ can_reuse_cached_package() {
     local cachepkgid pkgid xpkgid
     test -s "$1" || return 1
     if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.id" ; then
-       local ep=$(rpm -qp --qf "%{EPOCH}" "${1}")
+       local ep=$(rpm -qp --qf "%{EPOCH}" "'${1}'")
        if test "$ep" != "(none)"; then
                RPMIDFMT_EP="%{NAME}-%{EPOCH}:%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
-               pkgid=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "${1}"`
+               pkgid=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "'${1}'"`
        else
-               pkgid=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "${1}"`
+               pkgid=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "'${1}'"`
        fi
-       read cachepkgid < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id
+       read cachepkgid < "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.id
        # check if the build time is zero
        case $cachepkgid in
            *" 0-"*) xpkgid="${pkgid##* }"; pkgid="${pkgid% *} 0-${xpkgid#*-}" ;;
@@ -498,7 +498,7 @@ copy_qemu()
 
     echo "copying qemu"
 
-    mkdir -p $BUILD_ROOT/usr/bin
+    mkdir -p "$BUILD_ROOT"/usr/bin
 
     if check_copy_qemu; then
 
@@ -527,10 +527,10 @@ copy_qemu()
        done
 
        if [ -e /usr/sbin/qemu-binfmt-conf.sh \
-           -a ! -e $BUILD_ROOT/usr/sbin/qemu-binfmt-conf.sh ]; then
+           -a ! -e "$BUILD_ROOT"/usr/sbin/qemu-binfmt-conf.sh ]; then
            echo " /usr/sbin/qemu-binfmt-conf.sh"               # report copy
-           mkdir -p $BUILD_ROOT/usr/sbin
-           install -m755 /usr/sbin/qemu-binfmt-conf.sh $BUILD_ROOT/usr/sbin
+           mkdir -p "$BUILD_ROOT"/usr/sbin
+           install -m755 /usr/sbin/qemu-binfmt-conf.sh "$BUILD_ROOT"/usr/sbin
        fi
 
     fi
@@ -541,9 +541,9 @@ copy_qemu()
     if [ -n "$PREPARE_VM" ]; then
        if [ -x /bin/bash-static -a -x /bin/mount-static ]; then
            echo " /bin/bash-static /bin/mount-static"  # report copy
-           mkdir -p $BUILD_ROOT/bin
-           install -m755 /bin/bash-static $BUILD_ROOT/bin
-           install -m755 /bin/mount-static $BUILD_ROOT/bin
+           mkdir -p "$BUILD_ROOT"/bin
+           install -m755 /bin/bash-static "$BUILD_ROOT"/bin
+           install -m755 /bin/mount-static "$BUILD_ROOT"/bin
        fi
     fi
 }
@@ -567,10 +567,10 @@ fi
 if test -e "$BUILD_IS_RUNNING" ; then
     echo "It seems that there was an incomplete setup of $BUILD_ROOT."
     echo "To be sure, we will build it again completely..."
-    umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true
-    umount -n $BUILD_ROOT/proc 2> /dev/null
-    umount -n $BUILD_ROOT/dev/pts 2> /dev/null
-    umount -n $BUILD_ROOT/mnt 2> /dev/null
+    umount -n "$BUILD_ROOT"/proc/sys/fs/binfmt_misc 2> /dev/null || true
+    umount -n "$BUILD_ROOT"/proc 2> /dev/null
+    umount -n "$BUILD_ROOT"/dev/pts 2> /dev/null
+    umount -n "$BUILD_ROOT"/mnt 2> /dev/null
     echo "Your build system is broken!! Shall I execute"
     echo
     echo "    rm -rf -- $BUILD_ROOT/*"
@@ -582,7 +582,7 @@ if test -e "$BUILD_IS_RUNNING" ; then
     read ANSWER
     case "$ANSWER" in
        c|C)
-           rm -f $BUILD_IS_RUNNING $BUILD_ROOT/exit ;;
+           rm -f $BUILD_IS_RUNNING "$BUILD_ROOT"/exit ;;
        y|Y)
            clean_build_root ;;
        *)
@@ -593,22 +593,22 @@ fi
 #
 # store that we start to build system
 #
-mkdir -p $BUILD_ROOT
-mkdir -p $BUILD_ROOT/.build
+mkdir -p "$BUILD_ROOT"
+mkdir -p "$BUILD_ROOT"/.build
 touch $BUILD_IS_RUNNING
 
 if test -n "$PREPARE_VM" ; then
-    rm -f $BUILD_ROOT/.build/init_buildsystem.data
+    rm -f "$BUILD_ROOT"/.build/init_buildsystem.data
 fi
 
-if test -e $BUILD_ROOT/.build/init_buildsystem.data ; then
+if test -e "$BUILD_ROOT"/.build/init_buildsystem.data ; then
     # vm continuation
-    . $BUILD_ROOT/.build/init_buildsystem.data
-    if ! test -e $BUILD_ROOT/.init_b_cache/preinstall_finished ; then
+    . "$BUILD_ROOT"/.build/init_buildsystem.data
+    if ! test -e "$BUILD_ROOT"/.init_b_cache/preinstall_finished ; then
        # finish preinstall
        run_pkg_scripts
        pkg_initdb
-       touch $BUILD_ROOT/.init_b_cache/preinstall_finished
+       touch "$BUILD_ROOT"/.init_b_cache/preinstall_finished
     fi
 else
     #
@@ -621,13 +621,13 @@ else
        #
        # create rpmdeps file
        #
-       CACHE_FILE=$BUILD_ROOT/.srcfiles.cache
+       CACHE_FILE="$BUILD_ROOT"/.srcfiles.cache
        create_cache_file
 
        #
        # select and expand packages
        #
-       RPMLIST=$BUILD_ROOT/.init_b_cache/rpmlist
+       RPMLIST="$BUILD_ROOT"/.init_b_cache/rpmlist
        test -z "$LIST_STATE" && echo "expanding package dependencies..."
        VMOPT=
        test -z "$PREPARE_VM" || VMOPT=--vm
@@ -647,7 +647,7 @@ else
           test "$PKG" = "dist:" && continue
           test "$PKG" = "rpmid:" && continue
           echo "${SRC##*/}"
-       done < $BUILD_ROOT/.init_b_cache/rpmlist
+       done < "$BUILD_ROOT"/.init_b_cache/rpmlist
        rm -rf "$BUILD_ROOT/.init_b_cache"
        cleanup_and_exit 0
     fi
@@ -683,8 +683,8 @@ else
     RUNSCRIPTS_SEEN=
     PACKAGES_FROM_PREINSTALLIMAGE=
     GUESSED_DIST=unknown
-    mkdir -p $BUILD_ROOT/.init_b_cache/rpms
-    rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download
+    mkdir -p "$BUILD_ROOT"/.init_b_cache/rpms
+    rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download
     while read PKG SRC ; do
        if test "$PKG" = "preinstall:" ; then
            PACKAGES_TO_PREINSTALL=$SRC
@@ -721,7 +721,7 @@ else
            continue
        fi
        if test "$PKG" = "rpmid:" ; then
-           echo "${SRC#*:}" > $BUILD_ROOT/.init_b_cache/rpms/${SRC%%:*}.id
+           echo "${SRC#*:}" > "$BUILD_ROOT"/.init_b_cache/rpms/${SRC%%:*}.id
            continue
        fi
        if test "$PKG" != "${PKG%:}"; then
@@ -737,7 +737,7 @@ else
        if test "${SRC#/}" = "$SRC" ; then
            case "$SRC" in
                zypp://* | http://* | https://* | ftp://* | ftps://*)
-                   echo "$PKG $SRC" >>$BUILD_ROOT/.init_b_cache/rpmlist.download
+                   echo "$PKG $SRC" >>"$BUILD_ROOT"/.init_b_cache/rpmlist.download
                    continue
                    ;;
                *)
@@ -771,9 +771,9 @@ else
     fi
 
     # check if we really can use cached versions for packages on the download list
-    if test -s $BUILD_ROOT/.init_b_cache/rpmlist.download ; then
+    if test -s "$BUILD_ROOT"/.init_b_cache/rpmlist.download ; then
        echo "calculating packages to download..."
-       rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download2
+       rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download2
         while read PKG SRC ; do
            cachepkg="${SRC##*/}"
            cachepkg="${cachepkg/%.pkg.tar.?z/.arch}"
@@ -790,19 +790,19 @@ else
            cachedir="$(getcachedir "$SRC")"
            if can_reuse_cached_package "$cachedir/$cachepkg" ; then
                SRCSUF=${SRC/%.pkg.tar.?z/.arch}
-               ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
+        ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
                continue
            fi
            # not found in cache or cache has different package
            rm -f "$cachedir/$cachepkg"
-           echo "$PKG $SRC" >>$BUILD_ROOT/.init_b_cache/rpmlist.download2
-       done < $BUILD_ROOT/.init_b_cache/rpmlist.download
-       rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download
-       test -s $BUILD_ROOT/.init_b_cache/rpmlist.download2 && mv $BUILD_ROOT/.init_b_cache/rpmlist.download2 $BUILD_ROOT/.init_b_cache/rpmlist.download
+           echo "$PKG $SRC" >>"$BUILD_ROOT"/.init_b_cache/rpmlist.download2
+       done < "$BUILD_ROOT"/.init_b_cache/rpmlist.download
+       rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download
+       test -s "$BUILD_ROOT"/.init_b_cache/rpmlist.download2 && mv "$BUILD_ROOT"/.init_b_cache/rpmlist.download2 "$BUILD_ROOT"/.init_b_cache/rpmlist.download
     fi
 
     # now do the download of missing packages
-    if test -s $BUILD_ROOT/.init_b_cache/rpmlist.download ; then
+    if test -s "$BUILD_ROOT"/.init_b_cache/rpmlist.download ; then
         PACKAGES_TO_DOWNLOAD=`cat ${RPMLIST}.download|awk '{print $2}'`
         progress_setup PACKAGES_TO_DOWNLOAD
         while read PKG SRC ; do
@@ -811,15 +811,15 @@ else
            # downloadpkg modified $SRC, so it has a right name for use
            SRCSUF=${SRC/%.pkg.tar.?z/.arch}
            ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}"
-        done < $BUILD_ROOT/.init_b_cache/rpmlist.download
-        rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download
+        done < "$BUILD_ROOT"/.init_b_cache/rpmlist.download
+        rm -f "$BUILD_ROOT"/.init_b_cache/rpmlist.download
         echo
     fi
 
     # compatibility...
     test -z "$RUNSCRIPTS_SEEN" && PACKAGES_TO_RUNSCRIPTS="$PACKAGES_TO_PREINSTALL"
 
-    echo "$GUESSED_DIST" > $BUILD_ROOT/.guessed_dist
+    echo "$GUESSED_DIST" > "$BUILD_ROOT"/.guessed_dist
     test -n "$BUILD_DIST" || BUILD_DIST="$GUESSED_DIST"
 
     pkg_set_type
@@ -827,7 +827,7 @@ else
     if test -n "$PREINSTALL_IMAGE" ; then
        for PKG in $PACKAGES_FROM_PREINSTALLIMAGE ; do
            # touch the file so that the copying works
-           touch $BUILD_ROOT/.init_b_cache/rpms/"$PKG.$PSUF"
+           touch "$BUILD_ROOT"/.init_b_cache/rpms/"$PKG.$PSUF"
        done
     fi
 
@@ -836,12 +836,12 @@ fi
 #
 # test if we need to preinstall
 #
-if test ! -e $BUILD_ROOT/installed-pkg -a ! -e $BUILD_ROOT/.build/init_buildsystem.data ; then
-    mkdir -p $BUILD_ROOT/etc || cleanup_and_exit 1
-    mkdir -p $BUILD_ROOT/proc || cleanup_and_exit 1
-    test -f $BUILD_ROOT/etc/HOSTNAME || hostname -f > $BUILD_ROOT/etc/HOSTNAME
+if test ! -e "$BUILD_ROOT"/installed-pkg -a ! -e "$BUILD_ROOT"/.build/init_buildsystem.data ; then
+    mkdir -p "$BUILD_ROOT"/etc || cleanup_and_exit 1
+    mkdir -p "$BUILD_ROOT"/proc || cleanup_and_exit 1
+    test -f "$BUILD_ROOT"/etc/HOSTNAME || hostname -f > "$BUILD_ROOT"/etc/HOSTNAME
     for PKG in $PACKAGES_TO_RUNSCRIPTS ; do
-       : > $BUILD_ROOT/.init_b_cache/scripts/$PKG.run
+       : > "$BUILD_ROOT"/.init_b_cache/scripts/$PKG.run
     done
     PACKAGES_TO_PREINSTALL_FILTERED="$PACKAGES_TO_PREINSTALL"
     PACKAGES_TO_VMINSTALL_FILTERED="$PACKAGES_TO_VMINSTALL"
@@ -869,14 +869,14 @@ if test ! -e $BUILD_ROOT/installed-pkg -a ! -e $BUILD_ROOT/.build/init_buildsyst
     # for reorder
     check_exit
     if test -w /root ; then
-       test -c $BUILD_ROOT/dev/null || create_devs
+       test -c "$BUILD_ROOT"/dev/null || create_devs
     fi
-    test -e $BUILD_ROOT/etc/fstab || touch $BUILD_ROOT/etc/fstab
-    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
+    test -e "$BUILD_ROOT"/etc/fstab || touch "$BUILD_ROOT"/etc/fstab
+    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
     if test -z "$PREPARE_VM" ; then
        run_pkg_scripts
        pkg_initdb
-       touch $BUILD_ROOT/.init_b_cache/preinstall_finished
+       touch "$BUILD_ROOT"/.init_b_cache/preinstall_finished
     fi
     # mark as preinstalled no longer needed
     rm -rf "$BUILD_ROOT/installed-pkg"
@@ -886,9 +886,9 @@ fi
 if test -n "$PREPARE_VM" ; then
     echo "copying packages..."
     for PKG in $PACKAGES_TO_ALL ; do
-       rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
-       cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
-       ln -s -f ../$PKG.$PSUF $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF
+       rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
+       cp "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
+       ln -s -f ../$PKG.$PSUF "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF
        check_exit
     done
     # alreadyinstalled check will not work, but we have to live with that...
@@ -897,21 +897,21 @@ if test -n "$PREPARE_VM" ; then
     check_exit
     echo 'done'
     Q="'\''"
-    echo "PACKAGES_TO_INSTALL='${PACKAGES_TO_INSTALL//"'"/$Q}'" > $BUILD_ROOT/.build/init_buildsystem.data
-    echo "PACKAGES_TO_RUNSCRIPTS='${PACKAGES_TO_RUNSCRIPTS//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
+    echo "PACKAGES_TO_INSTALL='${PACKAGES_TO_INSTALL//"'"/$Q}'" > "$BUILD_ROOT"/.build/init_buildsystem.data
+    echo "PACKAGES_TO_RUNSCRIPTS='${PACKAGES_TO_RUNSCRIPTS//"'"/$Q}'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
     # needed for continuation in xen/kvm with rpm-x86
-    echo "PACKAGES_TO_PREINSTALL='${PACKAGES_TO_PREINSTALL//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
-    echo "PACKAGES_TO_AVAILABLE='${PACKAGES_TO_AVAILABLE//"'"/$Q}'" >> $BUILD_ROOT/.build/init_buildsystem.data
-    echo "PSUF='$PSUF'" >> $BUILD_ROOT/.build/init_buildsystem.data
+    echo "PACKAGES_TO_PREINSTALL='${PACKAGES_TO_PREINSTALL//"'"/$Q}'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
+    echo "PACKAGES_TO_AVAILABLE='${PACKAGES_TO_AVAILABLE//"'"/$Q}'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
+    echo "PSUF='$PSUF'" >> "$BUILD_ROOT"/.build/init_buildsystem.data
     rm -f $BUILD_IS_RUNNING
     cleanup_and_exit 0
 fi
 
 
-mkdir -p $BUILD_ROOT/proc
-mkdir -p $BUILD_ROOT/dev/pts
-mount -n -tproc none $BUILD_ROOT/proc 2>/dev/null || true
-mount -n -tdevpts -omode=0620,gid=5 none $BUILD_ROOT/dev/pts 2>/dev/null || true
+mkdir -p "$BUILD_ROOT"/proc
+mkdir -p "$BUILD_ROOT"/dev/pts
+mount -n -tproc none "$BUILD_ROOT"/proc 2>/dev/null || true
+mount -n -tdevpts -omode=0620,gid=5 none "$BUILD_ROOT"/dev/pts 2>/dev/null || true
 
 #
 # create .build.binaries directory if requested
@@ -933,7 +933,7 @@ fi
 #
 # reorder packages (already done in vm continuation)
 #
-if ! test -e $BUILD_ROOT/.build/init_buildsystem.data ; then
+if ! test -e "$BUILD_ROOT"/.build/init_buildsystem.data ; then
     echo -n 'reordering...'
     PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL`
     check_exit
@@ -943,7 +943,7 @@ fi
 #
 # get list and ids of already installed packages
 #
-mkdir -p $BUILD_ROOT/.init_b_cache/alreadyinstalled
+mkdir -p "$BUILD_ROOT"/.init_b_cache/alreadyinstalled
 listinstalled --root "$BUILD_ROOT" --type "$PSUF" --extraname | (
     while read id name buildid; do
        echo "$buildid" > "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$name"
@@ -957,16 +957,16 @@ pkg_prepare
 # delete all packages we don't want
 #
 if [ -z "$KEEP_PACKS" ]; then
-    mkdir -p $BUILD_ROOT/.init_b_cache/todelete
-    for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do
+    mkdir -p "$BUILD_ROOT"/.init_b_cache/todelete
+    for PKG in "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/* ; do
         PKG=${PKG##*/}
         test "$PKG" = "*" && continue
-        ln $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG $BUILD_ROOT/.init_b_cache/todelete/$PKG
+        ln "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG "$BUILD_ROOT"/.init_b_cache/todelete/$PKG
     done
     for PKG in $PACKAGES_TO_INSTALL; do
-        rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG
+        rm -f "$BUILD_ROOT"/.init_b_cache/todelete/$PKG
     done
-    for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do
+    for PKG in "$BUILD_ROOT"/.init_b_cache/todelete/* ; do
         PKG=${PKG##*/}
         test "$PKG" = "*" && continue
         echo "deleting $PKG"
@@ -984,45 +984,45 @@ done
 rm -rf "$BUILD_ROOT/installed-pkg"
 mkdir -p "$BUILD_ROOT/installed-pkg"
 
-test -x $BUILD_ROOT/sbin/ldconfig && chroot $BUILD_ROOT /sbin/ldconfig 2>&1
+test -x "$BUILD_ROOT"/sbin/ldconfig && chroot "$BUILD_ROOT" /sbin/ldconfig 2>&1
 
 MAIN_LIST="$PACKAGES_TO_INSTALL"
 progress_setup MAIN_LIST
 for PKG in $MAIN_LIST ; do
-    test -f $BUILD_ROOT/installed-pkg/$PKG && continue
+    test -f "$BUILD_ROOT"/installed-pkg/$PKG && continue
     progress_step MAIN_LIST
 
     if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -a ! -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" ; then
        # preinstallimage package, make sure it's in the image
-       if ! test -e $BUILD_ROOT/.preinstall_image/$PKG ; then
-           echo "Package $PKG is missing from the preinstall image"
+       if ! test -e "$BUILD_ROOT"/.preinstall_image/$PKG ; then
+               echo "Package $PKG is missing from the preinstall image"
            cleanup_and_exit 1
        fi
-       read PKG_HDRMD5 PKGID < $BUILD_ROOT/.preinstall_image/$PKG
+       read PKG_HDRMD5 PKGID < "$BUILD_ROOT"/.preinstall_image/$PKG
        echo "preinstalled ${PKGID%% *}"
-       echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
+       echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
        continue
     fi
 
     # get the hdrmd5 if we want to create a preinstall image
     PKG_HDRMD5=
-    if test -d $BUILD_ROOT/.preinstall_image -a ! -e $BUILD_ROOT/.preinstall_image/$PKG ; then
-       PKG_HDRMD5=`perl -I$BUILD_DIR -MBuild -e 'print Build::queryhdrmd5($ARGV[0])' $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF`
-       test -n "$PKG_HDRMD5" || cleanup_and_exit 1
+       if test -d "$BUILD_ROOT"/.preinstall_image -a ! -e "$BUILD_ROOT"/.preinstall_image/$PKG ; then
+       PKG_HDRMD5=`perl -I$BUILD_DIR -MBuild -e 'print Build::queryhdrmd5($ARGV[0])' "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF`
+    test -n "$PKG_HDRMD5" || cleanup_and_exit 1
     fi
 
-    test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF || continue
+       test -L "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF || continue
 
     # check if we can keep an already installed package
-    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
-       read PKGID < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id
-       read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG
+       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
+       read PKGID < "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.id
+       read OLDPKGID < "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG
        if test "$PKGID" = "$OLDPKGID" ; then
            echo "keeping ${PKGID%% *}"
-           rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
-           echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
-           test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
-           continue
+           rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
+               echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
+               test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > "$BUILD_ROOT"/.preinstall_image/$PKG
+               continue
        fi
     fi
 
@@ -1030,25 +1030,25 @@ for PKG in $MAIN_LIST ; do
    if test "$PSUF" != "rpm" ; then
        PKGID=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" buildid)
    else
-       ep=$(rpm -qp --qf "%{EPOCH}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF")
-       if test "$ep" != "(none)"; then
+       ep=$(rpm -qp --qf "%{EPOCH}" "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.$PSUF") 
+          if test "$ep" != "(none)"; then
            RPMIDFMT_EP="%{NAME}-%{EPOCH}:%{VERSION}-%{RELEASE} %{BUILDTIME}-%{ARCH}\n"
-           PKGID=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"`
-       else
-           PKGID=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"`
+                  PKGID=`rpm -qp --qf "${RPMIDFMT_EP}" $RPMCHECKOPTS_HOST "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.$PSUF"`
+          else
+                  PKGID=`rpm -qp --qf "${RPMIDFMT}" $RPMCHECKOPTS_HOST "'$BUILD_ROOT'/.init_b_cache/rpms/$PKG.$PSUF"`
        fi
    fi
 
-    if test -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then
-       read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG
+       if test -f "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG ; then
+       read OLDPKGID < "$BUILD_ROOT"/.init_b_cache/alreadyinstalled/$PKG
        if test "$PKGID" != "$OLDPKGID" ; then
            echo "deleting unwanted ${OLDPKGID%% *}"
            pkg_erase
        else
            if test "$VERIFY_BUILD_SYSTEM" != true || pkg_verify_installed ; then
                echo "keeping ${PKGID%% *}"
-               echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
-               test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
+               echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
+               test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > "$BUILD_ROOT"/.preinstall_image/$PKG
                continue
            fi
            echo "deleting incomplete ${OLDPKGID%% *}"
@@ -1066,8 +1066,8 @@ for PKG in $MAIN_LIST ; do
     fi
     # work around for cross-build installs, we must not overwrite the running rpm
     if test "$PKG" = rpm ; then
-       for i in $BUILD_ROOT/.init_b_cache/preinstalls/rpm-x86-* ; do
-           test -e "$i" && ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --justdb"
+       for i in "$BUILD_ROOT"/.init_b_cache/preinstalls/rpm-x86-* ; do
+                       test -e "$i" && ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --justdb"
        done
     fi
 
@@ -1079,39 +1079,38 @@ for PKG in $MAIN_LIST ; do
     # install the package
     echo "installing ${PKGID%% *}"
     if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -ef "$BUILD_ROOT/.init_b_cache/$PKG.$PSUF" ; then
-       rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
-       cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
-    fi
+       rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
+    cp "$BUILD_ROOT"/.init_b_cache/rpms/$PKG.$PSUF "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1
+       fi
     pkg_install
     check_exit
-    rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF
-    echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG
-    test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG
-
+       rm -f "$BUILD_ROOT"/.init_b_cache/$PKG.$PSUF
+       echo "$PKGID" > "$BUILD_ROOT"/installed-pkg/$PKG
+       test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > "$BUILD_ROOT"/.preinstall_image/$PKG
 done
 
 # do post-installation work
 pkg_finalize
 
 # devices can vanish if devs got uninstalled
-test -c $BUILD_ROOT/dev/null || create_devs
+test -c "$BUILD_ROOT"/dev/null || create_devs
 
-cd $BUILD_ROOT || cleanup_and_exit 1
+cd "$BUILD_ROOT" || cleanup_and_exit 1
 
 #
 # setup /etc/mtab
 #
-rm -f $BUILD_ROOT/etc/mtab
-cp /proc/mounts $BUILD_ROOT/etc/mtab
-chmod 644 $BUILD_ROOT/etc/mtab
+rm -f "$BUILD_ROOT"/etc/mtab
+cp /proc/mounts "$BUILD_ROOT"/etc/mtab
+chmod 644 "$BUILD_ROOT"/etc/mtab
 
 #
 # make sure, that our nis is not present in the chroot system
 #
-test -e $BUILD_ROOT/etc/nsswitch.conf && {
+test -e "$BUILD_ROOT"/etc/nsswitch.conf && {
     echo "removing nis flags from $BUILD_ROOT/etc/nsswitch.conf..."
-    cat $BUILD_ROOT/etc/nsswitch.conf | sed -e"s:nis::g" > $BUILD_ROOT/etc/nsswitch.conf.tmp
-    mv $BUILD_ROOT/etc/nsswitch.conf.tmp $BUILD_ROOT/etc/nsswitch.conf
+    cat "$BUILD_ROOT"/etc/nsswitch.conf | sed -e"s:nis::g" > "$BUILD_ROOT"/etc/nsswitch.conf.tmp
+    mv "$BUILD_ROOT"/etc/nsswitch.conf.tmp "$BUILD_ROOT"/etc/nsswitch.conf
 }
 
 #
@@ -1120,21 +1119,21 @@ test -e $BUILD_ROOT/etc/nsswitch.conf && {
 for DIR in /usr/share/doc/packages \
           /usr/X11R6/include/X11/pixmaps \
           /usr/X11R6/include/X11/bitmaps ; do
-    mkdir -p $BUILD_ROOT/$DIR
+    mkdir -p "$BUILD_ROOT"/$DIR
 done
 for FILE in /var/run/utmp /var/log/wtmp /etc/fstab ; do
-    mkdir -p $BUILD_ROOT/${FILE%/*}
-    touch $BUILD_ROOT/$FILE
+    mkdir -p "$BUILD_ROOT"/${FILE%/*}
+    touch "$BUILD_ROOT"/$FILE
 done
 
 echo now finalizing build dir...
-if test -x $BUILD_ROOT/sbin/ldconfig ; then
-       CHROOT_RETURN="`chroot $BUILD_ROOT /sbin/ldconfig 2>&1`"
+if test -x "$BUILD_ROOT"/sbin/ldconfig ; then
+       CHROOT_RETURN="`chroot "$BUILD_ROOT" /sbin/ldconfig 2>&1`"
        case "$CHROOT_RETURN" in
            *warning:*)
-               chroot $BUILD_ROOT /sbin/ldconfig
+               chroot "$BUILD_ROOT" /sbin/ldconfig
                echo
-               echo chroot $BUILD_ROOT /sbin/ldconfig
+               echo chroot "$BUILD_ROOT" /sbin/ldconfig
                echo
                echo "$CHROOT_RETURN"
                echo
@@ -1145,52 +1144,52 @@ if test -x $BUILD_ROOT/sbin/ldconfig ; then
        esac
 fi
 
-if test -x $BUILD_ROOT/usr/sbin/Check && ! grep -q "/usr/sbin/Check is obsolete" $BUILD_ROOT/usr/sbin/Check ; then
-    chroot $BUILD_ROOT /usr/sbin/Check
+if test -x "$BUILD_ROOT"/usr/sbin/Check && ! grep -q "/usr/sbin/Check is obsolete" "$BUILD_ROOT"/usr/sbin/Check ; then
+    chroot "$BUILD_ROOT" /usr/sbin/Check
 fi
 
-mkdir -p $BUILD_ROOT/var/adm/packages
-touch $BUILD_ROOT/var/adm/packages
+mkdir -p "$BUILD_ROOT"/var/adm/packages
+touch "$BUILD_ROOT"/var/adm/packages
 
-if test -x $BUILD_ROOT/sbin/SuSEconfig ; then
-    if grep norestarts $BUILD_ROOT/sbin/SuSEconfig > /dev/null ; then
-       chroot $BUILD_ROOT /sbin/SuSEconfig --norestarts --force
+if test -x "$BUILD_ROOT"/sbin/SuSEconfig ; then
+    if grep norestarts "$BUILD_ROOT"/sbin/SuSEconfig > /dev/null ; then
+       chroot "$BUILD_ROOT" /sbin/SuSEconfig --norestarts --force
     else
-       chroot $BUILD_ROOT /sbin/SuSEconfig --force
+       chroot "$BUILD_ROOT" /sbin/SuSEconfig --force
     fi
 fi
 
-if test -x $BUILD_ROOT/usr/X11R6/bin/switch2mesasoft ; then
-    chroot $BUILD_ROOT /usr/X11R6/bin/switch2mesasoft
+if test -x "$BUILD_ROOT"/usr/X11R6/bin/switch2mesasoft ; then
+    chroot "$BUILD_ROOT" /usr/X11R6/bin/switch2mesasoft
 fi
 
 for PROG in /usr/bin/TeX/texhash /usr/bin/texhash ; do
-    test -x $BUILD_ROOT/$PROG && \
-       chroot $BUILD_ROOT bash -c ". /etc/profile ; $PROG"
+    test -x "$BUILD_ROOT"/$PROG && \
+       chroot "$BUILD_ROOT" bash -c ". /etc/profile ; $PROG"
 done
 
-if test -e $BUILD_ROOT/usr/share/zoneinfo/UTC ; then
+if test -e "$BUILD_ROOT"/usr/share/zoneinfo/UTC ; then
     for PROG in /usr/sbin/zic /usr/bin/zic /bin/zic /sbin/zic ; do
-        test -x $BUILD_ROOT/$PROG  && chroot $BUILD_ROOT bash -c "$PROG -l \$(readlink -f /usr/share/zoneinfo/UTC)"
+        test -x "$BUILD_ROOT"/$PROG  && chroot "$BUILD_ROOT" bash -c "$PROG -l \$(readlink -f /usr/share/zoneinfo/UTC)"
     done
 fi
 
-test -e $BUILD_ROOT/.build/init_buildsystem.data || HOST=`hostname`
-test -e $BUILD_ROOT/etc/hosts || echo "127.0.0.1 localhost" > $BUILD_ROOT/etc/hosts
-if ! grep -F "127.0.0.1 $HOST" $BUILD_ROOT/etc/hosts > /dev/null ; then
+test -e "$BUILD_ROOT"/.build/init_buildsystem.data || HOST=`hostname`
+test -e "$BUILD_ROOT"/etc/hosts || echo "127.0.0.1 localhost" > "$BUILD_ROOT"/etc/hosts
+if ! grep -F "127.0.0.1 $HOST" "$BUILD_ROOT"/etc/hosts > /dev/null ; then
     # this makes a reverse lookup on 127.0.0.1 return the host name,
     # which is bad, but 127.0.0.2 does not work on all unix systems
-    echo "127.0.0.1 $HOST" > $BUILD_ROOT/etc/hosts.new
-    test -f $BUILD_ROOT/etc/hosts && cat $BUILD_ROOT/etc/hosts >> $BUILD_ROOT/etc/hosts.new
-    mv $BUILD_ROOT/etc/hosts.new $BUILD_ROOT/etc/hosts
+    echo "127.0.0.1 $HOST" > "$BUILD_ROOT"/etc/hosts.new
+    test -f "$BUILD_ROOT"/etc/hosts && cat "$BUILD_ROOT"/etc/hosts >> "$BUILD_ROOT"/etc/hosts.new
+    mv "$BUILD_ROOT"/etc/hosts.new "$BUILD_ROOT"/etc/hosts
 fi
 
 # XXX: still needed?
-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
+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
     pkg_initdb_rpm
-    chroot $BUILD_ROOT rpm -q --whatprovides rpm >/dev/null 2>&1       # create provides index
+    chroot "$BUILD_ROOT" rpm -q --whatprovides rpm >/dev/null 2>&1     # create provides index
 fi
-rm -f $BUILD_ROOT/.rpmmacros $BUILD_ROOT/root/.rpmmacros
+rm -f "$BUILD_ROOT"/.rpmmacros "$BUILD_ROOT"/root/.rpmmacros
 rm -rf "$BUILD_ROOT/.init_b_cache"
 rm -f $BUILD_IS_RUNNING
 rm -f $TMPFILE