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. Incidentally, if you generalize this enough you could probably re-use the code to implement dependency alternatives, if you are interested in that. The logic overlaps. Regards, Xyne