Skip to content

Commit 4c281f4

Browse files
committed
[update] : Use exit code to check channel
1 parent b4e4943 commit 4c281f4

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

build.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,9 @@ prepare_build() {
539539
check_bool boot_splash cleaning noconfirm nodepend customized_username customized_password noloopmod nochname tarball noiso noaur customized_syslinux norescue_entry debug bash_debug nocolor msgdebug noefi nosigcheck
540540

541541
# Check architecture for each channel
542-
if [[ ! "$(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -a ${arch} -n -b check "${channel_name}")" = "correct" ]]; then
542+
local _exit=0
543+
bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -a ${arch} -n -b check "${channel_name}" || _exit="${?}"
544+
if (( "${_exit}" != 0 )) && (( "${_exit}" != 1 )); then
543545
msg_error "${channel_name} channel does not support current architecture (${arch})." "1"
544546
fi
545547

@@ -1305,15 +1307,15 @@ if [[ "${bash_debug}" = true ]]; then set -x -v; fi
13051307

13061308
# Check for a valid channel name
13071309
if [[ -n "${1+SET}" ]]; then
1308-
case "$(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -n check "${1}")" in
1309-
"incorrect")
1310+
case "$(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -n check "${1}"; printf "${?}")" in
1311+
"2")
13101312
msg_error "Invalid channel ${1}" "1"
13111313
;;
1312-
"directory")
1314+
"1")
13131315
channel_dir="${1}"
13141316
channel_name="$(basename "${1%/}")"
13151317
;;
1316-
"correct")
1318+
"0")
13171319
channel_dir="${script_path}/channels/${1}"
13181320
channel_name="${1}"
13191321
;;

tools/channel.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ _help() {
3838
echo " -h | --help This help message"
3939
echo
4040
echo " --nocheck Do not check the channel with desc command.This option helps speed up."
41+
echo
42+
echo " check command exit code"
43+
echo " 0 (correct) Normal available channel"
44+
echo " 1 (directory) Channel outside the channel directory"
45+
echo " 2 (incorrect) Unavailable channel"
46+
echo " 3 Other error"
4147
}
4248

4349
gen_channel_list() {
@@ -111,19 +117,23 @@ check() {
111117
gen_channel_list
112118
if [[ ! "${#}" = "1" ]]; then
113119
_help
114-
exit 1
120+
exit 3
115121
fi
116122
if [[ $(printf '%s\n' "${channellist[@]}" | grep -qx "${1}"; echo -n ${?} ) -eq 0 ]]; then
117-
echo "correct"
123+
#echo "correct"
124+
exit 0
118125
elif [[ -d "${1}" ]] && [[ -n $(ls "${1}") ]]; then
119126
local _channel_name="$(basename "${1%/}")"
120127
if ! check_alteriso_version "${_channel}" || [[ "${opt_nochkver}" = true ]]; then
121-
echo "directory"
128+
#echo "directory"
129+
exit 1
122130
else
123-
echo "incorrect"
131+
#echo "incorrect"
132+
exit 2
124133
fi
125134
else
126-
echo "incorrect"
135+
#echo "incorrect"
136+
exit 2
127137
fi
128138
}
129139

@@ -133,7 +143,7 @@ desc() {
133143
_help
134144
exit 1
135145
fi
136-
if [[ "${opt_nocheck}" = false ]] && [[ ! "$(bash "${script_path}/tools/channel.sh" -a ${arch} -n -b check "${1}")" = "correct" ]]; then
146+
if [[ "${opt_nocheck}" = false ]] && ! bash "${script_path}/tools/channel.sh" -a ${arch} -n -b check "${1}"; then
137147
exit 1
138148
fi
139149
local _channel

0 commit comments

Comments
 (0)