Commit 67f4a11d authored by Diego Pasqualin's avatar Diego Pasqualin

Merge branch 'le-gera-iso'

parents ccbbad53 c734039f
......@@ -22,7 +22,8 @@
# This script is included in others scripts to use common functions
PREFIX="$(dirname "$(readlink -f $0)")"
DIR=$(readlink -f "$0")
PREFIX=`dirname "$(echo "$DIR")"`
checkStatus()
{
......@@ -46,32 +47,33 @@ checkUser()
loadConf()
{
if [ $# -gt 1 -a -f "$1" ]; then
conf=$(readlink -f $1)
conf=$(readlink -f "$1")
elif [ -f "$PREFIX/"*.conf ]; then
conf="$PREFIX/"*.conf
else
echo "Error: Config file not found."
echo "Error: Config file for $2 not found."
exit 1
fi
#read config file and declares only valid vars.
BASENAME=`basename $(echo "$2")`
while read var; do
egrep -qi "^[a-z_]+=" <<< "$var" &&
eval "export $(sed -e "s/DISTNAME/$2/g" <<< $var)"
done < $conf
eval "export $(echo $var | sed -e "s@DISTNAME@$2@g" -e "s/BASENAME/$BASENAME/g")"
done < "$conf"
return 0
}
removeMountList()
{
grep -v "$1" $MOUNTLIST > $MOUNTLIST.tmp
mv -f $MOUNTLIST.tmp $MOUNTLIST
grep -v "$1" "$MOUNTLIST" > "$MOUNTLIST".tmp
mv -f "$MOUNTLIST".tmp "$MOUNTLIST"
}
checkMountedFS()
{
touch $MOUNTLIST
for file in $(sort -r $MOUNTLIST); do
touch "$MOUNTLIST"
for file in $(sort -r "$MOUNTLIST"); do
if ! ( umount -l $file && removeMountList $file ); then
echo "Error: While umounting $file"
return 1
......
TMP="/dev/shm/tmp/DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/le5"
LEMIRROR="le5-testing"
TMP="/dev/shm/tmp/DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/le5"
LEMIRROR="le5-testing"
TMP="/dev/shm/tmp/tmp-DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/mc"
LEMIRROR="mc-testing"
DEBIAN_FRONTEND="noninteractive"
\ No newline at end of file
TMP="/dev/shm/tmp/tmp-DISTNAME"
LOGDIR="$PREFIX/log/DISTNAME"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts/DISTNAME"
INSTLIST="$PREFIX/pckg-list/DISTNAME/install.list"
RMLIST="$PREFIX/pckg-list/DISTNAME/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/DISTNAME/$DISTRO-BASENAME-i386"
TEMPLATES="$PREFIX/templates/DISTNAME"
LEHOST="windu.c3sl.ufpr.br/mc"
LEMIRROR="mc-testing"
DEBIAN_FRONTEND="noninteractive"
\ No newline at end of file
TMP="$PREFIX/tmp/tmp-DISTNAME"
TMP="/dev/shm/tmp/tmp-DISTNAME"
LOGDIR="$PREFIX/log"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/scripts"
SCRIPTSDIR="$PREFIX/enabled-scripts"
INSTLIST="$PREFIX/pckg-list/install.list-DISTNAME"
RMLIST="$PREFIX/pckg-list/remove.list"
CDDIR="$TMP/extract-cd"
......
......@@ -29,12 +29,12 @@ editDistro()
initFiles
# Edits live image
for file in $(ls $SCRIPTSDIR); do
for file in $(ls "$SCRIPTSDIR"); do
if [ -x "$SCRIPTSDIR/$file" ] && egrep -q '^[0-9]{2}-[a-z-]+' <<< "$file"; then
echo $file
echo "$file"
#read -p "PAUSADO ..."
if ! "$SCRIPTSDIR/$file" $1; then
log "Error: While running the $SCRIPTSDIR/$file"
log "Error: While running the "$SCRIPTSDIR/$file""
return 1
fi
fi
......@@ -46,16 +46,16 @@ editDistro()
regenerateManifest()
{
log "Regenerating manifest list ..."
chmod +w $CDDIR/casper/filesystem.manifest
chroot $CHROOTDIR dpkg-query -W --showformat='${Package} ${Version}\n' > \
$CDDIR/casper/filesystem.manifest
chmod +w "$CDDIR"/casper/filesystem.manifest
chroot "$CHROOTDIR" dpkg-query -W --showformat='${Package} ${Version}\n' > \
"$CDDIR"/casper/filesystem.manifest
#cp $CDDIR/casper/filesystem.manifest \
# $CDDIR/casper/filesystem.manifest-desktop
cat $INSTLIST-remove >> $CDDIR/casper/filesystem.manifest-remove
cat "$INSTLIST"-remove >> "$CDDIR"/casper/filesystem.manifest-remove
for package in $(cat $CDDIR/casper/filesystem.manifest-remove | cut -d '=' -f1 | grep -v "^#"); do
if ! grep -q "^$package " $CDDIR/casper/filesystem.manifest; then
sed -i "/$package/d" $CDDIR/casper/filesystem.manifest-remove
for package in $(cat "$CDDIR"/casper/filesystem.manifest-remove | cut -d '=' -f1 | grep -v "^#"); do
if ! grep -q "^$package " "$CDDIR"/casper/filesystem.manifest; then
sed -i "/$package/d" "$CDDIR"/casper/filesystem.manifest-remove
fi
done
#for package in $(cat $INSTLIST-desktop | cut -d '=' -f1 | grep -v "^#"); do
......@@ -75,10 +75,10 @@ compressFS()
return 1
fi
rm -f $CDDIR/casper/filesystem.squashfs
mksquashfs $CHROOTDIR $CDDIR/casper/filesystem.squashfs -comp gzip
rm -f "$CDDIR"/casper/filesystem.squashfs
mksquashfs "$CHROOTDIR" "$CDDIR"/casper/filesystem.squashfs -comp gzip
du -sx --block-size=1 $CHROOTDIR | cut -f1 > $CDDIR/casper/filesystem.size
du -sx --block-size=1 "$CHROOTDIR" | cut -f1 > "$CDDIR"/casper/filesystem.size
return 0
}
......@@ -88,15 +88,15 @@ extractISO()
log "Extracting $1 ..."
initFiles
mount -o loop $1 $TMP/$DISTROBASE && log "$TMP/$DISTROBASE" >> $MOUNTLIST
mount -o loop $1 "$TMP"/"$DISTROBASE" && log "$TMP/$DISTROBASE" >> "$MOUNTLIST"
rsync --exclude=/casper/filesystem.squashfs -a $TMP/$DISTROBASE/ $CDDIR\
rsync --exclude=/casper/filesystem.squashfs -a "$TMP"/"$DISTROBASE"/ "$CDDIR"\
|| return 1
unsquashfs $TMP/$DISTROBASE/casper/filesystem.squashfs || return 1
mv -f $SQUASHIMAGE $CHROOTDIR || return 1
unsquashfs "$TMP"/"$DISTROBASE"/casper/filesystem.squashfs || return 1
mv -f "$SQUASHIMAGE" "$CHROOTDIR" || return 1
umount $TMP/$DISTROBASE && removeMountList $TMP/$DISTROBASE
umount "$TMP"/"$DISTROBASE" && removeMountList "$TMP"/"$DISTROBASE"
return 0
}
......@@ -106,7 +106,7 @@ createISO()
log "Generating live ISO ..."
# Calculates MD5
cd $CDDIR/
cd "$CDDIR"/
rm -f md5sum.txt
find -type f -print0 | xargs -0 md5sum |
egrep -v 'isolinux/boot.cat|md5sum.txt' | tee md5sum.txt
......@@ -114,7 +114,7 @@ createISO()
# Generates ISO file
mkisofs -D -r -V "$DISTRO" -cache-inodes -J -l -b \
isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size \
4 -boot-info-table -o $DISTROISO.iso $CDDIR
4 -boot-info-table -o "$DISTROISO".iso "$CDDIR"
log "Generating iso checksum ..."
md5sum "$DISTROISO.iso" > "$DISTROISO.md5"
......@@ -122,21 +122,21 @@ createISO()
initFiles()
{
mkdir -p $TMP || return 1
mkdir -p $TMP/$DISTROBASE $CDDIR $LOGDIR || return 1
touch $MOUNTLIST || return 1
mkdir -p "$TMP" || return 1
mkdir -p "$TMP"/"$DISTROBASE" "$CDDIR" "$LOGDIR" || return 1
touch "$MOUNTLIST" || return 1
}
replaceIso()
{
if [ -e $CDDIR ]; then
if [ -e "$CDDIR" ]; then
log "Want to replace the current image? [y/N]"
read ack
if [ "$ack" == "y" ]; then
log "Cleaning temporary directory ..."
rm -rf $TMP/* $CHROOTDIR $CDDIR $SQUASHIMAGE || return 6
#$0 -clean -dist $1 || exit 6
rm -rf "$TMP"/* "$CHROOTDIR" "$CDDIR" "$SQUASHIMAGE" || return 6
#$0 --clean --dist $1 || exit 6
else
log "Extraction canceled!"
return 1
......@@ -148,7 +148,7 @@ replaceIso()
log()
{
if $LOGINFO && [ "$1" ]; then
if "$LOGINFO" && [ "$1" ]; then
echo "$@" | tee -a "$LOGFILE"
logger -t le-gera-iso "$@"
elif [ "$1" ]; then
......@@ -161,7 +161,8 @@ log()
#------------------------------------------------------------------------------
# Sets configuration variables
. "$(dirname "$(readlink -f $0)")/common.sh"
DIR=$(readlink -f "$0")
. "`dirname "$(echo "$DIR")"`/common.sh"
nextDist=false
nextAll=false
......@@ -173,21 +174,21 @@ edit=false
for opc in $*; do
case "$opc" in
-dist)
--dist)
dist=true
nextDist=true