Ce contenu n'est pas disponible dans la langue sélectionnée.
2.10.4. Converting RPM Scripts
This section describes general rules for converting RPM scripts that can often be found in the
%prep, %build, %install, %check, %pre, and %post sections of a conventional spec file.
- Replace all occurrences of
%namewith%pkg_name. Most importantly, this includes adjusting the%setupmacro.- Adjust the
%setupmacro in the%prepsection of the spec file so that the macro can deal with a different package name in the Software Collection environment:%setup -q -n %{pkg_name}-%{version}%setup -q -n %{pkg_name}-%{version}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that the%setupmacro is required and that you must always use the macro with the-noption to successfully build your Software Collection.
- If you are using any of the
%_root_macros to point to the system file system hierarchy, you must use conditionals for these macros so that you can then use the spec file for building both the conventional package and the Software Collection. Edit the macros as in the following example:mkdir -p %{?scl:%_root_sysconfdir}%{?!scl:%_sysconfdir}mkdir -p %{?scl:%_root_sysconfdir}%{?!scl:%_sysconfdir}Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When building Software Collection packages that depend on other Software Collection packages, it is often important to ensure that the
scl enablefunctionality links properly or run proper binaries, and so on. One of the examples where this is needed is compiling against a Software Collection library or running an interpreted script with the interpreter in the Software Collection.Wrap the script using the%{?scl:prefix, as in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow It is important to specifyset -ein the script so that the script behavior is consistent regardless of whether the script is executed in therpmshell or thesclenvironment. - Pay attention to any scripts that are executed during the Software Collection package installation, such as:
%pretrans,%pre,%post,%postun,%posttrans,%triggerin,%triggerun, and%triggerpostun.
If you use thescl enablefunctionality in those scripts, you are advised to start with an empty environment to avoid any unintentional collisions with the base system installation.To do so, useenv -i -before enabling the Software Collection, as in the following example:%posttrans %{?scl:env -i - scl enable %{scl} - << \EOF} %vagrant_plugin_register %{vagrant_plugin_name} %{?scl:EOF}%posttrans %{?scl:env -i - scl enable %{scl} - << \EOF} %vagrant_plugin_register %{vagrant_plugin_name} %{?scl:EOF}Copy to Clipboard Copied! Toggle word wrap Toggle overflow - All hardcoded paths found in RPM scripts must be replaced with proper macros. For example, replace all occurrences of
/usr/sharewith%{_datadir}. This is needed because the$RPM_BUILD_ROOTvariable and the%{build_root}macro are not relocated by thesclmacro.