Why is topdir set to its default value when rpmbuild called from tcl?

Barth picture Barth · Jan 6, 2009 · Viewed 36.9k times · Source

I have a tcl script which 'exec' rpmbuild. When doing so, the 'topdir' used by rpmbuild is wrong. I have a .rpmmacros file in my home directory and if I call manually rpmbuild, it works fine, ie. the 'topdir' is not the default one.

I added a [exec rpmbuild "--showrc" ] in the tcl script to check the value of topdir and it says '-14: _topdir %{_usrsrc}/redhat' which is the default value.

Can someone explain me why is that situation and how to solve it ?

I would prefer not to have to specify it with --define because it is actually done in a makefile and I don't want to touch it (if no other choice, I will do it).

Answer

Zach Garner picture Zach Garner · Jun 21, 2010

There's two ways to change the default rpmbuild topdir:

  1. Per-User: By configuring the RPM topdir in $HOME/.rpmmacros

    %_topdir    %{getenv:HOME}/rpmbuild
    
  2. Per-Project: By configuring the RPM topdir in the Makefile or on the command line

    rpmbuild --define '_topdir build' -ba package.spec
    

Note: in both cases, you will need to make sure your topdir directory has the appropriate directories (BUILD, SRPM, RPM, SPECS and SOURCES)