diff --git a/install.sh b/install.sh index 6440bff0fc..1ea8afe479 100755 --- a/install.sh +++ b/install.sh @@ -792,24 +792,18 @@ find_rpm_asset() { _package="$3" case "$_package" in - openshell) - _dev_name="openshell-dev-${_arch}.rpm" - _fallback_re="^openshell-[0-9].*\\.${_arch}\\.rpm$" - ;; - openshell-gateway) - _dev_name="openshell-gateway-dev-${_arch}.rpm" - _fallback_re="^openshell-gateway-[0-9].*\\.${_arch}\\.rpm$" - ;; - openshell-prover) - _dev_name="openshell-prover-dev-${_arch}.rpm" - _fallback_re="^openshell-prover-[0-9].*\\.${_arch}\\.rpm$" - ;; + openshell|openshell-gateway|openshell-prover) ;; *) error "unknown RPM package selector: ${_package}" ;; esac - awk -v dev_name="$_dev_name" -v fallback_re="$_fallback_re" ' + # Build the regex inside awk: -v values have their escapes processed. + awk -v package="$_package" -v arch="$_arch" ' + BEGIN { + dev_name = package "-dev-" arch ".rpm" + fallback_re = "^" package "-[0-9].*\\." arch "\\.rpm$" + } { name = $2 sub("^\\*", "", name) diff --git a/tasks/scripts/test-install-sh.sh b/tasks/scripts/test-install-sh.sh index 80ac03d2c6..fb5c382c8e 100755 --- a/tasks/scripts/test-install-sh.sh +++ b/tasks/scripts/test-install-sh.sh @@ -845,6 +845,32 @@ if [ "$(find_rpm_asset "${tmpdir}/checksums" x86_64 openshell-prover)" != "opens exit 1 fi +cat >"${tmpdir}/checksums" <<'EOF' +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa openshell-0.1.5-1xx86_64xrpm +bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb openshell-0.1.5-1.x86_64.rpm +cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc openshell-gateway-0.1.5-1.x86_64.rpm +EOF + +# gawk warns on bad regex escapes; mawk does not. Prefer gawk when present. +rpm_path="$PATH" +if gawk_bin="$(command -v gawk)"; then + mkdir "${tmpdir}/gawk-bin" + ln -s "$gawk_bin" "${tmpdir}/gawk-bin/awk" + rpm_path="${tmpdir}/gawk-bin:${PATH}" +fi + +rpm_err="${tmpdir}/rpm_err" +if [ "$(PATH="$rpm_path" find_rpm_asset "${tmpdir}/checksums" x86_64 openshell 2>"$rpm_err")" != "openshell-0.1.5-1.x86_64.rpm" ] || + [ "$(PATH="$rpm_path" find_rpm_asset "${tmpdir}/checksums" x86_64 openshell-gateway 2>>"$rpm_err")" != "openshell-gateway-0.1.5-1.x86_64.rpm" ]; then + echo "FAIL: RPM fallback must match a literal dot" >&2 + exit 1 +fi +if [ -s "$rpm_err" ]; then + echo "FAIL: RPM package selection must not print to stderr" >&2 + cat "$rpm_err" >&2 + exit 1 +fi + mock_gh_log="${tmpdir}/gh.log" PLATFORM=linux linux_package_method() {