diff --git a/README.md b/README.md index efd9f60..0adb4f3 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ buildiso is used to build CachyOS ISO. $ ./buildiso.sh -h Usage: buildiso [options] -c Disable clean work dir + -r Disable building in RAM on systems with more than 23GB RAM + -w Remove build directory (not the ISO) after ISO file is built -h This help -p Buildset or profile [default: desktop] -v Verbose output to log file, show profile detail (-q) @@ -34,7 +36,7 @@ cd cachyos-archiso ### Build ```bash -sudo ./buildiso.sh -p desktop -v +sudo ./buildiso.sh -p desktop -v -w ``` As the result iso appears at the `out` folder diff --git a/archiso/grub/grub.cfg b/archiso/grub/grub.cfg index 15d2f83..5ba7784 100644 --- a/archiso/grub/grub.cfg +++ b/archiso/grub/grub.cfg @@ -1,6 +1,6 @@ # Defining the Version of the ISO. This line could be easy changed by a Script wich do that automatic before creating ISO self. # Default "GIT", because if somebody outside from the DEVs create a ISO, this ISO wouldnt have a specific Version number. -CACHYOS_VERSION="250131" +CACHYOS_VERSION="251016" if [ "${grub_platform}" == 'efi' ]; then bios_or_uefi='(UEFI)!' diff --git a/buildiso.sh b/buildiso.sh index d7ca43d..7c1d10d 100755 --- a/buildiso.sh +++ b/buildiso.sh @@ -20,10 +20,14 @@ 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 Buildset or profile [default: ${build_list_iso}]" echo ' -v Verbose output to log file, show profile detail (-q)' echo ' -h This help' @@ -34,12 +38,14 @@ usage() { orig_argv=("$@") -opts='p:cvh' +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 ;; @@ -52,6 +58,11 @@ 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 diff --git a/util-iso.sh b/util-iso.sh index e64846a..2e79113 100755 --- a/util-iso.sh +++ b/util-iso.sh @@ -212,6 +212,16 @@ run_build() { fi done show_elapsed_time "${FUNCNAME}" "${timer_start}" + if [[ "$build_in_ram" == "true" && "$remove_build_dir" == "false" ]]; then + msg "!!! Remember to remove $work_dir !!!" + msg2 "sudo rm -rf $work_dir" + fi + if [[ "$remove_build_dir" == "true" ]]; then + msg "Automatically removing build directory ($work_dir)..." + umount_fs + [ -d ${work_dir} ] && sudo rm -rf ${work_dir} + msg2 "Removed" + fi } gen_iso_fn(){