5 script_path="$( cd -P "$( dirname "$(readlink -f "$0")" )" && cd .. && pwd )"
12 alteriso_version="3.1"
18 echo "usage ${0} [options] [command]"
20 echo "The script that performs processing related to channels"
22 echo " General command:"
23 echo " check [name] Returns whether the specified channel name is valid."
24 echo " desc [name] Display a description of the specified channel"
25 echo " show Display a list of channels"
26 echo " ver Display a version declared on the channel"
27 echo " help This help message"
29 echo " General options:"
30 echo " -a | --arch [arch] Specify the architecture"
31 echo " -b | --nobuiltin Exclude built-in channels"
32 echo " -d | --dirname Display directory names of all channel as it is"
33 echo " -f | --fullpath Display the full path of the channel (Use with -db)"
34 echo " -k | --kernel [name] Specify the supported kernel"
35 echo " -n | --nochkver Ignore channel version"
36 echo " -o | --only-add Only additional channels"
37 echo " -v | --version [ver] Specifies the AlterISO version"
38 echo " -h | --help This help message"
40 echo " --nocheck Do not check the channel with desc command.This option helps speed up."
45 for _dirname in $(ls -l "${script_path}"/channels/ | awk '$1 ~ /d/ {print $9}'); do
46 if [[ -n $(ls "${script_path}"/channels/${_dirname}) ]] && check_alteriso_version "${_dirname}/" || [[ "${opt_nochkver}" = true ]]; then
47 if [[ ! "${arch}" = "all" ]] && [[ -z "$(cat "${script_path}/channels/${_dirname}/architecture" 2> /dev/null | grep -h -v ^'#' | grep -x "${arch}")" ]] || [[ "${_dirname}" = "share" ]] || [[ "${_dirname}" = "share-extra" ]]; then
49 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
51 elif [[ $(echo "${_dirname}" | sed 's/^.*\.\([^\.]*\)$/\1/') = "add" ]]; then
52 if [[ "${opt_dir_name}" = true ]]; then
53 if [[ "${opt_fullpath}" = true ]]; then
54 channellist+=("${script_path}/channels/${_dirname}/")
56 channellist+=("${_dirname}")
59 channellist+=("$(echo ${_dirname} | sed 's/\.[^\.]*$//')")
61 elif [[ ! -d "${script_path}/channels/${_dirname}.add" ]] && [[ "${opt_only_add}" = false ]]; then
62 if [[ "${opt_fullpath}" = true ]]; then
63 channellist+=("${script_path}/channels/${_dirname}/")
65 channellist+=("${_dirname}")
72 if [[ "${opt_nobuiltin}" = false ]]; then
73 channellist+=("clean")
77 # check?alteriso_version <channel dir>
78 get_alteriso_version(){
80 if [[ ! -d "${script_path}/channels/${1}" ]]; then
81 _channel="${script_path}/channels/${1}.add"
83 _channel="${script_path}/channels/${1}"
85 if [[ ! -d "${_channel}" ]]; then
86 echo "${1} was not found." >&2
89 if [[ ! -f "${_channel}/alteriso" ]]; then
90 if (( $(find ./ -maxdepth 1 -mindepth 1 -name "*.x86_64" -o -name ".i686" -o -name "*.any" 2> /dev/null | wc -l) == 0 )); then
95 source "${_channel}/alteriso"
101 check_alteriso_version(){
102 #if [[ "$(get_alteriso_version "${1%.add}")" = "${alteriso_version}" ]]; then
103 if [[ "$(get_alteriso_version "${1%.add}" | cut -d "." -f 1)" = "$(echo "${alteriso_version}" | cut -d "." -f 1)" ]]; then
112 if [[ ! "${#}" = "1" ]]; then
116 if [[ $(printf '%s\n' "${channellist[@]}" | grep -qx "${1}"; echo -n ${?} ) -eq 0 ]]; then
118 elif [[ -d "${1}" ]] && [[ -n $(ls "${1}") ]] && [[ ! "$(basename "${1%/}")" = "share" ]] && [[ ! "$(basename "${1%/}")" = "share-extra" ]]; then
119 local _channel_name="$(basename "${1%/}")"
120 if ! check_alteriso_version "${_channel}" || [[ "${opt_nochkver}" = true ]]; then
132 if [[ ! "${#}" = "1" ]]; then
136 if [[ "${opt_nocheck}" = false ]] && [[ ! "$(bash "${script_path}/tools/channel.sh" -a ${arch} -n -b check "${1}")" = "correct" ]]; then
140 if [[ ! -d "${script_path}/channels/${1}" ]]; then
145 if ! check_alteriso_version "${_channel}" && [[ "${opt_nochkver}" = false ]]; then
146 "${script_path}/tools/msg.sh" --noadjust -l 'ERROR:' --noappname error "Not compatible with AlterISO3"
147 elif [[ -f "${script_path}/channels/${_channel}/description.txt" ]]; then
148 echo -ne "$(cat "${script_path}/channels/${_channel}/description.txt")\n"
150 "${script_path}/tools/msg.sh" --noadjust -l 'WARN :' --noappname warn "This channel does not have a description.txt"
156 if (( "${#channellist[*]}" > 0)); then
157 echo "${channellist[*]}"
164 opt_short="a:bdfk:nov:h"
165 opt_long="arch:,nobuiltin,dirname,fullpath,kernel:,only-add,nochkver,version:,help,nocheck"
166 OPT=$(getopt -o ${opt_short} -l ${opt_long} -- ${ARGUMENT})
167 [[ ${?} != 0 ]] && exit 1
170 unset OPT opt_short opt_long
203 alteriso_version="${2}"
222 if [[ -z "${1}" ]]; then
231 "check" ) check ${@} ;;
233 "desc" ) desc ${@} ;;
234 "ver" ) get_alteriso_version ${@} ;;
235 "help" ) _help; exit 0 ;;