Skip to content

Commit 430f1eb

Browse files
committed
[fix] : Exit when the wrong kernel or language is specified
1 parent 0896fdb commit 430f1eb

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

allarch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,8 +1191,8 @@ make_iso() {
11911191

11921192
# Parse files
11931193
parse_files() {
1194-
eval $(bash "${script_path}/tools/locale.sh" -a "${arch}" get "${locale_name}")
1195-
eval $(bash "${script_path}/tools/kernel.sh" -a "${arch}" get "${kernel}")
1194+
eval $(bash "${script_path}/tools/locale.sh" -s -a "${arch}" get "${locale_name}")
1195+
eval $(bash "${script_path}/tools/kernel.sh" -s -a "${arch}" get "${kernel}")
11961196
}
11971197

11981198
# Parse options

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,8 +1250,8 @@ make_iso() {
12501250

12511251
# Parse files
12521252
parse_files() {
1253-
eval $(bash "${script_path}/tools/locale.sh" -a "${arch}" get "${locale_name}")
1254-
eval $(bash "${script_path}/tools/kernel.sh" -a "${arch}" get "${kernel}")
1253+
eval $(bash "${script_path}/tools/locale.sh" -s -a "${arch}" get "${locale_name}")
1254+
eval $(bash "${script_path}/tools/kernel.sh" -s -a "${arch}" get "${kernel}")
12551255
}
12561256

12571257

tools/kernel.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mode=""
77
arch=""
88
channel=""
99
kernel=""
10+
script=false
1011

1112
_help() {
1213
echo "usage ${0} [options] [command]"
@@ -22,6 +23,7 @@ _help() {
2223
echo " General options:"
2324
echo " -a | --arch [arch] Specify the architecture"
2425
echo " -c | --channel Specify the channel"
26+
echo " -s | --script Enable script mode"
2527
echo " -h | --help This help message"
2628
}
2729

@@ -33,7 +35,7 @@ getclm() {
3335

3436
# Message functions
3537
msg_error() {
36-
"${script_path}/tools/msg.sh" -a "kernel.sh" error "${1}"
38+
"${script_path}/tools/msg.sh" -s 6 -a "kernel.sh" error "${1}"
3739
}
3840

3941
gen_kernel_list() {
@@ -60,8 +62,10 @@ check() {
6062
fi
6163
if [[ $(printf '%s\n' "${kernellist[@]}" | grep -qx "${1}"; echo -n ${?} ) -eq 0 ]]; then
6264
echo "correct"
65+
exit 0
6366
else
6467
echo "incorrect"
68+
exit 1
6569
fi
6670
}
6771

@@ -99,6 +103,9 @@ get() {
99103
# 不正なカーネル名なら終了する
100104
if [[ "${_kernel_line}" = "failed" ]]; then
101105
msg_error "Invalid kernel ${1}"
106+
if [[ "${script}" = true ]]; then
107+
echo "exit 1"
108+
fi
102109
exit 1
103110
fi
104111

@@ -116,8 +123,8 @@ EOF
116123

117124
# Parse options
118125
ARGUMENT="${@}"
119-
_opt_short="a:c:h"
120-
_opt_long="arch:,channel:,help"
126+
_opt_short="a:c:hs"
127+
_opt_long="arch:,channel:,help,script"
121128
OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
122129
[[ ${?} != 0 ]] && exit 1
123130

@@ -134,6 +141,10 @@ while true; do
134141
channel="${2}"
135142
shift 2
136143
;;
144+
-s | --script)
145+
script=true
146+
shift 1
147+
;;
137148
-h | --help)
138149
_help
139150
exit 0

tools/locale.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mode=""
77
arch=""
88
channel=""
99
locale=""
10+
script=false
1011

1112
_help() {
1213
echo "usage ${0} [options] [command]"
@@ -33,7 +34,7 @@ getclm() {
3334

3435
# Message functions
3536
msg_error() {
36-
"${script_path}/tools/msg.sh" -a "locale.sh" error "${1}"
37+
"${script_path}/tools/msg.sh" -s 6 -a "locale.sh" error "${1}"
3738
}
3839

3940
gen_locale_list() {
@@ -55,8 +56,10 @@ check() {
5556
fi
5657
if [[ $(printf '%s\n' "${localelist[@]}" | grep -qx "${1}"; echo -n ${?} ) -eq 0 ]]; then
5758
echo "correct"
59+
exit 0
5860
else
5961
echo "incorrect"
62+
exit 1
6063
fi
6164
}
6265

@@ -93,6 +96,9 @@ get() {
9396
# 不正なロケール名なら終了する
9497
if [[ "${_locale_line_number}" = "failed" ]]; then
9598
msg_error "${1} is not a valid language."
99+
if [[ "${script}" = true ]]; then
100+
echo "exit 1"
101+
fi
96102
exit 1
97103
fi
98104

@@ -112,8 +118,8 @@ EOF
112118

113119
# Parse options
114120
ARGUMENT="${@}"
115-
_opt_short="a:c:h"
116-
_opt_long="arch:,channel:,help"
121+
_opt_short="a:c:hs"
122+
_opt_long="arch:,channel:,help,script"
117123
OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
118124
[[ ${?} != 0 ]] && exit 1
119125

@@ -130,6 +136,10 @@ while true; do
130136
channel="${2}"
131137
shift 2
132138
;;
139+
-s | --script)
140+
script=true
141+
shift 1
142+
;;
133143
-h | --help)
134144
_help
135145
exit 0

0 commit comments

Comments
 (0)