rpmbuild -bb adds mysterious commands to my %build section

Hi everyone!
I run into a strange situation while running rpmbuild -bb. Would very appreciate your comments.

Background
I use SuSE 10.1.
My rpmbuild command is:
rpmbuild -bb --buildroot /tmp/mypackage/BUILD --define ‘_topdir /tmp/mypackage’ myPackage.spec.
The RPM_BUILD_ROOT is set to /tmp/mypackage/BUILD.
The %build section in myPackage.spec file is completely empty.

Problem
After adding set -x to the .sh file which calls rpmbuild, I see the following output:

Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.78582

  • umask 022
  • cd /tmp/mypackage/BUILD
    **+ /bin/rm -rf /tmp/mypackage/BUILD
    ++ dirname /tmp/mypackage/BUILD
  • /bin/mkdir -p /tmp/mypackage
  • /bin/mkdir /tmp/mypackage/BUILD**
  • exit 0

I know that the “umask” and the “cd” commands are executed for every section in the spec file, so I’m not worried about them. However, the 4 other commands (in red) seem to appear out of nowhere!
I already searched my scripts and files for the mysterious commands, but found nothing.

Do you happen to have an idea for me???:confused:

Hi
It’s just removing the build directory and then re-creating it to
ensure no previous build data there… it’s normal.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel 2.6.27.7-4-default
up 1 day 16:34, 2 users, load average: 0.03, 0.17, 0.30
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82

Oh, thanks! I appreciate your answer.
So - just want to make sure - I can’t find these 4 commands in any of the scripts because they are part of the rpmb executable?

Hi
Sounds like it’s the build macro your calling if there is nothing to
be done. Maybe a look down in /usr/lib/rpm may clarify.

Have you tried excluding the build macro, since it’s not required?


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.1 x86 Kernel 2.6.27.7-9-pae
up 0:52, 2 users, load average: 0.12, 0.19, 0.14
GPU GeForce 6600 TE/6200 TE - Driver Version: 177.82

What happened in the move from 11.1 to 11.2? You used to be able to leave %install blank with rpmbuild -bb but now its a disaster.

In a large consortium using RedHat Linux and hoping to use openSUSE, I’ve been using the same spec file to generate binary RPMs using:

BuildRoot: %{_builddir}/%{name}-%{version}

which will extract a binary tarball to:

BUILD/myName-myVersion-myRelease.x86_64

Note in particular I defined BuildRoot: not something called Build:. By the way I can set it to anything I like, but it still won’t work. It worked perfectly in openSUSE 11.1.

for example, /usr/lib/rpm/macros will move the files to:

%buildroot %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}

This causes builds to fail and means that you probably need:

%install
cp -rP * $RPM_BUILD_ROOT/

because ridiculously the definition of $RPM_BUILD_ROOT is changed from BUILD to BUILDROOT on the fly inside the scripts. I thought that perhaps I could avoid the change by logging in as root or setting up visudo for ALL rights to the user, but brp-compress wants to change the RPM_BUILD_ROOT no matter what.

Have I missed something?

please try:
remove %build from the spec file.

Removing %build doesn’t do anything. This is the really old fix to the rpmbuild -bb problem that most people know about now.

The issue stated in the thread is a brand new issue which I alerted the developers to a few months ago, but have received no reply.

It looks like you will actually need to include:

%install
cp -rP $BUILDROOT/* $RPM_BUILD_ROOT

The logic is all wrong as the previous person (cat_in_hat) has so well described in detail.

There was never a requirement for an install step content. It was always left blank. I’ve been building on openSUSE 9.3, 10.3 and 11.0, 11.1 over the past 5 years and this is only found in 11.2. I’m using a build system that automatically generates the spec file for RedHat systems and Yellow Dog Linux which both work fine. Only openSUSE shows up this issue.

[QUOTE=eamonnkenny;2135166]

It looks like you will actually need to include:

%install
cp -rP $BUILDROOT/* $RPM_BUILD_ROOT

Apologies, cat_in_hat had it exactly right:

cp -rP * $RPM_BUILD_ROOT

Very Interestingly cp -rP * $RPM_BUILD_ROOT doesn’t work either. Because of the way the SUSE scripts are written, suppose you are using:

Prefix: /usr/local

You will find that the scripts will generate:

BUILDROOT/%{name}-%{version}-%{release}.%{_arch}/usr
BUILDROOT/%{name}-%{version}-%{release}.%{_arch}/usr/local

so that it has two copies and then fails when checking files, so you actually must use:

cp -rP . $RPM_BUILD_ROOT

for it to work (which is ridiculous). I now have it working perfectly for me.