bdisk/lib/07-will_it_blend.func.sh
2014-12-23 22:59:29 -05:00

78 lines
2.8 KiB
Bash

function will_it_blend () {
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.
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 ${ROOTDIR}
else
cd ${ROOTDIR}
fi
# Generate the mtree spec.
# Not really necessary anymore.
#mtree -c -p ${ROOTDIR}/chroot -K flags,gid,mode,nlink,uid,link,time,type > ${ROOTDIR}/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}/*
cp -af ${BASEDIR}/extra/${UXNAME}.png ${TEMPDIR}/.
cp -af ${BASEDIR}/extra/${UXNAME}.png ${TFTPDIR}/.
mkdir -p ${TEMPDIR}/boot
cp -af ${CHROOTDIR}/boot/initramfs-linux-${PNAME}.img ${TEMPDIR}/boot/${UXNAME}.${ARCHSUFFIX}.img
cp -af ${CHROOTDIR}/boot/vmlinuz-linux-${PNAME} ${TEMPDIR}/boot/${UXNAME}.${ARCHSUFFIX}.kern
cp -af ${CHROOTDIR}/boot/initramfs-linux-${PNAME}.img ${TFTPDIR}/${UXNAME}.${ARCHSUFFIX}.img
cp -af ${CHROOTDIR}/boot/vmlinuz-linux-${PNAME} ${TFTPDIR}/${UXNAME}.${ARCHSUFFIX}.kern
cp -af ${ARCHBOOT}/* ${HTTPDIR}/${DISTNAME}/.
chown -R ${HTTPUSR}:${HTTPGRP} ${HTTPDIR}
chown ${TFTPUSR}:${TFTPGRP} ${TFTPDIR}/${UXNAME}.*
}