From 3103186443f2afbe61a9712e094ec6338cc0e5ff Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 11 Oct 2022 11:17:38 -0700 Subject: [PATCH] util: allow passing commit and checksum through envvars to acquire --- notwa-util/acquire | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/notwa-util/acquire b/notwa-util/acquire index 04aa036..f0cab0a 100755 --- a/notwa-util/acquire +++ b/notwa-util/acquire @@ -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" \