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

Source Code for Module conary.build.redirectrecipe

  1  # Copyright (c) 2005-2008 rPath, Inc. 
  2  # 
  3  # This program is distributed under the terms of the Common Public License, 
  4  # version 1.0. A copy of this license should have been distributed with this 
  5  # source file in a file called LICENSE. If it is not present, the license 
  6  # is always available at http://www.rpath.com/permanent/licenses/CPL-1.0. 
  7  # 
  8  # This program is distributed in the hope that it will be useful, but 
  9  # without any warranty; without even the implied warranty of merchantability 
 10  # or fitness for a particular purpose. See the Common Public License for 
 11  # full details. 
 12  # 
 13   
 14  from conary import trove, versions 
 15  from conary.deps import deps 
 16  from conary.build import errors as builderrors 
 17  from conary.build import macros 
 18  from conary.build import use 
 19  from conary.build.recipe import Recipe, RECIPE_TYPE_REDIRECT 
 20  from conary.lib import log 
 21   
22 -class _Redirect(object):
23 24 __slots__ = [ 'components', 'isRemove' ] 25
26 - def __init__(self):
27 self.components = []
28
29 - def addComponents(self, nameList):
30 self.components += nameList
31
32 -class _RemoveRedirect(_Redirect):
33 34 isRemove = True
35
36 -class _RedirectInfo(_Redirect):
37 38 __slots__ = [ 'targetName', 'targetBranch', 'targetFlavor', 'components' ] 39 isRemove = False 40
41 - def __init__(self, targetName, targetBranch, targetFlavor):
42 assert(targetName is not None) 43 _Redirect.__init__(self) 44 self.targetName = targetName 45 self.targetBranch = targetBranch 46 self.targetFlavor = targetFlavor
47
48 -class _Redirections(dict):
49
50 - def add(self, sourceName, sourceFlavor, redir):
51 l = self.setdefault((sourceName, sourceFlavor), []) 52 l.append(redir)
53
54 -class _RedirectRule(object):
55 __slots__ = [ 'destName', 'branchStr', 'sourceFlavor', 'targetFlavor', 56 'skipTargetMatching', 'sourceName', 'allowMultipleTargets' ] 57
58 - def findAvailableTargetFlavors(self, repos):
59 if self.branchStr is None: 60 # redirect to nothing 61 return set() 62 63 if self.branchStr[0] == '/': 64 branch = versions.VersionFromString(self.branchStr) 65 if not isinstance(branch, versions.Branch): 66 raise builderrors.RecipeFileError, \ 67 "Redirects must specify branches or labels, " \ 68 "not versions" 69 70 log.info('redirecting to branches is deprecated; redirects must ' 71 'be to labels') 72 73 matches = repos.