Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm new to RPM packaging and I got stuck for quite a long time and cannot find root cause of the problem. I'm not quite sure I fully understand the concept of BuildRoot in the spec file.

My RPM packaging happens in my home dir: /home/virtual/rpmbuild.

I'm trying to package a java application located in /home/virtual/rpmbuild/tmp/BDHistProcessor with the structure:

BDHistProcessor
 lib
 bin
 conf
 deploy

Here is my spec file I created:

%define _tmppath  /home/virtual/rpmbuild/tmp

Name:           BDHistProcessor
Version:        1.0.0
Release:        1%{?dist}
Summary:        component which feed data into DB

Group:        Applications/System   
License:      GPL  
URL:          https://www.tem.com/  
BuildRoot: %{tmppath}/%{name}

%description
Component which feed data into DB

%prep

%build

%install
rm -rf $RPM_BUILD_ROOT
cp -r  /home/virtual/rpmbuild/tmp/BDHistProcessor $RPM_BUILD_ROOT 

%files
%defattr(-,root,root)
%{buildroot}/BDHistProcessor/lib
%{buildroot}/BDHistProcessor/bin
%{buildroot}/BDHistProcessor/conf
%{buildroot}/BDHistProcessor/deploy
%{buildroot}/BDHistProcessor/README.txt

%doc
%changelog

Running rpmbuild -v -bb -clean SPECS/myRPM.spec returns output:

[virtual@virtual rpmbuild]$ rpmbuild -v -bb --clean SPECS/myRPM.spec
Executing(%prep): /bin/sh -e /home/virtual/rpmbuild/tmp/rpm-tmp.t2AMGe
+ umask 022
+ cd /home/virtual/rpmbuild/BUILD
+ exit 0
Executing(%build): /bin/sh -e /home/virtual/rpmbuild/tmp/rpm-tmp.1unXP8
+ umask 022
+ cd /home/virtual/rpmbuild/BUILD
+ exit 0
Executing(%install): /bin/sh -e /home/virtual/rpmbuild/tmp/rpm-tmp.SoaH02
+ umask 022
+ cd /home/virtual/rpmbuild/BUILD
+ rm -rf /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64
+ cp -r /home/virtual/rpmbuild/tmp/BDHistProcessor /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64
+ /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: BDHistProcessor-1.0.0-1.el6.x86_64
error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/lib
error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/bin
error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/conf
error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/deploy
error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/README.txt


RPM build errors:
    File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/lib
    File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/bin
    File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/conf
    File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/deploy
    File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/README.txt

I'm not quite sure how the paths get cycled in the error report. Can someone please clarify what I'm doing wrong here?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Background - rpmbuild setup

How did you create your rpmbuild directory? Did you use a tool such as rpmdev-setuptree? I always recommend newcomers start out by using this package, rpmdevtools.

Example

To start I have no bulid area, as user saml.

$ ls -la | grep -E "rpmbuild|\.rpm"
$

Then install the package rpmdevtools.

$ sudo yum install rpmdevtools

After it's been installed, you'll now have another application which you can use to create your rpmbuild directory.

$ rpmdev-setuptree

It won't say anything, it silently just did the following things for you:

$ ls -la | grep -E "rpmbuild|\.rpm"
drwxrwxr-x.   7 saml saml     4096 Dec 16 12:22 rpmbuild
-rw-rw-r--.   1 saml saml      620 Dec 16 12:22 .rpmmacros

Afterwards you'll now have the following directory structure in your rpmbuild developers directory:

$ ls -l ~/rpmbuild
total 20
drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 BUILD
drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 RPMS
drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 SOURCES
drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 SPECS
drwxrwxr-x. 2 saml saml 4096 Dec 16 12:22 SRPMS

Your issue

Your issue looks to be in the %files macro section of the .spec file. Looking at the output of the error messages:

error: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/BDHistProcessor/lib

Notice that the BUILDROOT path repeats 2 times. You don't need to include variable $buildroot in your %files macro section, it's already targeting this directory automatically for you.

Try this instead:

%files
%defattr(-,root,root)
/usr/bin/BDHistProcessor/lib
/usr/bin/BDHistProcessor/bin
/usr/bin/BDHistProcessor/conf
/usr/bin/BDHistProcessor/deploy
/usr/bin/BDHistProcessor/README.txt

Put whatever is the eventual destination for the packages in place of /usr/bin.

share|improve this answer
    
yes, I did install rpmdevtools and the structure were created via rpmdev-setuptree. I also used a command to create spec skeleton –  jaksky Dec 16 '13 at 19:07
    
I am not quite sure how I will specify that I would like the final rpm package install under /usr/local/BDHistProcessor. As now I am more fighting with creating rpm itself. I followed tutorials like this one link but I miss those details. Thanks for helping me out! –  jaksky Dec 16 '13 at 19:12
    
@jaksky - RPMs are useful if you want to deploy the software as part of a system build or it has dependencies, but in general isn't necessary for deploying standalone apps, unless you want to do it this way. –  slm Dec 16 '13 at 19:21
    
I am aware of that fact. I selected this way intentionally as we need to automate it to possibly large number of nodes and secondly we want to manage dependencies between packages. How the rpm system know where to install the package? I understand that buildroot is sort of proxy which should denote the root of the installation. –  jaksky Dec 16 '13 at 19:51
    
@jaksky - sorry didn't mean to imply you didn't know that, was just re-iterating in case you didn't. I've used this method for mass deployments as well, so IMO your rational makes sense. The %files macro will use buildroot during development, but when you deploy that variables is either blank or not part of the mix. Here's a post I wrote a while ago that shows how I packages JBoss for deployment as an RPM. lamolabs.org/blog/6837/… –  slm Dec 16 '13 at 19:55

For building simple RPMs (list of files only) I'm using a simple script. The process to make an RPM is simple:

1) create a directory that matches a name of your package and create a spec file inside as "spec". You need to modify all necessary items in a spec file such as platform, versions, group, license, changelog. You don't need to provide any files in the spec, the list of files will be populated automatically.

2) create a sub-tree with all the required files and make all necessary symbolic links.

Run a script. You can install a script and a demo package to test RPM builds from here: http://asmith.replaytrader.com/asmith/tmp/build_rpm-0.0.1-0.noarch.rpm

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.