Skip to Content.
Sympa Menu

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

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 (720289033ed09d08c369c1d0f67ac8e23d9d1f43)
  • Date: Wed, 19 Nov 2008 14:03:12 -0600

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

scripts/add-sauce.sh | 2 -
scripts/cauldronchr.sh | 2 -
scripts/cleaniso.sh | 2 -
scripts/mkinitrd.sh | 79
++++++++++++++++++++++++++++++++++++++----------
scripts/mkiso.sh | 2 -
scripts/mkrelease.sh | 2 -
scripts/mksystem.sh | 2 -
scripts/purify.sh | 80
+++++++++++++++++++++++++++++++++++++++++++++++++
scripts/spellcaster.sh | 2 -
9 files changed, 150 insertions(+), 23 deletions(-)

New commits:
commit 720289033ed09d08c369c1d0f67ac8e23d9d1f43
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/*.sh: don't show output on `which sudo`

The output for STDOUT was redirected to /dev/null, but if sudo wasn't
found in the path, which would output to STDERR. This commit ensures
that there is no output.

commit 1446e940eac29b40b3936ec87021cead8fda0e72
Author: Justin Boffemmyer <flux AT sourcemage.org>
Commit: Justin Boffemmyer <flux AT sourcemage.org>

scripts/mkinitrd.sh: standardize to other scripts

Add sudo and su code, and standardize usage printing and argument
processing with how the other scripts do it.

diff --git a/scripts/add-sauce.sh b/scripts/add-sauce.sh
index 2c857b8..85faa5f 100755
--- a/scripts/add-sauce.sh
+++ b/scripts/add-sauce.sh
@@ -45,7 +45,7 @@ SELF="$0"

if [[ $UID -ne 0 ]]
then
- if [[ -x $(which sudo > /dev/null) ]]
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
then
exec sudo "$SELF $*"
else
diff --git a/scripts/cauldronchr.sh b/scripts/cauldronchr.sh
index b009ae4..c73a330 100755
--- a/scripts/cauldronchr.sh
+++ b/scripts/cauldronchr.sh
@@ -45,7 +45,7 @@ SELF=$0

if [[ $UID -ne 0 ]]
then
- if [[ -x $(which sudo > /dev/null) ]]
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
then
exec sudo "$SELF $*"
else
diff --git a/scripts/cleaniso.sh b/scripts/cleaniso.sh
index 75d1b86..9af772b 100755
--- a/scripts/cleaniso.sh
+++ b/scripts/cleaniso.sh
@@ -38,7 +38,7 @@ SELF=$0

if [[ $UID -ne 0 ]]
then
- if [[ -x $(which sudo > /dev/null) ]]
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
then
exec sudo "$SELF $*"
else
diff --git a/scripts/mkinitrd.sh b/scripts/mkinitrd.sh
index 6fcd81f..2137750 100755
--- a/scripts/mkinitrd.sh
+++ b/scripts/mkinitrd.sh
@@ -1,18 +1,65 @@
#!/bin/bash
# This script will crank out an initrd image for the ISO to use.

-if [[ $# != 2 ]] ;then
- echo "Usage: $0 <path to chroot> <kernel version>"
- echo "(path to chroot can be / if you want to be sloppy)"
- exit 1
-fi >&2
-
-CHROOT_DIR=$1
+function usage() {
+ cat << EndUsage
+Usage: $(basename $0) [-o OUTPUT_FILE] /path/to/target ISO_KERNEL_VERSION
+
+Generates an initrd using /path/to/target. The output file is named initrd.gz
+and is placed in the current working directory by default, but can be
+overridden by the -o option. This script requires superuser privileges.
+
+Required:
+ /path/to/target
+ The target directory you would like to chroot to. Defaults to
+ current working directory.
+
+ ISO_KERNEL_VERSION
+ A string that specifies the version of the kernel to use.
Typically
+ you will only have one kernel version in your iso build directory,
+ but there's nothing which prevents you from having more than one,
+ so you need to specify the version the initrd will be built
+ against.
+Options:
+ -o FILENAME
+ Specify the output file as FILENAME (can include a path prefix).
+ Defaults to "initrd.gz" in the current working directory.
+
+ -h Shows this help information.
+EndUsage
+ exit 1
+} >&2
+
+while getopts ":o:h" Options
+do
+ case $Options in
+ o ) OUTPUT="$OPTARG" ;;
+ h ) usage ;;
+ * ) echo "Unrecognized option" >&2 && usage ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+SELF=$0
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
+ then
+ exec sudo "$SELF $*"
+ else
+ echo "Please enter the root password."
+ exec su -c "$SELF $*" root
+ fi
+fi
+
+[[ $# -ne 2 ]] && usage
+ISO_DIR=$1
KERNEL_VERSION=$2

-if ! [[ -d $CHROOT_DIR/lib/modules/$KERNEL_VERSION/kernel ]] ;then
+if ! [[ -d $ISO_DIR/lib/modules/$KERNEL_VERSION/kernel ]] ;then
echo "Chroot failed sanity check:"
- echo "Unable to find $CHROOT_DIR/lib/modules/$KERNEL_VERSION/kernel"
+ echo "Unable to find $ISO_DIR/lib/modules/$KERNEL_VERSION/kernel"
exit 2
fi >&2

@@ -29,7 +76,7 @@ EXECDIRS=(bin sbin usr/bin usr/sbin)
#---------------------------------------------------------------------
# Used to implicitly install linked-against-libs to the initrd with a binary
function libscan() {
- chroot $CHROOT_DIR /usr/bin/ldd "$1" |
+ chroot $ISO_DIR /usr/bin/ldd "$1" |
grep '/' |
cut -f 2 |
sed -e 's/.*=> //' |
@@ -41,7 +88,7 @@ function libscan() {
# by running libscan (ldd returns symlinks if that's what the binary
# links to). The leading '/' is removed for convenience.
function reallib() {
- chroot $CHROOT_DIR readlink -f $1 |
+ chroot $ISO_DIR readlink -f $1 |
sed -e 's/^[/]//'
}

@@ -67,7 +114,7 @@ function install_prog() {
for prog in $* ;do
# find executable
progpath=$(my_which $prog) &&
- # install executable (path will be relative to $CHROOT_DIR)
+ # install executable (path will be relative to $ISO_DIR)
cp --parents -f $progpath $INITRDROOT &&
# install needed libs
for i in $(libscan $progpath) ; do
@@ -128,9 +175,8 @@ fi >&2
rm -rf $INITRDROOT
mkdir -p $INITRDROOT

-OLDWD=$PWD
# Unless otherwise noted, this is our working directory.
-cd $CHROOT_DIR >/dev/null
+pushd $ISO_DIR >/dev/null

# Create all dirs we need on the initrd
echo "Creating dirs..."
@@ -167,7 +213,7 @@ touch $INITRDROOT/var/log/dmesg
# Add kernel modules that are supposed to be on the iso
echo "adding kernel modules"
mkdir -p ${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
-pushd $CHROOT_DIR/lib/modules/${KERNEL_VERSION}/kernel >/dev/null
+pushd $ISO_DIR/lib/modules/${KERNEL_VERSION}/kernel >/dev/null
while read line ; do
cp -pr --parents ./${line}
${INITRDROOT}/lib/modules/${KERNEL_VERSION}/kernel
done <$MYDIR/data/initrd.kernel
@@ -195,7 +241,8 @@ rm -f ${INITRDROOT}/depmod

# The initrd is complete now.
echo "Make the initrd"
-mk_initrd_file $INITRDROOT $OLDWD/initrd.gz
+popd >/dev/null
+mk_initrd_file $INITRDROOT "$OUTPUT"

echo "cleaning up..."
rm -rf ${INITRDROOT}
diff --git a/scripts/mkiso.sh b/scripts/mkiso.sh
index 7dbc39c..ba736fa 100755
--- a/scripts/mkiso.sh
+++ b/scripts/mkiso.sh
@@ -48,7 +48,7 @@ SELF=$0

if [[ $UID -ne 0 ]]
then
- if [[ -x $(which sudo > /dev/null) ]]
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
then
exec sudo "$SELF $*"
else
diff --git a/scripts/mkrelease.sh b/scripts/mkrelease.sh
index 18cb42e..e536a72 100755
--- a/scripts/mkrelease.sh
+++ b/scripts/mkrelease.sh
@@ -46,7 +46,7 @@ SELF=$0

if [[ $UID -ne 0 ]]
then
- if [[ -x $(which sudo > /dev/null) ]]
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
then
exec sudo "$SELF $*"
else
diff --git a/scripts/mksystem.sh b/scripts/mksystem.sh
index b4bacf7..6140159 100755
--- a/scripts/mksystem.sh
+++ b/scripts/mksystem.sh
@@ -35,7 +35,7 @@ SELF=$0

if [[ $UID -ne 0 ]]
then
- if [[ -x $(which sudo > /dev/null) ]]
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
then
exec sudo "$SELF $*"
else
diff --git a/scripts/purify.sh b/scripts/purify.sh
new file mode 100644
index 0000000..f47e0e0
--- /dev/null
+++ b/scripts/purify.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+# The intent of this script is to ensure some starting sanity for producing
ISO
+# builds from the basesystem tarballs. This is necessary because currently
+# there are no sanity checks or testing procedures in place during the
+# production of the basesystem tarballs, so sometimes things can sneak in.
+
+# The main source of problems is the /etc hierarchy.
+
+CLEANALL=false
+
+function usage() {
+ cat <<EndUsage
+Usage: $(basename $0) [-ch] /path/to/target
+
+Ensures starting sanity on a chroot directory by sweeping it for files that
+shouldn't be there and deleting them. In the future, this may include adding
+files as well if the need arises.
+
+Require:
+ /path/to/target
+ The path to the target directory you wish to purify.
+
+Options:
+ -c Run cleaniso.sh -a on the target as well.
+
+ -h Shows this help information
+EndUsage
+ exit 1
+} >&2
+
+while getopts ":ah" Option
+do
+ case $Option in
+ c ) CLEANALL=true ;;
+ h ) usage ;;
+ * ) echo "Unrecognized option." >&2 && usage ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+SELF=$0
+
+if [[ $UID -ne 0 ]]
+then
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
+ then
+ exec sudo "$SELF $*"
+ 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
+[[ $# -eq 1 ]] || usage
+
+# location of ISO chroot to clean from
+TARGET="$1"
+shift
+
+# Ensure sanity of chroot by making sure that it has
+# rm and rmdir.
+if ! [[ -e "$TARGET/bin/rm" ]]
+then
+ echo "Error: /bin/rm not found in $TARGET" >&2
+ exit 2
+fi
+if ! [[ -e "$TARGET/bin/rmdir" ]]
+then
+ echo "Error: /bin/rmdir not found in $TARGET" >&2
+ exit 2
+fi
+
+# if called with -c, run cleaniso.sh
+$CLEANALL && cleaniso.sh -a "$TARGET"
+
+[[ -e "$TARGET"/etc/udev/rules.d/70-persistent-net.rules ]] && rm
"$TARGET"/etc/udev/rules.d/70-persistent-net.rules
+
diff --git a/scripts/spellcaster.sh b/scripts/spellcaster.sh
index 6c8f205..43d5241 100755
--- a/scripts/spellcaster.sh
+++ b/scripts/spellcaster.sh
@@ -44,7 +44,7 @@ SELF="$0"

if [[ $UID -ne 0 ]]
then
- if [[ -x $(which sudo > /dev/null) ]]
+ if [[ -x $(which sudo > /dev/null 2>&1) ]]
then
exec sudo "$SELF $*"
else



  • [SM-Commit] GIT changes to test cauldron by Justin Boffemmyer (720289033ed09d08c369c1d0f67ac8e23d9d1f43), Justin Boffemmyer, 11/19/2008

Archive powered by MHonArc 2.6.24.

Top of Page