Commit 01ec84e1 authored by Daniel Bissani Furlin's avatar Daniel Bissani Furlin

SCRUM#263: Get initrd from chroot dynamically

parent 78a94c80
SHORTNAME=le6
TMP=/home/${SUDO_USER}/${_DIST}
CHROOTDIR=/home/${SUDO_USER}/overlay
TMPFS=/home/${SUDO_USER}/tmp
TMP=${PREFIX}/${_DIST}
CHROOTDIR=${PREFIX}/overlay
TMPFS=${PREFIX}/tmp
DISTRO=Linux_Educacional_6.1.0
DPLIST=${PREFIX}/pkg-list/${_DIST}/dependencies.list
INSTLIST=${PREFIX}/pkg-list/${_DIST}/install.list
......
......@@ -80,6 +80,10 @@ source "${PREFIX}/conf/$_DIST/create-iso.conf" \
TIME_STAMP="`date +'%Y-%m-%dT%H:%M:%S'`"
export LOG_FILE="${LOG_PATH}/create-iso-${TIME_STAMP}.log"
exec 1<&-
exec 2<&-
exec 1<> ${LOG_FILE}
exec 1>&1
mkdir --parents ${TMP}
source ${PREFIX}/common.sh
......
#le-all
le-all
linux-generic-hwe-16.04
xserver-xorg-hwe-16.04
......@@ -45,7 +45,7 @@ type addToChrootFile >/dev/null 2>&1 || source ${PREFIX}/common.sh
addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "export PATH='/fakebin:${PATH}'"
addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "export DEBIAN_FRONTEND=noninteractive"
#addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "apt-get update && apt-get --quiet --yes --target-release ${_REPO} install le-live-all; $(genErrHandleInChroot)"
#addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "apt-get update && apt-get --quiet --yes --target-release ${_REPO} install $(cat ${INSTLIST} | grep --invert-match '^#' | tr '\n' ' '); $(genErrHandleInChroot)"
addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "apt-get update && apt-get --quiet --yes --target-release ${_REPO} install le-live-all; $(genErrHandleInChroot)"
addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "apt-get update && apt-get --quiet --yes --target-release ${_REPO} install $(cat ${INSTLIST} | grep --invert-match '^#' | tr '\n' ' '); $(genErrHandleInChroot)"
exit 0
......@@ -44,9 +44,10 @@ PREFIX=$PWD
type genErrHandle >/dev/null 2>&1 || source ${PREFIX}/common.sh
type pinfo >/dev/null 2>&1 || source ${PREFIX}/helper/logging.incsh
cp ${PREFIX}/vmlinuz-*-generic ${TMP}/image/casper/vmlinuz; $(genErrHandle "Unable to copy kernel to image")
version=$(ls ${CHROOTDIR}/boot/ | egrep "initrd.img-[0-9,.,-]*-generic" | cut --delimiter='-' --fields=2,3 | sort --version-sort --reverse | head --lines=1)
cp "${CHROOTDIR}/boot/vmlinuz-${version}-generic" ${TMP}/image/casper/vmlinuz; $(genErrHandle "Unable to copy kernel to image")
if ! test -f initrd.lz; then
initname=$(ls "${PREFIX}/" | grep "initrd.*-generic")
initname="initrd.img-${version}-generic"
if [ ! -d ${PREFIX}/initrd ]; then
mkdir ${PREFIX}/initrd
else
......@@ -54,10 +55,12 @@ if ! test -f initrd.lz; then
fi
pinfo "Using '${initname}'"
pushd ${PREFIX}/initrd
gzip --decompress --stdout ${PREFIX}/${initname} | cpio --extract; $(genErrHandle "Unable to decompress initrd")
gzip --decompress --stdout "${CHROOTDIR}/boot/${initname}" | cpio --extract; $(genErrHandle "Unable to decompress initrd")
find . | cpio --quiet --create -H newc | lzma -7 > ../initrd.lz; $(genErrHandle "Unable to compress initrd")
popd
rm --recursive --force ${PREFIX}/initrd
fi
cp initrd.lz ${TMP}/image/casper/initrd.lz; $(genErrHandle "Unable to copy initrd to image")
mv initrd.lz ${TMP}/image/casper/initrd.lz; $(genErrHandle "Unable to copy initrd to image")
exit 0
......@@ -56,7 +56,11 @@ cp ${PREFIX}/src/isolinux/* ${TMP}/image/isolinux/; $(genErrHandle "Unable to co
cp ${PREFIX}/src/preseed/preseed.cfg ${TMP}/image/preseed/; $(genErrHandle "Unable to copy preseed to image")
cp ${PREFIX}/src/keyboard ${CHROOTDIR}/etc/default/ || \
pwarning "Unable to copy default keyboard layout"
du --summarize --one-file-system --block-size=1 ${CHROOTDIR} | cut --fields=1 > "${TMP}/image/casper/filesystem.size"; $(genErrHandle "Unable to get the size of chroot")
size=$(du --summarize --block-size=1 ${CHROOTDIR} | cut --fields=1); $(genErrHandle "Unable to get the size of chroot")
if test ${size} -eq 0; then
perror "The chroot return size 0"; /bin/bash
fi
echo ${size} > "${TMP}/image/casper/filesystem.size"
cp ${PREFIX}/src/README.diskdefines-${_ARCH} ${TMP}/image/README.diskdefines; $(genErrHandle "Unable to copy README.diskdefines to image")
pushd ${TMP}/image/
ln --symbolic . ubuntu; $(genErrHandle "Unable to create ${TMP}/image/ubuntu symbolic link")
......
......@@ -53,6 +53,6 @@ sed --in-place "s/##CODENAME##/${_REPO}/g" ${CHROOTDIR}/etc/apt/sources.list.d/$
addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "wget -O- http://repo.c3sl.ufpr.br/le6/le.c3sl.ufpr.br.key | apt-key add -; $(genErrHandleInChroot 'Unable to add a key to custom repository')"
addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "apt-get update; $(genErrHandleInChroot 'Unable to reash all repositories')"
#addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "apt-get --yes upgrade; $(genErrHandleInChroot 'Unable to upgrade packages')"
addToChrootFile ${CHROOTDIR} ${SCRIPT_NAME} "apt-get --yes upgrade; $(genErrHandleInChroot 'Unable to upgrade packages')"
exit 0
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