# A lot of snippets, inspiration, and some config directives are from https://projects.archlinux.org/archiso.git/ / the ArchLinux ISO layout.
# Many thanks and praise are deserved.
#DEBUG
#set -x
## Import settings
if[ -f "build.conf"];
then
echo"Now importing settings/variables."
set -e
source extra/build.conf.sample
source build.conf
set +e
else
echo"You have not configured a build.conf OR you are not running from the project's root directory (the git repository's working directory).
If you are indeed in the correct directory, you may copy the sample at extra/build.conf.sample,
edit it for appropriate values, and copy to <PROJECT ROOT>/build.conf"
echo'For now, though, I am using the defaults. If the build fails complaining about a'
echo'missing http user, you need to specify a custom/distro-pertinent one.'
cp extra/build.conf.sample build.conf
set -e
source extra/build.conf.sample
set +e
fi
## PREPARATION ##
# safemode browsing enabled. lolz
set -e
# do some basic error checking
ARCH=$(uname -m)
if[[${EUID} -ne 0]];
then
#echo "This script must be run as root" 1>&2
echo"This script must be run as root."
exit1
elif[ -f ${LOCKFILE}];
then
echo"Script already running, stale lockfile present, or an error occurred during last run."
echo"Please clear ${LOCKFILE} by hand before attempting another build."
echo -n "Timestamp of lockfile is: "
ls -l ${LOCKFILE}| awk '{print $6" "$7" "$8}'
exit1
elif[["$(uname -s)" !="Linux"]];
then
echo"ERROR: This script is only supported on GNU/Linux."
exit1
elif[["${ARCH}" !='x86_64']];
then
echo"Your hardware architecture, ${ARCH}, is not supported. Only x86_64 is supported."
echo"Dying now."
exit1
fi
echo"Checking directory structure and creating lockfile at ${LOCKFILE}..."
touch ${LOCKFILE}
# make sure the paths exist and then check for an existing chroot session
for i in ${ROOTDIR}${CHROOTDIR32}${CHROOTDIR64}${BUILDDIR}32${BUILDDIR}64${ISODIR}${MOUNTPT}${TEMPDIR}/{${UXNAME},${DISTNAME}}${ARCHBOOT}${SRCDIR}${TFTPDIR}${HTTPDIR}/${DISTNAME}${BASEDIR}/logs;