bdisk/lib/08-will_it_blend.func.sh

90 lines
3.1 KiB
Bash
Raw Normal View History

2015-07-07 08:16:29 -04:00
function will_it_blend () {
FUNCNAME="will_it_blend"
SQUASH_CMD="mksquashfs"
SQUASH_OPTS="-noappend -comp xz"
2015-07-07 08:16:29 -04:00
local ARCHSUFFIX="${1}"
if [[ "${1}" == "64" ]];
then
local CHROOTDIR="${CHROOTDIR}root.x86_64"
local BUILDDIR="${BUILDDIR}64"
local AIROOT="x86_64"
_CHROOT=${CHROOTDIR}
_BUILD=${BUILDDIR}
_AIROOT=${AIROOT}
elif [[ "${1}" == "32" ]];
then
local CHROOTDIR="${CHROOTDIR}root.i686"
local BUILDDIR="${BUILDDIR}32"
local AIROOT="i686"
_CHROOT=${CHROOTDIR}
_BUILD=${BUILDDIR}
_AIROOT=${AIROOT}
else
echo "WHOOPS. We hit an error that makes no logical sense."
echo 'Dying.'
exit 1
fi
if [[ "${I_AM_A_RACECAR}" == "y" ]];
then
RACECAR_CHK='nice -n -19 '
else
RACECAR_CHK=""
fi
if [ "${CHROOTDIR}/root/.bash_history" -nt "${ARCHBOOT}/${AIROOT}/airootfs.sfs" ] || [ ! -d "${BUILDDIR}/root/" ];
then
echo "Data is not sync'd to buildroot; syncing..."
CHROOTDIR="${CHROOTDIR_GLOB}"
BUILDDIR="${BUILDDIR_GLOB}"
jenny_craig ${ARCHSUFFIX}
CHROOTDIR="${_CHROOT}"
BUILDDIR="${_BUILD}"
fi
echo "[${ARCHSUFFIX}-bit] Now generating the squashed image (if we need to) and hashes. This may take some time."
BUILDDIR="${BUILDDIR_GLOB}"
local BUILDDIR="${BUILDDIR}${ARCHSUFFIX}"
# now let's build the squashed image... and generate some checksums as well to verify download integrity.
# are we building split-arch ISOs? do we need the below?
#if [[ "${MULTIARCH}" == "n" ]];
#then
# rm -rf ${ARCHBOOT}
#fi
mkdir -p ${ARCHBOOT}/${AIROOT}
if [ ! -f "${ARCHBOOT}/${AIROOT}/airootfs.sfs" ] || [ "${CHROOTDIR}/root/.bash_history" -nt "${ARCHBOOT}/${AIROOT}/airootfs.sfs" ];
then
echo "[${ARCHSUFFIX}-bit] Squashing filesystem. This can take a while depending on the size of your chroot(s)."
${RACECAR_CHK}${SQUASH_CMD} ${BUILDDIR} ${ARCHBOOT}/${AIROOT}/airootfs.sfs ${SQUASH_OPTS} >> "${LOGFILE}.${FUNCNAME}" 2>&1
cd ${ARCHBOOT}/${AIROOT}
${RACECAR_CHK}sha256sum airootfs.sfs >> airootfs.sha256
${RACECAR_CHK}md5sum airootfs.sfs >> airootfs.md5
cd ${BASEDIR}
else
cd ${BASEDIR}
fi
# Generate the mtree spec.
# Not really necessary anymore.
#mtree -c -p ${BASEDIR}/chroot -K flags,gid,mode,nlink,uid,link,time,type > ${BASEDIR}/extra/mtree.spec
# and now we copy stuff into the live directories
echo "[${ARCHSUFFIX}-bit] Copying files for PXE, and ISO building, please be patient."
#rm -rf ${TEMPDIR}/*
2015-08-03 11:18:33 -04:00
cat ${BASEDIR}/extra/bdisk.png > ${BASEDIR}/extra/${UXNAME}.png
2015-07-07 08:16:29 -04:00
cp -af ${BASEDIR}/extra/${UXNAME}.png ${TEMPDIR}/.
cp -af ${BASEDIR}/extra/${UXNAME}.png ${TFTPDIR}/.
mkdir -p ${TEMPDIR}/boot
2015-08-03 04:05:03 -04:00
cp -af ${CHROOTDIR}/boot/initramfs-linux-${DISTNAME}.img ${TEMPDIR}/boot/${UXNAME}.${ARCHSUFFIX}.img
cp -af ${CHROOTDIR}/boot/vmlinuz-linux-${DISTNAME} ${TEMPDIR}/boot/${UXNAME}.${ARCHSUFFIX}.kern
cp -af ${CHROOTDIR}/boot/initramfs-linux-${DISTNAME}.img ${TFTPDIR}/${UXNAME}.${ARCHSUFFIX}.img
cp -af ${CHROOTDIR}/boot/vmlinuz-linux-${DISTNAME} ${TFTPDIR}/${UXNAME}.${ARCHSUFFIX}.kern
2015-07-07 08:16:29 -04:00
cp -af ${ARCHBOOT}/* ${HTTPDIR}/${DISTNAME}/.
chown -R ${HTTPUSR}:${HTTPGRP} ${HTTPDIR}
chown ${TFTPUSR}:${TFTPGRP} ${TFTPDIR}/${UXNAME}.*
}