Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build/deploy RPM(s) for new Boost version on RHEL?

I work in a team of 10+ developers and we use RHEL 6.4 for both our development machines as well as our servers (where our software is deployed).

RHEL 6.4 comes with Boost 1.41 but I need fixes that come in at least 1.47. I'd like to upgrade to latest (currently 1.56).

It is not as easy as downloading the source and building/installing, because:

  • I want everyone on our team (including future team members) to have easy access to the new Boost version. Asking everyone to build/install is a lot of trouble and there might be inconsistencies.
  • Our software is deployed as RPMs that get installed on hundreds of servers (and the servers are owned by other teams and outside of our control). These are also running RHEL 6.4. Our software would (presumably) need to run-time link to the new Boost shared libraries on all these machines.

To make matters uglier, RedHat seems to have their own proprietary way of bundling/packaging the Boost software/libraries into RPMs. They don't have just one RPM but a series of smaller RPMs:

$ yum list installed|grep boost
boost.x86_64                          1.41.0-11.el6_1.2           @Workstation  
boost-date-time.x86_64                1.41.0-11.el6_1.2           @Workstation  
boost-devel.x86_64                    1.41.0-11.el6_1.2           @Workstation  
boost-filesystem.x86_64               1.41.0-11.el6_1.2           @Workstation  
boost-graph.x86_64                    1.41.0-11.el6_1.2           @Workstation  
boost-iostreams.x86_64                1.41.0-11.el6_1.2           @Workstation  
boost-program-options.x86_64          1.41.0-11.el6_1.2           @Workstation  
boost-python.x86_64                   1.41.0-11.el6_1.2           @Workstation  
boost-regex.x86_64                    1.41.0-11.el6_1.2           @Workstation  
boost-serialization.x86_64            1.41.0-11.el6_1.2           @Workstation  
boost-signals.x86_64                  1.41.0-11.el6_1.2           @Workstation  
boost-system.x86_64                   1.41.0-11.el6_1.2           @Workstation  
boost-test.x86_64                     1.41.0-11.el6_1.2           @Workstation  
boost-thread.x86_64                   1.41.0-11.el6_1.2           @Workstation  
boost-wave.x86_64                     1.41.0-11.el6_1.2           @Workstation  

I have been Googling and can't find an easy solution. I am also somewhat of a newbie when it comes to RPMs.

How can I build/deploy Boost 1.56 as RPM(s) in our situation?

like image 526
jfritz42 Avatar asked Sep 16 '14 23:09

jfritz42


2 Answers

Sam posted the general strategy (which works): Download the Boost 1.54 source RPM from Fedora 20 and modify it for my purposes.

Here is the extra detail of how I had to edit the boost.spec file to rename the RPMs to jason-boost* and install under /opt/install/thirdparty.

  1. Rename boost.spec to jason-boost.spec. Next, edit jason-boost.spec as follows.
  2. Redefine macros from /usr (default) to /opt/install/thirdparty. Add to top of file:

    # Override installation dirs. We don't want things to go into
    # /usr (default) because they would overwrite the system Boost
    # library.
    %define _prefix /opt/install/thirdparty
    %define _defaultdocdir /opt/install/thirdparty/share/doc
    %define _mandir /opt/install/thirdparty/share/man
    
  3. Change Name from "boost" to "jason-boost"

  4. Change Summary to "TBS LTE upgraded version of Boost library (no changes)"
  5. Change toplev_dirname

    • From:

      %define toplev_dirname %{name}_%{version_enc}
      
    • To:

      %define toplev_dirname boost_%{version_enc}
      
  6. Change Source0

    • From:

      Source0: http://downloads.sourceforge.net/%{name}/%{toplev_dirname}.tar.bz2
      
    • To:

      Source0: http://downloads.sourceforge.net/boost/boost_1_54_0.tar.bz2
      
  7. Rename "boost" sub-packages to "jason-boost"

    • E.g.

      • From:

        Requires: boost-atomic = %{version}-%{release} 
        
      • To:

        Requires: jason-boost-atomic = %{version}-%{release} 
        
    • E.g.

      • From:

        Requires: boost = %{version}-%{release} 
        
      • To:

        Requires: jason-boost = %{version}-%{release} 
        
  8. Add --prefix=/opt/install/thirdparty to bootstrap.sh options

    • From:

      ./bootstrap.sh --with-toolset=gcc --with-icu
      
    • To:

      ./bootstrap.sh --with-toolset=gcc --with-icu --prefix=/opt/install/thirdparty
      
  9. Change

    • From:

      %{_includedir}/%{name} 
      
    • To:

      %{_includedir}/boost
      
  10. Build RPMs without python3, mpich, or openmpi. Python3 isn't easily available unden RHEL 6.4 and mpich and openmpi have all kinds of other compile trouble.

    rpmbuild -ba jason-boost.spec --without python3 --without mpich --without openmpi
    
like image 73
jfritz42 Avatar answered Sep 23 '22 17:09

jfritz42


Building RPMS in of itself is a skill. Run, don't walk, to the nearest store, and buy a copy of the "Maximum RPM" book, 2nd edition, which will teach you how to build RPMS.

Building RPMS is not exactly rocket science, but it's not something that can be explained a couple of paragraphs, here. I am not very familiar with boost, but a quick check of the packages listed above: on Fedora all of them are built from the same source RPM. It's a single source package, and, as part of building RPMs, the RPM build script automatically chops it up into multiple packages, like the one you see. So, it's really a single package, and the RPM build script.

It might be worth a shot for you to try to rebuild Fedora's boost package from its source RPM, and see if it works for you. The latest boost package for Fedora appears to be 1.54, so 1.56 isn't even built yet. At least not yet on Fedora 20. 21 beta might have a newer boost; I don't know.

Trying to rebuild from source RPMS is worth a shot. It won't take long, it'll either work, or not. Go get a copy of boost-1.54.0-9.fc20.src.rpm from Fedora's download repository; download it on your RHEL box, and try to see what happens:

[user@localhost]$ rpmbuild --rebuild boost-1.54.0-9.fc20.src.rpm

You'll know fairly quick whether it'll work, or not.

But even if this work, you're not of the woods yet. Boost is not binary ABI compatible between releases. Meaning that, as soon as you update your boost packages, you are almost guaranteed to break any existing applications you have, including RHEL packages that link against boost; and rpm may or may not be able to catch that. So, if you get that far, prepare for the possibility of having to rebuild a bunch of other non-boost RPMS, too.

like image 32
Sam Varshavchik Avatar answered Sep 23 '22 17:09

Sam Varshavchik