OSDN Git Service

[add] : Added Added debug mode.
authorhayao <shun819.mail@gmail.com>
Wed, 26 Feb 2020 13:45:23 +0000 (22:45 +0900)
committerhayao <shun819.mail@gmail.com>
Wed, 26 Feb 2020 13:45:23 +0000 (22:45 +0900)
airootfs/root/customize_airootfs.sh
build.sh
config

index 96ade5b..31a320a 100755 (executable)
@@ -17,6 +17,7 @@ while getopts 'p:bt:k:' arg; do
         b) boot_splash=true ;;
         t) theme_name="${OPTARG}" ;;
         k) kernel="${OPTARG}" ;;
+        x) set -x ;;
     esac
 done
 
index bfd7d07..cafee00 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -26,6 +26,7 @@ theme_name="alter-logo"
 theme_pkg="plymouth-theme-alter-logo-git"
 sfs_comp="zstd"
 sfs_comp_opt=""
+debug=false
 
 # Load extra settings
 [[ -f ./config ]] && source config; echo "The settings have been overwritten by the config file."
@@ -70,6 +71,24 @@ _usage () {
     exit ${1}
 }
 
+# Check the value of a variable that can only be set to true or false.
+case ${boot_splash} in
+     true) : ;;
+    false) : ;;
+        *)
+            echo "The value ${boot_splash} set is invalid" >&2
+            ;;
+esac
+
+case ${debug} in
+     true) : ;;
+    false) : ;;
+        *)
+            echo "The value ${debug} set is invalid" >&2
+            ;;
+esac
+
+
 # Helper function to run make_*() only one time per architecture.
 run_once() {
     if [[ ! -e ${work_dir}/build.${1} ]]; then
@@ -173,14 +192,16 @@ make_customize_airootfs() {
     options=
     if [[ ${boot_splash} = true ]]; then
         if [[ -z ${theme_name} ]]; then
-            options="-b"
+            options="${options} -b"
         else
-            options="-b -t ${theme_name}"
+            options="${options} -b -t ${theme_name}"
         fi
     fi
     if [[ -n ${kernel} ]]; then
         options="${options} -k ${kernel}"
     fi
+    if ${debug}; then
+        options="${options} -x"
     if [[ -z ${options} ]]; then
         mkarchiso ${verbose} -w "${work_dir}/x86_64" -C "${work_dir}/pacman.conf" -D "${install_dir}" -r "/root/customize_airootfs.sh -p ${password}" run
     else
@@ -361,7 +382,7 @@ if [[ ${EUID} -ne 0 ]]; then
     _usage 1
 fi
 
-while getopts 'w:o:g:p:c:t:hbk:' arg; do
+while getopts 'w:o:g:p:c:t:hbk:x' arg; do
     case "${arg}" in
         p) password="${OPTARG}" ;;
         w) work_dir="${OPTARG}" ;;
@@ -386,19 +407,27 @@ while getopts 'w:o:g:p:c:t:hbk:' arg; do
                  "ck") kernel=ck  ;;
                  "rt") kernel=rt  ;;
                     *)
-                        echo "Invalid kernel ${OPTARG}"
+                        echo "Invalid kernel ${OPTARG}" >&2
                         _usage 1
                         ;;
             esac
             ;;
+        x) debug=true;;
         h) _usage 0 ;;
         *)
-           echo "Invalid argument '${arg}'"
+           echo "Invalid argument '${arg}'" >&2
            _usage 1
            ;;
     esac
 done
 
+# Debug mode
+if ${debug}; then
+    set -x
+else
+    set +x
+fi
+
 mkdir -p ${work_dir}
 
 # Show Alter Linux build options.
diff --git a/config b/config
index 09ac02d..1833767 100644 (file)
--- a/config
+++ b/config
@@ -55,4 +55,9 @@ sfs_comp_opt=""
 # Set the kernel that live session use.
 # Please don't set anything if you want to use normal kernel.
 # As of February 23, 2020, the available kernels are lts, zen, ck, , rt and lqx.
-kernel=
\ No newline at end of file
+kernel=
+
+# Set debug mode.
+# This setting can only be set to true or false.
+# When enabled, bash debug mode is enabled, making it easier to identify which command caused the error.
+debug=false
\ No newline at end of file