title: Check if installation folder of rpm exists on target machine then create another folder
body: <p>I have a rpm spec file which produces a rpm named cdplayer-1.10.x86_64.rpm. The rpm on target machines (rpm -ivh cdplayer-1.10.x86_64.rpm --nodeps)creates a directory "/opt/cd-player/" and put all files in it. What I need is when user runs rpm command on target m/c then it should check if directory exists and if yes then create different directory "/opt/cd-player_2/" and install files there otherwise install as "/opt/cd-player/". If we run one more then it should create "/opt/cd-player_3/".</p>
  
  <p>Spec file:</p>
  
  <pre><code>  BuildArch: x86_64
    Prefix: /opt
    code_root=/home/user/
  
    %install
    rm -rf $RPM_BUILD_ROOT
    vds_root=$RPM_BUILD_ROOT/opt/cd-player
    cp $code_root/abc        $vds_root/abc
  
    %files
  
    %defattr(-,root,root)
    /opt/cd-player
    %pre
    count=`rpm -qa | grep cd-player | wc -l`
    name=`rpm -qa | grep cd-player`
    if [ $count -gt 0 ]; then
    echo
    echo "Error:  $name is already installed!!!"
    echo
    exit 1
    fi
  </code></pre>
  
  <p>How can i create a directory before installing and extract rpm there ?</p>