[pacman-dev] [PATCH] Added mirror support to makepkg's source array.

Allan McRae allan at archlinux.org
Sun Nov 17 21:09:07 EST 2013


On 18/11/13 03:46, Xyne wrote:
> On 2013-11-15 21:06 +1000
> Allan McRae wrote:
> 
>> An idea is doing:
>>
>> source=("mirror://file.tar.gz")
>> mirror=("http://foo.com/" "http://bar.com/")
>>
>> makepkg would replace "mirror://" in the source line with a value from
>> the "mirror" array and try downloading from each one until success or
>> total failure.
>>
>> To allow multiple sources to have different mirrors, I am proposing we
>> detect an unknown protocol in the url and look for the corresponding
>> array.  e.g. we could have source=("sourceforge://file.tar.gz") and look
>> for the "sourceforge" array.
>>
>> Comments or other ideas?
> 
> Detecting "unknown" protocols is not future proof and will lead to an easy but
> never-ending game of whack-a-mole. It would also lead to unnecessary repetition
> in the "mirror" array.
> 
> I think it would be better to use a variable delimiter (possibly an illegal URL
> character, or a PKGBUILD-variable for maximum flexibility), e.g.
> 
> source_delim='*'
> source=("http://*mirror*file.tar.gz")
> mirror=("foo.com/" "bar.com/")
> 
> You could even use "source_" as a prefix for the source variables to avoid
> namespace polution (source_mirror, source_foo, etc).
> 
> Allowing variables at arbitrary points provides greater flexibility and
> reduces verbosity (e.g. the repetition of the scheme in this case). If you
> really want to limit this to URL prefixes, then I suggest enforcing a policy of
> using lower-case schemes for regular URLs and upper-case pseudo-schemes for
> mirrors, e.g.
> 
> source=("MIRROR://file.tar.gz")
> MIRROR=("http://foo.com/" "http://bar.com/")
> 
> While I think the previous approach is better, this would also avoid the
> eventual grief of a hard-coded list of recognized protocols.
> 

What did you think about the proposal in an earlier reply to this thread:

source=("mirror://_foo/blah/blah/foo.tar.gz")
_foo=("http://foo.com/" "http://bar.com/")

I think we can bet safely that "mirror://" will not become a valid
protocol.  And we are replacing the start of the URL so just using the
initial "/" as the delimiter is fine.

Allan



More information about the pacman-dev mailing list