[Fedora-packaging] unwanted directory removal during rpm build

Mattias Ellert mattias.ellert at fysast.uu.se
Tue Sep 1 07:20:42 UTC 2009


mån 2009-08-31 klockan 23:07 -0700 skrev Scott Frankel:
> Hello,
> 
> I'm new to rpm package development and just joined this list.  I'm  
> trying to create an rpm, but working subdirs of BUILDROOT are getting  
> deleted between %build and %install.  This causes subsequent copy  
> operations to fail and rpmbuild to error out with a bad exit status.   
> The `rm -rf` that removes the working dir is not coming from any  
> explicit statement in my spec file.
> 
> I'm copying pertinent lines from shell output, the spec file, and  
> system configuration below.  I'm hopeful someone can suggest a work- 
> around.
> 
> Thanks in advance!
> Scott

> The spec file has this %build section (in its entirety), followed by  
> the first of the failed copies.  Note that these are contiguous lines  
> of specfile code between %build and %install.
> 
> [ ... ]
> 	%build
> 	rm -rf $RPM_BUILD_ROOT
> 	mkdir $RPM_BUILD_ROOT
> 	mkdir $RPM_BUILD_ROOT/opt
> 	mkdir $RPM_BUILD_ROOT/opt/foo
> 
> 
> 	%install
> 	cp -r schema $RPM_BUILD_ROOT/opt/foo
> [ ... ]

The %build section must not create files or directories in the
$RPM_BUILD_ROOT. That must only be done in the %install section.

The Fedora packaging guidelines says that the first command in the
%install section must be "rm -rf $RPM_BUILD_ROOT". If you are using a
recent RPM version this will be enforced automatically, which is what
happens in this case.

%build

%install
rm -rf $RPM_BUILD_ROOT
mkdir $RPM_BUILD_ROOT
mkdir $RPM_BUILD_ROOT/opt
mkdir $RPM_BUILD_ROOT/opt/foo
cp -r schema $RPM_BUILD_ROOT/opt/foo

	Mattias

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2272 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/fedora-packaging/attachments/20090901/78daefc8/attachment.bin>


More information about the Fedora-packaging mailing list