LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 04-15-2011, 04:32 AM   #1
password636
Member
 
Registered: Jun 2006
Location: Beijing
Posts: 60

Rep: Reputation: 1
why rpmbuild deletes the BUILD directory?


Hi,

I'm using rpmbuild 4.8.0 to build my rpm package on RHEL6. The spec file works just fine with any other Linux Releases, including RHEL5. But at the end, build failed with:
"shell-init error retrieving current directory: getcwd: cannot access parent directories: No such file or directory"
I found that rpmbuild tried to compare the BUILD directory with the root filesystem, it will delete the BUILD directory if it's not '/'. My working directory is /tmp/test, so something like this in the /var/tmp/rpm-tmp file:
Code:
cd "/tmp/test/BUILD"
[ "RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"
I think this is the reason why the command failed.
And I can't find the two lines of similar code in an earlier version of rpmbuild on RHEL5.
Why rpmbuild does this?

THANKS!
 
Old 04-15-2011, 04:51 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If you use define _tmppath in your .spec file you can use "BuildRoot: %{_tmppath}/%{name}-%{version}" and subsequently "[ "${RPM_BUILD_ROOT}" = "%{_tmppath}/%{name}-%{version}" ]"?
 
Old 04-15-2011, 06:13 AM   #3
password636
Member
 
Registered: Jun 2006
Location: Beijing
Posts: 60

Original Poster
Rep: Reputation: 1
Is this issue kind of a bug?
 
Old 04-15-2011, 08:58 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
No. I your rpmbuild failed run it again as 'rpmbuild /path/to/packagename.spec 2>&1 | tee /tmp/rpmbuild.$$' and look at that log. If you can't find the error(s) post the contents of that temp file, preferably in BB code tags.
 
Old 04-17-2011, 10:40 PM   #5
password636
Member
 
Registered: Jun 2006
Location: Beijing
Posts: 60

Original Poster
Rep: Reputation: 1
I'm sorry. I gave some wrong information in my first post. Below is what I meant.
My working directory: /tmp/test
And in the .spec file:
%global _name testrpm
%global _pwd %(pwd)
BuildRoot: %{_pwd}/%{name}

Below is what happened when using the command line: rpmbuild -bb --buildroot=$PWD/testrpm --target=noarch testrpm.spec
Code:
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.v6EVh2
+ umask 022
+ cd /tmp/test/testrpm/BUILD
+ '[' /tmp/test/testrpm '!=' / ']'
+ rm -rf /tmp/test/testrpm
++ dirname /tmp/test/testrpm
+ mkdir -p /tmp/test
+ mkdir /tmp/test/testrpm
+ LANG=C
+ export LANG
+ unset DISPLAY
+ /usr/lib/rpm/check-buildroot
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
+ /usr/lib/rpm/brp-compress
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
 
Old 04-19-2011, 05:07 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
CYP just post the complete spec file and any /var/tmp/rpm-tmp.* at the time the error occurs?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rpmbuild -bb adds mysterious commands to my empty %build section catInHat Linux - Software 2 01-04-2009 03:26 AM
rpmbuild --with : mysql - unknown option. How to pass extra options to build? fireman949 Red Hat 0 07-06-2005 06:53 PM
rpmbuild - build section question jcalcote SUSE / openSUSE 3 03-12-2005 06:10 AM
rpmbuild doesn't produce the source code in /usr/src/redhat/BUILD Niceman2005 Linux - Software 2 11-29-2004 05:58 PM
Experiment with Alsaplayer Fails Build: Tarball and rpmbuild farmerdan Linux - Software 0 05-10-2004 08:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 03:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration