Issues creating a Dependent Software Collection with a Differing Provider

322 views Asked by At

OK, so in the interests of full disclosure, building RPMs, including Software Collections isn't really my day job, so apologies if I'm missing an obvious trick.

My goal is to create a Software Collection that packages a bunch of python modules (our own code plus some dependencies that aren't currently available in the main collections). I'm running RHEL 6.4.

The approach I'd like to go for is to depend on the main python27 packages where I can (python27-python-2.7.5-10.el6.x86_64, python27-python-libs-2.7.5-10.el6.x86_64, python27-python-jinja2-2.6-10.el6.noarch etc.)

Hence, the hope is that everything that's already available as part of the python27 collection is ultimately below /opt/rh/python27 (standard), and everything I need to add is below /opt/myorg/mycollection, steering clear of /opt/rh for anything non-standard.

Seemed like the right strategy to me, but if there is a better alternative approach I'd be pleased to hear it. One thing that did cross my mind was to just completely package python27 in our own Collection, but didn't feel like the best route.

So, having created the metapackage file (See Below), I'm hitting the following issues:

  1. "/opt/rh/..." files listed twice warnings on building metapackage. *
  2. (1) ripples through to the packages I build based on the metapackage.

* - Issue one hits even where I try exactly the vt191 example in the Software Collections v1.2 Packaging Guide ("Extending the python27 and python33 Software Collections", as originally per http://developerblog.redhat.com/2014/03/27/building-software-collections-on-top-of-rhscl/

I suspect the issue revolves around some of the predefined macros (scl_prefix?) but I can't crack it

L'il help greatly appreciated.

Metapackage Spec File.

%global scl_name_base myapp
%global scl_name_prefix myorg-
%global scl_name_version 122

# define name of the scl
%global scl %{scl_name_prefix}%{scl_name_base}%{scl_name_version}
%scl_package %scl
%global _scl_prefix /opt/myorg

# Defaults for the values for the python27 Software Collection. These
# will be used when python27-scldevel is not in the buildroot
%{!?scl_python:%global scl_python python27}
%{!?scl_prefix_python:%global scl_prefix_python %{scl_python}-}

# Only for this build, we need to override default __os_install_post, because
# the default one would find /opt/.../lib/python2.7/ and rpmbuild would
# try to bytecompile with the system /usr/bin/python2.7 (which doesn't exist)
%global __os_install_post %{%{scl_python}_os_install_post}
# Similarly, override __python_requires for automatic dependency generator
%global __python_requires %{%{scl_python}_python_requires}

# The directory for site packages for this Software Collection
%global myapp_sitelib %(echo %{python27python_sitelib} | sed 's|%{scl_python}|%{scl}|' | sed 's|/opt/rh|%{_scl_prefix}|')
%global myapp_sitearch %(echo %{python27python_sitearch} | sed 's|%{scl_python}|%{scl}|' | sed 's|/opt/rh|%{_scl_prefix}|')

Summary: Package that installs %scl
Name: %scl_name
Version: 1
Release: 1%{?dist}
License: TBD
BuildRequires: scl-utils-build
# Always make sure that there is the python27-sclbuild
# package in the buildroot
BuildRequires: %{scl_prefix_python}scldevel
# Require python27-python-devel, we will need macros from that package
BuildRequires: %{scl_prefix_python}python-devel

#TODO - On Near Completion, add all the runtime dependencies required. As per guide:
#Consider specifying all packages in your Software Collection that are essential for the Software
#Collection run time as dependencies of the metapackage. That way you can ensure that the
#packages are installed with the Software Collection metapackage.
#Need 27 backported subprocess32 module - Has threading fixes.
#Requires: %%{scl_prefix}python-subprocess32

%description
This is the main package for %scl Software Collection.
MyApp does stuff.

%package runtime
Summary: Package that handles %scl Software Collection.
Requires: scl-utils
Requires: %{scl_prefix_python}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 python27-scldevel so that there is always access
# to the %%scl_python and %%scl_prefix_python macros in builds for this Software
# Collection
Requires: %{scl_prefix_python}scldevel

%description build
Package shipping essential configuration macros to build %scl Software Collection.

#Do need an scldevel package to ship scl_name_base and scl_prefix macros?
%package scldevel
Summary: Package shipping development files for %scl

%description scldevel
Package shipping development files, especially useful for development of
packages depending on %scl Software Collection.

%prep
%setup -c -T

%install
%scl_install

#TODO - Further Update Path for everthing runtime on completion, especially paths.
# Create the enable scriptlet that:
# - Adds an additional load path for the Python interpreter.
# - Runs scl_source so that you can run:
#     scl enable package "bash"
#   instead of:
#     scl enable python27 package "bash"
cat >> %{buildroot}%{_scl_scripts}/enable << EOF
. scl_source enable %{scl_python}
export PYTHONPATH=%{myapp_sitelib}:%{myapp_sitearch}${PYTHONPATH:+:${PYTHONPATH}}
EOF

mkdir -p %{buildroot}%{myapp_sitelib}
mkdir -p %{buildroot}%{myapp_sitearch}

# - Enable Software Collection-specific byte compilation macros from
#   the python27-python-devel package.
# - Also override the %%python_sitelib and arch macro to point to the package Software
#   Collection.

cat >> %{buildroot}%{_root_sysconfdir}/rpm/macros.%{scl}-config << EOF
%%scl_package_override() %%{expand:%{?python27_os_install_post:%%global __os_install_post %%python27_os_install_post}
%%global __python_requires %%python27_python_requires
%%global __python_provides %%python27_python_provides
%%global __python %python27__python
%%global __python2 %python27__python
%%global python_sitelib %myapp_sitelib
%%global python2_sitelib %myapp_sitelib
%%global python_sitearch %myapp_sitearch
%%global python2_sitearch %myapp_sitearch
}
EOF

#And add the scldevel macros specific to this scl
#Could possibly just go with above?
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

%files runtime

%scl_files
%myapp_sitelib
%myapp_sitearch

%files build
%{_root_sysconfdir}/rpm/macros.%{scl}-config

%files scldevel
%{_root_sysconfdir}/rpm/macros.%{scl_name_base}-scldevel


%changelog
* Mon Jan 01 1970 John Doe <[email protected]> - 1-1
- Initial package.
0

There are 0 answers