I would have done
%(%{__urlgetfile} ... && echo %?)
But I''ve never figgered satisfactory solution for stderr out-of-band
returns. The in-band "echo $?" is far from satisfactory.
Someplace on the TODO is steal Panu's curl invocation and
wire up a new pipe-to-command based rpmio access type to
accomodaate those who simply must have external helpers as
well as lzma (and other external) compression.
73 de Jeff
On Dec 23, 2007, at 11:26 AM, Ralf S. Engelschall wrote:
> RPM Package Manager, CVS Repository
> http://rpm5.org/cvs/
>
> ____________________________________________________________________________
>
> Server: rpm5.org Name: Ralf S. Engelschall
> Root: /v/rpm/cvs Email: rse@rpm5.org
> Module: rpm Date: 23-Dec-2007 17:26:03
> Branch: HEAD Handle: 2007122316260201
>
> Modified files:
> rpm VENDOR
> rpm/rpmio url.c
>
> Log:
> Add an OpenPKG-specific addition: allow one to use macro %
> {__urlgetfile}
> for downloading still missing source files via an external
> command. This
> allows us to consistently use the same download tool, even for
> RPM's
> fetching tasks.
>
> Summary:
> Revision Changes Path
> 2.13 +16 -0 rpm/VENDOR
> 1.46 +17 -0 rpm/rpmio/url.c
>
> ____________________________________________________________________________
>
> patch -p0 <<'@@ .'
> Index: rpm/VENDOR
>
> =
> =
> =
> =
> =
> =
> ======================================================================
> $ cvs diff -u -r2.12 -r2.13 VENDOR
> --- rpm/VENDOR 22 Dec 2007 11:06:57 -0000 2.12
> +++ rpm/VENDOR 23 Dec 2007 16:26:02 -0000 2.13
> @@ -281,4 +281,20 @@
> better be able to check for a --quiet option
> via
> macros), but for %track we really want to
> control
> verbosity explicitly.
> +
> ________________________________________________________________________
> +
> + Change: support-external-download-command
> + Purpose: Allow one to use macro %{__urlgetfile} for
> downloading
> + still missing source files via an external
> command
> + Reason: The internal URL fetching functionality was
> discovered
> + to be not sufficient in practice when it
> comes to
> + HTTP redirects, FTP passive/active modes,
> etc. To
> + easily workaround this and at the same time be
> + consistent in the used downloading tool, we
> want
> + to use an external download tool. In OpenPKG
> cURL
> + is part of the OpenPKG bootstrap (and used
> for all
> + other downloads outside of RPM anyway), so we
> will
> + use '%__urlgetfile() %{l_curl} -o "%2" "%1"'
> in the
> + global "rpmmacros" file. Other tools can be
> used
> + similarily.
>
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmio/url.c
>
> =
> =
> =
> =
> =
> =
> ======================================================================
> $ cvs diff -u -r1.45 -r1.46 url.c
> --- rpm/rpmio/url.c 23 Dec 2007 16:15:29 -0000 1.45
> +++ rpm/rpmio/url.c 23 Dec 2007 16:26:03 -0000 1.46
> @@ -524,6 +524,9 @@
> FD_t tfd = NULL;
> const char * sfuPath = NULL;
> int urlType = urlPath(url, &sfuPath);
> +#if defined(RPM_VENDOR_OPENPKG) /* support-external-download-
> command */
> + char *cmd;
> +#endif
>
> if (*sfuPath == '\0')
> return FTPERR_UNKNOWN;
> @@ -537,6 +540,20 @@
> if (dest == NULL)
> return FTPERR_UNKNOWN;
>
> +#if defined(RPM_VENDOR_OPENPKG) /* support-external-download-
> command */
> + cmd = rpmExpand("%{?__urlgetfile:%{__urlgetfile ", url, " ",
> dest, "}}", NULL);
> + if (cmd != NULL && cmd[0] != '\0') {
> + rc = system(cmd);
> + if ((rc >> 8) != 0) {
> + rpmlog(RPMLOG_DEBUG, D_("failed to fetch URL %s via
> external command: %s: %s\n"), url, Fstrerror(sfd));
> + rc = FTPERR_UNKNOWN;
> + cmd = _free(cmd);
> + goto exit;
> + }
> + }
> + cmd = _free(cmd);
> +#endif
> +
> sfd = Fopen(url, "r");
> if (sfd == NULL || Ferror(sfd)) {
> rpmlog(RPMLOG_DEBUG, D_("failed to open %s: %s\n"), url,
> Fstrerror(sfd));
> @@ .
> ______________________________________________________________________
> RPM Package Manager http://rpm5.org
> CVS Sources Repository rpm-cvs@rpm5.org
Received on Sun Dec 23 18:30:37 2007