Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How to Create Dependent Software Collections

September 4, 2014
Marcela Maslanova
Related topics:
Linux
Related products:
Red Hat Enterprise Linux

Share:

    Are you fed up by enabling multiple collections, which are dependent on themselves? We were. For example, thermostat needs mongo, mongo needs v8.  Enabling them looks like:

    scl enable thermostat1 mongodb24 v8314 bash
    

    There another reason to use dependent collections:  when you are missing packages in a RHSCL collection and you want to add them. Obviously, we don't plan to package everything because some packages have high maintenance costs or they are changing too fast even for two or three years of support.

    Dependent collections have been available since RHSCL 1.1 and are supported by scl-utils-20131017 and higher.

    Where are dependent collections are useful

    Let's say you are using the ruby193 collection and would like to use additional gems. Some users are doing a rebuild of the existing ruby193 collection and mixing their gems with those provided by ruby193. It might lead to a problem, however, especially if RHSCL adds the same package as you previously added. It already has happened to the passenger gem where the user's version was overridden by RHSCL passenger and they were quite surprised by the new version. The correct solution is to package additional gems as a dependent collection. Another benefit would be portability to a new version of a ruby collection, so you could use your dependent collection even with ruby210 (or whatever will be in the next RHSCL Ruby release). It does work for passenger - see the passenger testing collection on the upstream pages.

    How to create dependent collection

    Now let's show you how to write specfiles to create a dependent collection. Let's look at the best existing example of dependent collections:  Ruby on Rails (ror40) and Ruby (ruby200) as two collections and made them dependent.

    Into ruby200.spec add scldevel subpackage:

    %package scldevel
    Summary: Package shipping development files for %scl
    %description scldevel
    Package shipping development files, especially usefull for development of
    packages depending on %scl Software Collection.
    ...
    cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel << EOF
    %%scl_%{scl_name_base} %{scl}
    %%scl_prefix_%{scl_name_base} %{scl_prefix}
    EOF
    ...
    %files scldevel
    %{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel
    

    This code will create file installed into /etc/rpm/macros.ruby-scldevel. It contains basic macros needed for dependent collection.

    %scl_ruby ruby200
    %scl_prefix_ruby ruby200-
    

    You can access the whole source rpm package on upstream page and look at the whole specfile. No git yet, we are sorry.

    How can you enable ruby200 collection as dependent collection? Just add scl_source macro into another specfile e.g. ror40 (ruby on rails). The dependent collection will be also automatically enabled, you will need to run only scl enable ror40 and ruby200 will be enabled automatically. You can enable more collections than one. Let's look at example of ror40 specfile:

    # Fallback to ruby200 in case ruby200-scldevel is not available.
    %{!?scl_ruby:%global scl_ruby ruby200}
    # Must be defined for enabling ruby200 collection because standard       
    # scl_prefix macro will contain ror40 in this specfile.
     %{!?scl_prefix_ruby:%global scl_prefix_ruby %{scl_ruby}-}
    ...
    # Don't forget to add ruby200-scldevel into build requirements of package
     BuildRequires: %{scl_prefix_ruby}scldevel
    ...
    # Install section calls scl_source for enabling ruby200 collection in ror40 enable scriptlet.
    %install
    %scl_install
    cat >> %{buildroot}%{_scl_scripts}/enable << EOF
    export PATH=%{_bindir}${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=%{_libdir}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
    export MANPATH=%{_mandir}:${MANPATH}
    export PKG_CONFIG_PATH=%{_libdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
    export GEM_PATH=%{gem_dir}:${GEM_PATH:+${GEM_PATH}}${GEM_PATH:-`scl enable %{scl_ruby} -- ruby -e "print Gem.path.join(':')"`}
    
    . scl_source enable %{scl_ruby}
    EOF
    

    The source rpm is again on the upstream page. You can access complete collections on softwarecollections.org for more experiments.

    Where to put scl_source

    The dependency between Ruby and RoR was obvious, but in other cases it may not be so straight forward. For example v8 as javascript interpreter is enabled by rubygem-rubyracer, which is using it. The v8 is not automatically enabled for all of ror40, because not all gems or all customers use it. It's up to your actual use-case where you put the scl_source.

    Last updated: November 2, 2023

    Recent Posts

    • Splitting OpenShift machine config pool without node reboots

    • Node.js 20+ memory management in containers

    • Integrate incident detection with OpenShift Lightspeed via MCP

    • One model is not enough, too many models is hard: Technical deep dive

    • What's new in Ansible Automation Platform 2.6

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue