Packaging:Globus

From FedoraProject

Revision as of 05:24, 18 April 2009 by Ellert (Talk | contribs)

Jump to: navigation, search
Warning (medium size).png
This page is a draft only
It is still under construction and content may change. Do not rely on the information on this page.

This document describes the guidelines and conventions for packaging components from the Globus Toolkit in Fedora. The following guidelines applies to the components of the Globus Toolkit written in C. A future version of the guidelines may address the packaging of components written in java as well.

Contents

What is the Globus Toolkit?

The Globus Toolkit is a set of libraries and tools used as building blocks for grid computing applications. The toolkit is developed and maintained by the Globus Alliance.

Obtaining sources

The sources for the Globus Toolkit are distributed as one big installer tarball that contain the sources for more than 300 packages. Since including this huge tarball in every Globus source RPM and use less than 1% of it to compile a single Globus package would be extremely wasteful in terms of diskspace and bandwidth, the relevant subdirectory from the installer tarball must be extracted and repackaged for each package. This must be documented using comments in the spec file according to the Packaging:SourceURL guidelines so that the source tarball can be reproduced, as in the following example:

#		Source is extracted from the globus toolkit installer:
#		wget -N http://www-unix.globus.org/ftppub/gt4/4.2.1/installers/src/gt4.2.1-all-source-installer.tar.bz2
#		tar -jxf gt4.2.1-all-source-installer.tar.bz2
#		mv gt4.2.1-all-source-installer/source-trees/core/source globus_core-5.15
#		tar -zcf globus_core-5.15.tar.gz globus_core-5.15
Source: 	%{_name}-%{version}.tar.gz

Off-release upstream updates

Occasionally the Globus Alliance publishes an off-release update of a package. For these updates each updated package is available as a separate tarball, and the repackaging discribed above should not be done:

Source: 	http://www-unix.globus.org/ftppub/gt4/4.2.1/updates/src/%{_name}-%{version}.tar.gz

In order to keep the packaging consistent, the naming of the tarfiles extracted from the installer should use the same naming convention as upstream uses for the tarfiles for these updates, i.e. the upstream package name and version.

Grid packaging tools

The Globus Toolkit uses its own build system called the grid packaging tools (GPT). This is available in Fedora in the grid-packaging-tools package.

globus-core

The globus-core package is a development package that provides common build instructions for all globus packages. The globus-core package is not required at runtime and must not be listed as a Requires other than for -devel packages.

Creating the specfile for a Globus package

All metadata about a Globus package needed to create the specfile is available in the package's GPT source package description file, usually obtainable as pkgdata/pkg_data_src.gpt.in in the package's sources. This is an XML file that contains the package's

  • Name
  • Version
  • Description
  • Build dependencies
  • Link dependencies
  • Runtime dependencies

The underscores in the upstream package name are changed to dashes in order to comply with the Packaging/NamingGuidelines#Separators guidelines.

GPT packages vs. RPM packages

GPT has its own packaging mechanism, and automatically distributes the installed files generated from the GPT source package into several GPT binary packages. By taking advantage of this feature the split of the installed files into several binary RPMs can be automatised.

For a globus package that provides libraries the mapping between GPT and RPM packages is as follows:

  • %{flavor}_rtl.gpt → main package
  • %{flavor}_dev.gpt → -devel package
  • noflavor_doc.gpt → -doc package

And if the package provides programs as well as libraries:

  • %{flavor}_pgm.gpt → -progs package

For a globus package that provides only programs the mapping is as follows:

  • %{flavor}_pgm.gpt → main package

GPT metadata files

The grid-packaging-tools install GPT metadata about the binary packages they create. Each GPT binary package has two metadata files in /usr/share/globus/<source_package_name>. These files should be packaged in the binary RPMs since they are needed by GPT to resolve build dependencies and by GPT user tools, such as gpt-query.

Some of the GPT metadata files contain information about architecture specific files. However, the metadata itself is architecture independant and therefore belong in /usr/share rather than /usr/lib. GPT uses different filenames for metadata files containing architecture dependent information, so there are no filename clashes in a multi-architecture installation.

These GPT metadata files are also used to generate the RPM filelists. The main difference between the GPT and RPM filelist format is that the prefix (/usr) is missing in the GPT filelist. The translation can be done using a simple sed replacement.

Doc packages

The globus library APIs are documented using doxygen comments. These are used to generate the documentation in the GPT doc packages. For some globus packages these packages are very large, while for others they are quite small. In order to provide consistent and user predictable packaging for all globus packages, the GPT doc packages should be packaged as separate doc RPMs for all globus packages regardless of their size.

Setup packages

Some globus packages has a corresponding setup package. These two packages usually requires each other and it doesn't make sense to create separate RPMs for them. The source RPM should therefore contain the sources for both packages.

A setup package normally contains a postinstall script. Since the install location of the RPM package is known it is on most occasions possible to convert the commands in this postinstall script to commands in the install section of the specfile instead, and not use a postinstall scriptlet. It is usually not a good idea to run the postinstall script provided in the sources as a postinstall scriptlet in the RPM since it often depends on the grid-packaging-tools, which is a development package and should not be Required by a non-devel package.

Plugins

Most globus libraries are simply libraries. However, globus occasionally uses a plugin mechanism based on the libtool dynamic loader library (libltdl). Libraries used as plugins in this way can be recognized by that they have an empty pkg_libs tag in the Build_Environment in the GPT source description file. Since the libtool dynamic loader library requires the libtool archive (.la) files at runtime for proper functionality, these packages as an exception should contain these files.

Library flavor tags

In a default Globus installation a flavor tag, encoding the name of the compiler and the architecture, is added to the name of the libraries in order to allow libraries for multiple architectures to be installed in the same directory. This is not needed in Fedora since in a multi-architecture installation, Fedora installs libraries for different architectures in different directories. Also encoding this information in the library names violates the packaging guidelines.

By adding a ColocateLibraries="no" attribute to the With_Flavors tag in the GPT source package description file, GPT can be told to generate Makefile rules without the flavor tag in the library names.

GPT glue packages

Some of the GPT packages in the huge Globus Toolkit installer tarball contain copies of sources of external libraries the Globus packages depend on. Such code should not be packaged in Fedora, since these libraries are already available in the distribution. However, since building the Globus packages uses GPT, the build process expects that the GPT metadata for these packages exists. In this case, a GPT glue package should be created containing only GPT metadata files. These files should refer to the Fedora version of the library as an external dependency. The version of this package should be the same as the version of the globus package it replaces.

Autogenerating specfiles (informational)

It is possible to autogenerate an initial version of the specfile from the information in the GPT source package description file by running the globus-spec.pl script. Using this script is optional, but provides increased maintainability of the package and reduces the risk of cut and paste errors. The following examples shows the autogenerated specfiles generated by the script in a few cases.

Globus package that provides a library

./globus-spec.pl -g globus_gsi_openssl_error-0.14/pkgdata/pkg_data_src.gpt.in -d gsi/openssl_error/source

  • The -g option specifies the GPT source package description file
  • The -d option specifies the directory in the installer from where the code was extracted
  • The -e option can be used to specify the packager's e-mail address (defaults to username@host)
%ifarch alpha ia64 ppc64 s390x sparc64 x86_64
%global flavor gcc64pthr
%else
%global flavor gcc32pthr
%endif

Name:		globus-gsi-openssl-error
%global _name %(tr - _ <<< %{name})
Version:	0.14
Release:	1%{?dist}
Summary:	Globus Toolkit - Globus OpenSSL Error Handling

Group:		System Environment/Libraries
License:	ASL 2.0
URL:		http://www.globus.org/
#		Source is extracted from the globus toolkit installer:
#		wget -N http://www-unix.globus.org/ftppub/gt4/4.2.1/installers/src/gt4.2.1-all-source-installer.tar.bz2
#		tar -jxf gt4.2.1-all-source-installer.tar.bz2
#		mv gt4.2.1-all-source-installer/source-trees/gsi/openssl_error/source globus_gsi_openssl_error-0.14
#		tar -zcf globus_gsi_openssl_error-0.14.tar.gz globus_gsi_openssl_error-0.14
Source: 	%{_name}-%{version}.tar.gz
#		This is a workaround for the broken epstopdf script in RHEL5
#		See: https://bugzilla.redhat.com/show_bug.cgi?id=450388
Source8:	epstopdf-2.9.5gw
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Requires:	globus-openssl >= 1
BuildRequires:	grid-packaging-tools
BuildRequires:	globus-common-devel >= 3
BuildRequires:	globus-openssl-devel >= 1
BuildRequires:	globus-core >= 4
BuildRequires:	doxygen
%if %{?fedora}%{!?fedora:0} >= 3
BuildRequires:	graphviz
BuildRequires:	ghostscript
%else
%if %{?rhel}%{!?rhel:0} >= 5
BuildRequires:	graphviz
BuildRequires:	ghostscript
%if "%{?rhel}" == "5"
BuildRequires:	graphviz-gd
%endif
%endif
%endif
%if %{?fedora}%{!?fedora:0} >= 9
BuildRequires:	tex(latex)
%else
%if %{?rhel}%{!?rhel:0} >= 6
BuildRequires:	tex(latex)
%else
BuildRequires:	tetex-latex
%endif
%endif

%package devel
Summary:	Globus Toolkit - Globus OpenSSL Error Handling Development Files
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	globus-common-devel >= 3
Requires:	globus-openssl-devel >= 1
Requires:	globus-core >= 4

%package doc
Summary:	Globus Toolkit - Globus OpenSSL Error Handling Documentation Files
Group:		Documentation
Requires:	%{name} = %{version}-%{release}

%description
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name} package contains:
Globus OpenSSL Error Handling

%description devel
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name}-devel package contains:
Globus OpenSSL Error Handling Development Files

%description doc
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name}-doc package contains:
Globus OpenSSL Error Handling Documentation Files

%prep
%setup -q -n %{_name}-%{version}

%if "%{rhel}" == "5"
mkdir bin
install %{SOURCE8} bin/epstopdf
%endif

%build
%if "%{rhel}" == "5"
export PATH=$PWD/bin:$PATH
%endif

# Remove files that should be replaced during bootstrap
rm -f doxygen/Doxyfile*
rm -f doxygen/Makefile.am
rm -f pkgdata/Makefile.am
rm -f globus_automake*
rm -rf autom4te.cache

# Remove flavor tags
for f in `find . -name Makefile.am` ; do
  sed -e 's!^flavorinclude_HEADERS!include_HEADERS!' \
      -e 's!\(lib[a-zA-Z_]*\)_$(GLOBUS_FLAVOR_NAME)\.la!\1.la!g' \
      -e 's!^\(lib[a-zA-Z_]*\)___GLOBUS_FLAVOR_NAME__la_!\1_la_!' -i $f
done
sed -e "s!<With_Flavors!<With_Flavors ColocateLibraries=\"no\"!" \
  -i pkgdata/pkg_data_src.gpt.in

%{_datadir}/globus/globus-bootstrap.sh

%configure --with-flavor=%{flavor} --enable-doxygen

make %{?_smp_mflags}

%install
%if "%{rhel}" == "5"
export PATH=$PWD/bin:$PATH
%endif

rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

# Remove libtool archives (.la files)
find $RPM_BUILD_ROOT%{_libdir} -name 'lib*.la' -exec rm -v '{}' \;
sed '/lib.*\.la$/d' \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_rtl.filelist

# Remove static libraries (.a files)
find $RPM_BUILD_ROOT%{_libdir} -name 'lib*.a' -exec rm -v '{}' \;
sed '/lib.*\.a$/d' \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_dev.filelist

# Generate pkg-config file from GPT metadata
mkdir -p $RPM_BUILD_ROOT%{_libdir}/pkgconfig
%{_datadir}/globus/globus-gpt2pkg-config pkgdata/pkg_data_%{flavor}_dev.gpt > \
  $RPM_BUILD_ROOT%{_libdir}/pkgconfig/%{name}.pc

# Move documentation to default RPM location
mv $RPM_BUILD_ROOT%{_docdir}/%{_name} \
  $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
sed s!doc/%{_name}!doc/%{name}-%{version}! \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/noflavor_doc.filelist

# Remove unwanted documentation
rm -f $RPM_BUILD_ROOT%{_mandir}/man3/deprecated.3
rm -f $RPM_BUILD_ROOT%{_mandir}/man3/*_%{_name}-%{version}_*.3
sed -e '/deprecated\.3/d' \
    -e '/_%{_name}-%{version}_.*\.3/d' \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/noflavor_doc.filelist

# Generate package filelists
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_rtl.filelist \
  | sed s!^!%{_prefix}! > package.filelist
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_dev.filelist \
  | sed s!^!%{_prefix}! > package-devel.filelist
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/noflavor_doc.filelist \
  | sed -e 's!/man/.*!&*!' -e 's!^!%doc %{_prefix}!' > package-doc.filelist

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files -f package.filelist
%defattr(-,root,root,-)
%dir %{_datadir}/globus/packages/%{_name}

%files -f package-devel.filelist devel
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/%{name}.pc

%files -f package-doc.filelist doc
%defattr(-,root,root,-)
%dir %{_docdir}/%{name}-%{version}
%dir %{_docdir}/%{name}-%{version}/html

%changelog
* Wed Apr 15 2009 Mattias Ellert <mattias.ellert@fysast.uu.se> - 0.14-1
- Autogenerated

Globus package that only provides programs

./globus-spec.pl -g globus_proxy_utils-2.5/pkgdata/pkg_data_src.gpt.in -d gsi/proxy/proxy_utils/source

%ifarch alpha ia64 ppc64 s390x sparc64 x86_64
%global flavor gcc64pthr
%else
%global flavor gcc32pthr
%endif

Name:		globus-proxy-utils
%global _name %(tr - _ <<< %{name})
Version:	2.5
Release:	1%{?dist}
Summary:	Globus Toolkit - Globus GSI Proxy Utility Programs

Group:		Applications/Internet
License:	ASL 2.0
URL:		http://www.globus.org/
#		Source is extracted from the globus toolkit installer:
#		wget -N http://www-unix.globus.org/ftppub/gt4/4.2.1/installers/src/gt4.2.1-all-source-installer.tar.bz2
#		tar -jxf gt4.2.1-all-source-installer.tar.bz2
#		mv gt4.2.1-all-source-installer/source-trees/gsi/proxy/proxy_utils/source globus_proxy_utils-2.5
#		tar -zcf globus_proxy_utils-2.5.tar.gz globus_proxy_utils-2.5
Source: 	%{_name}-%{version}.tar.gz
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Requires:	globus-openssl >= 1
BuildRequires:	grid-packaging-tools
BuildRequires:	globus-gsi-proxy-ssl-devel >= 1
BuildRequires:	globus-gsi-credential-devel >= 1
BuildRequires:	globus-gsi-callback-devel
BuildRequires:	globus-openssl-module-devel
BuildRequires:	globus-gss-assist-devel >= 3
BuildRequires:	globus-gsi-openssl-error-devel
BuildRequires:	globus-openssl-devel >= 1
BuildRequires:	globus-gsi-proxy-core-devel >= 1
BuildRequires:	globus-core >= 4
BuildRequires:	globus-gsi-cert-utils-devel >= 1
BuildRequires:	globus-common-devel >= 3
BuildRequires:	globus-gsi-sysconfig-devel >= 1

%description
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name} package contains:
Globus GSI Proxy Utility Programs

%prep
%setup -q -n %{_name}-%{version}

%build
# Remove files that should be replaced during bootstrap
rm -f doxygen/Doxyfile*
rm -f doxygen/Makefile.am
rm -f pkgdata/Makefile.am
rm -f globus_automake*
rm -rf autom4te.cache

%{_datadir}/globus/globus-bootstrap.sh

%configure --with-flavor=%{flavor}

make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

# Generate package filelists
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_pgm.filelist \
  | sed s!^!%{_prefix}! > package.filelist

%clean
rm -rf $RPM_BUILD_ROOT

%files -f package.filelist
%defattr(-,root,root,-)
%dir %{_datadir}/globus/packages/%{_name}

%changelog
* Thu Apr 16 2009 Mattias Ellert <mattias.ellert@fysast.uu.se> - 2.5-1
- Autogenerated

Globus package containing a plugin

./globus-spec.pl -g globus_xio_popen_driver-0.2/pkgdata/pkg_data_src.gpt.in -d xio/drivers/popen/source -n %{name}-wrong-dep.patch

  • The -n option can be used to disable the generation of a doc package for Globus packages that don't have any doxygen markup in the sources.

In this case the autogenerated specfile will instead of the commands for deleting the .la files contain a comment explaining why the .la files can not be removed.

This example also illustrates that the names of patches can be listed as arguments to the script. For each patch listed on the command line the autogenerated specfile will contain a stub comment saying "INSERT PATCH DESCRIPTION HERE" and an incomplete reference to the upstream bugzilla where the bug number should be entered.

%ifarch alpha ia64 ppc64 s390x sparc64 x86_64
%global flavor gcc64pthr
%else
%global flavor gcc32pthr
%endif

Name:		globus-xio-popen-driver
%global _name %(tr - _ <<< %{name})
Version:	0.2
Release:	1%{?dist}
Summary:	Globus Toolkit - Globus XIO BW Limit Driver

Group:		System Environment/Libraries
License:	ASL 2.0
URL:		http://www.globus.org/
#		Source is extracted from the globus toolkit installer:
#		wget -N http://www-unix.globus.org/ftppub/gt4/4.2.1/installers/src/gt4.2.1-all-source-installer.tar.bz2
#		tar -jxf gt4.2.1-all-source-installer.tar.bz2
#		mv gt4.2.1-all-source-installer/source-trees/xio/drivers/popen/source globus_xio_popen_driver-0.2
#		tar -zcf globus_xio_popen_driver-0.2.tar.gz globus_xio_popen_driver-0.2
Source: 	%{_name}-%{version}.tar.gz
#		### INSERT PATCH DESCRIPTION HERE ###:
#		http://bugzilla.globus.org/bugzilla/show_bug.cgi?id=###BUG NUMBER###
Patch0: 	%{name}-wrong-dep.patch
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Requires:	globus-common
BuildRequires:	grid-packaging-tools
BuildRequires:	globus-xio-devel

%package devel
Summary:	Globus Toolkit - Globus XIO BW Limit Driver Development Files
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	globus-xio-devel

%description
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name} package contains:
Globus XIO BW Limit Driver

%description devel
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name}-devel package contains:
Globus XIO BW Limit Driver Development Files

%prep
%setup -q -n %{_name}-%{version}
%patch0 -p1

%build
# Remove files that should be replaced during bootstrap
rm -f doxygen/Doxyfile*
rm -f doxygen/Makefile.am
rm -f pkgdata/Makefile.am
rm -f globus_automake*
rm -rf autom4te.cache

# Remove flavor tags
for f in `find . -name Makefile.am` ; do
  sed -e 's!^flavorinclude_HEADERS!include_HEADERS!' \
      -e 's!\(lib[a-zA-Z_]*\)_$(GLOBUS_FLAVOR_NAME)\.la!\1.la!g' \
      -e 's!^\(lib[a-zA-Z_]*\)___GLOBUS_FLAVOR_NAME__la_!\1_la_!' -i $f
done
sed -e "s!<With_Flavors!<With_Flavors ColocateLibraries=\"no\"!" \
  -i pkgdata/pkg_data_src.gpt.in

%{_datadir}/globus/globus-bootstrap.sh

%configure --with-flavor=%{flavor}

make %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

# This library is opened using lt_dlopenext, so the libtool archives
# (.la files) can not be removed - fix the libdir...
for lib in `find $RPM_BUILD_ROOT%{_libdir} -name 'lib*.la'` ; do
  sed "s!^libdir=.*!libdir=\'%{_libdir}\'!" -i $lib
done

# Remove static libraries (.a files)
find $RPM_BUILD_ROOT%{_libdir} -name 'lib*.a' -exec rm -v '{}' \;
sed '/lib.*\.a$/d' \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_dev.filelist

# Generate pkg-config file from GPT metadata
mkdir -p $RPM_BUILD_ROOT%{_libdir}/pkgconfig
%{_datadir}/globus/globus-gpt2pkg-config pkgdata/pkg_data_%{flavor}_dev.gpt > \
  $RPM_BUILD_ROOT%{_libdir}/pkgconfig/%{name}.pc

# Generate package filelists
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_rtl.filelist \
  | sed s!^!%{_prefix}! > package.filelist
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_dev.filelist \
  | sed s!^!%{_prefix}! > package-devel.filelist

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files -f package.filelist
%defattr(-,root,root,-)
%dir %{_datadir}/globus/packages/%{_name}

%files -f package-devel.filelist devel
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/%{name}.pc

%changelog
* Thu Apr 16 2009 Mattias Ellert <mattias.ellert@fysast.uu.se> - 0.2-1
- Autogenerated

Globus package that provides both a library and programs and that has a corresponding setup package

./globus-spec.pl -g globus_common-10.2/pkgdata/pkg_data_src.gpt.in -s globus_common_setup-2.6/pkgdata/pkg_data_src.gpt.in -r 2 -d common/source

  • The -s option is used to indicate the GPT source package description file for the setup package
  • The -r option is used to set the release version of the specfile to 2 (default is 1, as in the previous examples)

The patches have been excluded from this example to keep it short. For this package some additional editing is needed. Compare the autogenerated file below with the specfile in the actual package to see the differences.

%ifarch alpha ia64 ppc64 s390x sparc64 x86_64
%global flavor gcc64pthr
%else
%global flavor gcc32pthr
%endif

Name:		globus-common
%global _name %(tr - _ <<< %{name})
Version:	10.2
%global setupversion 2.6
Release:	2%{?dist}
Summary:	Globus Toolkit - Common Library

Group:		System Environment/Libraries
License:	ASL 2.0
URL:		http://www.globus.org/
#		Source is extracted from the globus toolkit installer:
#		wget -N http://www-unix.globus.org/ftppub/gt4/4.2.1/installers/src/gt4.2.1-all-source-installer.tar.bz2
#		tar -jxf gt4.2.1-all-source-installer.tar.bz2
#		mv gt4.2.1-all-source-installer/source-trees/common/source globus_common-10.2
#		tar -zcf globus_common-10.2.tar.gz globus_common-10.2
Source: 	%{_name}-%{version}.tar.gz
#		Source1 is extracted from the globus toolkit installer:
#		wget -N http://www-unix.globus.org/ftppub/gt4/4.2.1/installers/src/gt4.2.1-all-source-installer.tar.bz2
#		tar -jxf gt4.2.1-all-source-installer.tar.bz2
#		mv gt4.2.1-all-source-installer/source-trees/common/setup globus_common_setup-2.6
#		tar -zcf globus_common_setup-2.6.tar.gz globus_common_setup-2.6
Source1:	%{_name}_setup-%{setupversion}.tar.gz
#		This is a workaround for the broken epstopdf script in RHEL5
#		See: https://bugzilla.redhat.com/show_bug.cgi?id=450388
Source8:	epstopdf-2.9.5gw
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Requires:	globus-libtool >= 1
BuildRequires:	grid-packaging-tools
BuildRequires:	globus-libtool-devel >= 1
BuildRequires:	globus-core >= 4
BuildRequires:	doxygen
%if %{?fedora}%{!?fedora:0} >= 3
BuildRequires:	graphviz
BuildRequires:	ghostscript
%else
%if %{?rhel}%{!?rhel:0} >= 5
BuildRequires:	graphviz
BuildRequires:	ghostscript
%if "%{?rhel}" == "5"
BuildRequires:	graphviz-gd
%endif
%endif
%endif
%if %{?fedora}%{!?fedora:0} >= 9
BuildRequires:	tex(latex)
%else
%if %{?rhel}%{!?rhel:0} >= 6
BuildRequires:	tex(latex)
%else
BuildRequires:	tetex-latex
%endif
%endif

%package progs
Summary:	Globus Toolkit - Common Library Programs
Group:		Applications/Internet
Provides:	%{name}-setup = %{setupversion}
Requires:	%{name} = %{version}-%{release}
Requires:	globus-libtool >= 1
Requires:	globus-common-progs >= 3
Requires:	globus-common-setup >= 2

%package devel
Summary:	Globus Toolkit - Common Library Development Files
Group:		Development/Libraries
Requires:	%{name} = %{version}-%{release}
Requires:	globus-libtool-devel >= 1
Requires:	globus-core >= 4

%package doc
Summary:	Globus Toolkit - Common Library Documentation Files
Group:		Documentation
Requires:	%{name} = %{version}-%{release}

%description
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name} package contains:
Common Library

%description progs
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name}-progs package contains:
Common Library Programs
Common Setup

%description devel
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name}-devel package contains:
Common Library Development Files

%description doc
The Globus Toolkit is an open source software toolkit used for building Grid
systems and applications. It is being developed by the Globus Alliance and
many others all over the world. A growing number of projects and companies are
using the Globus Toolkit to unlock the potential of grids for their cause.

The %{name}-doc package contains:
Common Library Documentation Files

%prep
%setup -q -n %{_name}-%{version}
%setup -D -T -q -n %{_name}-%{version} -a 1

%if "%{rhel}" == "5"
mkdir bin
install %{SOURCE8} bin/epstopdf
%endif

%build
%if "%{rhel}" == "5"
export PATH=$PWD/bin:$PATH
%endif

# Remove files that should be replaced during bootstrap
rm -f doxygen/Doxyfile*
rm -f doxygen/Makefile.am
rm -f pkgdata/Makefile.am
rm -f globus_automake*
rm -rf autom4te.cache

# Remove flavor tags
for f in `find . -name Makefile.am` ; do
  sed -e 's!^flavorinclude_HEADERS!include_HEADERS!' \
      -e 's!\(lib[a-zA-Z_]*\)_$(GLOBUS_FLAVOR_NAME)\.la!\1.la!g' \
      -e 's!^\(lib[a-zA-Z_]*\)___GLOBUS_FLAVOR_NAME__la_!\1_la_!' -i $f
done
sed -e "s!<With_Flavors!<With_Flavors ColocateLibraries=\"no\"!" \
  -i pkgdata/pkg_data_src.gpt.in

%{_datadir}/globus/globus-bootstrap.sh

%configure --with-flavor=%{flavor} --enable-doxygen

make %{?_smp_mflags}

# setup package
cd %{_name}_setup-%{setupversion}

# Remove files that should be replaced during bootstrap
rm -f doxygen/Doxyfile*
rm -f doxygen/Makefile.am
rm -f pkgdata/Makefile.am
rm -f globus_automake*
rm -rf autom4te.cache

%{_datadir}/globus/globus-bootstrap.sh

%configure --without-flavor

make %{?_smp_mflags}

cd -

%install
%if "%{rhel}" == "5"
export PATH=$PWD/bin:$PATH
%endif

rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

# setup package
cd %{_name}_setup-%{setupversion}
make install DESTDIR=$RPM_BUILD_ROOT
cd -

# Register setup
perl -MGrid::GPT::Setup <<EOF
my \$metadata = new Grid::GPT::Setup(package_name => "%{_name}_setup",
				     globusdir => "$RPM_BUILD_ROOT%{_prefix}");
\$metadata->finish();
EOF

# Create setup files

### INSERT RELEVANT PARTS OF setup-globus-common HERE ###

# Remove libtool archives (.la files)
find $RPM_BUILD_ROOT%{_libdir} -name 'lib*.la' -exec rm -v '{}' \;
sed '/lib.*\.la$/d' \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_rtl.filelist

# Remove static libraries (.a files)
find $RPM_BUILD_ROOT%{_libdir} -name 'lib*.a' -exec rm -v '{}' \;
sed '/lib.*\.a$/d' \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_dev.filelist

# Generate pkg-config file from GPT metadata
mkdir -p $RPM_BUILD_ROOT%{_libdir}/pkgconfig
%{_datadir}/globus/globus-gpt2pkg-config pkgdata/pkg_data_%{flavor}_dev.gpt > \
  $RPM_BUILD_ROOT%{_libdir}/pkgconfig/%{name}.pc

# Move documentation to default RPM location
mv $RPM_BUILD_ROOT%{_docdir}/%{_name} \
  $RPM_BUILD_ROOT%{_docdir}/%{name}-%{version}
sed s!doc/%{_name}!doc/%{name}-%{version}! \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/noflavor_doc.filelist

# Remove unwanted documentation
rm -f $RPM_BUILD_ROOT%{_mandir}/man3/deprecated.3
rm -f $RPM_BUILD_ROOT%{_mandir}/man3/*_%{_name}-%{version}_*.3
sed -e '/deprecated\.3/d' \
    -e '/_%{_name}-%{version}_.*\.3/d' \
  -i $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/noflavor_doc.filelist

# Generate package filelists
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_rtl.filelist \
  | sed s!^!%{_prefix}! > package.filelist
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_pgm.filelist \
    $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}_setup/noflavor_pgm.filelist \
  | sed s!^!%{_prefix}! > package-progs.filelist
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/%{flavor}_dev.filelist \
  | sed s!^!%{_prefix}! > package-devel.filelist
cat $RPM_BUILD_ROOT%{_datadir}/globus/packages/%{_name}/noflavor_doc.filelist \
  | sed -e 's!/man/.*!&*!' -e 's!^!%doc %{_prefix}!' > package-doc.filelist

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files -f package.filelist
%defattr(-,root,root,-)
%dir %{_datadir}/globus/packages/%{_name}

%files -f package-progs.filelist progs
%defattr(-,root,root,-)
%dir %{_datadir}/globus/packages/%{_name}_setup
%{_datadir}/globus/packages/setup
%dir %{_datadir}/globus/setup

%files -f package-devel.filelist devel
%defattr(-,root,root,-)
%{_libdir}/pkgconfig/%{name}.pc

%files -f package-doc.filelist doc
%defattr(-,root,root,-)
%dir %{_docdir}/%{name}-%{version}
%dir %{_docdir}/%{name}-%{version}/html

%changelog
* Thu Apr 16 2009 Mattias Ellert <mattias.ellert@fysast.uu.se> - 10.2-2
- Autogenerated