Re: Use immutable CRAN URLs

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

 



>>>>> "JLT" == Jason L Tibbitts <tibbs@xxxxxxxxxxx> writes:

JLT> It depends on how far you want to go, and how specific you can be
JLT> before you're not actually simplifying a majority of the R packages
JLT> we have.

Just for fun I took the R-webp package and constructed a macro that
generates most of the package.  Obviously it's somewhat bound to this
specific package, but it appears that most R packages have rather
similar boilerplate so it might be more generally useful.  It's just a
hack but it seems like it might be interesting to explore this a bit.
The technique should still apply to package sets which have significant
uniformity.

The spec looks like:
-----
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

Suggests:         R-jpeg R-png

BuildRequires:    libwebp-devel
BuildRequires:    R-jpeg R-png

%description
Lossless webp images are 26% smaller in size compared to PNG. Lossy webp
images are 25-34% smaller in size compared to JPEG. This package reads and
writes webp images into a 3 (rgb) or 4 (rgba) channel bitmap array using
conventions from the 'jpeg' and 'png' packages.

%r_simple_archful_package

%files -f %packname.files

%changelog
-----

This builds fine and produces the same output as the current spec in
git.  I could go even further and not have the %files section at all,
really.

I don't really know how useful this would be.  I know (from another
package I glanced at) that applying patches seems to be a bit weird
because of the directory structure, so maybe using %autosetup isn't the
right way to go.  But I could still easily duplicate the patch
application part of %autosetup.  And the auto file-list generation
stuff could easily grow smarts to handle other cases.

The macros, which you can drop temporarily in /usr/lib/rpm/macros.d for
testing, follow.  These aren't "complete" and you still need the other
macros I posted earlier.  You can cram them together in one file if you
like.

 - J<

# The basic sections
%r_prep %{lua:\
    local packname = rpm.expand('%packname')
    local autosetup = rpm.expand("%{autosetup -c -n " .. packname .. "}")
\
    print(autosetup .. "\\\n")
}

%r_install %{lua:\
    local rlibdir = rpm.expand('%rlibdir')
    local bindir = rpm.expand('%_bindir')
    local packname = rpm.expand('%packname')
    local buildroot = rpm.expand('%buildroot')
\
    -- A function to simplify adding to the file list
    local function add_file(file, type)
        print("echo '")
        if (type ~= nil) then
            print("%" .. type .. " ")
        end
        print(rlibdir .. "/" .. packname)
        if (file ~= nil) then
            print("/" .. file)
        end
        print("' >> " .. packname .. ".files\\\n")
    end
\
    print("mkdir -p " .. buildroot .. rlibdir .. "\\\n")
    print(bindir .. "/R CMD INSTALL -l " .. buildroot .. rlibdir .. " " .. packname .. "\\\n")
    print("test -d " .. packname .. "/src && (cd " .. packname .. "/src; rm -f *.o *.so)\\\n")
    print("rm -f " .. buildroot .. rlibdir .. "/R.css\\\n")
\
    -- R packages have a somewhat regularlized file structure
    -- This could be pushed out to a shell script and called like %find_lang is
    -- called.  But for now we'll just inline the code.
    print("\\\n# Generate a default file list\\\n")
    add_file(nil, "dir")
    add_file("html/", "doc")
    add_file("libs", "dir")
    add_file("libs/" .. packname .. ".so")
    add_file("DESCRIPTION")
    add_file("LICENSE", "license")
    add_file("NEWS", "doc")
    add_file("INDEX")
    add_file("NAMESPACE")
    add_file("Meta/")
    add_file("R/")
    add_file("help/")
\
    print("ls -lR " .. buildroot .. "\\\n")
}

%r_check %{lua:\
    local bindir = rpm.expand('%_bindir')
    local packname = rpm.expand('%packname')
\
    print(bindir .. "/R CMD check " .. packname .. "\\\n")
}

# For noarch packages
%r_noarch_package %{lua:\
    print("BuildArch: noarch\\\n")
    print("Requires: R-core\\\n")
    print("BuildRequires: R-devel tex(latex)\\\n")
    rpm.define("rlibdir  %{_datadir}/R/library")
    print("%build\\\n\\\n")
}

%r_archful_package %{lua:\
    print("BuildRequires: R-devel tex(latex)\\\n")
    rpm.define("rlibdir  %{_libdir}/R/library")
    print("%build\\\n\\\n")
}

%r_simple_archful_package %{lua:\
    print(rpm.expand("%r_archful_package"))
\
    local prep = rpm.expand("%r_prep")
    print("%prep\\\n")
    print(prep .. "\\\n\\\n")
\
    -- Hack around bizarre redefinition of %install.
    local pre_install = rpm.expand('%{?_enable_debug_packages:%{debug_package}}')
    print(pre_install .. "\\\n")
\
    local install = rpm.expand('%r_install')
    print("%install\\\n")
    print(install .. "\\\n\\\n")
\
    local check = rpm.expand('%r_check')
    print("%check\\\n")
    print(check .. "\\\n\\\n")
\
    -- We could even add the files section here, but this needs magic to
    -- determine packname since it hasn't yet been defined.
    -- print("%files -f " .. packname .. ".files\\n")
}
_______________________________________________
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