Commit f9495558 authored by Daniel Bissani Furlin's avatar Daniel Bissani Furlin
Browse files

Merge branch 'modularize' into 'develop'

Modularize

See merge request !1
parents 82512507 02825b57
chroot
image
*.swp
iso/**/*.iso
Essa é a versão modular do script de geração de isos do le6.
Este script gera uma iso de acordo com os scripts habilitados na pasta ´scripts-enabled´
para cada distribuição, este modelo está configurado para funcionar com a distrubuição
le6/testing, para criar uma nova distribuição basta criar uma pasta com o nome da nova
distribuição nos diretórios, pkg-list, que contém as listas de pacotes que devem ser
instalados e removidos, em scripts-enabled, e linkar os scripts que devem ser executados
para a geração da iso. iso, onde será criada a imagem. log, onde será criado o arquivo
de log, e em conf, e nessa pasta criar um arquivo de configuração para a geração da iso.
Esta versão não mantem o diretório base "limpo", ou seja, a cada execução as modificações
para a geração da iso se mantém.
#!/bin/bash
cleanTmpFiles()
{
rm -rf ${TMP}
closeChroot
}
emergency_shell()
{
cleanTmpFiles
echo "FATAL ERROR!"
exit 1
}
log()
{
local _TYPE=$1
local _TXT=$(echo $@ | cut -d' ' -f2-)
local _FILE=${PREFIX}/log/${DIST}/${_TYPE}-create-iso.log
if [ "$_TXT" ]; then
if [ "$LOGINFO" ]; then
echo "${_TYPE}: ${_TXT}" | tee -a $_FILE
else
echo "${_TYPE}: ${_TXT}"
fi
fi
if [ "${_TYPE}" == "ERROR" ]; then
emergency_shell
fi
}
removeMountList()
{
grep -v "$1" ${MOUNTLIST} > ${MOUNTLIST}.tmp
mv -f ${MOUNTLIST}.tmp ${MOUNTLIST}
}
initChroot()
{
local _DIST=$1
mkdir -p ${CHROOTDIR}/var/log/create-iso/
if [ ! -d ${PREFIX}/log/${_DIST} ]; then
mkdir -p ${PREFIX}/log/${_DIST}
fi
cp /etc/resolv.conf ${CHROOTDIR}/etc/
cp /etc/hosts ${CHROOTDIR}/etc/
mount --bind /dev ${CHROOTDIR}/dev && echo "${CHROOTDIR}/dev" >> ${MOUNTLIST}
mount --bind /sys ${CHROOTDIR}/sys && echo "${CHROOTDIR}/sys" >> ${MOUNTLIST}
mount --bind /dev/pts ${CHROOTDIR}/dev/pts && echo "${CHROOTDIR}/dev/pts" \
>> ${MOUNTLIST}
mount --bind ${PREFIX}/log/${_DIST}/ ${CHROOTDIR}/var/log/create-iso/ && \
echo "${CHROOTDIR}/var/log/create-iso/" >> ${MOUNTLIST} || \
log ERROR "Failed to mount log dir."
mount --bind /proc ${CHROOTDIR}/proc && echo "${CHROOTDIR}/proc" >> ${MOUNTLIST}
chroot ${CHROOTDIR} dbus-uuidgen > ${CHROOTDIR}/var/lib/dbus/machine-id
# Prevent services from being started in the chrooted environment
rm -rf ${CHROOTDIR}/fakebin
chroot ${CHROOTDIR} mkdir /fakebin
chroot ${CHROOTDIR} ln -s /bin/true /fakebin/initctl
chroot ${CHROOTDIR} ln -s /bin/true /fakebin/invoke-rc.d
chroot ${CHROOTDIR} ln -s /bin/true /fakebin/restart
chroot ${CHROOTDIR} ln -s /bin/true /fakebin/start
chroot ${CHROOTDIR} ln -s /bin/true /fakebin/stop
chroot ${CHROOTDIR} ln -s /bin/true /fakebin/service
chroot ${CHROOTDIR} ln -s /bin/true /fakebin/start-stop-daemon
}
closeChroot()
{
chroot ${CHROOTDIR} apt-get clean
rm -rf ${CHROOTDIR}/fakebin
rm -rf ${CHROOTDIR}/root/.bash_history ${CHROOTDIR}/var/lib/dbus/machine-id
rm -rf ${CHROOTDIR}/tmp/*
if grep -qs ${CHROOTDIR}/dev/pts ${MOUNTLIST}; then
umount -l ${CHROOTDIR}/dev/pts && removeMountList ${CHROOTDIR}/dev/pts
fi
echo "1"
if grep -qs ${CHROOTDIR}/sys ${MOUNTLIST}; then
umount -l ${CHROOTDIR}/sys && removeMountList ${CHROOTDIR}/sys
fi
if grep -qs ${CHROOTDIR}/proc ${MOUNTLIST}; then
umount -l ${CHROOTDIR}/proc && removeMountList ${CHROOTDIR}/proc
fi
if grep -qs ${CHROOTDIR}/dev ${MOUNTLIST}; then
umount -l ${CHROOTDIR}/dev && removeMountList ${CHROOTDIR}/dev
fi
if grep -qs ${CHROOTDIR}/var/log/create-iso/ ${MOUNTLIST}; then
umount -l ${CHROOTDIR}/var/log/create-iso/ \
&& removeMountList ${CHROOTDIR}/var/log/create-iso/
fi
rm -rf ${CHROOTDIR}/var/log/create-iso/
}
addToChrootFile()
{
local _FILE=$1
local _CMD=$2
echo "$_CMD \\" >> "$_FILE"
echo '|| /bin/bash' >> "$_FILE"
}
execChroot()
{
_FILE=$1
_DIR=$2
chmod +x $_FILE
cp $_FILE ${CHROOTDIR}/tmp/exec.sh
chroot $_DIR /tmp/exec.sh
return $?
TMP=/dev/shm/${_DIST}/
ISOLINUX=${PREFIX}/src/isolinux/
DISTRO=Linux_Educacional_6
CHROOTDIR=${PREFIX}/chroot/
SCRIPTSDIR=${PREFIX}/scripts-enabled/${_DIST}/
RMLIST=${PREFIX}/pkg-list/${_DIST}/remove.list
INSTLIST=${PREFIX}/pkg-list/${_DIST}/install.list
CHROOTFILE=${TMP}/todo.sh
MOUNTLIST=${TMP}/mountlist
File added
File added
File added
File added
File added
#! /bin/sh
set -e
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Only do this once.
if [ -z "$DEBCONF_REDIR" ]; then
exec <&4
export DEBIAN_HAS_FRONTEND=1
export DEBCONF_REDIR=1
fi
root="$1"
. "$root/usr/share/debconf/confmodule"
question="$2"
value="$3"
seen="$4"
[ "$seen" ] || seen=true
if ! db_set "$question" "$value"; then
db_register debian-installer/dummy "$question"
db_set "$question" "$value"
fi
db_fset "$question" seen "$seen"
exit 0
#! /bin/sh
set -e
export PATH=/usr/bin:/usr/sbin:/sbin:/bin
frontend=noninteractive
findcommandinroot() {
ROOT="$1/"
shift
while [ "$#" -ge 1 ]; do
P="$PATH"
while [ "$P" ]; do
D=${P%%:*}
P=${P#*:}
if [ "$D" = "$P" ]; then
P=
fi
if [ -z "$D" ]; then
D=.
fi
if [ -x "$ROOT$D/$1" ]; then
echo "$D/$1"
return 0
fi
done
shift
done
return 1
}
runcommandinroot() {
C=$(findcommandinroot "$1" "$2")
ROOT="$1"
shift
shift
[ -n "$C" ] && chroot "$ROOT" "$C" "$@"
}
root="$1"
package="$2"
version=$(runcommandinroot "$root" dpkg-query -W --showformat='${Version}' "$package" 2>/dev/null) || version=""
if [ -z "$version" ]; then
echo >&2 "$0: package '$package' is not installed"
exit 0
fi
unset DEBIAN_HAS_FRONTEND
unset DEBIAN_FRONTEND
unset DEBCONF_REDIR
runcommandinroot "$root" dpkg-reconfigure -fnoninteractive --no-reload "$package"
exit 0
#!/bin/sh
# Cloned-and-hacked from preseed/debconf-set-selections for casper.
set -e
OLDIFS="$IFS"
CR=$(echo -en "\r")
NL="
"
. /scripts/casper-functions
load_confmodule
# Returns the first field in the current line
first_field() {
echo "$line" | grep -q "[[:space:]]" || return 1
echo "$line" | sed -r 's/^([^[:space:]]*).*/\1/'
}
# Returns any fields after the first field in the current line
rest_line() {
if echo "$line" | grep -q "[[:space:]]"; then
echo "$line" | sed 's/^[^[:space:]]*[[:space:]]*//'
fi
}
SEEN=1
if [ "$1" = --unseen ]; then
SEEN=
shift
fi
file="$1"
parse_error() {
echo "Error parsing preconfiguration file: $*" >&2
exit 1
}
IFS="$NL"
multiline=""
# TODO: this squashes \r elsewhere in the line too
for line in $(grep -v '^#\|^[[:space:]]*$' "$file" | sed "s/$CR//g"); do
IFS="$OLDIFS"
line="$(echo "$line" | sed 's/^[[:space:]]*//')"
if echo "$line" | grep -q '\\$'; then
multiline="${multiline:+$multiline }$(echo "$line" | \
sed 's/[[:space:]]*\\$//')"
continue
elif [ -n "$multiline" ]; then
line="$multiline $line"
multiline=""
fi
echo "$line" >>/tmp/casper-preseed.log
package=""
var=""
type=""
val=""
if ! package="$(first_field)"; then
parse_error "Syntax error: unable to determine template owner"
fi
line="$(rest_line)"
if ! var="$(first_field)"; then
parse_error "Syntax error: unable to determine template name"
fi
line="$(rest_line)"
if ! type="$(first_field)"; then
# Allow for lines without separator before an empty value
if [ "$line" ]; then
type="$line"
else
parse_error "Syntax error: unable to determine template type"
fi
fi
line="$(rest_line)"
val="$line"
if [ "$type" = seen ]; then
# Set seen flag.
db_fset "$var" "$type" "$val" || true # how to handle this error?
else
if ! db_set "$var" "$val"; then
# Question does not exist yet.
db_register debian-installer/dummy "$var"
db_set "$var" "$val"
db_subst "$var" ID "$var"
fi
if [ "$SEEN" ]; then
db_fset "$var" seen true
fi
fi
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment