Package conary :: Package build :: Module source :: Class addPatch
[hide private]
[frames] | no frames]

Class addPatch

source code

  action.Action --+            
                  |            
action.RecipeAction --+        
                      |        
             _AnySource --+    
                          |    
                    _Source --+
                              |
                             addPatch


NAME
====

B{C{r.addPatch()}} - Add a patch to source code

SYNOPSIS
========

C{r.addPatch(I{patchfilename}, [I{backup}=,] [I{dir}=,] [I{extraArgs}=,] [I{keyid}=,] [I{httpHeaders}=,] [I{package})=,] [I{level}=,] [I{macros}=,] [I{rpm}=,] [I{use}=,] [I{sourceDir}=,] [I{patchName}=])}

DESCRIPTION
===========

The C{r.addPatch()} class adds a patch to be applied to the source code
during the build phase.

KEYWORDS
========

The following keywords are recognized by C{r.addPatch}:

B{backup} : The suffix to use when storing file versions before applying
the patch.

B{dir} : Instructs C{r.addPatch} to change to the directory specified by
C{dir} prior to applying the patch. An absolute C{dir} value will be
considered relative to C{%(destdir)s}, whereas a relative C{dir} value
will be considered relative to C{%(builddir)s}.


B{extraArgs} : As a last resort, arbitrary arguments may be passed to the
patch program  with the C{extraArgs} keyword. This should not normally be
required, and is indicative of a possible bug which should be reported
with the suggestion of direct support for the patch arguments in question.

B{keyid} : Using the C{keyid} keyword indicates the eight-digit GNU
Privacy Guard (GPG) key ID, without leading C{0x} for the source code
archive signature should be sought, and checked. If you provide the
C{keyid} keyword, {r.addPatch} will search for a file named
I{patchfilename}C{.{sig,sign,asc}}, and ensure it is signed with the
appropriate GPG key. A missing signature results in a warning; a failed
signature check is fatal.

B{level} : By default, conary attempts to patch the source using
levels 1, 0, 2, and 3, in that order. The C{level} keyword can
be given an integer value to resolve ambiguity, or if an even
higher level is required.  (This is the C{-p} option to the
patch program.)

B{macros} : The C{macros} keyword accepts a boolean value, and defaults
to false. However, if the value of C{macros} is true, recipe macros in the
body  of the patch will be interpolated before applying the patch. For
example, a patch which modifies the value C{CFLAGS = -02} using
C{CFLAGS = %(cflags)s} will update the C{CFLAGS} parameter based upon the
current setting of C{recipe.macros.cflags}.

B{rpm} : If the C{rpm} keyword is used, C{Archive}
looks in the file, or URL specified by C{rpm} for an RPM
containing I{patchfilename}.

B{use} : A Use flag, or boolean, or a tuple of Use flags, and/or
boolean values which determine whether the source code archive is
actually unpacked or merely stored in the archive.

B{httpHeaders} : A dictionary containing a list of headers to send with
the http request to download the source archive.  For example, you could
set Authorization credentials, fudge a Cookie, or, if direct links are
not allowed for some reason (e.g. a click through EULA), a Referer can
be provided.

B{package} : (None) If set, must be a string that specifies the package
(C{package='packagename'}), component (C{package=':componentname'}), or
package and component (C{package='packagename:componentname'}) in which
to place the files added while executing this command.
Previously-specified C{PackageSpec} or C{ComponentSpec} lines will
override the package specification, since all package and component
specifications are considered in strict order as provided by the recipe

B{sourceDir} : Instructs C{r.addPatch} to look in the directory
specified by C{sourceDir} for the patch to apply.
An absolute C{sourceDir} value will be considered relative to
C{%(destdir)s}, whereas a relative C{sourceDir} value will be
considered relative to C{%(builddir)s}.

B{patchName} : Name of patch program to run (Default: C{patch))

EXAMPLES
========

The following examples demonstrate invocations of C{r.addPatch}
from within a recipe:

C{r.addPatch('iptables-1.3.0-no_root.patch')}

Simple usage of C{r.addPatch} specifying the application of the patch
C{iptables-1.3.0-no_root.patch}.

C{r.addPatch('Xaw3d-1.5E-xorg-imake.patch', level=0, dir='lib/Xaw3d')}

Uses the C{level} keyword specifying that no initial subdirectory names be
stripped, and a C{dir} keyword, instructing C{r.addPatch} to change to the
C{lib/Xaw3d} directory prior to applying the patch.



Instance Methods [hide private]
 
__init__(self, recipe, *args, **keywords) source code
 
_applyPatch(self, patchlevel, patch, destDir, dryRun=True) source code
 
_patchAtLevels(self, patchPath, patch, destDir, patchlevels) source code
 
doDownload(self) source code
 
do(self) source code
 
doFile(self, patchPath) source code

Inherited from _Source: doAction, doPrep, fetch, fetchLocal, getPath

Inherited from action.RecipeAction: doSuggestAutoBuildReqs, init_error

Inherited from action.Action: addArgs

Inherited from action.Action (private): _applyDefaults

Class Variables [hide private]
  keywords = {'backup': '', 'extraArgs': '', 'level': None, 'mac...
The keywords and default values accepted by the class
Method Details [hide private]

__init__(self, recipe, *args, **keywords)
(Constructor)

source code 
Parameters:
  • recipe - The recipe object currently being built is provided automatically by the PackageRecipe object. Passing in recipe from within a recipe is unnecessary.
  • backup - The suffix to use when storing file versions before applying the patch.
  • extraArgs - As a last resort, arbitrary arguments may be passed to the patch program with the extraArgs keyword. This should not normally be required, and is indicative of a possible bug which should be reported with the suggestion of direct support for the patch arguments in question.
  • dir - Instructs r.addPatch to change to the directory specified by dir prior to applying the patch. An absolute dir value will be considered relative to %(destdir)s, whereas a relative dir value will be considered relative to %(builddir)s.
  • keyid - Using the keyid keyword indicates the eight-digit GNU Privacy Guard (GPG) key ID, without leading 0x for the source code archive signature should be sought, and checked. If you provide the keyid keyword, {r.addPatch} will search for a file named patchname.{sig,sign,asc}, and ensure it is signed with the appropriate GPG key. A missing signature results in a warning; a failed signature check is fatal.
  • level - By default, conary attempts to patch the source using levels 1, 0, 2, and 3, in that order. The level keyword can be given an integer value to resolve ambiguity, or if an even higher level is required. (This is the -p option to the patch program.)
  • macros - The macros keyword accepts a boolean value, and defaults to false. However, if the value of macros is true, recipe macros in the body of the patch will be interpolated before applying the patch. For example, a patch which modifies the value CFLAGS = -02 using CFLAGS = %(cflags)s will update the CFLAGS parameter based upon the current setting of recipe.macros.cflags.
  • rpm - If the rpm keyword is used, addArchive looks in the file, or URL specified by rpm for an RPM containing patchname.
  • use - A Use flag, or boolean, or a tuple of Use flags, and/or boolean values which determine whether the source code archive is actually unpacked, or merely stored in the archive.
  • httpHeaders - A dictionary containing headers to add to an http request when downloading the source code archive.
  • package - A string that specifies the package, component, or package and component in which to place the files added while executing this command
Overrides: _Source.__init__

do(self)

source code 
Overrides: _Source.do

Class Variable Details [hide private]

keywords

The keywords and default values accepted by the class
Value:
{'backup': '',
 'extraArgs': '',
 'level': None,
 'macros': False,
 'patchName': 'patch'}