livecd: functions-live, remaster/livecd_create, remaster/livecd_ge...
havner
havner at pld-linux.org
Tue Jul 4 14:29:35 CEST 2006
Author: havner Date: Tue Jul 4 12:29:35 2006 GMT
Module: livecd Tag: HEAD
---- Log message:
- more functions for remaster scripts
---- Files affected:
livecd:
functions-live (1.12 -> 1.13)
livecd/remaster:
livecd_create (1.2 -> 1.3) , livecd_gen_initrd (1.6 -> 1.7) , livecd_gen_iso (1.15 -> 1.16) , livecd_remaster_prep (1.14 -> 1.15)
---- Diffs:
================================================================
Index: livecd/functions-live
diff -u livecd/functions-live:1.12 livecd/functions-live:1.13
--- livecd/functions-live:1.12 Mon Feb 27 20:51:46 2006
+++ livecd/functions-live Tue Jul 4 14:29:30 2006
@@ -120,4 +120,72 @@
dmesg | grep "^sr.:" | awk '{print $1}' | sed -e "s/://g;s/sr/scd/g" | sort | uniq
}
+check_root() {
+if [ "$UID" != "0" ]; then
+ echo "You must be root to run this script."
+ exit 1
+fi
+}
+
+check_config() {
+if [ -n "$HOME_ETC" -a -f "$HOME_ETC/.livecd_remaster" ]; then
+ . $HOME_ETC/.livecd_remaster
+elif [ -f ~/.livecd_remaster ]; then
+ . ~/.livecd_remaster
+elif [ "$1" = "create" ]; then
+ echo "There is no config file in your home dir."
+ if [ -d "$HOME_ETC" ]; then
+ P=$HOME_ETC/.livecd_remaster
+ else
+ P=~/.livecd_remaster
+ fi
+ cat >> "$P" << EOF
+# main
+MAINDIR=~/LIVECD
+CD=\$MAINDIR/CD
+INITRD=\$MAINDIR/INITRD
+ROOTFS=\$MAINDIR/ROOTFS
+ISODIR=\$MAINDIR # generated iso will be placed here
+
+# temp
+SQUASHFS=\$MAINDIR/SQUASHFS
+
+# remaster_prep
+MNT_CDROM=/media/cdrom
+MNT_INITRD=\$MAINDIR/mnt_initrd
+MNT_SQUASHFS=\$MAINDIR/mnt_squashfs
+EOF
+ echo "$P generated. Please have a look at this file"
+ echo "and read README before using this script."
+ exit 1
+else
+ echo "There is no config file in your home or \$HOME_ETC dir"
+ exit 1
+fi
+
+[ -d "$MAINDIR" ] || (echo "Main dir: \"$MAINDIR\" does not exist."; exit 1)
+[ -d "$CD" ] || (echo "Cd dir: \"$CD\" does not exist."; exit 1)
+[ -d "$INITRD" ] || (echo "Initrd dir: \"$INITRD\" does not exist."; exit 1)
+[ -d "$ROOTFS" ] || (echo "Rootfs dir: \"$ROOTFS\" does not exist."; exit 1)
+[ -d "$ISODIR" ] || (echo "ISO dir: \"$ISODIR\" does not exist."; exit 1)
+
+[ -d `dirname "$SQUASHFS"` ] || (echo "Parent dir for squashfs: \"`dirname \"$SQUASHFS\"`\" does not exist"; exit 1)
+[ -d `dirname "$MNT_INITRD"` ] || (echo "Parent dir for mounting initrd: \"`dirname \"$MNT_INITRD\"`\" does not exist"; exit 1)
+[ -d `dirname "$MNT_SQUASHFS"` ] || (echo "Parent dir for mounting squashfs: \"`dirname \"$MNT_SQUASHFS\"`\" does not exist"; exit 1)
+
+[ -d "$MNT_CDROM" ] || (echo "CD-ROM mount point: \"$MNT_CDROM\" does not exist."; exit 1)
+
+}
+
+check_deps() {
+while [ "$#" != "0" ]; do
+ if [ ! -f "$1" -a ! -f "`which $1`" ]; then
+ echo "Install $1 before running this script."
+ FAIL=true
+ fi
+ shift
+[ "$FAIL" = "true" ] && exit 1
+done
+}
+
# vi: syntax=sh:shiftwidth=8:
================================================================
Index: livecd/remaster/livecd_create
diff -u livecd/remaster/livecd_create:1.2 livecd/remaster/livecd_create:1.3
--- livecd/remaster/livecd_create:1.2 Tue Jul 4 13:02:21 2006
+++ livecd/remaster/livecd_create Tue Jul 4 14:29:30 2006
@@ -5,21 +5,14 @@
. /etc/rc.d/init.d/functions-live
-if [ -n "$HOME_ETC" -a -f "$HOME_ETC/.livecd_remaster" ]; then
- . "$HOME_ETC/.livecd_remaster"
-elif [ -f ~/.livecd_remaster ]; then
- . ~/.livecd_remaster
-else
- echo "no config file"
- exit 1
-fi
+check_config
cd $ROOTFS
for I in $SYMLINKS; do
if [ -e ".$I" -a ! -h ".$I" -a ! -f "live$I" ]; then
DIR=`dirname $I`
- FIL=`basename $I`
+ #FILE=`basename $I`
DEEP=`echo $DIR | sed "s/[^\/]//g" | wc -c`
mkdir -p "live$DIR"
mv ".$I" "live$DIR"
================================================================
Index: livecd/remaster/livecd_gen_initrd
diff -u livecd/remaster/livecd_gen_initrd:1.6 livecd/remaster/livecd_gen_initrd:1.7
--- livecd/remaster/livecd_gen_initrd:1.6 Tue Jul 4 13:13:16 2006
+++ livecd/remaster/livecd_gen_initrd Tue Jul 4 14:29:30 2006
@@ -4,24 +4,9 @@
# TODO: memtest, isolinux, pci-database (upgrade everything)
-if [ ! $UID = 0 ]; then
- echo "You must run this script as root"
- exit 1
-fi
-
-if [ -n "$HOME_ETC" -a -f "$HOME_ETC/.livecd_remaster" ]; then
- . $HOME_ETC/.livecd_remaster
-elif [ -f ~/.livecd_remaster ]; then
- . ~/.livecd_remaster
-else
- echo "There is no config file in your home or \$HOME_ETC dir"
- exit 1
-fi
-
-if [ ! -f "`which genromfs`" ]; then
- echo "Install genromfs (poldek -i genromfs) before running this script"
- exit 1
-fi
+check_root
+check_config
+check_deps genromfs
# You don't even have to tell mi it's ugly
initrd_dirs=" drivers \
================================================================
Index: livecd/remaster/livecd_gen_iso
diff -u livecd/remaster/livecd_gen_iso:1.15 livecd/remaster/livecd_gen_iso:1.16
--- livecd/remaster/livecd_gen_iso:1.15 Mon Feb 27 20:51:47 2006
+++ livecd/remaster/livecd_gen_iso Tue Jul 4 14:29:30 2006
@@ -5,34 +5,9 @@
# Source function library
. /etc/rc.d/init.d/functions-live
-if [ ! $UID = 0 ]; then
- echo "You must run this script as root"
- exit 1
-fi
-
-if [ -n "$HOME_ETC" -a -f "$HOME_ETC/.livecd_remaster" ]; then
- . $HOME_ETC/.livecd_remaster
-elif [ -f ~/.livecd_remaster ]; then
- . ~/.livecd_remaster
-else
- echo "There is no config file in your home or \$HOME_ETC dir"
- exit 1
-fi
-
-if [ ! -x "`which busybox`" ]; then
- echo "Install busybox (poldek -i busybox) before running this script"
- exit 1
-fi
-
-if [ ! -x "`which mksquashfs`" ]; then
- echo "Install squashfs (poldek -i squashfs) before running this script"
- exit 1
-fi
-
-if [ ! -x "`which mkisofs`" ]; then
- echo "Install mkisofs (poldek -i cdrtools-mkisofs) before running this script"
- exit 1
-fi
+check_root
+check_config
+check_deps busybox mksquashfs mkisofs
# preparation, external scripts
================================================================
Index: livecd/remaster/livecd_remaster_prep
diff -u livecd/remaster/livecd_remaster_prep:1.14 livecd/remaster/livecd_remaster_prep:1.15
--- livecd/remaster/livecd_remaster_prep:1.14 Mon Feb 27 17:28:48 2006
+++ livecd/remaster/livecd_remaster_prep Tue Jul 4 14:29:30 2006
@@ -2,40 +2,11 @@
# Lukasz Pawelczyk <havner at pld-linux.org> 2004
# $Id$
-if [ ! $UID = 0 ]; then
- echo "You must run this script as root"
- exit 1
-fi
+check_root
+check_config create
-if [ -n "$HOME_ETC" -a -f "$HOME_ETC/.livecd_remaster" ]; then
- . "$HOME_ETC/.livecd_remaster"
-elif [ -f ~/.livecd_remaster ]; then
- . ~/.livecd_remaster
-else
- echo "There is no config file in your home dir"
- cat >> ~/.livecd_remaster << EOF
-# main
-MAINDIR=~/LIVECD
-CD=\$MAINDIR/CD
-INITRD=\$MAINDIR/INITRD
-ROOTFS=\$MAINDIR/ROOTFS
-ISODIR=\$MAINDIR # generated iso will be placed here
-
-# temp
-SQUASHFS=\$MAINDIR/SQUASHFS
-
-# remaster_prep
-MNT_CDROM=/media/cdrom
-MNT_INITRD=\$MAINDIR/mnt_initrd
-MNT_SQUASHFS=\$MAINDIR/mnt_squashfs
-EOF
- echo "${HOME}/.livecd_remaster generated. Please have a look at this file"
- echo "and read README before using this script."
- exit 1
-fi
-
-if [ -d $MAINDIR ]; then
- echo "$MAINDIR already exists"
+if [ -d "$MAINDIR" ]; then
+ echo "$MAINDIR already exists."
exit 1
fi
================================================================
---- CVS-web:
http://cvs.pld-linux.org/livecd/functions-live?r1=1.12&r2=1.13&f=u
http://cvs.pld-linux.org/livecd/remaster/livecd_create?r1=1.2&r2=1.3&f=u
http://cvs.pld-linux.org/livecd/remaster/livecd_gen_initrd?r1=1.6&r2=1.7&f=u
http://cvs.pld-linux.org/livecd/remaster/livecd_gen_iso?r1=1.15&r2=1.16&f=u
http://cvs.pld-linux.org/livecd/remaster/livecd_remaster_prep?r1=1.14&r2=1.15&f=u
More information about the pld-cvs-commit
mailing list