Building RPMs of perl modules and gnome software

Sam Isaacson (sbi@nbcs.rutgers.edu)


Currently we are maintaining two repositories for sun4u machines running Solaris 8: sparc64-sun-solaris2.8, and sparc64-sun-solaris2.8_sun-perl,gnome. The former repository contains packages built against our RPMs whenever possible; the latter, packages built against software bundled with Solaris whenever possible (excluding the shells). The key differences between the repositories are the presence of Sun's perl and gnome packages.

To ease the maintenance of both repositories, we have a set of RPM macros which allows properly-written specfiles to built without modification for both repositories. This document outlines the proper use of these macros.

Perl modules

The perl macros are defined in perl-header.spec:

# When updating perl, be sure to update this file and reuse perl.spec
# instead of rewriting it.  This file is (or will be) %included in all
# the perl-related specfiles, so upgrading should be relatively
# painless.

%include machine-header.spec

%if %{which_perl} == "REPOSITORY"
%define perl_version      5.6.1
%define perl_prefix       /usr/local/perl5
%define perl_arch         sun4-solaris-thread-multi
%define global_perl       %{perl_prefix}/lib/%{perl_version}
%define global_perl_arch  %{global_perl}/%{perl_arch}
%define site_perl         %{perl_prefix}/lib/site_perl/%{perl_version}
%define site_perl_arch    %{site_perl}/%{perl_arch}

%define perl_binary       %{perl_prefix}/bin/perl

%define pmake_install     make install PREFIX=%{buildroot}%{perl_prefix}
%endif

%if %{which_perl} == "SOLARIS"
%ifos solaris2.8
%define perl_version      5.00503
%define perl_prefix       /usr/perl5
%define perl_arch         sun4-solaris
%define global_perl       %{perl_prefix}/%{perl_version}
%define global_perl_arch  %{global_perl}/%{perl_arch}
%define site_perl         %{perl_prefix}/site_perl/5.005
%define site_perl_arch    %{site_perl}/%{perl_arch}

%define perl_binary       %{perl_prefix}/bin/perl

%define pmake_install	make install INSTALLARCHLIB=%{buildroot}/%{global_perl_arch} INSTALLSITEARCH=%{buildroot}/%{site_perl_arch} INSTALLPRIVLIB=%{buildroot}/%{global_perl} INSTALLSITELIB=%{buildroot}/%{site_perl} INSTALLBIN=%{buildroot}/%{perl_prefix}/bin INSTALLSCRIPT=%{buildroot}/%{perl_prefix}/bin INSTALLMAN1DIR=%{buildroot}/usr/perl5/man/man1 INSTALLMAN3DIR=%{buildroot}/usr/perl5/man/man3
%endif
%endif

When writing specfiles for perl modules, insert the line "%include perl-header.spec" at the beginning of the specfile. Note that perl-header.spec and machine-header.spec must be present in the directory where rpm is invoked to build your specfile. Replace all absolute paths relating to perl by the longest possible macro that fits. If the module you are building uses ExtUtils::MakeMaker, install the module into the buildroot with "%{pmake_install}".

Most perl modules will install perllocal.pod in %{global_perl_arch}/perllocal.pod. Don't include this in the RPM, as it can prevent the installation of multiple modules.

Gnome packages

The gnome macros are defined in gnome-header.spec:

# This is NOT meant to aid in the relocation of our gnome packages but
# only in the building of software not included in Solaris gnome.

%include machine-header.spec

%if %{which_gnome} == "REPOSITORY"
%define glib_prefix  /usr/local
%define gtk_prefix   /usr/local
%define imlib_prefix /usr/local
%define gnome_prefix /usr/local

%define glib_pkg     glib
%define glib_dev     glib
%define gtk_pkg      gtk+
%define gtk_dev      gtk+-devel
%define imlib_pkg    imlib
%define imlib_dev    imlib-devel
%define gnome_pkg    gnome-libs
%define gnome_dev    gnome-libs-devel

%define gnome_ldflags  -L/usr/local/lib -R/usr/local/lib
%define gnome_cppflags -I/usr/local/include
%endif

# Regarding GNOME, we generally drop repository packages in favor of
# their repository counterparts.  However, we include packages that
# require gtk+ (e.g. vim, freeciv), necessitating these macros:

%if %{which_gnome} == "SOLARIS"
%define glib_prefix  /opt/gnome-1.4
%define gtk_prefix   /opt/gnome-1.4
%define imlib_prefix /opt/gnome-1.4
%define gnome_prefix /opt/gnome-1.4

%define glib_pkg     vpkg-SUNWglib
%define glib_dev     vpkg-SUNWglib
%define gtk_pkg      vpkg-SUNWgtk+
%define gtk_dev      vpkg-SUNWgtk+
%define imlib_pkg    vpkg-SUNWimlib
%define imlib_dev    vpkg-SUNWimlib
%define gnome_pkg    vpkg-SUNWglibs
%define gnome_dev    vpkg-SUNWglibs

%define gnome_ldflags  -L/opt/gnome-1.4/lib -R/opt/gnome-1.4/lib
%define gnome_cppflags -I/opt/gnome-1.4/include
%endif

Just as with perl, add "%include gnome-header.spec" to the beginning of the specfile. Use the "*(dev|pkg)" names in place of explicit package names; e.g. if a package requires GTK+, use

Requires: %{gtk_pkg}
BuildRequires: %{gtk_dev}
instead of
Requires: gtk+
BuildRequires: gtk+-devel
Add %{gnome_ldflags} to LDFLAGS and %{gnome_cppflags} to CPPFLAGS if linking against dynamic libraries in gtk+, gnome, or imlib. To do this, add the macro inside the string: LDFLAGS="%{gnome_ldflags}". Finally, replace absolute paths to the existing gnome installation with the *-prefix variables. That is, don't build gnome applications in %{gnome-prefix}, but pass %{gnome-prefix} to configure.

Note that gnome-header.spec is only intended for use with packages that depend on gnome, not core gnome packages. For packages such as vim, which are in both repositories, use gnome-header.spec; but for packages such as gnome-core, which should not be built on a system with an installed Sun gnome, don't use gnome-header.spec


$Id: building_perl_modules.html,v 1.1.1.1 2001/12/14 20:38:47 sbi Exp $