From 45e8fd75c621899365406141d9b9fe0aab0183e0 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 16 Jan 2021 05:20:21 -0500 Subject: profile_prepare_install(): New function profile_installer_type() will be the first caller of _prof_proteanos_get_platforms() to be called, but it will be called in a subshell. As a result, _prof_proteanos_get_platforms() would be called twice. To solve this, factor out _prof_proteanos_get_platforms() calls from other functions, making them pure (subshell-safe). --- diff --git a/src/install.sh b/src/install.sh index e3e9819..c5d3a5a 100644 --- a/src/install.sh +++ b/src/install.sh @@ -337,6 +337,7 @@ install_system() if [ "x${mirror}" = 'x' ]; then mirror="$(profile_select_mirror)" fi + profile_prepare_install "${mirror}" "${suite}" if ! profile_validate_archplat "${mirror}" "${arch}" "${plat}" \ "${suite}"; then diff --git a/src/profile.sh b/src/profile.sh index 744ddef..582166c 100644 --- a/src/profile.sh +++ b/src/profile.sh @@ -70,10 +70,10 @@ profile_detect() } for func in normalize_suite detect_arch default_plat select_mirror \ - installer_type validate_archplat opkg_state_dir opkg_conf_file \ - feeds get_cert_url get_root_key dep_fields include_pkg \ - get_fstab file_systems_mounted bind_mount bind_umount \ - configure_system_native configure_system_foreign find_kernel \ - make_initramfs; do + prepare_install installer_type validate_archplat \ + opkg_state_dir opkg_conf_file feeds get_cert_url get_root_key \ + dep_fields include_pkg get_fstab file_systems_mounted \ + bind_mount bind_umount configure_system_native \ + configure_system_foreign find_kernel make_initramfs; do eval "profile_${func}() { \"prof_\${_profile}_${func}\" \"\${@}\"; }" done diff --git a/src/profile/proteanos.sh b/src/profile/proteanos.sh index 0f34f5d..e208464 100644 --- a/src/profile/proteanos.sh +++ b/src/profile/proteanos.sh @@ -77,20 +77,6 @@ _prof_proteanos_platforms_paragraph() )\"\${_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() { local root="${1}" @@ -162,6 +148,20 @@ prof_proteanos_select_mirror() printf '%s\n' "${mirrors}" | sed -n "${mirror_num}p" } +prof_proteanos_prepare_install() +{ + 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_installer_type() { local mirror="${1}" @@ -174,13 +174,12 @@ prof_proteanos_installer_type() local archplat= local installer_type= - _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 "installer_type=\"\${_prof_proteanos_archplat_type_${archplat}}\"" - return "${installer_type}" + printf '%s' "${installer_type}" } prof_proteanos_validate_archplat() @@ -192,8 +191,6 @@ prof_proteanos_validate_archplat() shift 4 local archplat= - _prof_proteanos_get_platforms "${mirror}" "${suite}" - case " ${_prof_proteanos_platforms} " in *" ${arch}/${plat} "*) return 0 @@ -231,7 +228,6 @@ prof_proteanos_feeds() local p= local s= - _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}" -- cgit v0.9.1