title: RPM Build - Permission Denied
body: <p>I have a Python-based SVN pre-commit script that generates an <code>rpmbuild</code> <code>.spec</code> file and runs <code>rpmbuild -bb my.spec</code> via <code>subprocess</code>.  The current state is:</p>
  
  <p>1) When doing an SVN commit (SVN over SSH) remotely the <code>rpmbuild</code> fails with...</p>
  
  <pre><code>error: failed to create directory %{_topdir}: /rpmbuild: Permission denied
  </code></pre>
  
  <p>2) When I <code>rpmbuild -bb my.spec</code> (local on the SVN server) it completes successfully</p>
  
  <p>I have <code>~/.rpmmacros</code>...</p>
  
  <pre><code>%_topdir /tmp/rpmbuild
  </code></pre>
  
  <p>When doing #2 (above) <code>rpmbuild</code> will create <code>BUILD</code>, <code>BUILDROOT</code>, <code>RPMS</code>, <code>SOURCES</code>, <code>SPECS</code>, and <code>SRPMS</code> under <code>/tmp/rpmbuild</code> and an RPM is created in <code>RPMS</code>.</p>
  
  <p>From the command line, if I <code>rpm --showrc</code> the dirs are as I expect (and should be which is why the process completes successfully).</p>
  
  <p>But I have different results from the process running via pre-commit...</p>
  
  <p>Command line...
  <code>-14: _topdir   /tmp/rpmbuild</code></p>
  
  <p>Pre-commit...
  <code>-14: _topdir   %{getenv:HOME}/rpmbuild</code></p>
  
  <p>I suspect this is the problem and I do not know how to correct this.  I also tried:</p>
  
  <p>1) To set the path in <code>my.spec</code>... <code>%define _topdir /tmp/rpmbuild</code> which gave the same permission denied error.</p>
  
  <p>2) To set the path in the rpmbuild command... <code>rpmbuild --define='_topdir /tmp/rpmbuild'</code> which resulted in <code>error: Macro % has illegal name (%define)</code>.</p>
  
  <p>Your expertise in resolving this appreciated; thanks very much!</p>