Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwlive.git;a=commitdiff;h=fc019ab6a7af4a114bb01901f0f3bd28326ab9ab

commit fc019ab6a7af4a114bb01901f0f3bd28326ab9ab
Author: Miklos Vajna <vmik...@frugalware.org>
Date:   Thu Nov 3 00:04:16 2011 +0100

01create-rootfs.sh: more error checking

diff --git a/01create-rootfs.sh b/01create-rootfs.sh
index 09193d9..67dc08f 100755
--- a/01create-rootfs.sh
+++ b/01create-rootfs.sh
@@ -1,55 +1,41 @@
-#!/bin/bash
+#!/bin/bash -xe

. /etc/makepkg.conf
. $PWD/config

-chroot_umount() {
-       echo "Attempting to umount chroot directories..."
-       umount $CHROOTDIR/proc >/dev/null
-       umount $CHROOTDIR/sys >/dev/null
-       umount $CHROOTDIR/var/cache/pacman-g2 >/dev/null
-       if [ "$?" != "0" ]; then
-               echo "An error occurred while attempting to umount chroot 
directories."
-               exit 1
-       fi
-       echo "Successfully umounted chroot directories."
-}
-
-chroot_mount() {
-       echo "Attempting to mount chroot directories..."
-       mount -t proc none $CHROOTDIR/proc >/dev/null
-       mount -t sysfs none $CHROOTDIR/sys >/dev/null
-       mount -o bind /var/cache/pacman-g2 $CHROOTDIR/var/cache/pacman-g2 
>/dev/null
-       if [ "$?" != "0" ]; then
-               echo "An error occurred while attempting to mount chroot 
directories."
-               exit 1
-       fi
-       echo "Successfully mounted chroot directories."
-}
-
-# Create the chroot environment.
if [ "`id -u`" != 0 ]; then
echo "Building the chroot as an unprivileged user is not possible."
exit 1
fi

+# Create empty dir
rm -rf $CHROOTDIR
mkdir -p $CHROOTDIR/{etc,proc,sys,var/cache/pacman-g2,var/tmp/fst,tmp,var/log}

-chroot_mount
+# Mount chroot
+echo "Attempting to mount chroot directories..."
+mount -t proc none $CHROOTDIR/proc >/dev/null
+mount -t sysfs none $CHROOTDIR/sys >/dev/null
+mount -o bind /var/cache/pacman-g2 $CHROOTDIR/var/cache/pacman-g2 >/dev/null
+echo "Successfully mounted chroot directories."

+# Build it
echo "Building chroot environment"
-
-[ -e pacman-g2.conf ] && rm -f pacman-g2.conf;
-[ $TREE == "current" ] && echo "[frugalware-current]" > pacman-g2.conf
-[ $TREE == "stable" ] && echo "[frugalware]" > pacman-g2.conf
+if [ -e pacman-g2.conf ]; then
+       rm -f pacman-g2.conf
+fi
+if [ $TREE == "current" ]; then
+       echo "[frugalware-current]" > pacman-g2.conf
+fi
+if [ $TREE == "stable" ]; then
+       echo "[frugalware]" > pacman-g2.conf
+fi
echo "Server = 
http://ftp.frugalware.org/pub/frugalware/frugalware-$TREE/frugalware-$ARCH"; >> 
pacman-g2.conf
-
pacman -Sy base -r "$CHROOTDIR" --noconfirm --config pacman-g2.conf

-if [ "$?" != "0" ]; then
-       echo "Failed to build chroot environment."
-       chroot_umount
-       exit 1
-fi
-chroot_umount
+# Umount
+echo "Attempting to umount chroot directories..."
+umount $CHROOTDIR/proc >/dev/null
+umount $CHROOTDIR/sys >/dev/null
+umount $CHROOTDIR/var/cache/pacman-g2 >/dev/null
+echo "Successfully umounted chroot directories."
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to