OSDN Git Service

[update] : Check version with channel.sh
authorhayao <hayao@fascode.net>
Tue, 2 Mar 2021 11:57:57 +0000 (20:57 +0900)
committerhayao <hayao@fascode.net>
Tue, 2 Mar 2021 11:57:57 +0000 (20:57 +0900)
build.sh
tools/channel.sh

index a5df91f..f81aa44 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -164,10 +164,10 @@ _usage () {
 
     echo
     echo " Channel:"
-    for _dirname in $(bash "${tools_dir}/channel.sh" -d -b -n show); do
+    for _dirname in $(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -d -b -n show); do
         echo -ne "    ${_dirname%.add}"
         echo_blank "$(( ${blank} - 3 - $(echo ${_dirname%.add} | wc -m) ))"
-        "${tools_dir}/channel.sh" --nocheck desc "${_dirname%.add}"
+        "${tools_dir}/channel.sh" --version "${alteriso_version}" --nocheck desc "${_dirname%.add}"
     done
 
     echo
@@ -497,7 +497,7 @@ prepare_build() {
     check_bool boot_splash cleaning noconfirm nodepend shmkalteriso customized_username customized_password noloopmod nochname tarball noiso noaur customized_syslinux norescue_entry debug bash_debug nocolor msgdebug noefi include_extra nosigcheck
 
     # Check architecture for each channel
-    if [[ ! "$(bash "${tools_dir}/channel.sh" -a ${arch} -n -b check "${channel_name}")" = "correct" ]]; then
+    if [[ ! "$(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -a ${arch} -n -b check "${channel_name}")" = "correct" ]]; then
         msg_error "${channel_name} channel does not support current architecture (${arch})." "1"
     fi
 
@@ -1223,7 +1223,7 @@ if [[ "${bash_debug}" = true ]]; then set -x -v; fi
 
 # Check for a valid channel name
 if [[ -n "${1+SET}" ]]; then
-    case "$(bash "${tools_dir}/channel.sh" -n check "${1}")" in
+    case "$(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" -n check "${1}")" in
         "incorrect")
             msg_error "Invalid channel ${1}" "1"
             ;;
@@ -1252,12 +1252,12 @@ fi
 
 # Check channel version
 msg_debug "channel path is ${channel_dir}"
-if [[ ! "$(cat "${channel_dir}/alteriso" 2> /dev/null)" = "alteriso=${alteriso_version}" ]] && [[ "${nochkver}" = false ]]; then
+if [[ "$(bash "${tools_dir}/channel.sh" --version "${alteriso_version}" ver "${channel_name}" | cut -d "." -f 1)" = "$(echo "${alteriso_version}" | cut -d "." -f 1)" ]] && [[ "${nochkver}" = false ]]; then
     msg_error "This channel does not support Alter ISO 3."
     if [[ -d "${script_path}/.git" ]]; then
         msg_error "Please run \"git checkout alteriso-2\"" "1"
     else
-        msg_error "Please download Alter ISO 2 here.\nhttps://github.com/FascodeNet/alterlinux/archive/alteriso-2.zip" "1"
+        msg_error "Please download old version here.\nhttps://github.com/FascodeNet/alterlinux/releases" "1"
     fi
 fi
 
index 5271266..3ff89b5 100755 (executable)
@@ -9,7 +9,7 @@ opt_nochkver=false
 opt_nobuiltin=false
 opt_fullpath=false
 opt_nocheck=false
-alteriso_version="3.0"
+alteriso_version="3.1"
 mode=""
 arch="all"
 kernel="all"
@@ -23,6 +23,7 @@ _help() {
     echo "    check [name]       Returns whether the specified channel name is valid."
     echo "    desc [name]        Display a description of the specified channel"
     echo "    show               Display a list of channels"
+    echo "    ver                Display a version declared on the channel"
     echo "    help               This help message"
     echo
     echo " General options:"
@@ -42,7 +43,7 @@ _help() {
 gen_channel_list() {
     local _dirname
     for _dirname in $(ls -l "${script_path}"/channels/ | awk '$1 ~ /d/ {print $9}'); do
-        if [[ -n $(ls "${script_path}"/channels/${_dirname}) ]] && [[ "$(cat "${script_path}/channels/${_dirname}/alteriso" 2> /dev/null)" = "alteriso=${alteriso_version}" ]] || [[ "${opt_nochkver}" = true ]]; then
+        if [[ -n $(ls "${script_path}"/channels/${_dirname}) ]] && check_alteriso_version "${_dirname}/" || [[ "${opt_nochkver}" = true ]]; then
             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
                 continue
             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
@@ -74,7 +75,7 @@ gen_channel_list() {
 }
 
 # check?alteriso_version <channel dir>
-check_alteriso_version(){
+get_alteriso_version(){
     local _channel
     if [[ ! -d "${script_path}/channels/${1}" ]]; then
         _channel="${script_path}/channels/${1}.add"
@@ -97,6 +98,15 @@ check_alteriso_version(){
     fi
 }
 
+check_alteriso_version(){
+    #if [[ "$(get_alteriso_version "${1%.add}")" = "${alteriso_version}" ]]; then
+    if [[ "$(get_alteriso_version "${1%.add}" | cut -d "." -f 1)" = "$(echo "${alteriso_version}" | cut -d "." -f 1)" ]]; then
+        return 0
+    else
+        return 1
+    fi
+}
+
 check() {
     gen_channel_list
     if [[ ! "${#}" = "1" ]]; then
@@ -107,7 +117,7 @@ check() {
         echo "correct"
     elif [[ -d "${1}" ]] && [[ -n $(ls "${1}") ]] && [[ ! "$(basename "${1%/}")" = "share" ]] && [[ ! "$(basename "${1%/}")" = "share-extra" ]]; then
         local _channel_name="$(basename "${1%/}")"
-        if [[ "$(cat "${script_path}/channels/${_dirname}/alteriso" 2> /dev/null)" = "alteriso=${alteriso_version}" ]] || [[ "${opt_nochkver}" = true ]]; then
+        if ! check_alteriso_version "${_channel}" || [[ "${opt_nochkver}" = true ]]; then
             echo "directory"
         else
             echo "incorrect"
@@ -132,7 +142,7 @@ desc() {
     else
         _channel="${1}"
     fi
-    if [[ ! "$(cat "${script_path}/channels/${_channel}/alteriso" 2> /dev/null)" = "alteriso=${alteriso_version}" ]] && [[ "${opt_nochkver}" = false ]]; then
+    if ! check_alteriso_version "${_channel}" && [[ "${opt_nochkver}" = false ]]; then
         "${script_path}/tools/msg.sh" --noadjust -l 'ERROR:' --noappname error "Not compatible with AlterISO3"
     elif [[ -f "${script_path}/channels/${_channel}/description.txt" ]]; then
         echo -ne "$(cat "${script_path}/channels/${_channel}/description.txt")\n"
@@ -221,7 +231,7 @@ case "${mode}" in
     "check" ) check ${@}                  ;;
     "show"  ) show                        ;;
     "desc"  ) desc ${@}                   ;;
-    "ver"   ) check_alteriso_version ${@} ;;
+    "ver"   ) get_alteriso_version ${@} ;;
     "help"  ) _help; exit 0               ;;
     *       ) _help; exit 1               ;;
 esac