On Fri, Feb 28, 2003 at 01:57:55PM +0100, Ralf S. Engelschall wrote:
>On Fri, Feb 28, 2003, Christoph Schug wrote:
>
>> [...]
>>   +##
>>   +##  @l_prefix@/etc/cyrus-imapd/cyrus.conf - Cyrus IMAP server configuration
>>   +##
>> [...]
>
>Should be @l_prefix@/etc/imapd/cyrus.conf, shouldn't it?
>
>> [...]
>>    %install
>>   -    #rm -rf $RPM_BUILD_ROOT
>>   +    rm -rf $RPM_BUILD_ROOT
>> [...]
>
>Be careful, you have to disable this "rm -rf" here because the
>"perl-openpkg install" under %build already created and installed into
>$RPM_BUILD_ROOT. Yes, this is unclean behaviour, but until I enhance the
>functionality of perl-openpkg it cannot be done differently here. So,
>you have to leave out the "rm -rf" or your Perl modules are missing
>in the package...

The current versions of perl include a patch I submitted about two years
ago to allow installation relative to an environment variable.
        PERL_INSTALL_ROOT=$RPM_BUILD_ROOT
        export PERL_INSTALL_ROOT

I'm attaching a prototype perl spec file that we've been using for several
years now.  Usually it requires minimal changes when building from CPAN
sources, adding the module name and description in most cases (all RPMS are
named ``perl-$modulename'').  Using this the first time, I built RPMS for
about 40 modules from CPAN sources in about two hours.

This prototype uses a couple of macros from Caldera's RPM to make and
remove RPM_BUILD_ROOT safely (%{mkDESTDIR} and %{rmDESTDIR}) and their
%{mkLists} macro which does much the same thing as the shtool files
command, but with some features that make it easier to build multiple
packages.  It would be easy to make this conform to openpkg standards.

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

My brother sent me a postcard the other day with this big satellite photo
of the entire earth on it. On the back it said: ``Wish you were here''.
                -- Steven Wright
# $Header: /u/usr/cvs/perl/Csys/Maildir/perl-Csys-Maildir.spec,v 1.2 2001/07/06 
23:40:31 bill Exp $
# @(#) $Id: perl-Csys-Maildir.spec,v 1.2 2001/07/06 23:40:31 bill Exp $
#
%define PACKAGE_NAME modulename
Group: Programming/Library
Name:         perl-%{PACKAGE_NAME}
Summary:      Put your summary here
URL:          http://www.celestial.com/
Vendor:       Celestial Software LLC
Packager:     Bill Campbell <[EMAIL PROTECTED]>
Distribution: CSOFT
Group:        Programming/Tools
License:      GPL
Version:      0.90
Release:      20020124
Group:        Programming/Tools

Source: perl-%{PACKAGE_NAME}-%{Version}.tar.gz

#   build information
Prefix:       %{l_prefix}
BuildRoot:    %{l_buildroot}
BuildPreReq:  OpenPKG, openpkg >= 1.1.0
PreReq:       OpenPKG, openpkg >= 1.1.0
AutoReq:      no
AutoReqProv:  no

%Description
        put your description here

%Prep
        %setup -n perl-%{PACKAGE_NAME}-%{Version}

%Build
        [ -z "$ENV" ] || unset ENV
        [ %{l_prefix} != '/usr/local' ] && {
                find . -type f ! -name Changes |
                        xargs egrep -l \
                                '/usr/local|/usr/bin/perl' > tmpchanges

                %{l_shtool} subst -s \
                        -e "s!/usr/local!%{l_prefix}!g" \
                        -e "s!/usr/bin/perl!%{l_prefix}/perl!g" \
                        `cat tmpchanges`
        }
        perl Makefile.PL

        # this builds PERL5LIB so that it's a mirror of the @INC directory relative
        # to $RPM_BUILD_ROOT which will be searched before perl looks in the @INC
        # array for libraries.  This insures that the module being built is found
        # before any existing modules.
        PERL5LIB=`perl -e '
                $RPM_BUILD_ROOT = $ENV{RPM_BUILD_ROOT};
                for $dir (@INC) {
                        next if ($dir eq ".");
                        push(@dirs, "$RPM_BUILD_ROOT$dir");
                }
                print join(":", @dirs);
                '`
        export PERL5LIB
        echo $PERL5LIB

        %{__make} 2>&1 | tee makelist
        # this may well not work on some modules when building before they're
        # installed.
        %{__make} test 2>&1 | tee mk.test

%Install
        %{mkDESTDIR}

        # see above on @INC processing.
        PERL5LIB=`perl -e '
                $RPM_BUILD_ROOT = $ENV{RPM_BUILD_ROOT};
                for $dir (@INC) {
                        next if ($dir eq ".");
                        push(@dirs, "$RPM_BUILD_ROOT$dir");
                }
                print join(":", @dirs);
                '`
        export PERL5LIB

        # This is used by hacked Install.pm to install relative
        # The longer name is used to prevent possible interference when buildig
        # modules that may have other means for installing relative to some other
        # directory.
        RPM_BUILD_ROOT_PERL=$RPM_BUILD_ROOT
        PERL_INSTALL_ROOT=$RPM_BUILD_ROOT
        export PERL_INSTALL_ROOT RPM_BUILD_ROOT_PERL

        PREFIX=$DESTDIR%{l_prefix}
        INSTALLMAN1DIR=$DESTDIR$PREFIX/man/man1
        INSTALLMAN3DIR=$DESTDIR$PREFIX/share/perl5/man/man3

        %{__install} -d $PREFIX $INSTALLMAN1DIR $INSTALLMAN3DIR

        # pure_install bypasses some things we really don't want to do when building
        # relative to some arbitrary directory.
        %{__make} \
                pure_install 2>&1 | tee mk.install

        %{__install} -d $DESTDIR%{BINDIR}
        %{__install} examples/deliver_post.pl $DESTDIR%{BINDIR}

        %{mkLists} -c %{Name}
cat << 'EOF' | %{mkLists} -f %{Name}
Csys/.*\.pl$    IGNORE
.*                      base
EOF
        packlist="$DESTDIR"`grep '\.packlist$' files-%{Name}-base`
        tmpfile="/tmp/packlist$$"
        sed "s,$DESTDIR,," < $packlist > $tmpfile
        cp $tmpfile $packlist;
        rm $tmpfile;

        # Creates html and postscript documentation
        # These files are included in the %doc line below
        pod2doc.pl -v
        exit 0

%post
exit 0

%preun
        [ "$1" = 0 ] && {
                true
        }
        exit 0

%Clean
        %{rmDESTDIR}

%Files -f files-%{Name}-base
%defattr(-,%{l_susr},%{l_sgrp})
%doc Changes MANIFEST *.ps *.html examples

%ChangeLog

Reply via email to