Package conary :: Package build :: Module policy
[hide private]
[frames] | no frames]

Source Code for Module conary.build.policy

  1  # 
  2  # Copyright (c) 2004-2008 rPath, Inc. 
  3  # 
  4  # This program is distributed under the terms of the Common Public License, 
  5  # version 1.0. A copy of this license should have been distributed with this 
  6  # source file in a file called LICENSE. If it is not present, the license 
  7  # is always available at http://www.rpath.com/permanent/licenses/CPL-1.0. 
  8  # 
  9  # This program is distributed in the hope that it will be useful, but 
 10  # without any warranty; without even the implied warranty of merchantability 
 11  # or fitness for a particular purpose. See the Common Public License for 
 12  # full details. 
 13  # 
 14  """ 
 15  Base classes and data used for all policy 
 16  """ 
 17   
 18  import imp 
 19  import itertools 
 20  import os 
 21  import sys 
 22  import types 
 23   
 24  from conary.lib import util, log, graph 
 25  from conary.build import action, errors, filter, trovefilter 
 26   
 27   
 28  # buckets (enum -- but may possibly work someday as bitmask for policy 
 29  # that could run more than once in different contexts) 
 30  TESTSUITE            = 1 << 0 
 31  DESTDIR_PREPARATION  = 1 << 1 
 32  DESTDIR_MODIFICATION = 1 << 2 
 33  PACKAGE_CREATION     = 1 << 3 
 34  PACKAGE_MODIFICATION = 1 << 4 
 35  ENFORCEMENT          = 1 << 5 
 36  ERROR_REPORTING      = 1 << 6 
 37  GROUP_ENFORCEMENT    = 1 << 7 
 38   
 39  # requirements (sparse bitmask, 5 sensible states) 
 40  REQUIRED               = 1 << 0 
 41  ORDERED                = 1 << 1 
 42  PRIOR                  = 1 << 2 
 43  REQUIRED_PRIOR         = REQUIRED|ORDERED|PRIOR 
 44  REQUIRED_SUBSEQUENT    = REQUIRED|ORDERED 
 45  CONDITIONAL_PRIOR      = ORDERED|PRIOR 
 46  CONDITIONAL_SUBSEQUENT = ORDERED 
 47   
 48  # file trees 
 49  NO_FILES = 0 << 0 
 50  DESTDIR  = 1 << 0 
 51  BUILDDIR = 1 << 1 
 52  DIR      = DESTDIR|BUILDDIR 
 53  PACKAGE  = 1 << 2 
 54   
 55   
56 -class BasePolicy(action.RecipeAction):
57 """ 58 Abstract Superclass for all policy actions. Common bits between Policy 59 and GroupPolicy should be defined at this level 60 """ 61 invariantsubtrees = [] 62 invariantexceptions = [] 63 invariantinclusions = [] 64 allowUnusedFilters = False 65
66 - def __init__(self, *args, **kwargs):
67 self.unusedFilters = {'inclusions' : set(), 'exceptions' : set()} 68 action.RecipeAction.__init__(self, *args, **kwargs)
69
70 - def postInit(self):
71 """ 72 Hook for initialization that cannot happen until after all 73 policies have been loaded into the recipe and thus cannot 74 happen in __init__; mainly for policies that need to pass 75 information to other policies at initialization time. 76 """ 77 pass
78
79 - def updateArgs(self, *args, **keywords):
80 """ 81 The default way to update a class is to override any provided 82 keywords. Subclasses which have the ability to provide more 83 intelligent handling can override this method. This method 84 is invoked automatically by recipe.py when a recipe references 85 a policy object. It acts rather like __init__ except that it 86 can meaningfully be called more than once for an object. 87 88 Some keyword arguments (at least C{exceptions} and C{subtrees}) 89 should be appended rather than replaced. 90 """ 91 allowUnusedFilters =