Commit 7ce1a817 authored by Strozzi's avatar Strozzi

Issue SCRUM#119: Implements old standard in this new script

parent 832f2b62
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/
cp /etc/resolv.conf ${CHROOTDIR}/etc/
cp /etc/hosts ${CHROOTDIR}/etc/
mount --bind /dev ${CHROOTDIR}/dev && echo "${CHROOTDIR}/dev" >> ${MOUNTLIST}
mount --bind /proc ${CHROOTDIR}/proc && echo "${CHROOTDIR}/proc" >> ${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."
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
PREFIX="/root/create-iso/"
TMP=$PREFIX
ISOLINUX="${PREFIX}/src/isolinux/"
#!/bin/bash
mount --bind /dev chroot/dev
mount --bind /dev/pts chroot/dev/pts
mount --bind /sys chroot/sys
mount --bind /proc chroot/proc
chroot chroot dbus-uuidgen > chroot/var/lib/dbus/machine-id
chroot chroot
#!/bin/bash
sudo apt-get install syslinux squashfs-tools genisoimage || exit 1
rm -rf image || exit 1
rm -rf LinuxEducacional-6.iso || exit 1
mkdir -p image/{casper,isolinux,install} || exit 1
cp -v chroot/boot/vmlinuz-*-generic image/casper/vmlinuz || exit 1
#cp -v chroot/boot/initrd.img-*-generic image/casper/initrd.lz || exit 1
cp -v initrd.lz image/casper/initrd.lz || exit 1
cp -v -r src/pool image/ || exit 1
cp -v /usr/lib/ISOLINUX/isolinux.bin image/isolinux/ || exit 1
cp -v /usr/lib/syslinux/modules/bios/ldlinux.c32 image/isolinux/ || exit 1
cp -v /boot/memtest86+.bin image/install/memtest || exit 1
cp -v src/isolinux.txt image/isolinux/ || exit 1
cp -v src/isolinux/* image/isolinux/ || exit 1
cp -v -r src/pool image/ || exit 1
cp -v -r src/dists image/ || exit 1
#cp -v -r src/preseed/ image/ || exit 1
sudo chroot chroot dpkg-query -W --showformat='${Package} ${Version}\n' | sudo tee image/casper/filesystem.manifest
sudo cp -v image/casper/filesystem.manifest image/casper/filesystem.manifest-desktop || exit 1
REMOVE='ubiquity ubiquity-frontend-gtk ubiquity-frontend-kde casper lupin-casper live-initramfs user-setup discover1 xresprobe os-prober libdebian-installer4 le-ubiquity-slideshow' || exit 1
for i in ${REMOVE}
do
sudo sed -i "/${i}/d" image/casper/filesystem.manifest-desktop
source common.sh
if [ "$(id -u)" != "0" ]; then
echo You must have more power to run this script
exit -1
fi
if [ ! $# -eq 1 ]; then
echo "Usage: $0 [dist]"
exit 1
fi
if [ "$1" == '--help' ]; then
echo "Usage: $0 [dist]"
exit 2
fi
_DIST=$1
export PREFIX=$(pwd)
SCRIPTSDIR="${PREFIX}/scripts-enabled/${_DIST}/"
source ${PREFIX}/conf/$_DIST/create-iso.conf \
|| log ERROR "configuration file not found for dist: \"${_DIST}\""
mkdir -p ${TMP}
sudo apt-get install syslinux squashfs-tools genisoimage \
|| log ERROR "Failed to install basic tools: \"${_DIST}\""
for file in $(ls ${SCRIPTSDIR}); do
if [ -x "${SCRIPTSDIR}/${file}" ] && egrep -q '^[0-9]{2}-[a-z-]+' <<< "$file"; then
echo "$file"
if ! "${SCRIPTSDIR}/${file}" ${_DIST}; then
log ERROR "While running \"${SCRIPTSDIR}/${file}\""
fi
fi
done
sudo mksquashfs chroot image/casper/filesystem.squashfs || exit 1
printf $(sudo du -sx --block-size=1 chroot | cut -f1) > image/casper/filesystem.size || exit 1
cp -v src/README.diskdefines image/ || exit 1
touch image/ubuntu || exit 1
mkdir image/.disk || exit 1
cd image/.disk || exit 1
touch base_installable || exit 1
echo "full_cd/single" > cd_type || exit 1
echo "Linux-Educacional 6.0" > info || exit 1
echo "https://linuxeducacional.c3sl.ufpr.br" > release_notes_url || exit 1
cd ../.. || exit 1
(cd image && find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt) || exit 1
cd image || exit 1
sudo genisoimage -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../LinuxEducacional-6.iso . || exit 1
cd ..
NAME="LinuxEducacional6-$(echo ${_DIST} | cut -d'/' -f2).iso"
cd ${TMP}/image
sudo genisoimage -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table -o ${PREFIX}/iso/${_DIST}/${NAME} \
. ||\
log ERROR "Failed to generate iso image."
cd -
cleanTmpFiles
exit 0
#!/bin/bash
source config.conf
_DIST=$1
PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source ${PREFIX}/common.sh
mkdir -p $TMP/bl/
cd $TMP/bl/
cpio -i < $ISOLINUX/bootlogo
......@@ -15,3 +21,6 @@ cd $ISOLINUX
sed -i 's/ubuntu/Linux Educacional/Ig' ./*.{tr,hlp}
rm -rf $TMP/bl/
rm $TMP/list
exit 0
#!/bin/bash
_DIST=$1
PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source ${PREFIX}/common.sh
initChroot $_DIST || \
log ERROR "failed to initialize chroot."
execChroot $CHROOTFILE $CHROOTDIR
RET=$?
closeChroot || \
log ERROR "failed to close chroot."
exit $?
#!/bin/bash
_DIST=$1
export PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source ${PREFIX}/common.sh
sudo mksquashfs $CHROOTDIR ${TMP}/image/casper/filesystem.squashfs ||\
log ERROR "Failed to compress ${CHROOTDIR}."
(cd ${TMP}/image && find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" > md5sum.txt) ||\
log ERROR "Failed to generate md5sum."
exit 0
#!/bin/bash
_DIST=$1
PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source ${PREFIX}/common.sh
addToChrootFile $CHROOTFILE "env PATH='/fakebin:${PATH}'"
addToChrootFile $CHROOTFILE "apt-get -y install --purge $(cat ${INSTLIST} | grep -v '^#' | tr '\n' ' ')"
exit 0
#!/bin/bash
_DIST=$1
export PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source common.sh
#This packages must not appear in the manifest
_IgnList="ubiquity
ubiquity-frontend-gtk
ubiquity-frontend-kde
casper
lupin-casper
live-initramfs
user-setup
discover1
xresprobe
os-prober
libdebian-installer4
le-ubiquity-slideshow"
sudo cp ${TMP}image/casper/filesystem.manifest ${TMP}image/casper/filesystem.manifest-desktop
IFS_OLD=$IFS
IFS=$'\n'
for i in $_IgnList
do
sudo sed -i "/${i}/d" ${TMP}/image/casper/filesystem.manifest-desktop
done
IFS=$IFS_OLD
exit 0
#!/bin/bash
_DIST=$1
export PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source common.sh
# Umount mounted dir to generate the manifest file in `pre-manifest.sh`
umount ${CHROOTDIR}/casper/ || \
log ERROR "Failed to umount casper dir."
rm -rf ${CHROOTDIR}/casper/
exit 0
#!/bin/bash
_DIST=$1
export PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source common.sh
#mount casper dir on chroot for generating the manifest file
mkdir -p ${CHROOTDIR}/casper/
mount --bind ${TMP}/image/casper/ ${CHROOTDIR}/casper/ || \
log ERROR "While mounting ${TMP}/image/casper/ on ${CHROOTDIR}/tmp/casper/."
addToChrootFile $CHROOTFILE "dpkg-query -W --showformat='${Package} ${Version}\n' > /casper/filesystem.manifest"
exit 0
#!/bin/bash
_DIST=$1
PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
source ${PREFIX}/common.sh
addToChrootFile $CHROOTFILE "apt-get -y --force-yes purge $(cat ${RMLIST} | grep -v "^#" | tr '\n' ' ')"
addToChrootFile $CHROOTFILE "apt-get -y --force-yes autoremove"
exit 0
#!/bin/bash
_DIST=$1
PREFIX=$PWD
source ${PREFIX}/conf/$_DIST/create-iso.conf
mkdir -p ${TMP}/image/{casper,isolinux,install} || exit 1
cp chroot/boot/vmlinuz-*-generic ${TMP}/image/casper/vmlinuz || exit 1
#cp -v chroot/boot/initrd.img-*-generic image/casper/initrd.lz || exit 1
cp initrd.lz ${TMP}/image/casper/initrd.lz || exit 1
cp -r src/pool ${TMP}/image/ || exit 1
cp /usr/lib/ISOLINUX/isolinux.bin ${TMP}/image/isolinux/ || exit 1
cp /usr/lib/syslinux/modules/bios/ldlinux.c32 ${TMP}/image/isolinux/ || exit 1
cp /boot/memtest86+.bin ${TMP}/image/install/memtest || exit 1
cp src/isolinux.txt ${TMP}/image/isolinux/ || exit 1
cp src/isolinux/* ${TMP}/image/isolinux/ || exit 1
cp -r src/pool ${TMP}/image/ || exit 1
cp -r src/dists ${TMP}/image/ || exit 1
#cp -v -r src/preseed/ image/ || exit 1
printf $(sudo du -sx --block-size=1 chroot | cut -f1) > ${TMP}image/casper/filesystem.size || exit 1
cp src/README.diskdefines ${TMP}/image/ || exit 1
touch ${TMP}image/ubuntu || exit 1
mkdir ${TMP}/image/.disk || exit 1
cd ${TMP}/image/.disk || exit 1
touch base_installable || exit 1
echo "full_cd/single" > cd_type || exit 1
echo "Linux-Educacional 6.0" > info || exit 1
echo "https://linuxeducacional.c3sl.ufpr.br" > release_notes_url || exit 1
exit 0
../../../scripts-available/setup.sh
\ No newline at end of file
../../../scripts-available/remove.sh
\ No newline at end of file
../../../scripts-available/install.sh
\ No newline at end of file
../../../scripts-available/pre-manifest.sh
\ No newline at end of file
../../../scripts-available/chroot.sh
\ No newline at end of file
../../../scripts-available/post-epilogue.sh
\ No newline at end of file
../../../scripts-available/manifest.sh
\ No newline at end of file
../../../scripts-available/compress.sh
\ No newline at end of file
#!/bin/bash
rm /var/lib/dbus/machine-id
umount -lf /dev/pts
umount -lf /dev
umount -lf /sys
umount -lf /proc
No preview for this file type
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