5 script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )"
13 alteriso_version="3.1"
19 echo "usage ${0} [options] [command]"
21 echo "The script that performs processing related to channels"
23 echo " General command:"
24 echo " check [name] Returns whether the specified channel name is valid."
25 echo " desc [name] Display a description of the specified channel"
26 echo " show Display a list of channels"
27 echo " ver Display a version declared on the channel"
28 echo " help This help message"
30 echo " General options:"
31 echo " -a | --arch [arch] Specify the architecture"
32 echo " -b | --nobuiltin Exclude built-in channels"
33 echo " -d | --dirname Display directory names of all channel as it is"
34 echo " -f | --fullpath Display the full path of the channel (Use with -db)"
35 echo " -k | --kernel [name] Specify the supported kernel"
36 echo " -n | --nochkver Ignore channel version"
37 echo " -o | --only-add Only additional channels"
38 echo " -v | --version [ver] Specifies the AlterISO version"
39 echo " -h | --help This help message"
41 echo " --nocheck Do not check the channel with desc command.This option helps speed up."
42 echo " --line Line break the output"
44 echo " check command exit code"
45 echo " 0 (correct) Normal available channel"
46 echo " 1 (directory) Channel outside the channel directory"
47 echo " 2 (incorrect) Unavailable channel"
53 for _dirname in $(ls -l "${script_path}"/channels/ | awk '$1 ~ /d/ {print $9}'); do
54 if [[ -n $(ls "${script_path}"/channels/${_dirname}) ]] && check_alteriso_version "${_dirname}/" || [[ "${opt_nochkver}" = true ]]; then
55 if [[ ! "${arch}" = "all" ]] && [[ -z "$(cat "${script_path}/channels/${_dirname}/architecture" 2> /dev/null | grep -h -v ^'#' | grep -x "${arch}")" ]]; then
57 elif [[ ! "${kernel}" = "all" ]] && [[ -f "${channel_dir}/kernel_list-${arch}" ]] && [[ -z $( ( cat "${script_path}/channels/${_dirname}/kernel_list-${arch}" | grep -h -v ^'#' | grep -x "${kernel}" ) 2> /dev/null) ]]; then
59 elif [[ $(echo "${_dirname}" | sed 's/^.*\.\([^\.]*\)$/\1/') = "add" ]]; then
60 if [[ "${opt_dir_name}" = true ]]; then
61 if [[ "${opt_fullpath}" = true ]]; then
62 channellist+=("${script_path}/channels/${_dirname}/")
64 channellist+=("${_dirname}")
67 #channellist+=("$(echo ${_dirname} | sed 's/\.[^\.]*$//')")
68 readarray -t -O "${#channellist[@]}" channellist < <(echo "${_dirname}" | sed 's/\.[^\.]*$//')
70 elif [[ ! -d "${script_path}/channels/${_dirname}.add" ]] && [[ "${opt_only_add}" = false ]]; then
71 if [[ "${opt_fullpath}" = true ]]; then
72 channellist+=("${script_path}/channels/${_dirname}/")
74 channellist+=("${_dirname}")
81 if [[ "${opt_nobuiltin}" = false ]]; then
82 channellist+=("clean")
86 # check?alteriso_version <channel dir>
87 get_alteriso_version(){
89 if [[ ! -d "${script_path}/channels/${1}" ]]; then
90 _channel="${script_path}/channels/${1}.add"
92 _channel="${script_path}/channels/${1}"
94 if [[ ! -d "${_channel}" ]]; then
95 echo "${1} was not found." >&2
98 if [[ ! -f "${_channel}/alteriso" ]]; then
99 if (( $(find ./ -maxdepth 1 -mindepth 1 -name "*.x86_64" -o -name ".i686" -o -name "*.any" 2> /dev/null | wc -l) == 0 )); then
104 source "${_channel}/alteriso"
110 check_alteriso_version(){
111 #if [[ "$(get_alteriso_version "${1%.add}")" = "${alteriso_version}" ]]; then
112 if [[ "$(get_alteriso_version "${1%.add}" | cut -d "." -f 1)" = "$(echo "${alteriso_version}" | cut -d "." -f 1)" ]]; then
123 if [[ ! "${#}" = "1" ]]; then
127 if [[ $(printf '%s\n' "${channellist[@]}" | grep -qx "${1}"; echo -n ${?} ) -eq 0 ]]; then
130 elif [[ -d "${1}" ]] && [[ -n $(ls "${1}") ]]; then
131 _channel_name="$(basename "${1%/}")"
132 if check_alteriso_version "${_channel_name}" || [[ "${opt_nochkver}" = true ]]; then
147 if [[ ! "${#}" = "1" ]]; then
151 if [[ "${opt_nocheck}" = false ]] && ! bash "${script_path}/tools/channel.sh" -a ${arch} -n -b check "${1}"; then
155 if [[ ! -d "${script_path}/channels/${1}" ]]; then
160 if ! check_alteriso_version "${_channel}" && [[ "${opt_nochkver}" = false ]]; then
161 "${script_path}/tools/msg.sh" --noadjust -l 'ERROR:' --noappname error "Not compatible with AlterISO3"
162 elif [[ -f "${script_path}/channels/${_channel}/description.txt" ]]; then
163 echo -ne "$(cat "${script_path}/channels/${_channel}/description.txt")\n"
165 "${script_path}/tools/msg.sh" --noadjust -l 'WARN :' --noappname warn "This channel does not have a description.txt"
171 if (( "${#channellist[*]}" > 0)); then
172 if [[ "${opt_line}" = true ]]; then
173 printf "%s\n" "${channellist[@]}"
175 echo "${channellist[*]}"
183 OPTL="arch:,nobuiltin,dirname,fullpath,kernel:,only-add,nochkver,version:,help,nocheck,line"
184 if ! OPT=$(getopt -o ${OPTS} -l ${OPTL} -- "${@}"); then
221 alteriso_version="${2}"
244 if [[ -z "${1}" ]]; then
253 "check" ) check "${@}" ;;
255 "desc" ) desc "${@}" ;;
256 "ver" ) get_alteriso_version "${@}" ;;
257 "help" ) _help; exit 0 ;;