On Sat, Apr 05, 2008, Jeff Johnson wrote:
> [...]
> Likely non-functional in rpm-5.0, mostly because everyone wants to
> do the fetch differently, and network access is disabled by rpm5.org
> policy choice. I've twice setup examples (you're looking at the
> example config from my last setup), but the interest (except for one
> guy in Hungary) has been non-existent judging from weblogs.
>
> I'll get back to the fetch over the next couple months. The higher
> priority is establishing rpmio bona fides.
> [...]
RPM 5.1 provides support for easily hooking in an arbitrary download
command and also for triggering just the download step from the CLI:
1. One configures "rpmmacros" either trivially...
%__urlgetfile() %(curl '-#'' -L -R -o %2 %1; if [ $? -eq 0]; then echo "OK"; else echo "ERROR"; fi)
...or the OpenPKG way for even optional global and local mirror and
backup location support:
%__urlgetfile_urls_mirror() \
%{nil}
%__urlgetfile_urls_backup() %{lua: \
local url = rpm.expand("%1") \
local name = rpm.expand("%{name}") \
if name ~= "" and url ~= "" then \
local cache = "http://download.example.com/cache/" .. name .. "/" \
url = util.rsubst(url, "^.+/([^/]+)$", cache .. "%1") \
print(url) \
end \
}
%__urlgetfile_urls() \
%{?__urlgetfile_urls_mirror %1} %1 %{?__urlgetfile_urls_backup %1}
%__urlgetfile() %{lua: \
local url_orig = rpm.expand("%1") \
local file = rpm.expand("%2") \
local urls = util.rsplit(rpm.expand("%{?__urlgetfile_urls " .. url_orig .. "}"), "\\\\s+") \
local result = "ERROR" \
local type = "mirror" \
for i, url in ipairs(urls) do \
if url ~= "" then
if url == url_orig then \
type = "original" \
elseif type == "original" then \
type = "backup" \
end \
io.stdout:write(string.format("Fetching(%s): %s\\n", type, url)) \
local rc = rpm.expand( \
"%(%{l_prefix}/bin/openpkg curl '-#' -L -R " .. \
"-o '" .. file .. "'" .. " '" .. url .. "' 1>&2; echo $?)" \
) \
if rc == "0" then \
result = "OK" \
break \
end \
end
end \
print(result) \
}
2. With this in place whenever RPM detects that a SourceX or PatchX file
is still missing and the above macro is defined, it automatically
tries to download the file or you even could trigger this downloading
step manually by "building" the "fetching" step explicitly:
$ rpm -bf openpkg.spec
Fetching(Source8): http://rpm5.org/files/rpm/rpm-5.1/SNAPSHOT/rpm-5.1.SNAPSHOT.20080405.tar.gz
Fetching(mirror): http://download.openpkg.org/components/cache/openpkg/rpm-5.1.SNAPSHOT.20080405.tar.gz
curl: (22) The requested URL returned error: 404
Fetching(original): http://rpm5.org/files/rpm/rpm-5.1/SNAPSHOT/rpm-5.1.SNAPSHOT.20080405.tar.gz
[...]
As you can see, RPM 5.1 already provides everything one needs to hook an
arbitrary complex and customized downloading approach into the package
build procedure.
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
Received on Sun Apr 6 09:42:39 2008