mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: jon@ringle.org
Cc: ptxdist@pengutronix.com, Jon Ringle <jringle@gridpoint.com>
Subject: Re: [ptxdist] [PATCH 1/1] ptxd_make_get: Add support for downloading s3:// urls via aws s3 cp
Date: Tue, 30 Aug 2022 09:02:15 +0200	[thread overview]
Message-ID: <Yw219wYzuRTgjJfK@pengutronix.de> (raw)
In-Reply-To: <20220819103913.2869281-1-jon@ringle.org>

On Fri, Aug 19, 2022 at 06:39:13AM -0400, jon@ringle.org wrote:
> 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##*/}"

unused?

> +
> +	# 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}" && {

	aws s3 ... || return
	...

	to avoid the { } and indention.

Michael

> +		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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2022-08-30  7:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 10:39 jon
2022-08-30  7:02 ` Michael Olbrich [this message]

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=Yw219wYzuRTgjJfK@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=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