diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-01-16 04:49:56 (EST) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2021-01-16 05:41:49 (EST) |
commit | 854d8403909e7deb0e945ca4723d63ef34357192 (patch) | |
tree | 5b629971e592809644beb98318525d8d8816141f /src/profile | |
parent | 399a3e2a4710fb8ad8e19024e1fc867c6054384f (diff) |
profile/proteanos: Use archive's Platforms file
Diffstat (limited to 'src/profile')
-rw-r--r-- | src/profile/proteanos.sh | 100 |
1 files changed, 73 insertions, 27 deletions
diff --git a/src/profile/proteanos.sh b/src/profile/proteanos.sh index 30e20f4..8a2cf91 100644 --- a/src/profile/proteanos.sh +++ b/src/profile/proteanos.sh @@ -1,6 +1,6 @@ # ProteanOS architecture detection and feeds lists. # -# Copyright (C) 2013-2016 Patrick McDermott +# Copyright (C) 2013-2016, 2021 Patrick McDermott # # This file is part of the ProteanOS Development Kit. # @@ -36,7 +36,60 @@ start() rm -f "${SCRIPT}" } ' -_prof_proteanos_manifest='' + +_prof_proteanos_platforms='' +_prof_proteanos_platforms_platform='' +_prof_proteanos_platforms_type='' +_prof_proteanos_platforms_sections='' + +_prof_proteanos_platforms_field() +{ + local name="${1}" + local value="${2}" + shift 2 + + case "${name}" in + 'Platform') + _prof_proteanos_platforms_platform="${value}" + ;; + 'Type') + _prof_proteanos_platforms_type="${value}" + ;; + 'Sections') + _prof_proteanos_platforms_sections="${value}" + ;; + esac +} + +_prof_proteanos_platforms_paragraph() +{ + local platform= + local archplat= + + platform="${_prof_proteanos_platforms_platform}" + archplat="$(printf '%s' "${platform}" | tr -c '[a-z0-9/]' '_')" + archplat="${archplat%/*}__${archplat#*/}" + + _prof_proteanos_platforms="${_prof_proteanos_platforms}${platform} " + eval "_prof_proteanos_archplat_type_${archplat}=$(: \ + )\"\${_prof_proteanos_platforms_type}\"" + eval "_prof_proteanos_archplat_sections_${archplat}=$(: \ + )\"\${_prof_proteanos_platforms_sections}\"" +} + +_prof_proteanos_get_platforms() +{ + local mirror="${1}" + local suite="${2}" + shift 2 + + [ -n "${_prof_proteanos_platforms}" ] && return + + parse_control - _prof_proteanos_platforms_field \ + _prof_proteanos_platforms_paragraph 0<<-EOF + $(${WGET} -q -O - -- "${mirror}/feeds/${suite}/Platforms") + EOF +} prof_proteanos_detect_root() { @@ -118,20 +171,13 @@ prof_proteanos_validate_archplat() shift 4 local archplat= - [ -z "${_prof_proteanos_manifest}" ] && \ - _prof_proteanos_manifest="$(${WGET} -q -O - -- \ - "${mirror}/feeds/${suite}/Manifest")" + _prof_proteanos_get_platforms "${mirror}" "${suite}" - while read -r archplat; do - case "${archplat}" in - all/*/* | */all/*) ;; - "${arch}/${plat}/"*) - return 0 - ;; - esac - done <<-EOF - ${_prof_proteanos_manifest} - EOF + case " ${_prof_proteanos_platforms} " in + *" ${arch}/${plat} "*) + return 0 + ;; + esac return 1 } @@ -155,27 +201,27 @@ prof_proteanos_feeds() local plat="${3}" local suite="${4}" shift 4 + local arch_clean= + local plat_clean= + local archplat= local sects= + local manifest= local a= local p= local s= - [ -z "${_prof_proteanos_manifest}" ] && \ - _prof_proteanos_manifest="$(${WGET} -q -O - -- \ - "${mirror}/feeds/${suite}/Manifest")" + _prof_proteanos_get_platforms "${mirror}" "${suite}" + arch_clean="$(printf '%s' "${arch}" | tr -c '[a-z0-9/]' '_')" + plat_clean="$(printf '%s' "${plat}" | tr -c '[a-z0-9/]' '_')" + archplat="${arch_clean}__${plat_clean}" + eval "sects=\"\${_prof_proteanos_archplat_sections_${archplat}}\"" + + manifest="$(${WGET} -q -O - -- "${mirror}/feeds/${suite}/Manifest")" - case "${plat}" in - 'dev') - sects='base dev lib libdev share util' - ;; - *) - sects='base boot lib share util' - esac - for a in "${arch}" 'all'; do for p in "${plat}" 'all'; do for s in ${sects}; do - case "${LF}${_prof_proteanos_manifest}${LF}" in + case "${LF}${manifest}${LF}" in *"${LF}${a}/${p}/${s}${LF}"*) ;; *) continue;; esac |