@@ -30,6 +30,8 @@ DEFAULT_ARGUMENT=""
3030ARGUMENT=(" ${@ } " )
3131alteriso_version=" 3.1"
3232norepopkg=()
33+ legacy_mode=false
34+ rerun=false
3335
3436# Load config file
3537[[ ! -f " ${defaultconfig} " ]] && " ${tools_dir} /msg.sh" -a ' build.sh' error " ${defaultconfig} was not found." && exit 1
@@ -42,8 +44,7 @@ umask 0022
4244# Message common function
4345# msg_common [type] [-n] [string]
4446msg_common (){
45- local _msg_opts=(" -a" " build.sh" ) _type=" ${1} "
46- shift 1
47+ local _msg_opts=(" -a" " build.sh" ) _type=" ${1} " && shift 1
4748 [[ " ${1} " = " -n" ]] && _msg_opts+=(" -o" " -n" ) && shift 1
4849 [[ " ${msgdebug} " = true ]] && _msg_opts+=(" -x" )
4950 [[ " ${nocolor} " = true ]] && _msg_opts+=(" -n" )
@@ -83,28 +84,7 @@ getclm() { cut -d " " -f "${1}"; }
8384echo_blank (){ yes " " 2> /dev/null | head -n " ${1} " | tr -d " \n" ; }
8485
8586_usage () {
86- echo " usage ${0} [options] [channel]"
87- echo
88- echo " A channel is a profile of AlterISO settings."
89- echo
90- echo " General options:"
91- echo " -b | --boot-splash Enable boot splash"
92- echo " -e | --cleanup | --cleaning Enable post-build cleaning"
93- echo " -r | --tarball Build rootfs in tar.xz format"
94- echo " -h | --help This help message and exit"
95- echo
96- echo " -a | --arch <arch> Set iso architecture"
97- echo " -c | --comp-type <comp_type> Set SquashFS compression type (gzip, lzma, lzo, xz, zstd)"
98- echo " -g | --gpgkey <key> Set gpg key"
99- echo " -l | --lang <lang> Specifies the default language for the live environment"
100- echo " -k | --kernel <kernel> Set special kernel type. See below for available kernels"
101- echo " -o | --out <out_dir> Set the output directory"
102- echo " -p | --password <password> Set a live user password"
103- echo " -t | --comp-opts <options> Set compressor-specific options."
104- echo " -u | --user <username> Set user name"
105- echo " -w | --work <work_dir> Set the working directory"
106- echo
107-
87+ cat " ${script_path} /docs/build.sh/help.1"
10888 local blank=" 29" _arch _dirname _type _output _first
10989 for _type in " locale" " kernel" ; do
11090 echo " ${_type} for each architecture:"
@@ -124,36 +104,7 @@ _usage () {
124104 _first=false
125105 done
126106 done
127-
128- echo
129- echo " Debug options: Please use at your own risk."
130- echo " -d | --debug Enable debug messages"
131- echo " -x | --bash-debug Enable bash debug mode(set -xv)"
132- echo " --channellist Output the channel list and exit"
133- echo " --config Load additional config file"
134- echo " --[no]gitversion Add Git commit hash to image file version"
135- echo " --logpath <file> Set log file path (use with --log)"
136- echo " --[no]log (No) log ;re-run script with tee"
137- echo " --msgdebug Enables output debugging"
138- echo " --noaur Ignore aur packages (Use only for debugging)"
139- echo " --nocolor No output colored output"
140- echo " --[no]confirm (No) check the settings before building"
141- echo " --nochkver No check the version of the channel"
142- echo " --nodebug Disable all debug messages"
143- echo " --noefi No efi boot (Use only for debugging)"
144- echo " --noloopmod No check and load kernel module automatically"
145- echo " --nodepend No check package dependencies before building"
146- echo " --noiso No build iso image (Use with --tarball)"
147- echo " --nosigcheck No pacman signature check"
148- echo " --pacman-debug Enable pacman debug mode"
149- echo " --normwork No remove working dir"
150- echo " --nopkgbuild Ignore PKGBUILD (Use only for debugging)"
151- echo " --tar-type <comp_type> Set compression type (gzip, lzma, lzo, xz, zstd)"
152- echo " --tar-opts <option> Set tar command argument (Use with --tarball)"
153- echo " --add-module <module> Load additional modules (Separated by \" ,\" )"
154- echo
155- echo " Many packages are installed from AUR, so specifying --noaur can cause problems."
156- echo
107+ cat " ${script_path} /docs/build.sh/help.2"
157108 [[ -n " ${1:- } " ]] && exit " ${1} "
158109}
159110
@@ -298,7 +249,8 @@ check_bool() {
298249 for _variable in " ${@ } " ; do
299250 msg_debug -n " Checking ${_variable} ..."
300251 eval " : \$ {${_variable} :=''}"
301- _value=" $( eval echo " \$ ${_variable} " ) "
252+ _value=" $( eval echo " \$ {${_variable} ,,}" ) "
253+ eval " ${_variable} =${_value} "
302254 if [[ ! -v " ${1} " ]] || [[ " ${_value} " = " " ]]; then
303255 [[ " ${debug} " = true ]] && echo ; msg_error " The variable name ${_variable} is empty." " 1"
304256 elif [[ ! " ${_value} " = " true" ]] && [[ ! " ${_value} " = " false" ]]; then
@@ -414,6 +366,7 @@ prepare_build() {
414366 if [[ " $( bash " ${tools_dir} /channel.sh" --version " ${alteriso_version} " ver " ${channel_name} " ) " = " 3.0" ]]; then
415367 msg_warn " The module cannot be used because it works with Alter ISO3.0 compatibility."
416368 modules=(" legacy" )
369+ legacy_mode=true
417370 [[ " ${include_extra-" unset" } " = true ]] && modules=(" legacy-extra" )
418371 fi
419372
@@ -425,8 +378,8 @@ prepare_build() {
425378
426379 # Check modules
427380 module_check (){
428- msg_debug " Checking ${1} module ..."
429- bash " ${tools_dir} /module.sh" check " ${1} " || msg_error " Module ${1} is not available." " 1" ;
381+ msg_debug -n " Checking ${1} module ... "
382+ bash " ${tools_dir} /module.sh" check " ${1} " || msg_error " Module ${1} is not available." " 1" && echo " ${module_dir} / ${1} "
430383 }
431384 readarray -t modules < <( printf " %s\n" " ${modules[@]} " | awk ' !a[$0]++' )
432385 for_module " module_check {}"
@@ -478,8 +431,8 @@ prepare_build() {
478431 if [[ ! " ${logging} " = false ]]; then
479432 [[ " ${customized_logpath} " = false ]] && logging=" ${out_dir} /${iso_filename% .iso} .log"
480433 mkdir -p " $( dirname " ${logging} " ) " && touch " ${logging} "
481- msg_warn " Re-run sudo ${0} ${ARGUMENT[*]} --nodepend --nolog --nocolor 2>&1 | tee ${logging} "
482- sudo " ${0} " " ${ARGUMENT[@]} " --nolog --nocolor --nodepend 2>&1 | tee " ${logging} "
434+ msg_warn " Re-run sudo ${0} ${ARGUMENT[*]} --nodepend --nolog --nocolor --rerun 2>&1 | tee ${logging} "
435+ sudo " ${0} " " ${ARGUMENT[@]} " --nolog --nocolor --nodepend --rerun 2>&1 | tee " ${logging} "
483436 exit " ${?} "
484437 fi
485438
@@ -549,18 +502,20 @@ make_packages_repo() {
549502 readarray -t _pkglist_install < <( " ${tools_dir} /pkglist.sh" " ${pkglist_args[@]} " )
550503
551504 # Package check
552- # readarray -t _pkglist < <("${tools_dir}/pkglist.sh" "${pkglist_args[@]}")
553- # readarray -t repopkgs < <(pacman-conf -c "${build_pacman_conf}" -l | xargs -I{} pacman -Sql --config "${build_pacman_conf}" --color=never {} && pacman -Sg)
554- # local _pkg
555- # for _pkg in "${_pkglist[@]}"; do
556- # msg_info "Checking ${_pkg}..."
557- # if printf "%s\n" "${repopkgs[@]}" | grep -qx "${_pkg}"; then
558- # _pkglist_install+=("${_pkg}")
559- # else
560- # msg_info "${_pkg} was not found. Install it with yay from AUR"
561- # norepopkg+=("${_pkg}")
562- # fi
563- # done
505+ if [[ " ${legacy_mode} " = true ]]; then
506+ readarray -t _pkglist < <( " ${tools_dir} /pkglist.sh" " ${pkglist_args[@]} " )
507+ readarray -t repopkgs < <( pacman-conf -c " ${build_pacman_conf} " -l | xargs -I{} pacman -Sql --config " ${build_pacman_conf} " --color=never {} && pacman -Sg)
508+ local _pkg
509+ for _pkg in " ${_pkglist[@]} " ; do
510+ msg_info " Checking ${_pkg} ..."
511+ if printf " %s\n" " ${repopkgs[@]} " | grep -qx " ${_pkg} " ; then
512+ _pkglist_install+=(" ${_pkg} " )
513+ else
514+ msg_info " ${_pkg} was not found. Install it with yay from AUR"
515+ norepopkg+=(" ${_pkg} " )
516+ fi
517+ done
518+ fi
564519
565520 # Create a list of packages to be finally installed as packages.list directly under the working directory.
566521 echo -e " # The list of packages that is installed in live cd.\n#\n" > " ${build_dir} /packages.list"
@@ -704,9 +659,10 @@ make_setup_mkinitcpio() {
704659 cp " ${script_path} /system/initcpio/install/${_hook} " " ${airootfs_dir} /etc/initcpio/install"
705660 done
706661
662+ sed -i " s|%COWSPACE%|${cowspace} |g" " ${airootfs_dir} /etc/initcpio/hooks/archiso"
707663 sed -i " s|/usr/lib/initcpio/|/etc/initcpio/|g" " ${airootfs_dir} /etc/initcpio/install/archiso_shutdown"
708664 cp " ${script_path} /system/initcpio/install/archiso_kms" " ${airootfs_dir} /etc/initcpio/install"
709- cp " ${script_path} /system/initcpio/archiso_shutdown" " ${airootfs_dir} /etc/initcpio"
665+ cp " ${script_path} /system/initcpio/script/ archiso_shutdown" " ${airootfs_dir} /etc/initcpio"
710666 cp " ${script_path} /mkinitcpio/mkinitcpio-archiso.conf" " ${airootfs_dir} /etc/mkinitcpio-archiso.conf"
711667 [[ " ${boot_splash} " = true ]] && cp " ${script_path} /mkinitcpio/mkinitcpio-archiso-plymouth.conf" " ${airootfs_dir} /etc/mkinitcpio-archiso.conf"
712668
@@ -1005,9 +961,9 @@ make_alteriso_info(){
1005961make_overisofs () {
1006962 local _over_isofs_list _isofs
1007963 _over_isofs_list=(" ${channel_dir} /over_isofs.any" " ${channel_dir} /over_isofs.${arch} " )
1008- for_module ' _over_isofs_list+=("${module_dir}/{}/over_isofs.any""${module_dir}/{}/over_isofs.${arch}")'
964+ for_module ' _over_isofs_list+=("${module_dir}/{}/over_isofs.any" "${module_dir}/{}/over_isofs.${arch}")'
1009965 for _isofs in " ${_over_isofs_list[@]} " ; do
1010- [[ -d " ${_isofs} " ]] && cp -af " ${_isofs} " /* " ${isofs_dir} "
966+ [[ -d " ${_isofs} " ]] && [[ -n " $( find " ${_isofs} " -mindepth 1 -maxdepth 2 ) " ]] && cp -af " ${_isofs} " /* " ${isofs_dir} "
1011967 done
1012968
1013969 return 0
@@ -1048,7 +1004,7 @@ make_iso() {
10481004
10491005
10501006# Parse options
1051- ARGUMENT=(" ${DEFAULT_ARGUMENT[@]} " " ${@ } " ) OPTS=(" a:" " b" " c:" " d" " e" " g:" " h" " j" " k:" " l:" " o:" " p:" " r" " t:" " u:" " w:" " x" ) OPTL=(" arch:" " boot-splash" " comp-type:" " debug" " cleaning" " cleanup" " gpgkey:" " help" " lang:" " japanese" " kernel:" " out:" " password:" " comp-opts:" " user:" " work:" " bash-debug" " nocolor" " noconfirm" " nodepend" " gitversion" " msgdebug" " noloopmod" " tarball" " noiso" " noaur" " nochkver" " channellist" " config:" " noefi" " nodebug" " nosigcheck" " normwork" " log" " logpath:" " nolog" " nopkgbuild" " pacman-debug" " confirm" " tar-type:" " tar-opts:" " add-module:" " nogitversion" )
1007+ ARGUMENT=(" ${DEFAULT_ARGUMENT[@]} " " ${@ } " ) OPTS=(" a:" " b" " c:" " d" " e" " g:" " h" " j" " k:" " l:" " o:" " p:" " r" " t:" " u:" " w:" " x" ) OPTL=(" arch:" " boot-splash" " comp-type:" " debug" " cleaning" " cleanup" " gpgkey:" " help" " lang:" " japanese" " kernel:" " out:" " password:" " comp-opts:" " user:" " work:" " bash-debug" " nocolor" " noconfirm" " nodepend" " gitversion" " msgdebug" " noloopmod" " tarball" " noiso" " noaur" " nochkver" " channellist" " config:" " noefi" " nodebug" " nosigcheck" " normwork" " log" " logpath:" " nolog" " nopkgbuild" " pacman-debug" " confirm" " tar-type:" " tar-opts:" " add-module:" " nogitversion" " cowspace: " " rerun " " depend " " loopmod " )
10521008GETOPT=(-o " $( printf " %s," " ${OPTS[@]} " ) " -l " $( printf " %s," " ${OPTL[@]} " ) " -- " ${ARGUMENT[@]} " )
10531009getopt -Q " ${GETOPT[@]} " || exit 1 # 引数エラー判定
10541010readarray -t OPT < <( getopt " ${GETOPT[@]} " ) # 配列に代入
@@ -1141,15 +1097,19 @@ while true; do
11411097 --noaur ) noaur=true && shift 1 ;;
11421098 --nochkver ) nochkver=true && shift 1 ;;
11431099 --noefi ) noefi=true && shift 1 ;;
1144- --channellist ) show_channel_list && exit 0 ;;
1145- --config ) source " ${2} " && shift 2 ;;
1100+ --channellist ) show_channel_list && exit 0 ;;
1101+ --config ) source " ${2} " ; shift 2 ;;
11461102 --pacman-debug ) pacman_debug=true && shift 1 ;;
11471103 --nosigcheck ) nosigcheck=true && shift 1 ;;
11481104 --normwork ) normwork=true && shift 1 ;;
11491105 --log ) logging=true && shift 1 ;;
11501106 --nolog ) logging=false && shift 1 ;;
11511107 --nopkgbuild ) nopkgbuild=true && shift 1 ;;
11521108 --nogitversion ) gitversion=false && shift 1 ;;
1109+ --cowspace ) cowspace=" ${2} " && shift 2 ;;
1110+ --rerun ) rerun=true && shift 1 ;;
1111+ --depend ) nodepend=false && shift 1 ;;
1112+ --loopmod ) noloopmod=false && shift 1 ;;
11531113 -- ) shift 1 && break ;;
11541114 * )
11551115 msg_error " Argument exception error '${1} '"
@@ -1162,7 +1122,7 @@ done
11621122if (( ! "${EUID} " == 0 )) ; then
11631123 msg_warn " This script must be run as root." >&2
11641124 msg_warn " Re-run 'sudo ${0} ${ARGUMENT[*]} '"
1165- sudo " ${0} " " ${ARGUMENT[@]} "
1125+ sudo " ${0} " " ${ARGUMENT[@]} " --rerun
11661126 exit " ${?} "
11671127fi
11681128
0 commit comments