Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix openSUSE 15.4 image build; begin replacing fpm with nFPM #136

Merged
merged 2 commits into from
Aug 24, 2022
Merged

Conversation

glin
Copy link
Contributor

@glin glin commented Aug 23, 2022

The SUSE 15.4 image build failed as soon as I merged #134 due to a Ruby gem dependency issue with fpm, the DEB/RPM packaging tool:
https://github.com/rstudio/r-builds/runs/7924309239?check_suite_focus=true

Step 6/12 : RUN gem install fpm &&     ln -s /usr/bin/fpm.ruby2.5 /usr/local/bin/fpm
 ---> Running in 6ac62b82d651
ERROR:  Error installing fpm:
	The last version of public_suffix (< 6.0, >= 2.0.2) to support your Ruby & RubyGems was 4.0.7. Try installing it with `gem install public_suffix -v 4.0.7` and then running the current command again
	public_suffix requires Ruby version >= 2.6. The current ruby version is 2.5.0.

The public_suffix gem depends on Ruby >= 2.6 which openSUSE doesn't provide, so we would've had to pin fpm to an older version or wait for a fix in fpm.

Instead, I've replaced fpm with a different tool called nFPM, which @atheriel recommended a while back:

nFPM is a simple, 0-dependencies, deb, rpm and apk packager.

While fpm is great, for me, it is a bummer that it depends on ruby, tar and other software.
I wanted something that could be used as a binary and/or as a library and that was really simple.
So I decided to create nFPM: a simpler, 0-dependency, as-little-assumptions-as-possible alternative to fpm.

nFPM is a Go-based alternative to fpm that should be more reliable, has better support for code signing (#7), and still has all the features we need from fpm. fpm has had so many Ruby gem dependency issues over the years that have made it a pain to maintain:
#86
#110 (comment)
#83 (comment)
#64 (comment)

The migration was pretty straightforward, and there were just a few differences in the configs to account for:

  • nFPM is configured through a YAML file instead of CLI args, and only supports environment variable values in some fields. Templating is explicitly not supported, and they recommend using envsubst from the gettext package instead. Here, I've just inlined the YAML into the packaging scripts since it's not too complicated and matches the old CLI args closely.
  • nFPM adds empty Epoch: 0 and Distribution: (none) fields to the RPMs, unlike fpm, which I couldn't figure out how to remove. I don't think this is a big deal.
  • While migrating, I also addressed some of the DEB linting issues from Existing .deb packages generate many warnings and errors from the linter #119:
    • Remove invalid License/Vendor fields from DEBs
    • Fix Maintainer formatting to RStudio, PBC <https://github.com/rstudio/r-builds>, although lintian still says this is invalid (because it's not an email perhaps)
    • Set Section to universe/math on Ubuntu and gnu-r on Debian to match the r-base packages

I only replaced fpm for the newest platforms here to get SUSE 15.4 fixed asap, and will migrate the other platforms later.


Here's what the RPM and DEB fields look like, before and after.

RPMs:

# fpm
$ rpm -qi R-4.2.1-1-1.x86_64.rpm
Name        : R-4.2.1
Version     : 1
Release     : 1
Architecture: x86_64
Install Date: (not installed)
Group       : default
Size        : 101532248
License     : GPL-2
Signature   : (none)
Source RPM  : R-4.2.1-1-1.src.rpm
Build Date  : Thu 23 Jun 2022 03:09:41 AM CDT
Build Host  : ip-172-16-135-66
Relocations : / 
Packager    : RStudio, PBC https://github.com/rstudio/r-builds
Vendor      : RStudio, PBC
URL         : http://www.r-project.org/
Summary     : GNU R statistical computation and graphics system
Description :
GNU R statistical computation and graphics system

# nFPM
$ rpm -qi R-4.2.1-1-1.x86_64.rpm 
Name        : R-4.2.1
Epoch       : 0
Version     : 1
Release     : 1
Architecture: x86_64
Install Date: (not installed)
Group       : 
Size        : 101534144
License     : GPLv2+
Signature   : (none)
Source RPM  : R-4.2.1-1-1.src.rpm
Build Date  : Mon Aug 22 22:51:31 2022
Build Host  : 3a8657e10c34
Relocations : (not relocatable)
Packager    : RStudio, PBC <https://github.com/rstudio/r-builds>
Vendor      : RStudio, PBC
URL         : https://www.r-project.org
Summary     : GNU R statistical computation and graphics system
Description :
GNU R statistical computation and graphics system

Distribution: (none)

DEBs:

# fpm
$ dpkg -f r-4.2.1_1_amd64.deb 
Package: r-4.2.1
Version: 1
License: GPL-2
Vendor: RStudio, PBC
Architecture: amd64
Maintainer: RStudio, PBC https://github.com/rstudio/r-builds
Installed-Size: 91012
Depends: g++, gcc, gfortran, libbz2-dev, libc6, libcairo2, libcurl4, libglib2.0-0, libgomp1, libicu-dev, libjpeg8, liblzma-dev, libopenblas-dev, libpango-1.0-0, libpangocairo-1.0-0, libpaper-utils, libpcre2-dev, libpng16-16, libreadline8, libtcl8.6, libtiff5, libtk8.6, libx11-6, libxt6, make, ucf, unzip, zip, zlib1g-dev
Section: default
Priority: optional
Homepage: http://www.r-project.org/
Description: GNU R statistical computation and graphics system
Bugs: https://github.com/rstudio/r-builds/issues

# nFPM
$ dpkg -f r-4.2.1_1_amd64.deb 
Package: r-4.2.1
Version: 1
Section: universe/math
Priority: optional
Architecture: amd64
Maintainer: RStudio, PBC <https://github.com/rstudio/r-builds>
Installed-Size: 91013
Depends: g++, gcc, gfortran, libbz2-dev, libc6, libcairo2, libcurl4, libglib2.0-0, libgomp1, libicu-dev, libjpeg8, liblzma-dev, libopenblas-dev, libpango-1.0-0, libpangocairo-1.0-0, libpaper-utils, libpcre2-dev, libpng16-16, libreadline8, libtcl8.6, libtiff5, libtk8.6, libx11-6, libxt6, make, ucf, unzip, zip, zlib1g-dev
Homepage: https://www.r-project.org
Description: GNU R statistical computation and graphics system
Bugs: https://github.com/rstudio/r-builds/issues

glin added 2 commits August 22, 2022 19:00
fpm currently fails to install because the public_suffix gem dependency
requires Ruby 2.6, which openSUSE 15.4 doesn't provide. Because there have
been so many Ruby dependency issues with fpm in the past, switch to the fewer-
dependency nfpm, which also has better support for code signing if we want to
do that in the future.
fpm has had multiple Ruby gem dependency issues, and nfpm has better support
for code signing if we wanted to do that in the future. The rest of the
platforms may be migrated to nfpm later.
@atheriel
Copy link

I'm delighted to see this, in part because it makes it more feasible for us to pursue #7 (which nFPM supports natively but fpm does not).

Small historical aside: I proactively contributed a feature to nFPM a few months ago to support our use of the Bugs field, which Greg seems to have picked up on. 😄

@atheriel atheriel mentioned this pull request Aug 24, 2022
Copy link
Contributor

@jonyoder jonyoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@glin glin merged commit 92ef513 into master Aug 24, 2022
@glin glin deleted the fix-fpm branch August 24, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants