Commit bcdce468 authored by Michael Liang's avatar Michael Liang

Merge branch 'master' of git:./le5/unstable

parents d41f7da8 1f23a12c

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

This module is slightly different form le-gera-iso and will be merged to the latter as soon as possible.
#!/bin/bash
# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-base
#
# le-base is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# This script is included in others scripts to use common functions
PREFIX="$(dirname "$(readlink -f $0)")"
checkStatus()
{
if [ -n "$(grep "$DEVICE" /etc/mtab)" ]; then
echo "Error: /dev/$DEVICE is mounted according with mtab"
return 1
fi
return 0
}
checkUser()
{
if ! [ -w /dev/$DEVICE ]; then
echo "Error: Please, execute this script as root!"
return 1
fi
return 0
}
loadConf()
{
if [ $# -gt 1 -a -f "$1" ]; then
conf=$(readlink -f $1)
elif [ -f "$PREFIX/"*.conf ]; then
conf="$PREFIX/"*.conf
else
echo "Error: Config file not found."
exit 1
fi
#read config file and declares only valid vars.
while read var; do
egrep -qi "^[a-z_]+=" <<< "$var" &&
eval "export $(sed -e "s/DISTNAME/$2/g" <<< $var)"
done < $conf
return 0
}
removeMountList()
{
grep -v "$1" $MOUNTLIST > $MOUNTLIST.tmp
mv -f $MOUNTLIST.tmp $MOUNTLIST
}
checkMountedFS()
{
touch $MOUNTLIST
for file in $(sort -r $MOUNTLIST); do
if ! ( umount -l $file && removeMountList $file ); then
echo "Error: While umounting $file"
return 1
fi
done
return 0
}
TMP="$PREFIX/tmp/tmp-DISTNAME"
LOGDIR="$PREFIX/log"
LOGINFO="true"
DISTROBASE=ubuntu-12.04
RC="alpha1"
DISTRO=Linux_Educacional_5
SCRIPTSDIR="$PREFIX/enabled-scripts"
INSTLIST="$PREFIX/pckg-list/install.list-DISTNAME"
RMLIST="$PREFIX/pckg-list/remove.list"
CDDIR="$TMP/extract-cd"
CHROOTDIR="$TMP/live-image"
MOUNTLIST="$TMP/mountlist"
SQUASHIMAGE="$PREFIX/squashfs-root"
DISTROISO="$PREFIX/iso/$DISTRO-DISTNAME-i386"
TEMPLATES="$PREFIX/templates"
LEHOST="windu.c3sl.ufpr.br/mc"
LEMIRROR="mc-testing"
#!/bin/bash
# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
#
# This file is part of le-base
#
# le-base is free software; you can redistNameribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distNameributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#------------------------------------------------------------------------------
editDistro()
{
log "Editing $DISTROBASE ..."
initFiles
# Edits live image
for file in $(ls $SCRIPTSDIR); do
if [ -x "$SCRIPTSDIR/$file" ] && egrep -q '^[0-9]{2}-[a-z-]+' <<< "$file"; then
echo $file
#read -p "PAUSADO ..."
if ! "$SCRIPTSDIR/$file" $1; then
log "Error: While running the $SCRIPTSDIR/$file"
return 1
fi
fi
done
return 0
}
regenerateManifest()
{
log "Regenerating manifest list ..."
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
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
# ( printf "$package "; chroot $CHROOTDIR apt-cache showpkg $package |
# grep "^[0-9]" | tail -n1 | cut -d ' ' -f1 ) >> \
# $CDDIR/casper/filesystem.manifest-desktop
#done
return 0
}
compressFS()
{
log "Compressing squash image ..."
if [ -n "$(cat $MOUNTLIST)" ]; then
log "Error to umount $(cat $MOUNTLIST | tr '\n' ' ')"
return 1
fi
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
return 0
}
extractISO()
{
log "Extracting $1 ..."
initFiles
mount -o loop $1 $TMP/$DISTROBASE && log "$TMP/$DISTROBASE" >> $MOUNTLIST
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
umount $TMP/$DISTROBASE && removeMountList $TMP/$DISTROBASE
return 0
}
createISO()
{
log "Generating live ISO ..."
# Calculates MD5
cd $CDDIR/
rm -f md5sum.txt
find -type f -print0 | xargs -0 md5sum |
egrep -v 'isolinux/boot.cat|md5sum.txt' | tee md5sum.txt
# Generates ISO file
mkisofs -D -r -V "$DISTRO" -cache-inodes -J -l -b \