mirror of
https://github.com/theupriser/steamify-cachyos-live-iso.git
synced 2026-10-02 15:10:26 +02:00
* feat: Implement building ISO in RAM * feat: Implement removing build directory * README: Remove build directory by default * Use mktemp to create work directory Co-authored-by: Vasiliy Stelmachenok <92667539+ventureoo@users.noreply.github.com> * Adapt cehcks for mktemp * util-iso.sh: Fix typo Co-authored-by: Vasiliy Stelmachenok <92667539+ventureoo@users.noreply.github.com> * util-iso.sh: Ensure safe removal of directory by quoting variable Co-authored-by: Vasiliy Stelmachenok <92667539+ventureoo@users.noreply.github.com> * util-iso.sh: umount_fs first and then start removal * util-iso.sh: Properly handle removal of work directory --------- Co-authored-by: Vasiliy Stelmachenok <92667539+ventureoo@users.noreply.github.com>
80 lines
2.4 KiB
Bash
Executable File
80 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; version 2 of the License.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
src_dir=$(pwd)
|
|
[[ -r ${src_dir}/util-msg.sh ]] && source ${src_dir}/util-msg.sh
|
|
import ${src_dir}/util.sh
|
|
|
|
# setting of the general parameters
|
|
work_dir="${src_dir}/build"
|
|
outFolder="${src_dir}/out"
|
|
|
|
build_list_iso="desktop"
|
|
clean_first=true
|
|
verbose=false
|
|
build_in_ram=true
|
|
remove_build_dir=false
|
|
|
|
usage() {
|
|
echo "Usage: ${0##*/} [options]"
|
|
echo ' -c Disable clean work dir'
|
|
echo ' -r Disable building in RAM on systems with more than 23GB RAM'
|
|
echo ' -w Remove build directory (not the ISO) after ISO file is built'
|
|
echo " -p <profile> Buildset or profile [default: ${build_list_iso}]"
|
|
echo ' -v Verbose output to log file, show profile detail (-q)'
|
|
echo ' -h This help'
|
|
echo ''
|
|
echo ''
|
|
exit $1
|
|
}
|
|
|
|
orig_argv=("$@")
|
|
|
|
opts='p:cvhrw'
|
|
|
|
while getopts "${opts}" arg; do
|
|
case "${arg}" in
|
|
c) clean_first=false ;;
|
|
p) build_list_iso="$OPTARG" ;;
|
|
r) build_in_ram=false ;;
|
|
w) remove_build_dir=true ;;
|
|
v) verbose=true ;;
|
|
h|?) usage 0 ;;
|
|
*) echo "invalid argument '${arg}'"; usage 1 ;;
|
|
esac
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
timer_start=$(get_timer)
|
|
|
|
#check_root "$0" "${orig_argv[@]}"
|
|
|
|
# Build ISO in RAM if RAM amount is greater than 23GB. This would speed up build process and extend disk lifetime
|
|
if [[ "$build_in_ram" == "true" ]] && [[ $(grep MemTotal /proc/meminfo | awk '{print int($2/1024/1024)}') -gt 23 ]]; then
|
|
work_dir="$(mktemp -d --suffix="-cachyos-iso")"
|
|
fi
|
|
|
|
prepare_dir "${work_dir}"
|
|
|
|
import ${src_dir}/util-iso.sh
|
|
import ${src_dir}/util-iso-mount.sh
|
|
|
|
check_requirements
|
|
|
|
for sig in TERM HUP QUIT; do
|
|
trap "trap_exit $sig \"$(gettext "%s signal caught. Exiting...")\" \"$sig\"" "$sig"
|
|
done
|
|
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
|
|
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
|
|
|
run_build "${build_list_iso}"
|