Error while trying to create RPM for java app
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
.
Related videos on Youtube
jaksky
Updated on September 18, 2022Comments
-
jaksky almost 2 years
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?
-
jaksky over 10 yearsI 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!
-
slm over 10 years@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.
-
jaksky over 10 yearsI 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.
-
slm over 10 years@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/… -
jaksky over 10 yearsthanks for your replies. I wasn't probably clear so sorry for that. Let me clarify that: I still don't fully understand how the buildroot is propagated (set) during the rpm installation. Because if the build root is taken from the spec than I have to do all the packaging under /usr/local - that seems to me as a nonsense, or I have to supply it latter somehow. Hopefully question make sense. For some reason I cannot access link you posted.
-
jaksky over 10 yearsI tried to alter the %files part as you suggest targeting to /usr/local/BDhistProcessor ...
%files %defattr(-,root,root) /usr/local/BDHistProcessor/lib /usr/local/BDHistProcessor/bin /usr/local/BDHistProcessor/conf /usr/local/BDHistProcessor/deploy /usr/local/BDHistProcessor/README.txt
And know getting errors like: File not found: /home/virtual/rpmbuild/BUILDROOT/BDHistProcessor-1.0.0-1.el6.x86_64/usr/local/BDHistProcessor/lib That's why I was asking why the BuildRoot is set for the rpm installation as that is not clear to me. Do I need to mimic real strucute starting from root?