LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   rpmbuild picking up default buildroot even after explicitily defining in spec file ? (https://www.linuxquestions.org/questions/linux-software-2/rpmbuild-picking-up-default-buildroot-even-after-explicitily-defining-in-spec-file-945144/)

Rohit_4739 05-15-2012 03:03 PM

rpmbuild picking up default buildroot even after explicitily defining in spec file ?
 
Hello Guys,

I am caught up in a bit strange situation, i am trying to build a rpm package, everything is working fine and smoothly. However my BUILDROOT directory is not what i am specifying in my .spec file.

The rmpbuild program is picking the BUILDROOT as /home/rohit/rpm/BUILDROOT, whereas in my spec file i specified it to be as /home/rohit/rpm/tmp. First i created my own .rpmmacros file under my home directory and override the macros _tmppath and _topdir but i didn't worked then i defined it in my spec file even then also it is not working. If i display the value of _tmppath it displays the expected correct direcory but the buildroot directory is not being chnaged.

Infact i did not created the BUILDROOT directory in first place, it was created automatically.

I understand that this is probably being read from default /usr/lib/macros file but how can i change it.

So could you guys please explain me why it is happening and how can i change this default behavior.

Here is my spec file

Code:

%define _tmppath /home/rohit/rpm/tmp

Name:  pack
Version: 1
Release:        1
Summary:Simple hello rpm

Group:  test
License:GPL
Source0:        pack-1.tar.gz
BuildRoot:      %{_tmppath}%{name}-buildroot
Buildarch: noarch


%description
This is a simple rpm package that packages three files.

%prep
%setup -q

%build
echo "$RPM_BUILD_ROOT"


%install
install -m 0755 -d $RPM_BUILD_ROOT/opt/pack-1
install -m 0644 test1 $RPM_BUILD_ROOT/opt/pack-1/test1
install -m 0644 test2 $RPM_BUILD_ROOT/opt/pack-1/test2
install -m 0644 reply $RPM_BUILD_ROOT/opt/pack-1/reply
%clean
rm -rf $RPM_BUILD_ROOT


%files
%dir /opt/pack-1
/opt/pack-1/test1
/opt/pack-1/test2
/opt/pack-1/reply
#%defattr(-,root,root,-)
#%doc



%changelog


DaveG 05-16-2012 08:03 AM

The BuildRoot tag has be deprecated by Fedora, who run RPM.

See http://fedoraproject.org/wiki/Packag...#BuildRoot_tag.

Quote:

Fedora (as of F-10) does not require the presence of the BuildRoot tag in the spec and if one is defined it will be ignored. The provided buildroot will automatically be cleaned before commands in %install are called.
--DaveG.

Rohit_4739 05-16-2012 09:15 AM

Quote:

Originally Posted by DaveG (Post 4679877)
The BuildRoot tag has be deprecated by Fedora, who run RPM.

See http://fedoraproject.org/wiki/Packag...#BuildRoot_tag.



--DaveG.

Thanks Dave for the information, so is there no way to change that behavior ?

DaveG 05-16-2012 11:54 AM

I believe that you can use ~/.rpmmacros to set the '_topdir' macro which BuildRoot uses:
===%<---
# ~/.rpmmacros
# Define the build root.
%_topdir %(echo $HOME)/rpmbuild
--->%===
The file /usr/lib/rpm/macros includes the lines:
%_buildrootdir %{_topdir}/BUILDROOT
and
%buildroot %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}
... so changing _topdir should change the BuildRoot parent directory, if that helps.
As a last resort, take a backup and edit /usr/lib/rpm/macros directly to your liking.

Have fun!,

--DaveG.

Rohit_4739 05-16-2012 01:01 PM

Quote:

Originally Posted by DaveG (Post 4680090)
I believe that you can use ~/.rpmmacros to set the '_topdir' macro which BuildRoot uses:
===%<---
# ~/.rpmmacros
# Define the build root.
%_topdir %(echo $HOME)/rpmbuild
--->%===
The file /usr/lib/rpm/macros includes the lines:
%_buildrootdir %{_topdir}/BUILDROOT
and
%buildroot %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}
... so changing _topdir should change the BuildRoot parent directory, if that helps.
As a last resort, take a backup and edit /usr/lib/rpm/macros directly to your liking.

Have fun!,

--DaveG.

Thanks Dave for sharing the information, well i tried defining the buildrootdir and builddir in my .rpmmacros file and it worked then.


All times are GMT -5. The time now is 12:11 PM.