rpmbuild fails BUILDROOT

Hi All

I have lots of rpms I’ve been recompiling for years, but after I upgraded from 11.1 to 11.4 this simple .spec does not work anymore. it seems like BUILDROOT is deleted before it is processed

I’ve commented out the %clean stage, but it does not help.
Works fine on all versions of RedHat EL5 and all Opensuse version from 11.1 and downwards. (have not tested 11.2 and 11.3)

MortenB, Oslo, Norway

sudo rpmbuild -ba ./secana_perl_589.spec
<skipped lots of processing input, compiling etc goes fine>
make[1]: Leaving directory `/usr/src/packages/BUILD/perl-5.8.9'
+ /usr/lib/rpm/brp-lib64-linux
[email]sf@suse.de[/email]: if you find problems with this script, drop me a note
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-symlink
Processing files: secana_perl-5.8.9-1.x86_64
error: File not found: /usr/src/packages/BUILDROOT/secana_perl-5.8.9-1.x86_64/opt/perl

RPM build errors:
    File not found: /usr/src/packages/BUILDROOT/secana_perl-5.8.9-1.x86_64/opt/perl

ls -l /usr/src/packages/BUILDROOT/secana_perl-5.8.9-1.x86_64/
total 0

cat ./secana_perl_589.spec
# spec file for package secana_perl
# defined your distribution settings
%define distro  OpenSuse
%define arch    x86_64

# ignore /usr/lib/rpm/find-debuginfo.sh since this version in centos5.2 is buggy
%define debug_package %{nil}

Name:           secana_perl
License:        Commercial
Group:          Application
Provides:       secana_perl
Autoreqprov:    on
URL:            http://www.experian-scorex.no
Version:        5.8.9
Release:        1
Summary:        Perl barebone build of Secana
Source:         perl-%{version}.tar.gz
Packager:       Morten Bjoernsvik <morten.bjornsvik@experian-scorex.no>
Vendor:         Experian Decision Analytics AS, Oslo, Norway
Scratch perl for Secana SCP last version with preudohash 

%setup -n perl-%{version}

if  %{distro} == 'OpenSuse' ]; then
    # perl-5.x.0 - OpensuSe11.x compile file
    sh Configure -Dprefix=/opt/perl -Dnoextensions=ODBM_File -des -Accflags="-fPIC" || :
    sh Configure -Dprefix=/opt/perl -des -Accflags="-fPIC" || :

make install

#rm -rf /opt/perl


cd /opt/perl
if  -d /opt/perl/opt/perl ]; then 
        cp /opt/perl/opt/perl/* /opt/perl/ || :
        rm -rf /opt/perl/opt || :

%changelog -n %{name}
* Mon Sep 15 2008 - morten.bjornsvik@experian-da.no
- initial build for perl589

The problem is the %files section, If I uncomment %files it builds the *.rpm and *.src.rpm, but then no files are packages, the rpm is just an empty shell

Why are you using rpmbuild as root (sudo)?

I just switched to root when this initially failed, to see if it could be reproduced as root.

Before files /opt/perl points to this:

  • pwd /opt/perl

but $RPM_BUILD_ROOT = /usr/src/packages/BUILDROOT/secana_perl-5.8.9-1.x86_64

but in %files
/opt/perl then points to /usr/src/packages/BUILDROOT/secana_perl-5.8.9-1.x86_64/opt/perl

This got to be a bug. or a new environment variable that is not documented in rpmdevtools examples.

%if 0%{?suse_version} >= 1140
# fix for opensuse11.4 which do not seem to use buildroot before
if  ! -d $RPM_BUILD_ROOT%{perl_dir} ]; then
  mkdir -p $RPM_BUILD_ROOT%{perl_dir}
cp -Rp %{perl_dir}/. $RPM_BUILD_ROOT%{perl_dir}/.

Vendor:         Experian Decision Analytics AS, Oslo, Norway
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Scratch perl for Secana SCP last version with preudohash

Add this line (in red) in your .spec file. And don’t build as root!
See what files are missing in ~/rpmbuild/BUILDROOT when you try to build the package.

Thanks it seem to work,
only the user need to have write access to /opt/perl and not $RPM_BUILD_ROOT/opt/perl