Ce contenu n'est pas disponible dans la langue sélectionnée.
2.9. Converting a Conventional Spec File
The following steps show how to convert a conventional spec file into a Software Collection spec file so that the Software Collection spec file can be used in both the conventional package and the Software Collection.
Procedure 2.1. Converting a conventional spec file into a Software Collection spec file
- Add the
%scl_packagemacro to the spec file. Place the macro in front of the spec file preamble as follows:%{?scl:%scl_package package_name} - You are advised to define the
%pkg_namemacro in the spec file in case the package is not built for the Software Collection:%{!?scl:%global pkg_name %{name}}Consequently, you can use the%pkg_namemacro to define the original name of the package wherever it is needed in the spec file that you can then use for building both the conventional package and the Software Collection. - Change the
Nametag in the spec file preamble as follows:Name: %{?scl_prefix}package_name - If you are building or linking with other Software Collection packages, then prefix the names of those Software Collection packages in the
RequiresandBuildRequirestags with%{?scl_prefix}as follows:Requires: %{?scl_prefix}ifconfigWhen depending on the system versions of packages, you should avoid using versionedRequiresorBuildRequires. If you need to depend on a package that could be updated by the system, consider including that package in your Software Collection, or remember to rebuild your Software Collection when the system package updates. - To check that all essential Software Collection's packages are dependencies of the main metapackage, add the following macro after the
BuildRequiresorRequirestags in the spec file:%{?scl:Requires: %scl_runtime} - Prefix the
Obsoletes,ConflictsandBuildConflictstags with%{?scl_prefix}. This is to ensure that the Software Collection can be used to deploy new packages to older systems without having the packages specified, for example, byObsoleteremoved from the base system installation. For example:Obsoletes: %{?scl_prefix}lesspipe < 1.0 - Prefix the
Providestag with%{?scl_prefix}, as in the following example:Provides: %{?scl_prefix}more - For any subpackages that define their name with the
-noption, prefix their name with%{?scl_prefix}, as in the following example:%package -n %{?scl_prefix}more - Add or edit 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}Note that the%setupmacro is required and that you must always use the macro with the-noption to successfully build your Software Collection.
Example of the Converted Spec File
To see what the diff file comparing a conventional spec file with a converted spec file looks like, refer to the following example:
--- a/less.spec
+++ b/less.spec
@@ -1,10 +1,13 @@
+%{?scl:%scl_package less}
+%{!?scl:%global pkg_name %{name}}
+
Summary: A text file browser similar to more, but better
-Name: less
+Name: %{?scl_prefix}less
Version: 444
Release: 7%{?dist}
License: GPLv3+
Group: Applications/Text
-Source: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
+Source: http://www.greenwoodsoftware.com/less/%{pkg_name}-%{version}.tar.gz
Source1: lesspipe.sh
Source2: less.sh
Source3: less.csh
@@ -19,6 +22,7 @@ URL: http://www.greenwoodsoftware.com/less/
Requires: groff
BuildRequires: ncurses-devel
BuildRequires: autoconf automake libtool
-Obsoletes: lesspipe < 1.0
+Obsoletes: %{?scl_prefix}lesspipe < 1.0
+%{?scl:Requires: %scl_runtime}
%description
The less utility is a text file browser that resembles more, but has
@@ -31,7 +35,7 @@ You should install less because it is a basic utility for viewing text
files, and you'll use it frequently.
%prep
-%setup -q
+%setup -q -n %{pkg_name}-%{version}
%patch1 -p1 -b .Foption
%patch2 -p1 -b .search
%patch4 -p1 -b .time
@@ -51,16 +55,16 @@ make CC="gcc $RPM_OPT_FLAGS -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOU
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
-mkdir -p $RPM_BUILD_ROOT/etc/profile.d
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
install -p -c -m 755 %{SOURCE1} $RPM_BUILD_ROOT/%{_bindir}
-install -p -c -m 644 %{SOURCE2} $RPM_BUILD_ROOT/etc/profile.d
-install -p -c -m 644 %{SOURCE3} $RPM_BUILD_ROOT/etc/profile.d
-ls -la $RPM_BUILD_ROOT/etc/profile.d
+install -p -c -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
+install -p -c -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
+ls -la $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
%files
%defattr(-,root,root,-)
%doc LICENSE
-/etc/profile.d/*
+%{_sysconfdir}/profile.d/*
%{_bindir}/*
%{_mandir}/man1/*