~alpine/devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2

[alpine-devel] [PATCH] abuild: created 'saveas-*://' URI support

Details
Message ID
<1293589337-5232-1-git-send-email-mcs@darkregion.net>
Sender timestamp
1293589337
DKIM signature
missing
Download raw message
Patch: +9 -2
'saveas-*://' URI support has been created for use with the source= line of
APKBUILD files.

It allows for a remote source file to be saved with an arbitrary filename.  This
is useful in situations where the last component of the URI is not the preferred
filename.

Here's how it works.  Say we have the following URI:

  http://oss.example.org/?get=software&ver=1.0

Both Busybox Wget and GNU Wget will save this with the filename:

  ?get=software&ver=1.0

To get around this, we could use cURL to save the file using the filename in the
HTTP response headers:

  $ curl -JO "http://oss.example.org/?get=software&ver=1.0"

Or we could use this 'saveas' hack.  Essentially, the original URI is converted
to read:

  saveas-http://oss.example.org/?get=software&ver=1.0/software-1.0.tar.gz

In the download process, the 'saveas-' portion is removed, and the file is
downloaded from the original URI, but is saved with the filename being the last
component of the URI.  In this case, it will be saved as 'software-1.0.tar.gz'.

It is designed so that it works with any protocol supported by abuild.
For example:

  saveas-ftp://oss.example.org/?get=software&ver=1.0/software-1.0.tar.gz

Check it out and let me know what you think.

Thanks,
Matt
---
 abuild.in |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/abuild.in b/abuild.in
index e5809dc..8f9e773 100755
--- a/abuild.in
+++ b/abuild.in
@@ -179,7 +179,14 @@ uri_fetch() {

	# we need GNU wget for this
	case "$uri" in
		https://*) opts="--no-check-certificate";;
		*https://*) opts="--no-check-certificate";;
	esac

	# fix saveas-*://* URIs
	case "$uri" in
		# remove 'saveas-' from beginning and
		# '/filename' from end of URI
		saveas-*://*) uri="${uri:7:$(expr ${#uri} - 7 - ${#d} - 1)}";;
	esac
	
	mkdir -p "$SRCDEST"
@@ -194,7 +201,7 @@ uri_fetch() {

is_remote() {
	case "$1" in
		http://*|ftp://*|https://*)
		http://*|ftp://*|https://*|saveas-*://*)
			return 0;;
	esac
	return 1
-- 
1.7.3.3



---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Natanael Copa <ncopa@alpinelinux.org>
Details
Message ID
<20101229084540.3012bfc8@ncopa-desktop.nor.wtbts.net>
In-Reply-To
<1293589337-5232-1-git-send-email-mcs@darkregion.net> (view parent)
Sender timestamp
1293608740
DKIM signature
missing
Download raw message
On Tue, 28 Dec 2010 20:22:17 -0600
Matt Smith <mcs@darkregion.net> wrote:

> 'saveas-*://' URI support has been created for use with the source=
> line of APKBUILD files.
> 
> It allows for a remote source file to be saved with an arbitrary
> filename.  This is useful in situations where the last component of
> the URI is not the preferred filename.
> 
> Here's how it works.  Say we have the following URI:
> 
>   http://oss.example.org/?get=software&ver=1.0
> 
> Both Busybox Wget and GNU Wget will save this with the filename:
> 
>   ?get=software&ver=1.0

Yes, I'm aware of this problem.

> To get around this, we could use cURL to save the file using the
> filename in the HTTP response headers:
> 
>   $ curl -JO "http://oss.example.org/?get=software&ver=1.0"

The drawback with this is that abuild will not know the filename til
after the file is downloaded. How do we check if the file already exist
in cache? How do we know what package we shoudl try unpack?


> Or we could use this 'saveas' hack.  Essentially, the original URI is
> converted to read:
> 
>   saveas-http://oss.example.org/?get=software&ver=1.0/software-1.0.tar.gz
> 
> In the download process, the 'saveas-' portion is removed, and the
> file is downloaded from the original URI, but is saved with the
> filename being the last component of the URI.  In this case, it will
> be saved as 'software-1.0.tar.gz'.
> 
> It is designed so that it works with any protocol supported by abuild.
> For example:
> 
>   saveas-ftp://oss.example.org/?get=software&ver=1.0/software-1.0.tar.gz
> 
> Check it out and let me know what you think.

I think this hack was pretty clever. It is technically simple to
implement. The only thing im sceptic about is that adding "magic"
features makes it harder for newcomers. We would need to document it.

Do we have other options? I'd say we got for the saveas- hack unless
someone have better a better option.

-nc


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Natanael Copa <ncopa@alpinelinux.org>
Details
Message ID
<20101230203533.37d4d3dc@alpinelinux.org>
In-Reply-To
<1293589337-5232-1-git-send-email-mcs@darkregion.net> (view parent)
Sender timestamp
1293741333
DKIM signature
missing
Download raw message
On Tue, 28 Dec 2010 20:22:17 -0600
Matt Smith <mcs@darkregion.net> wrote:

... 
> Or we could use this 'saveas' hack.  Essentially, the original URI is
> converted to read:
> 
>   saveas-http://oss.example.org/?get=software&ver=1.0/software-1.0.tar.gz
> 
> In the download process, the 'saveas-' portion is removed, and the
> file is downloaded from the original URI, but is saved with the
> filename being the last component of the URI.  In this case, it will
> be saved as 'software-1.0.tar.gz'.
> 
> It is designed so that it works with any protocol supported by abuild.
> For example:
> 
>   saveas-ftp://oss.example.org/?get=software&ver=1.0/software-1.0.tar.gz
> 
...
> ---
>  abuild.in |   11 +++++++++--
>  1 files changed, 9 insertions(+), 2 deletions(-)
> 

No-one had better patches. Applied!

Thanks!

-nc


---
Unsubscribe:  alpine-devel+unsubscribe@lists.alpinelinux.org
Help:         alpine-devel+help@lists.alpinelinux.org
---
Reply to thread Export thread (mbox)