1

好的,所以为了全面披露,构建 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 用于任何非标准的东西。

对我来说似乎是正确的策略,但如果有更好的替代方法,我会很高兴听到它。我想到的一件事就是将 python27 完全打包到我们自己的集合中,但感觉不是最好的路线。

因此,在创建了元包文件(见下文)后,我遇到了以下问题:

  1. “/opt/rh/...”文件在构建元包时列出了两次警告。*
  2. (1) 波及到我基于元包构建的包。

* - 即使我在软件集合 v1.2 打包指南(“扩展 python27 和 python33 软件集合”,最初按照http://developerblog.redhat.com/2014/03/ 27/在 rhscl 顶部构建软件集合/

我怀疑问题与一些预定义的宏(scl_prefix?)有关,但我无法破解

L'il 帮助非常感谢。

元包规范文件。

%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.
4

0 回答 0