util: allow passing commit and checksum through envvars to acquire

This commit is contained in:
Connor Olding 2022-10-11 11:17:38 -07:00
parent fca8488b08
commit 3103186443
1 changed files with 7 additions and 3 deletions

View File

@ -30,11 +30,17 @@ argue()
(dest) dest="$rhs" ;; \
(commit) commit="$rhs" ;; \
(checksum) checksum="$rhs" ;; \
(env) env="${rhs%%[!A-Za-z0-9_]*}" ;; \
(*) warn "ignoring unknown key: $lhs" ;; \
esac \
|| exit \
;done \
&& { [ "${#from}" != 0 ] || die "missing a required key: from" ;} \
&& if [ -n "$env" ] && [ ".${env#[0-9]}" = ".$env" ] \
;then : \
"${commit:="$(printenv "${env}_COMMIT")"}" \
"${checksum:="$(printenv "${env}_SHA256")"}" \
;fi \
&& if [ "$from" = github ] || [ "$from" = sourcehut ] \
;then : \
&& missing key repo "$repo" \
@ -62,9 +68,7 @@ argue()
|| exit \
;}
ok=1 from= repo= commit= checksum=
: \
ok=1 from= repo= commit= checksum= env= \
&& { [ "$#" == 0 ] || argue "$@" ;} \
&& { [ -d "/tmp" ] || die '/tmp must be mounted (or just exist)' ;} \
&& missing variable dest "$dest" \