One of the most confusing areas in RPM is certainly the %setup macro and
how its options interact with each other. I found myself cut & pasting
existing examples or doing trail & error for every new package. I've now
read the (incomplete) documentation and (more complete ;-) source code
in-depth and tried to summarize this beast for us.

                                      - - - 

Synopsis
--------

%setup[<x>]
-q        # quiet unpacking operation
-n <dir>  # set name of directory
-c        # create directory (and change to it) before unpacking
-D        # do not delete directory before unpacking sources
-T        # do not perform default archive unpacking of %{SOURCE<x>}
-b <n>    # also unpack %{SOURCE<n>} before changing to directory
            (usually combined with -T, -D)
-a <n>    # also unpack %{SOURCE<n>} after  changing to directory
            (usually combined with -T, -D, -c)

%patch[<x>]
-P <n>    # apply %{PATCH<n>} instead of %{PATCH<x>}
-p <#>    # strip <#> leading slashes and directories from patch filenames
-b <ext>  # set the backup file extension to <ext> instead of ".orig"
-E        # remove empty output files
-R        # apply patch as it would be reversed

Visualization
-------------

Input:
  %setup[<x>]                      # default for <x> is 0

Output:
  rm -rf <name>-<version>          # changed by -n <dir>, omitted by -D
  mkdir <name>-<version>           # changed by -n <dir>, added by -c (else omitted)
  cd <name>-<version>              # changed by -n <dir>, added by -c (else omitted)
  gunzip <%{SOURCE<x>} | tar xvf - # omitted by -T,   "xvf" replaced with "xf" by -q
  gunzip <%{SOURCE<n>} | tar xvf - # added by -b <n>, "xvf" replaced with "xf" by -q
  cd <name>-<version>              # changed by -n <dir>
  gunzip <%{SOURCE<n>} | tar xvf - # added by -a <n>, "xvf" replaced with "xf" by -q

                                      - - - 

Keep especially the above "Output" sequence in mind when fiddling around
with the %setup options. Then %setup is no more mystery and can be used
straight-forward...

                                       Ralf S. Engelschall
                                       [EMAIL PROTECTED]
                                       www.engelschall.com

______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
Developer Communication List                   [EMAIL PROTECTED]

Reply via email to