Re: Base URL handling
Zdenek Pavlas <[email protected]> Mon, 4 Mar 2013 08:18:05 -0500 (EST)
| Newsgroups | gmane.linux.rpm.yum |
|---|---|
| Message-ID | <[email protected]> |
> <location xml:base="http://download.example.com/root"
> href="packages/example-0.1-1.x86_64.rpm"/>
>
> My reading of RFC 3986 suggests that the combined URL should be:
>
> http://download.example.com/packages/example-0.1-1.x86_64.rpm
After reading the RFC, I must agree.
o return a string consisting of the reference's path component
appended to all but the last segment of the base URI's path (i.e.,
excluding any characters after the right-most "/" in the base URI
path, or excluding the entire base URI path if it does not contain
any "/" characters).
That's how urlparse.urljoin() works.
> However, the expected URL (from the server directory layout and the
> fact that yum can download the RPM) appears to be:
>
> http://download.example.com/root/packages/example-0.1-1.x86_64.rpm
Yes, instead of merging, Yum just joins all components, inserting
a slash in the middle if there's not one already.
> Is there a high-level description of how yum combines URLs? Any
> suggestions for approximating that?
Yum handles base URLs in variety of ways:
1) metalink.xml
The <url> elements always end with "/repodata/repomd.xml". Yum checks
for this and strips these last two path components. This is probably
an accepted de-facto standard.
2) baseurl set in *.repo file
If the baseurl does not end with "/", Yum includes the last component
in full url.
3) repomd.xml
The <location base=".."> is parsed, but never used. Mirror URLs are used
instead.
4) primary.xml
That's the example you used. Handled as in #2, with one small extra bug,
that "/" may be duplicated. createrepo sets the baseurl attribute directly
from the --baseurl cli option.
IMO, #1 can't be changed. #2 is mostly ok, as the shipped .repo files
almost always have baseurls with trailing slashes anyway.
I'm surprised that baseurls in #3 and #4 are handled differently.
#4 could be worked around in createrepo, by appending a trailing slash
to --baseurl option.