2023-04-02 06:34:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# desc:
|
|
|
|
# stages, builds, installs
|
|
|
|
|
|
|
|
# make variables persist in subprocesses for logging function
|
|
|
|
set -a
|
2023-05-26 02:38:19 +00:00
|
|
|
set -u
|
2023-04-02 06:34:59 +00:00
|
|
|
|
|
|
|
APPNAME="livecd"
|
|
|
|
|
|
|
|
# the file to log to
|
|
|
|
LOGFILE="${APPNAME}.log"
|
|
|
|
|
|
|
|
# ISO 8601 variation
|
|
|
|
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
|
|
|
|
|
|
|
|
# the path where logs are written to
|
|
|
|
# note: LOGS_ROOT is sourced from environment
|
|
|
|
LOG_DIR="${LOGS_ROOT}/${APPNAME}-${TIMESTAMP}"
|
|
|
|
|
|
|
|
|
|
|
|
# print to stdout, print to log
|
|
|
|
logprint() {
|
|
|
|
mkdir -p "${LOG_DIR}"
|
|
|
|
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
|
|
|
|
| tee -a "${LOG_DIR}/${LOGFILE}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Tell the user we're alive...
|
|
|
|
logprint "Initializing the ${APPNAME} utility..."
|
|
|
|
|
|
|
|
logprint "Creating grub boot directory..."
|
|
|
|
mkdir -p ${T_SYSROOT}/boot/grub
|
|
|
|
assert_zero $?
|
|
|
|
|
|
|
|
logprint "Installing livecd grub config"
|
|
|
|
cp -vf ${CONFIGS_DIR}/boot_grub_grub.cfg ${T_SYSROOT}/boot/grub/grub.cfg
|
|
|
|
assert_zero $?
|
|
|
|
|
2023-04-08 12:54:32 +00:00
|
|
|
logprint "Staging OverlayFS Init Script"
|
|
|
|
cp ${CONFIGS_DIR}/init-overlay ${T_SYSROOT}/boot/init-overlay
|
|
|
|
assert_zero $?
|
|
|
|
|
2023-04-02 06:34:59 +00:00
|
|
|
pushd ${dir_artifacts}
|
|
|
|
assert_zero $?
|
|
|
|
|
2023-04-02 22:49:57 +00:00
|
|
|
logprint "Emptying source stage..."
|
|
|
|
rm -Rf ${TEMP_STAGE_DIR}
|
|
|
|
assert_zero $?
|
|
|
|
|
2023-04-08 12:54:32 +00:00
|
|
|
rm -Rf ${T_SYSROOT}/${rex_dir}
|
2023-04-02 22:49:57 +00:00
|
|
|
assert_zero $?
|
|
|
|
|
2023-04-02 06:34:59 +00:00
|
|
|
logprint "Generating initramfs..."
|
|
|
|
# TODO chroot ignores this, and it breaks binutils pass 3
|
|
|
|
ulimit -n 3000000
|
|
|
|
/usr/sbin/chroot "${T_SYSROOT}" /usr/bin/env -i \
|
|
|
|
HOME=/root \
|
|
|
|
TERM="xterm-256color" \
|
|
|
|
PS1='\n(dark horse linux) [ \u @ \H ] << \w >>\n\n[- ' \
|
|
|
|
PATH=/usr/bin:/usr/sbin \
|
2023-04-07 04:37:06 +00:00
|
|
|
dracut -c /usr/etc/dracut.conf --force '' 6.0.12
|
2023-04-02 06:34:59 +00:00
|
|
|
assert_zero $?
|
|
|
|
|
|
|
|
logprint "Generating bootable ISO"
|
2023-04-08 12:54:32 +00:00
|
|
|
grub2-mkrescue -A livecd -o DHLP.iso -V "livecd" ${T_SYSROOT}
|
2023-04-02 06:34:59 +00:00
|
|
|
assert_zero $?
|
|
|
|
|
|
|
|
logprint "Thanks for using Dark Horse Linux. Your experimental build is at '${dir_artifacts}/DHLP.iso'."
|
|
|
|
logprint "You can test your new ISO with qemu using:"
|
|
|
|
logprint "qemu-system-x86_64 -cdrom ${dir_artifacts}/DHLP.iso -m 2048 -boot d"
|
|
|
|
|
|
|
|
logprint "Execution of ${APPNAME} completed."
|