Re: Use immutable CRAN URLs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 31 Oct 2018 at 19:52, Jason L Tibbitts III <tibbs@xxxxxxxxxxx> wrote:
>
> >>>>> "IU" == Iñaki Ucar <iucar@xxxxxxxxxxxxxxxxx> writes:
>
> IU> https://cran.r-project.org/package=simmer&version=3.0.0
>
> IU> returns a redirection (303) to the complete URL, with file
> IU> extension.
>
> 303 is actually "See Other".  Which is odd as that's usually sent in
> response to a PUT or POST, not a GET.  Maybe you can get the files via
> POST as well; I'm not sure.

Why is this odd? It's not "moved", either permanently or temporarily
(301, 302). It clearly matches the "see other" case. 303 was
*primarily* motivated by the POST use case, but I think this is a
pretty fair use.

> In any case, none of that has any effect on the filename that spectool
> (really curl) will use.  It can't use data supplied by the remote host
> for that, for obvious reasons.
>
> IU> CRAN maintainers are pretty strict with this kind of stuff: if it
> IU> works now, it's guaranteed to continue to work.
>
> Well, that's good, but this is a hack so it's not a terrible idea to
> inform them that we have to use this kind of thing so that they can
> either bless this method or provide a cleaner one.

I'll raise the issue in the R-devel mailing list and report back.

> IU> There are no other formats: every package is tar.gz. But, as I
> IU> pointed out above, the immutable URL is a redirection to the
> IU> complete URL, so you can still extract the extension.
>
> No, you can't.  Not in the context and under the limitations where we're
> running.  Certainly we can't know anything about that in an RPM macro as
> we have to provide an extension in a complete vacuum.
>
> But given what you say, certainly defaulting to tar.gz will work for
> everything now.

For what it's worth, this (the extension) is clearly specified in the
"Writing R Extensions" and the "R Installation and Administration"
manuals. It always has been the same, and I'd say it's *extremely*
unlikely to change.

> Try dropping the below into /usr/lib/rpm/macros.d/macros.test
> (temporarily, make sure to deleted it when you're done experimenting).
> See if it gives the results you expect when you use %cran_url and
> %cran_source.  Do fedpkg prep or some local builds.  Try spectool -g and
> rpmspec -P.

Thanks, I'll give it a try and report back.

> Note that I've snuck a bit of magic in there which I'm not sure should
> be kept: If you don't have %packname defined and you call either
> %cran_url or %cran_source, then it will be automatically defined for you
> by stripping the leading "R-" from the name.

This is great. However, in theory, given the naming guidelines, by
stripping the leading "R-" you should get the package name. In
practice, at least one package doesn't adhere to this: R-TH-data,
while the R package name is TH.data, not TH-data. I see that the SPEC
says "# Cannot use . in name", but this is clearly not true (maybe it
was true long ago?).

> With this, you can just have:
>
> Name:             R-webp
> Version:          0.4
> Release:          3%{?dist}
> Summary:          A New Format for Lossless and Lossy Image Compression
>
> License:          MIT
> URL:              %cran_url
> Source0:          %cran_source
>
> And use %packname in %prep as usual without explicitly defining it.  But
> I'm not sure that much magic is a good idea.
>
> (And while we're doing R macros, that package suggests that we should
> also have a macro defined to %_libdir/R/library....)

That would require a good ton of magic. You have seen something like this:

%global rlibdir   %{_libdir}/R/library

The thing is, this is the path for R packages *with* compiled code,
while R packages *without* compiled code must go to
%_datadir/R/library. That's why every R package has this global on top
of the SPEC. Are you able to detect that and set the path
appropriately with an RPM macro? :) That would certainly be very
convenient for us, packagers.

>
> - J<
>
> # Macros to replace overly complicated references to CRAN URLs and source files.
> # %cran_source -
> #   Expands to the CRAN URL for a package
> #   Accepts zero to three arguments:
> #   1:  The CRAN project name, defaulting to %packname if it is defined.
> #       If not, R- will be stripped from %name and %packname defined to that.
> #   2:  The CRAN version, defaulting to %version.
> #   3:  The file extension, defaulting to %__cran_default_extension (tar.gz).
> #   Requires %__cran_package_url_template and %__cran_default_extension to be defined.
> #   %__cran_package_url_template will undergo substitution (case-sensitive):
> #   *  "PACKNAME" will be replaced with the above CRAN project name.
> #   *  "PACKVERSION" will be replaced with the above CRAN version.
> #   *  "EXTENSION" will be replaced with the above extension.
> #
> # %cran_url -
> #   Expands to the CRAN URL for a package
> #   Accepts zero or one arguments:
> #   1:  The CRAN project name, defaulting to %packname if it is defined.
> #       If not, R- will be stripped from %name and %packname defined to that.
> #   Requires %__cran_project_url_template to be defined.
> #   %__cran_project_url_template will undergo substitution (case-sensitive):
> #   *  "PACKNAME" will be replaced with the above CRAN project name.
>
> %__cran_project_url_template https://cran.r-project.org/package=PACKNAME
> %__cran_package_url_template %{__cran_project_url_template}&version=PACKVERSION#/PACKNAME_PACKVERSION.EXTENSION
> %__cran_default_extension tar.gz
>
> %cran_source() %{lua:
>     local src = rpm.expand('%1')
>     local ver = rpm.expand('%2')
>     local ext = rpm.expand('%3')
>     local url = rpm.expand('%__cran_package_url_template')
> \
>     -- If no first argument, try %packname, then %name with 'R-' stripped.
>     -- Note that rpm leaves macros unchanged if they are not defined.
>     if src == '%1' then
>         src = rpm.expand('%packname')
>     end
>     if src == '%packname' then
>         src = string.gsub(rpm.expand('%name'), "^R%-", "")
>         -- Since packname wasn't defined, define it for convenience.
>         rpm.define("packname " .. src)
>     end
> \
>     -- If no second argument, use %version
>     if ver == '%2' then
>         ver = rpm.expand('%version')
>     end
> \
>     -- If no third argument, use the preset default extension
>     if ext == '%3' then
>         ext = rpm.expand('%__cran_default_extension')
>     end
> \
>     -- Now substitute in all the values
>     url = string.gsub(url, "PACKNAME", src)
>     url = string.gsub(url, "PACKVERSION", ver)
>     url = string.gsub(url, "EXTENSION", ext)
> \
>     print(url)
> }
>
> %cran_url() %{lua:
>     local src = rpm.expand('%1')
>     local url = rpm.expand('%__cran_project_url_template')
> \
>     -- If no first argument, try %packname, then %name with 'R-' stripped.
>     -- Note that rpm leaves macros unchanged if they are not defined.
>     if src == '%1' then
>         src = rpm.expand('%packname')
>     end
>     if src == '%packname' then
>         src = string.gsub(rpm.expand('%name'), "^R%-", "")
>         -- Since packname wasn't defined, define it for convenience.
>         rpm.define("packname " .. src)
>     end
> \
>     -- Substitute in the URL value
>     url = string.gsub(url, "PACKNAME", src)
> \
>     print(url)
> }
>
>


-- 
Iñaki Ucar
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux