From: jon@ringle.org
To: ptxdist@pengutronix.com
Cc: Jon Ringle <jringle@gridpoint.com>
Subject: [ptxdist] [PATCH 1/1] ptxd_make_get: Add support for downloading s3:// urls via aws s3 cp
Date: Fri, 19 Aug 2022 06:39:13 -0400 [thread overview]
Message-ID: <20220819103913.2869281-1-jon@ringle.org> (raw)
From: Jon Ringle <jringle@gridpoint.com>
This allows downloading files stored in an AWS S3 bucket via an s3:// url
This allows you to point PTXCONF_SETUP_PTXMIRROR to an s3:// bucket
Signed-off-by: Jon Ringle <jringle@gridpoint.com>
---
scripts/lib/ptxd_make_get.sh | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh
index ee6b01346..d575ac13e 100644
--- a/scripts/lib/ptxd_make_get.sh
+++ b/scripts/lib/ptxd_make_get.sh
@@ -270,6 +270,35 @@ ptxd_make_get_svn() {
}
export -f ptxd_make_get_svn
+#
+# in env:
+#
+# ${path} : local file name
+# ${url} : the url to download
+# ${opts[]} : an array of options
+#
+ptxd_make_get_s3() {
+ local temp_file
+ set -- "${opts[@]}"
+ unset opts
+
+ local file="${url##*/}"
+
+ # remove any pending or half downloaded files
+ rm -f -- "${path}."*
+
+ temp_file="$(mktemp "${path}.XXXXXXXXXX")" || ptxd_bailout "failed to create tempfile"
+
+ aws s3 cp "${url}" "${temp_file}" && {
+ chmod 644 -- "${temp_file}" &&
+ touch -- "${temp_file}" &&
+ mv -- "${temp_file}" "${path}"
+ }
+
+ ptxd_make_serialize_put
+}
+export -f ptxd_make_get_s3
+
#
# check if download is disabled
@@ -412,6 +441,10 @@ ptxd_make_get() {
ptxd_make_get_download_permitted &&
ptxd_make_get_http && return
;;
+ s3://*)
+ ptxd_make_get_download_permitted &&
+ ptxd_make_get_s3 && return
+ ;;
file*)
local thing="${url/file:\/\///}"
--
2.25.1
next reply other threads:[~2022-08-19 10:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-19 10:39 jon [this message]
2022-08-30 7:02 ` Michael Olbrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220819103913.2869281-1-jon@ringle.org \
--to=jon@ringle.org \
--cc=jringle@gridpoint.com \
--cc=ptxdist@pengutronix.com \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox