* [ptxdist] [PATCH v2 1/1] ptxd_make_get: Add support for downloading s3:// urls via aws s3 cp
@ 2022-08-30 12:04 jon
2022-09-11 7:09 ` [ptxdist] [APPLIED] " Michael Olbrich
0 siblings, 1 reply; 2+ messages in thread
From: jon @ 2022-08-30 12:04 UTC (permalink / raw)
To: ptxdist; +Cc: Jon Ringle
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 | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh
index ee6b01346..1578689d7 100644
--- a/scripts/lib/ptxd_make_get.sh
+++ b/scripts/lib/ptxd_make_get.sh
@@ -270,6 +270,32 @@ 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
+
+ # 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}" || return
+ 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 +438,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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ptxdist] [APPLIED] ptxd_make_get: Add support for downloading s3:// urls via aws s3 cp
2022-08-30 12:04 [ptxdist] [PATCH v2 1/1] ptxd_make_get: Add support for downloading s3:// urls via aws s3 cp jon
@ 2022-09-11 7:09 ` Michael Olbrich
0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2022-09-11 7:09 UTC (permalink / raw)
To: ptxdist; +Cc: Jon Ringle
Thanks, applied as 913167a9872060706cd6ae6e90607010cd6d7c1d.
Michael
[sent from post-receive hook]
On Sun, 11 Sep 2022 09:09:54 +0200, Jon Ringle <jon@ringle.org> wrote:
> 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>
> Message-Id: <20220830120453.612075-1-jon@ringle.org>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
>
> diff --git a/scripts/lib/ptxd_make_get.sh b/scripts/lib/ptxd_make_get.sh
> index ee6b01346f93..1578689d72dc 100644
> --- a/scripts/lib/ptxd_make_get.sh
> +++ b/scripts/lib/ptxd_make_get.sh
> @@ -270,6 +270,32 @@ 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
> +
> + # 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}" || return
> + 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 +438,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:\/\///}"
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-11 7:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-30 12:04 [ptxdist] [PATCH v2 1/1] ptxd_make_get: Add support for downloading s3:// urls via aws s3 cp jon
2022-09-11 7:09 ` [ptxdist] [APPLIED] " Michael Olbrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox