Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (93594dd2baf7eecd19bc508efbe394cf20c2e95d)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Justin Boffemmyer <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (93594dd2baf7eecd19bc508efbe394cf20c2e95d)
  • Date: Mon, 13 Oct 2008 21:49:54 -0500

GIT changes to test cauldron by Justin Boffemmyer <flux AT sourcemage.org>:

scripts/add-sauce.sh | 38 ++++++++++++++++++++++++++------------
scripts/cauldronchr.sh | 35 +++++++++++++++++++++--------------
scripts/cleaniso.sh | 18 ++++++++++++++++--
scripts/mkiso.sh | 17 +++++++++++++++--
scripts/mkrelease.sh | 20 +++++++++++++++++---
scripts/mksystem.sh | 16 +++++++++++++++-
6 files changed, 110 insertions(+), 34 deletions(-)

New commits:
commit 93594dd2baf7eecd19bc508efbe394cf20c2e95d
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/*: ability to use sudo

All of the scripts can now make use of sudo to run superuser
privileged commands. If the UID is not 0, the scripts will attempt
sudo if sudo is found on the system, else they will prompt for the
root password and rerun themselves via su.

diff --git a/scripts/add-sauce.sh b/scripts/add-sauce.sh
index feb1e38..2b65c89 100755
--- a/scripts/add-sauce.sh
+++ b/scripts/add-sauce.sh
@@ -41,6 +41,20 @@ do
done
shift $(($OPTIND - 1))

+SELF=$0
+SUDOCMD=""
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo) ]]
+ then
+ SUDOCMD="sudo"
+ else
+ echo "Please enter the root password."
+ exec su -c "$SELF $*" root
+ fi
+fi
+
if [[ $TYPE == "bad" || -z $1 ]] ;then
usage
fi
@@ -64,19 +78,19 @@ fi >&2


# make sure we start with a clean TEMPDIR each run
-rm -rf $TEMPDIR
-mkdir -m 0700 $TEMPDIR
+$SUDOCMD rm -rf $TEMPDIR
+$SUDOCMD mkdir -m 0700 $TEMPDIR

# add the contents of base, which are files that
# should go onto both iso and system chroots
# this is mostly /etc content
-cp -a $MYDIR/base/* $TEMPDIR/
+$SUDOCMD cp -a $MYDIR/base/* $TEMPDIR/

# ISO Sauce
if [[ $TYPE == "iso" ]] ;then
# copy everything from the cauldron repo iso dir
# into the TEMPDIR staging area
- cp -a $MYDIR/iso/* $TEMPDIR/
+ $SUDOCMD cp -a $MYDIR/iso/* $TEMPDIR/
fi

# System Sauce
@@ -85,13 +99,13 @@ then
# make sure that the grub stage files are available in /boot
# by copying them from CHROOTDIR (system) into the /boot dir
# in our TEMPDIR staging area
- cp -a $CHROOTDIR/usr/lib/grub/i386-pc/* $TEMPDIR/boot/grub/
+ $SUDOCMD cp -a $CHROOTDIR/usr/lib/grub/i386-pc/* $TEMPDIR/boot/grub/
fi

# ==== FIXUP starts here ====
-chown -R 0:0 $TEMPDIR/
-chmod -R u=rwX,go=u-w $TEMPDIR/
-chmod 0600 $TEMPDIR/etc/shadow
+$SUDOCMD chown -R 0:0 $TEMPDIR/
+$SUDOCMD chmod -R u=rwX,go=u-w $TEMPDIR/
+$SUDOCMD chmod 0600 $TEMPDIR/etc/shadow
# ==== end fixup ====

# Get a list of all files we want to install
@@ -102,7 +116,7 @@ do
# This is safe even if the dir already exists
if [[ -d $i ]]
then
- mkdir -p $CHROOTDIR/$FILE
+ $SUDOCMD mkdir -p $CHROOTDIR/$FILE
continue
fi

@@ -122,12 +136,12 @@ do
echo ""
if [[ $OVERWRITE == y ]]
then
- cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
+ $SUDOCMD cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
fi
else
- cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
+ $SUDOCMD cp -a $TEMPDIR/$FILE $CHROOTDIR/$FILE
fi
done

-rm -rf $TEMPDIR
+$SUDOCMD rm -rf $TEMPDIR

diff --git a/scripts/cauldronchr.sh b/scripts/cauldronchr.sh
index 7bde1c6..7220247 100755
--- a/scripts/cauldronchr.sh
+++ b/scripts/cauldronchr.sh
@@ -4,13 +4,6 @@
# assumes $CWD as chroot path and /bin/bash -l as CHROOT_CMD
# if not specified

-SELF=$0
-
-[[ $UID -eq 0 ]] || {
- echo "Enter the root password, please."
- exec su -c "$SELF $*" root
-}
-
CHROOT_DIR=
CHROOT_CMD=

@@ -48,16 +41,30 @@ do
done
shift $(($OPTIND - 1))

+SELF=$0
+SUDOCMD=""
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo) ]]
+ then
+ SUDOCMD="sudo"
+ else
+ echo "Please enter the root password."
+ exec su -c "$SELF $*" root
+ fi
+fi
+
CHROOT_DIR="${CHROOT_DIR:-.}"
[[ $# -gt 0 ]] && CHROOT_CMD="$@"
CHROOT_CMD="${CHROOT_CMD:-/bin/bash -l}"

-mount --bind /dev "$CHROOT_DIR"/dev
-mount --bind /dev/pts "$CHROOT_DIR"/dev/pts
-mount --bind /proc "$CHROOT_DIR"/proc
+$SUDOCMD mount --bind /dev "$CHROOT_DIR"/dev
+$SUDOCMD mount --bind /dev/pts "$CHROOT_DIR"/dev/pts
+$SUDOCMD mount --bind /proc "$CHROOT_DIR"/proc

-chroot "$CHROOT_DIR" $CHROOT_CMD
+$SUDOCMD chroot "$CHROOT_DIR" $CHROOT_CMD

-umount "$CHROOT_DIR"/proc
-umount "$CHROOT_DIR"/dev/pts
-umount "$CHROOT_DIR"/dev
+$SUDOCMD umount "$CHROOT_DIR"/proc
+$SUDOCMD umount "$CHROOT_DIR"/dev/pts
+$SUDOCMD umount "$CHROOT_DIR"/dev
diff --git a/scripts/cleaniso.sh b/scripts/cleaniso.sh
index 3c10948..b4b5d71 100755
--- a/scripts/cleaniso.sh
+++ b/scripts/cleaniso.sh
@@ -34,6 +34,20 @@ do
done
shift $(($OPTIND - 1))

+SELF=$0
+SUDOCMD=""
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo) ]]
+ then
+ SUDOCMD="sudo"
+ else
+ echo "Please enter the root password."
+ exec su -c "$SELF $*" root
+ fi
+fi
+
# Check to make sure we have the right number of arguments
# taking the option flag into account
if [[ $# -eq 1 ]]
@@ -87,11 +101,11 @@ do
then
# chroot and clean a directory using rmdir
echo "Attempting to remove directory
$ISOCHROOT/$DIRT"
- chroot "$ISOCHROOT" rmdir "$DIRT"
+ $SUDOCMD chroot "$ISOCHROOT" rmdir
--ignore-fail-on-non-empty "$DIRT"
else
# chroot and clean an individual file
echo "Attempting to delete $ISOCHROOT/$DIRT"
- chroot "$ISOCHROOT" rm "$DIRT"
+ $SUDOCMD chroot "$ISOCHROOT" rm "$DIRT"
fi
fi
done
diff --git a/scripts/mkiso.sh b/scripts/mkiso.sh
index 6b1d8f3..5948a7c 100755
--- a/scripts/mkiso.sh
+++ b/scripts/mkiso.sh
@@ -42,13 +42,26 @@ do
done
shift $(($OPTIND - 1))

+SELF=$0
+SUDOCMD=""
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo) ]]
+ then
+ SUDOCMD="sudo"
+ else
+ echo "Please enter the root password."
+ exec su -c "$SELF $*" root
+ fi
+fi
ISO_CHROOT=$1
ISO_VERSION=$2

-mkisofs -R -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot
-boot-load-size 4 -boot-info-table -V SOURCEMAGE -o "${ISO_VERSION}.iso"
"$ISO_CHROOT"
+$SUODOCMD mkisofs -R -b isolinux/isolinux.bin -c isolinux/boot.cat
-no-emul-boot -boot-load-size 4 -boot-info-table -V ${ISO_VERSION} -publisher
"Source Mage GNU/Linux" -p "Cauldron" -o "${ISO_VERSION}.iso" "$ISO_CHROOT"

if [[ "$COMPRESS" == yes || -n "$KEEP" ]]
then
- bzip2 -f -v $KEEP "${ISO_VERSION}.iso"
+ $SUODOCMD bzip2 -f -v $KEEP "${ISO_VERSION}.iso"
fi

diff --git a/scripts/mkrelease.sh b/scripts/mkrelease.sh
index 38bcc35..48010bd 100755
--- a/scripts/mkrelease.sh
+++ b/scripts/mkrelease.sh
@@ -39,16 +39,30 @@ do
done
shift $(($OPTIND - 1))

+SELF=$0
+SUDOCMD=""
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo) ]]
+ then
+ SUDOCMD="sudo"
+ else
+ echo "Please enter the root password."
+ exec su -c "$SELF $*" root
+ fi
+fi
+
[[ $# -lt 2 ]] && usage

GRIMOIRE_VER=$(< "$TARGET"/var/lib/sorcery/codex/stable/VERSION)

for file in $(grep -qr '@ISO_VERSION@'
$TARGET/{etc,isolinux,usr/share/doc/smgl.install}/*)
do
- sed -i "s/@ISO_VERSION@/$VERSION/" "$file"
+ $SUDOCMD sed -i "s/@ISO_VERSION@/$VERSION/" "$file"
done

-sed -i "s/@GRIMOIRE_VERSION@/$GRIMOIRE_VER/" "$TARGET"/isolinux/isolinux.msg
+$SUDOCMD sed -i "s/@GRIMOIRE_VERSION@/$GRIMOIRE_VER/"
"$TARGET"/isolinux/isolinux.msg

-$(dirname $0)/mkiso.sh -k "$TARGET" "smgl-$VERSION"
+$SUDOCMD $(dirname $0)/mkiso.sh $ISOCHOWN -kz "$TARGET" "smgl-$VERSION"

diff --git a/scripts/mksystem.sh b/scripts/mksystem.sh
index 6e267b2..0a67030 100755
--- a/scripts/mksystem.sh
+++ b/scripts/mksystem.sh
@@ -31,6 +31,20 @@ do
done
shift $(($OPTIND - 1))

+SELF=$0
+SUDOCMD=""
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo) ]]
+ then
+ SUDOCMD="sudo"
+ else
+ echo "Please enter the root password."
+ exec su -c "$SELF $*" root
+ fi
+fi
+
SYSDIR=${1:-system}
SYSTAR="${2:-$(basename $SYSDIR).tar.bz2}"

@@ -41,7 +55,7 @@ SYSTAR="${2:-$(basename $SYSDIR).tar.bz2}"
[[ -z $SYSDIR ]] && usage

cd $SYSDIR
-tar $VERBOSE -jcf "$SYSTAR" *
+$SUDOCMD tar $VERBOSE -jcf "$SYSTAR" *
echo "Output written to: $SYSTAR"

exit



  • [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (93594dd2baf7eecd19bc508efbe394cf20c2e95d), Justin Boffemmyer, 10/13/2008

Archive powered by MHonArc 2.6.24.

Top of Page