4.4. Extending the rh-perl524 Software Collection This section describes extending the rh-perl524 Software Collection by building your own dependent Software Collection. Important Examples described in this section only work as expected when extending the rh-perl524 Software Collection with packages that: do not provide any Perl modules, and only depend on Perl modules provided by the rh-perl524 Software Collection. 4.4.1. The h2m144 Software Collection This section contains a commented example of a dependent Software Collection's metapackage. The dependent Software Collection is named h2m144 and contains the help2man Perl package version 1.44.1. The h2m144 Software Collection depends on the rh-perl524 Software Collection. Note the following in the h2m144 Software Collection metapackage: The h2m144 Software Collection metapackage has the following build dependency set: BuildRequires: %{scl_prefix_perl}scldevel This expands to rh-perl524-scldevel . The rh-perl524-scldevel subpackage contains two important macros, %scl_perl and %scl_prefix_perl , and also provides Perl dependency generators. Note that the macros are defined at the top of the metapackage spec file. Although the definitions are not required, they provide a visual hint that the h2m144 Software Collection has been designed to be built on top of the rh-perl524 Software Collection. They also serve as a fallback value. The h2m144-build subpackage has the following dependency set: Requires: %{scl_prefix_perl}scldevel This expands to rh-perl524-scldevel . The purpose of this dependency is to ensure that the macros and dependency generators are always present when building packages for the h2m144 Software Collection. The enable scriptlet for the h2m144 Software Collection contains the following line: . scl_source enable %{scl_perl} Note the dot at the beginning of the line. This line makes the Perl Software Collection start implicitly when the h2m144 Software Collection is started so that the user can only type scl enable h2m144 command instead of scl enable rh-perl524 h2m144 command to run command in the Software Collection environment. The macro file macros.h2m144-config calls the Perl dependency generators, and certain Perl-specific macros used in other packages' spec files. %global scl h2m144 %scl_package %scl # Default values for the rh-perl524 Software Collection. These # will be used when rh-perl524-scldevel is not in the build root. %{!?scl_perl:%global scl_perl rh-perl524} %{!?scl_prefix_perl:%global scl_prefix_perl %{scl_perl}-} # Only for this build, override __perl_requires for the automatic dependency # generator. %global __perl_requires /usr/lib/rpm/perl.req.stack Summary: Package that installs %scl Name: %scl_name Version: 1 Release: 1%{?dist} License: GPLv2+ BuildRequires: scl-utils-build # Always make sure that there is the rh-perl524-scldevel # package in the build root. BuildRequires: %{scl_prefix_perl}scldevel # Require rh-perl524-perl-macros; you will need macros from that package. BuildRequires: %{scl_prefix_perl}perl-macros Requires: %{scl_prefix}help2man %description This is the main package for %scl Software Collection. %package runtime Summary: Package that handles %scl Software Collection. Requires: scl-utils Requires: %{scl_prefix_perl}runtime %description runtime Package shipping essential scripts to work with %scl Software Collection. %package build Summary: Package shipping basic build configuration Requires: scl-utils-build # Require rh-perl524-scldevel so that there is always access to the %%scl_perl # and %%scl_prefix_perl macros in builds for this Software Collection. Requires: %{scl_prefix_perl}scldevel %description build Package shipping essential configuration macros to build %scl Software Collection. %prep %setup -c -T %build %install %scl_install # Create the enable scriptlet that: # - Adds an additional load path for the Perl interpreter. # - Runs scl_source so that you can run: # scl enable h2m144 'bash' # instead of: # scl enable rh-perl524 h2m144 'bash' cat >> %{buildroot}%{_scl_scripts}/enable << EOF . scl_source enable %{scl_perl} export PATH="%{_bindir}:%{_sbindir}\USD{PATH:+:\USD{PATH}}" export MANPATH="%{_mandir}:\USD{MANPATH:-}" EOF cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-config << EOF %%scl_package_override() %%{expand:%%global __perl_requires /usr/lib/rpm/perl.req.stack %%global __perl_provides /usr/lib/rpm/perl.prov.stack %%global __perl %{_scl_prefix}/%{scl_perl}/root/usr/bin/perl } EOF %files %files runtime -f filelist %scl_files %files build %{_root_sysconfdir}/rpm/macros.%{scl}-config %changelog * Tue Apr 22 2014 John Doe <jdoe@example.com> - 1-1 - Initial package. 4.4.2. The help2man Package Below is a commented example of the help2man package spec file. Note the following in the spec file: The BuildRequires tags are prefixed with %{?scl_prefix_perl} instead of %{scl_prefix} . %{?scl:%scl_package help2man} %{!?scl:%global pkg_name %{name}} # Supported build option: # # --with nls ... build this package with --enable-nls %bcond_with nls Name: %{?scl_prefix}help2man Summary: Create simple man pages from --help output Version: 1.44.1 Release: 1%{?dist} Group: Development/Tools License: GPLv3+ URL: http://www.gnu.org/software/help2man Source: ftp://ftp.gnu.org/gnu/help2man/help2man-%{version}.tar.xz %{!?with_nls:BuildArch: noarch} BuildRequires: %{?scl_prefix_perl}perl(Getopt::Long) BuildRequires: %{?scl_prefix_perl}perl(POSIX) BuildRequires: %{?scl_prefix_perl}perl(Text::ParseWords) BuildRequires: %{?scl_prefix_perl}perl(Text::Tabs) BuildRequires: %{?scl_prefix_perl}perl(strict) %{?with_nls:BuildRequires: %{?scl_prefix_perl}perl(Locale::gettext) /usr/bin/msgfmt} %{?with_nls:BuildRequires: %{?scl_prefix_perl}perl(Encode)} %{?with_nls:BuildRequires: %{?scl_prefix_perl}perl(I18N::Langinfo)} Requires: %{?scl_prefix_perl}perl(:MODULE_COMPAT_%(%{?scl:scl enable %{scl_perl} '}eval "`perl -V:version`"; echo USDversion%{?scl:'})) Requires(post): /sbin/install-info Requires(preun): /sbin/install-info %description help2man is a script to create simple man pages from the --help and --version output of programs. Since most GNU documentation is now in info format, this provides a way to generate a placeholder man page pointing to that resource while still providing some useful information. %prep %setup -q -n help2man-%{version} %build %configure --%{!?with_nls:disable}%{?with_nls:enable}-nls --libdir=%{_libdir}/help2man %{?scl:scl enable %{scl} "} make %{?_smp_mflags} %{?scl:"} %install %{?scl:scl enable %{scl} "} make install_l10n DESTDIR=USDRPM_BUILD_ROOT %{?scl:"} %{?scl:scl enable %{scl} "} make install DESTDIR=USDRPM_BUILD_ROOT %{?scl:"} %find_lang %pkg_name --with-man %post /sbin/install-info %{_infodir}/help2man.info %{_infodir}/dir 2>/dev/null || : %preun if [ USD1 -eq 0 ]; then /sbin/install-info --delete %{_infodir}/help2man.info \ %{_infodir}/dir 2>/dev/null || : fi %files -f %pkg_name.lang %doc README NEWS THANKS COPYING %{_bindir}/help2man %{_infodir}/* %{_mandir}/man1/* %if %{with nls} %{_libdir}/help2man %endif %changelog * Tue Apr 22 2014 John Doe <jdoe@example.com> - 1.44.1-1 - Built for h2m144 SCL. 4.4.3. Building the h2m144 Software Collection To build the h2m144 Software Collection: Install the rh-perl524-scldevel and rh-perl524-perl-macros packages that are part of the perl524 Software Collection. Build h2m144.spec and install the h2m144-runtime and h2m144-build packages. Install the rh-perl524-perl , rh-perl524-perl-Text-ParseWords and rh-perl524-perl-Getopt-Long packages, which are all build requirements for help2man . Build help2man.spec . 4.4.4. Testing the h2m144 Software Collection To test the h2m144 Software Collection: Install the h2m144-help2man package. Run the following command: Verify that the output is similar to the following lines:

Commands:
BuildRequires: %{scl_prefix_perl}scldevel
Requires: %{scl_prefix_perl}scldevel
. scl_source enable %{scl_perl}
%global scl h2m144 %scl_package %scl Default values for the rh-perl524 Software Collection. These will be used when rh-perl524-scldevel is not in the build root. %{!?scl_perl:%global scl_perl rh-perl524} %{!?scl_prefix_perl:%global scl_prefix_perl %{scl_perl}-} Only for this build, override __perl_requires for the automatic dependency generator. %global __perl_requires /usr/lib/rpm/perl.req.stack Summary: Package that installs %scl Name: %scl_name Version: 1 Release: 1%{?dist} License: GPLv2+ BuildRequires: scl-utils-build Always make sure that there is the rh-perl524-scldevel package in the build root. BuildRequires: %{scl_prefix_perl}scldevel Require rh-perl524-perl-macros; you will need macros from that package. BuildRequires: %{scl_prefix_perl}perl-macros Requires: %{scl_prefix}help2man %description This is the main package for %scl Software Collection. %package runtime Summary: Package that handles %scl Software Collection. Requires: scl-utils Requires: %{scl_prefix_perl}runtime %description runtime Package shipping essential scripts to work with %scl Software Collection. %package build Summary: Package shipping basic build configuration Requires: scl-utils-build Require rh-perl524-scldevel so that there is always access to the %%scl_perl and %%scl_prefix_perl macros in builds for this Software Collection. Requires: %{scl_prefix_perl}scldevel %description build Package shipping essential configuration macros to build %scl Software Collection. %prep %setup -c -T %build %install %scl_install Create the enable scriptlet that: - Adds an additional load path for the Perl interpreter. - Runs scl_source so that you can run: scl enable h2m144 'bash' instead of: scl enable rh-perl524 h2m144 'bash' cat >> %{buildroot}%{_scl_scripts}/enable << EOF . scl_source enable %{scl_perl} export PATH="%{_bindir}:%{_sbindir}\USD{PATH:+:\USD{PATH}}" export MANPATH="%{_mandir}:\USD{MANPATH:-}" EOF cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-config << EOF %%scl_package_override() %%{expand:%%global __perl_requires /usr/lib/rpm/perl.req.stack %%global __perl_provides /usr/lib/rpm/perl.prov.stack %%global __perl %{_scl_prefix}/%{scl_perl}/root/usr/bin/perl } EOF %files %files runtime -f filelist %scl_files %files build %{_root_sysconfdir}/rpm/macros.%{scl}-config %changelog * Tue Apr 22 2014 John Doe <jdoe@example.com> - 1-1 - Initial package.
%{?scl:%scl_package help2man} %{!?scl:%global pkg_name %{name}} Supported build option: # --with nls ... build this package with --enable-nls %bcond_with nls Name: %{?scl_prefix}help2man Summary: Create simple man pages from --help output Version: 1.44.1 Release: 1%{?dist} Group: Development/Tools License: GPLv3+ URL: http://www.gnu.org/software/help2man Source: ftp://ftp.gnu.org/gnu/help2man/help2man-%{version}.tar.xz %{!?with_nls:BuildArch: noarch} BuildRequires: %{?scl_prefix_perl}perl(Getopt::Long) BuildRequires: %{?scl_prefix_perl}perl(POSIX) BuildRequires: %{?scl_prefix_perl}perl(Text::ParseWords) BuildRequires: %{?scl_prefix_perl}perl(Text::Tabs) BuildRequires: %{?scl_prefix_perl}perl(strict) %{?with_nls:BuildRequires: %{?scl_prefix_perl}perl(Locale::gettext) /usr/bin/msgfmt} %{?with_nls:BuildRequires: %{?scl_prefix_perl}perl(Encode)} %{?with_nls:BuildRequires: %{?scl_prefix_perl}perl(I18N::Langinfo)} Requires: %{?scl_prefix_perl}perl(:MODULE_COMPAT_%(%{?scl:scl enable %{scl_perl} '}eval "`perl -V:version`"; echo USDversion%{?scl:'})) Requires(post): /sbin/install-info Requires(preun): /sbin/install-info %description help2man is a script to create simple man pages from the --help and --version output of programs. Since most GNU documentation is now in info format, this provides a way to generate a placeholder man page pointing to that resource while still providing some useful information. %prep %setup -q -n help2man-%{version} %build %configure --%{!?with_nls:disable}%{?with_nls:enable}-nls --libdir=%{_libdir}/help2man %{?scl:scl enable %{scl} "} make %{?_smp_mflags} %{?scl:"} %install %{?scl:scl enable %{scl} "} make install_l10n DESTDIR=USDRPM_BUILD_ROOT %{?scl:"} %{?scl:scl enable %{scl} "} make install DESTDIR=USDRPM_BUILD_ROOT %{?scl:"} %find_lang %pkg_name --with-man %post /sbin/install-info %{_infodir}/help2man.info %{_infodir}/dir 2>/dev/null || : %preun if [ USD1 -eq 0 ]; then /sbin/install-info --delete %{_infodir}/help2man.info %{_infodir}/dir 2>/dev/null || : fi %files -f %pkg_name.lang %doc README NEWS THANKS COPYING %{_bindir}/help2man %{_infodir}/* %{_mandir}/man1/* %if %{with nls} %{_libdir}/help2man %endif %changelog * Tue Apr 22 2014 John Doe <jdoe@example.com> - 1.44.1-1 - Built for h2m144 SCL.
scl enable h2m144 'help2man bash'
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.44.1. .TH BASH, "1" "April 2014" "bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)" "User Commands" .SH NAME bash, \- manual page for bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) .SH SYNOPSIS .B bash [\fIGNU long option\fR] [\fIoption\fR] .SH DESCRIPTION GNU bash, version 4.1.2(1)\-release\-(x86_64\-redhat\-linux\-gnu) .IP bash [GNU long option] [option] script\-file .SS "GNU long options:" .HP \fB\-\-debug\fR