title: How to control the rpmbuild buildroot and install directory
body: <p>I am confused about some directories in rpmbuild.</p>
  
  <p>1: buildroot: which should be used to store the files that are supposed to be installed when the binary package is installed by an end-user.  </p>
  
  <p>Questions:  how to control this directory? What does BuildRoot mean?</p>
  
  <pre><code> $ cat 3.spec
   ..
   BuildRoot: /opt/abc
   ..
   %prep
   echo %{buildroot}
   echo  $RPM_BUILD_ROOT   
  </code></pre>
  
  <p>whatever I set the BuildRoot to,  I get the result which was defined in <code>/usr/lib/rpm/macros</code>. If I define <code>%buildroot</code> in <code>~/.rpmmacros</code>, I will get the result from it. </p>
  
  <p>2: How do I control the destination when we install the rpm package? For example: <code>rpm -ivh xxx.rpm</code>, where the files will be installed?</p>