好的,所以为了充分披露,构建RPM(包括软件集合)并不是我的日常工作,所以如果我错过了一个明显的技巧,那么道歉。
我的目标是创建一个包含一堆python模块的软件集合(我们自己的代码加上一些目前在主集合中不可用的依赖项)。我正在运行RHEL 6.4。
我想要的方法是依赖主要的python27包我可以(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等。)
因此,希望所有已经作为python27集合的一部分提供的内容最终都在/ opt / rh / python27(标准)之下,我需要添加的所有内容都在/ opt / myorg / mycollection之下,对于非标准的任何东西,转向/ opt / rh。
对我来说似乎是正确的策略,但如果有更好的替代方法,我会很高兴听到它。我想到的一件事就是在我们自己的Collection中完全打包python27,但并不觉得这是最好的路线。
因此,创建了元数据包文件(见下文)后,我遇到了以下问题:
* - 即使我在“软件集合”v1.2打包指南(&#34;扩展python27和python33软件集合&#34;,最初按http://developerblog.redhat.com/2014/03/27/building-software-collections-on-top-of-rhscl/ < / p>
我怀疑这个问题围绕着一些预定义的宏(scl_prefix?),但是我无法破解它
L&#39;我非常感谢。
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 <john.doe@anorg.com> - 1-1
- Initial package.