#!/usr/bin/env python import os import sys import os.path from GuessProgramCase import * from GetAvailable import * from GuessLatest import * from FindPackage import * from PythonUtils import * from UseFlags import * import Alien import re global_wget_timeout = getGoboVariable('timeout', 'Scripts/GetAvailable.conf') global_dependencies_cache_dir = os.path.expanduser(getGoboVariable('goboTemp')+'/Scripts-'+os.getenv('USER')+'/dependencies_cache/') global_dependencies_blacklist = [ i.lower() for i in getGoboVariable('','Scripts/Dependencies.blacklist') ] global_compatibility_list = {} for line in getGoboVariable('','Scripts/CompatibilityList'): try: dependency_x = line.split(':')[0].strip() is_satisfiable_by = line.split(':')[1].split() global_compatibility_list[dependency_x.lower()] = is_satisfiable_by except: pass if not os.access(global_dependencies_cache_dir, os.R_OK): os.makedirs(global_dependencies_cache_dir) for i in ['recipe', 'official_package', 'contrib_package', 'local_package']: if not os.access(global_dependencies_cache_dir+i, os.F_OK): os.makedirs(global_dependencies_cache_dir+i) ############################################################################# # Functions used to identify which rules apply to a given program version # type (a specific url can be passed, to avoid calling 'FindPackage') ############################################################################# def add_compatible_dependencies(rule): program_name = rule['program'].lower() if program_name in global_compatibility_list.keys(): for option in global_compatibility_list[program_name]: # compatible_rule could also be set to something more related to # rule itself (using the same version range, for example). compatible_rule = {'program' : option, 'versions' : [], 'optional' : True } rule['option'] = compatible_rule rule = compatible_rule # linked list of compatible_rules def get_rules_of_files(depfiles, t=None, no_compatlist=False, cross_compile=False): toReturn = [] if depfiles and 'Recipes' in depfiles[0]: index = depfiles[0].rfind('/Resources/') basedir = depfiles[0][0:index] flags = UseFlags(basedir) else: flags = frozenset() for depfile in depfiles: if depfile and os.access(depfile, os.R_OK): f = open(depfile) for line in f.readlines(): options=line.split("|") prev_rule = None first_rule = None for o in options: try: rule = interpret_dependency_line(o,t, cross_compile=cross_compile, flags=flags) except ParseError, e: Log_Terse("At file '%s': "%depfile + e.args[0], 'CheckDependencies') if rule: # Precedence is left-right. Save this to return later. if not first_rule: first_rule = rule # Build a chain of ['option'] values hanging off # each rule. if prev_rule: prev_rule['option'] = rule prev_rule = rule if first_rule: if not no_compatlist: add_compatible_dependencies(first_rule) toReturn.append(first_rule) f.close() return toReturn # Notice that type may be required since dependencies(recipe(p)) != dependencies(package(p)) def get_rules_for(p, v, r, t, u, noWeb=False, no_compatlist=False, no_builddeps=False, cross_compile=False, availables=None): if availables is None: availables = GetAvailable(types=['installed','local_package','official_package', 'recipe', 'contrib_package', 'tracked'], accessWeb=not noWeb) depfiles = find_dependencies_files(p, v, r, t, u, noWeb=False, no_builddeps=no_builddeps, availables=availables) toReturn = get_rules_of_files(depfiles, t=t, no_compatlist=no_compatlist, cross_compile=cross_compile) return toReturn global_not_found_cache=[] def find_dependencies_files(p, v, r, t, u=None, noWeb=False, no_builddeps=False, goboPrograms=None, availables=None): if availables is None: availables = GetAvailable(types=['installed','local_package','official_package', 'recipe', 'contrib_package', 'tracked'], accessWeb=not noWeb) if t == 'installed': p = GuessProgramCase(p, v) if goboPrograms: localdep = goboPrograms + '/' + p + '/' + v + "/Resources/Dependencies" else: localdep = Get_Dir('runtime', p, v)+"/Resources/Dependencies" if os.access(localdep, os.R_OK): return [ localdep ] if availables is None: availables = GetAvailable(types=['installed','local_package','official_package', 'recipe', 'contrib_package', 'tracked'], accessWeb=not noWeb) elif t == 'local_package': if not u or not os.access(u, os.R_OK): ret = FindPackage(p, v, r, types=[t], availables=availables, accessWeb=not noWeb) if ret: p,v,r,t,u = ret[0] if u: if os.path.isdir(u): if os.access(u+'/Resources/Dependencies', os.R_OK): return [ u+'/Resources/Dependencies' ] else: cachedep = global_dependencies_cache_dir+'/'+t+'/'+ u.split('/')[-1] if os.access(cachedep, os.R_OK): return [ cachedep ] err = bash("tar xvfj %s -O %s/%s/Resources/Dependencies 2> /dev/null > %s"%(u,p,v,cachedep), mode='v') if err == 0: return [ cachedep ] else: os.remove(cachedep) elif t == 'recipe': if u and not u.startswith('http'): if no_builddeps: return [ u+'/Resources/Dependencies' ] else: return [ u+'/Resources/Dependencies', u+'/Resources/BuildDependencies' ] # searches local recipes first compileRecipeDirs, getRecipeStores = getCompileOptions() for compileRecipeDir in compileRecipeDirs: recipedir=compileRecipeDir+'/'+p+'/'+Join_Version_Revision(v,r)+'/' if os.access(recipedir+'Recipe', os.R_OK): if no_builddeps: return [ recipedir+'/Resources/Dependencies' ] else: return [ recipedir+'/Resources/Dependencies', recipedir+'/Resources/BuildDependencies' ] if t in [ 'official_package', 'contrib_package', 'recipe' ]: if not u: ret = FindPackage(p, v, r, types=[t], availables=availables, accessWeb = not noWeb) if ret: u = ret[0][4] if u and t in [ 'official_package', 'contrib_package' ]: cachedep = global_dependencies_cache_dir+'/'+t+'/'+ u.split('/')[-1] if os.access(cachedep, os.R_OK): return [ cachedep ] if not noWeb: temp = u.split('/') dependency_u = string.join(temp[:-1]+['dependencies']+[temp[-1][:-len('.tar.bz2')]],'/') if not dependency_u in global_not_found_cache: err = bash("wget --timeout="+global_wget_timeout+" -q -O "+cachedep+" "+dependency_u+"", mode='v') if err == 0: return [ cachedep ] else: global_not_found_cache.append(dependency_u) os.remove(cachedep) if t == 'recipe' and not noWeb: # gets remote recipe, if no cache was found if u: f = os.popen('GetRecipe %s 2> /dev/null'%(u)) else: f = os.popen('GetRecipe %s %s 2> /dev/null'%(p,Join_Version_Revision(v,r))) s = f.read().strip() ret = f.close() if s: return [ s+'/Resources/Dependencies', s+'/Resources/BuildDependencies' ] #sys.stderr.write('Dependencies for %s %s %s %s %s not found\n'%(p,v,r,t,u)) return [] def interpret_dependency_line(whole_line, t=None, cross_compile=False, flags=None): line = whole_line.split('#')[0].strip() if not line: return if line.startswith('['): return global global_dependencies_blacklist l = line.split() programname = l[0] rest = " ".join(l[1:]) activeflags = frozenset() if rest and rest[-1] == ']': l = rest.split('[') rest = l[0] useflags = l[1][:-1] useflagssplit = useflags.split(',') if (('cross' in useflagssplit and not cross_compile) or ('!cross' in useflagssplit and cross_compile)): return # If none of the listed flags are enabled, skip this dependency activeflags = frozenset(useflagssplit).intersection(flags) if not activeflags: return string_versions = rest.split(',') versions = [] for string_version in string_versions: if not string_version: continue list_version = string_version.split() if len(list_version) == 1: if t != 'recipe': versions.append(('>=', list_version[0])) elif len(list_version) == 2: if not list_version[0] in ['>', '<', '<=', '>=', '=', '!=']: raise ParseError("Unsupported operand '%s' at line '%s'"%(list_version[0], whole_line.strip())) versions.append((list_version[0], list_version[1])) else: raise ParseError("Error at line '%s'"%(whole_line.strip())) ret = { 'program' : programname, 'versions' : versions, 'optional' : True, 'activeflags': activeflags } return ret ############################################################################# # Function that interpret the semantic of the rule, # and compares it to a given version ############################################################################# def does_version_match_rule(version, rule): for (operand, dependency_version) in rule['versions']: if operand == '!=' and dependency_version != version: continue if operand in [ '>=', '<=', '=' ] and dependency_version == version: continue if operand in [ '>', '>='] and (GuessLatest([version, dependency_version]) != dependency_version): continue if operand in [ '<', '<='] and (GuessLatest([version, dependency_version]) != version): continue return False return True ############################################################################# # Function that try to match the given rule against the installed programs # and available packages/recipes ############################################################################# # This cache variable is reset at each CheckDependencies call global_matches_cache = {} def version_range_string(rule): return ", ".join([ x[0] + ' ' + x[1] for x in rule['versions'] ]) def rule_to_string(rule): return rule['program'] + ' ' + version_range_string(rule) def find_matching_package(rule, acceptable_types, noWeb=False, goboPrograms=None, localdirs=None, availables=None): global global_matches_cache string_rule = rule_to_string(rule) + str(acceptable_types) if global_matches_cache.has_key(string_rule): return global_matches_cache[string_rule] if not availables: availables = GetAvailable(types=['installed','local_package','official_package', 'recipe', 'contrib_package', 'tracked'], accessWeb=not noWeb, localdirs=localdirs, goboPrograms=goboPrograms) available_options = FindPackage(rule['program'], types=acceptable_types, availables=availables, accessWeb=not noWeb, fulllist=True, goboPrograms=goboPrograms, localdirs=localdirs) if available_options: for p,v,r,t,u in available_options: if does_version_match_rule(v, rule): global_matches_cache[string_rule] = (p, v, r, t, u) return (p, v, r, t, u) to_return = ((rule['program'], version_range_string(rule).replace(' ',''), '', None, "NO_VERSION")) else: to_return = ((rule['program'], None, '', None, "NO_PROGRAM")) # if we got here, no matching program/version was found. if rule.has_key('option'): ret = find_matching_package(rule['option'], acceptable_types, noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables) if ret and ret[3]: # ret[3] corresponds to 'type' global_matches_cache[string_rule] = ret return ret global_matches_cache[string_rule] = to_return return to_return ############################################################################# # User interaction Functions ############################################################################# global_always_do=None def ask_if_install(match, goboPrograms=None): p,v,r,t,u=match global global_always_do installed = FindPackage(p, types=['installed'], goboPrograms=goboPrograms) if installed: reason = p + " is installed, but version "+installed[0][1]+" does not match given dependency." else: reason = p + " is not installed." if t == None: Log_Terse('%s\nUnable to fulfill the dependency.'%(reason), 'CheckDependencies') return if install_optional == 'never': Log_Terse('%s'%(reason)) return if global_always_do: if global_always_do=='install/compile': if t == 'recipe': action = "Compiled" else: action = "Installed" else: action = 'Skipped' Log_Terse("%s\n%s %s (%s) will be %s"%(reason,p,v,t,action), 'CheckDependencies') if global_always_do == 'install/compile': return True else: return False while True: if t == 'recipe': action = "Compile" else: action = "Install" yes = action[0] reply = Ask_Option('%s\n%s %s for %s %s or skip this dependency? [%s]%s/[S]Skip/[%sA]%s All/[SA]Skip All'%(reason,action,t,p,v,yes,action,yes,action), 'CheckDependencies') if reply: if reply[0] in [yes.lower() ,'s']: install = (reply[0] == yes.lower()) if len(reply) >= 2 and reply[1] == 'a': if reply[0] == yes.lower(): global_always_do = 'install/compile' else: global_always_do = 'skip' return install return True ############################################################################# # Hi-level Functions ############################################################################# # # Recursivelly identifies the dependencies for a given package / recipe as long as a 'solution' for each one # def get_all_dependencies_and_matches_for( p, v=None, r='', t=None, u=None, acceptable_types=None, mode='missing', recursive=True, hook=None, noWeb=False, add_self='if_required', install_optional='ask', ask_hook=None, all_matches = None, no_compatlist=False, cross_compile=False, depfile=None, goboPrograms=None, localdirs=None, availables=None): global global_dependencies_blacklist ordered_matches, ordered_rules = [], [] self_match, self_rule = None, None if availables is None: availables = GetAvailable(types=['installed','local_package','official_package', 'recipe', 'contrib_package', 'tracked'], accessWeb=not noWeb, localdirs=localdirs, goboPrograms=goboPrograms) if all_matches == None: global_always_do = None all_matches = [] first_call = True else: first_call = False if not acceptable_types: acceptable_types = getGoboVariable('defaultRepositories', 'Scripts/FindPackage.conf', True) if not depfile and ((add_self == 'always') or (add_self != 'never' and (not v or not t))): if t: ret = FindPackage(p, v, r, types=[t], accessWeb=not noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables) else: if not v or not r: ret = FindPackage(p, v, r, accessWeb=not noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables, types=acceptable_types) else: ret = FindPackage(p, v, r, types=['installed'], accessWeb=not noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables) if ret: ret = FindPackage(p, v, r, accessWeb=not noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables, types=acceptable_types) if not ret: return [], [] self_rule = { 'program':p, 'versions':[], 'optional':True } self_match = ret[0] # We need to check against acceptable_types, or there's # no reason to have it. if self_match[3] not in acceptable_types: for match in ret: if match[3] in acceptable_types: self_match = match break if self_match[3] not in acceptable_types: return [], [] all_matches.append(self_match) p,v,r,t,u = self_match if depfile: all_rules = get_rules_of_files([depfile]) else: all_rules = get_rules_for(p, v, r, t, u, noWeb=noWeb, no_compatlist=no_compatlist, cross_compile=cross_compile, availables=availables) # optimization only: #all_rules = [ rule for rule in all_rules if not any(pp == rule['program'] for pp,vv,tt,uu in all_matches) ] missing_dependencies = [ rule for rule in all_rules if not find_matching_package(rule, ['installed'], noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables) ] for rule in all_rules: if rule['program'].lower() in global_dependencies_blacklist: continue if hook: hook("Checking dependencies", len(all_matches), len(all_matches)+1) if ':' in rule['program']: # It's an alien. alientype, alienpkg = Alien.split(rule['program']) if not Alien.havealienmanager(alientype): # If the alien manager is not installed, # add it to the list. arule = Alien.getmanagerrule(alientype) amatch = find_matching_package \ (arule, acceptable_types, noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables) ordered_matches.append(amatch) ordered_rules.append(arule) # For aliens, we *only* care if the dependency is # met, regardless of mode - the alien package manager # deals with upgrades. If it is satisfied, do no more # with this dependency. if Alien.dependencymet(rule): continue # Otherwise, it's unmet, so append a match tuple # with the right version in it. ver = Alien.getinstallversion(rule) alienmatch = ((rule['program'], ver, None, 'recipe', rule['program'])) if mode != 'all': # Asking here! if install_optional == 'never' or (install_optional == 'ask' and ask_hook and not ask_hook(alienmatch, goboPrograms=goboPrograms)): continue ordered_matches.append(alienmatch) ordered_rules.append(rule) continue if mode == 'missing' and find_matching_package(rule, ['installed'], noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables)[3]: continue if mode == 'all': match = find_matching_package(rule, acceptable_types, noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables) # (program, version, type, site) else: match = find_matching_package(rule, ['installed']+acceptable_types, noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs, availables=availables) # (program, version, type, site) if mode == 'updating' and match[3] == 'installed': continue # Note: if no package is found, find_matching_package returns a # tuple with None in the place of type if not match in all_matches: all_matches.append(match) # we append before, to avoid asking twice for a package that is meant to be skipped if mode != 'all': # Asking here! if install_optional == 'never' or (install_optional == 'ask' and ask_hook and not ask_hook(match, goboPrograms=goboPrograms)): continue pp, vv, rr, tt, uu = match if tt and recursive: rr, mm = get_all_dependencies_and_matches_for(pp, vv, rr, tt, uu, acceptable_types, mode, recursive, hook=hook, all_matches=all_matches, ask_hook=ask_hook, install_optional=install_optional, noWeb=noWeb, availables=availables) ordered_matches += mm ordered_rules += rr # Using recursion in our favor: appending after recursion returns ensures an # automatic correct output ordering (which is indeed nice :) # Note that this explains why two lists are used (ordered_matches and all_matches: # the later being responsible to avoid infinite recursion on circular dependencies) ordered_matches.append(match) ordered_rules.append(rule) if self_match and self_rule: #rule = self_rule #ret_type = find_matching_package(rule, ['installed'], noWeb=noWeb)[2] #if not ((mode == 'missing' and ret_type) or (mode == 'updating' and ret_type == 'installed')): ordered_matches.append(self_match) ordered_rules.append(self_rule) if hook and first_call: hook("Checking dependencies", len(all_matches), len(all_matches)) return ordered_rules, ordered_matches # # This function is used when mode == 'convert' # simple implementation for now # def ConvertRecipeToBinary(p, v, r, t, u, depfile, availables=None): global global_dependencies_blacklist global_dependencies_blacklist = [] if depfile: rules = get_rules_of_files([depfile]) else: rules = get_rules_for(p, v, r, t, u, noWeb=True, no_compatlist=True, no_builddeps=True) goboPrograms = getGoboVariable('goboPrograms') ret = '' for rule in rules: cmd=""" source ScriptFunctions Import GoboLinux Get_Version %s Current"""%rule['program'] installed_version = bash(cmd) if installed_version: ret += rule['program'] + ' >= ' + installed_version for op, ver in rule['versions']: if '<' in op or '!=' == op: ret += ', ' + op + ' ' + ver ret += '\n' return ret # # This function is used when mode == 'list' # def ListDependencies(p, v, r, t, u, mode = 'terminal', types=None, report_missing=False, report_updating=False, recursive=True, hook=None, noWeb=False, cross_compile=False, depfile=None, goboPrograms=None, localdirs=None): if not types: types = getGoboVariable('defaultRepositories', 'Scripts/FindPackage.conf', True) all_rules, all_matches = get_all_dependencies_and_matches_for(p,v,r,t,u, types, recursive=recursive, hook=hook, mode='all', noWeb=noWeb, cross_compile=cross_compile, depfile=depfile, goboPrograms=goboPrograms, localdirs=localdirs) if report_missing: missing_dependencies = [ rule for rule in all_rules if not find_matching_package(rule, ['installed'], noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs)[3] ] missing_programs = [ rule for rule in missing_dependencies if 'NO_PROGRAM' == find_matching_package(rule, ['installed'], noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs)[4] ] unresolvable_dependencies = [ rule for rule in missing_dependencies if not find_matching_package(rule, ['installed']+types, noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs)[3] ] if report_updating: updating_dependencies = [ rule for rule in all_rules if not find_matching_package(rule, ['installed']+types, noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs)[3] == 'installed' ] tracked_is_higher_dependencies = [ rule for rule in all_rules if find_matching_package(rule, ['installed']+types+['tracked'], noWeb=noWeb, goboPrograms=goboPrograms, localdirs=localdirs)[3] == 'tracked' ] if mode == 'terminal': s = '' for rule in all_rules: ss = rule['program'] ss += ' ' + version_range_string(rule) if report_missing and rule in missing_dependencies: ss += ' M' + (rule in missing_programs and 'P' or 'V') if report_updating and rule in updating_dependencies: ss += ' U' s += ss + '\n' return s.strip() elif mode == 'html': s = '
['+'Dependencies'+']
'
for rule in all_rules:
ss=''
if report_missing and rule in missing_dependencies:
if rule in missing_programs:
ss += ''
if rule in unresolvable_dependencies: ss += ''
else:
ss += ''
else:
ss += ''
ss += rule['program']
if report_missing and rule in missing_dependencies:
if report_missing and not rule in missing_programs:
ss += ''
if rule in unresolvable_dependencies: ss += ''
elif report_updating and rule in updating_dependencies:
ss += ''
elif report_updating and rule in tracked_is_higher_dependencies:
ss += ''
ss += ' ' + version_range_string(rule)
if rule in unresolvable_dependencies: ss += ''
s += ss + '
'+'\n'
if not all_rules: s += '-
'
return s
else:
return rules
#
# This function is used only in Manager at this time
#
def does_x_depend_on_y(x, py, acceptable_types=None, all_programs=None, hook=None, noWeb=False):
px, vx, rx, tx, ux = x
if all_programs == None:
all_programs = []
if px.lower() == py.lower():
return True
for rule in get_rules_for(px, vx, rx, tx, ux):
if hook:
hook()
p = rule['program']
if p.lower() == py.lower():
return True
if not p in all_programs:
all_programs.append(p)
match = find_matching_package(rule, acceptable_types, noWeb=noWeb) # (program, version, type, site)
pp, vv, rr, tt, uu = match
if tt:
x = does_x_depend_on_y((pp, vv, rr, tt, uu), py, acceptable_types, all_programs, hook=hook)
if x:
return True
return False
#############################################################################
# Main
#############################################################################
CheckDependencies=get_all_dependencies_and_matches_for
if __name__ == '__main__':
try:
import sys
import getopt, os
try:
if not sys.argv[1:]:
sys.argv[1:] = [ '--help' ]
opts, args = getopt.getopt(sys.argv[1:], 't:m:s:i:bWRBChf:l:p:', ['add-self=','install-optional=', 'batch','types=', 'type=', 'mode=', 'no-web', 'no-recursive', 'no-blacklist', 'blacklist=', 'quiet-progress', 'no-compatlist', 'cross-compile', 'file=', 'help', 'local-dirs=', 'gobo-programs=', 'no-prompt'])
except getopt.GetoptError, detail:
print sys.argv[0].split('/')[-1]+': '+str(detail)
sys.exit(1)
validTypes = ['installed', 'local_package', 'official_package', 'recipe', 'contrib_package', 'tracked', 'all']
types = None
mode = 'missing'
recursive = True
noWeb = False
add_self='if_required'
progress_hook=consoleProgressHook
install_optional = 'ask'
no_compatlist = False
cross_compile = False
depfile = None
localdirs = None
goboPrograms = None
for o, a in opts:
if o in ['--types','--type', '-t']:
types = a.split(',')
for i in range(len(types)):
if len (types[i]) == 1:
for t in validTypes:
if types[i][0] == t[0]:
types[i] = t
break
if 'all' in types:
types = validTypes[:-1] # don't include 'all'
elif o in ['--mode','-m']:
mode = a
elif o in ['--no-recursive','-R']:
recursive = False
elif o in ['--quiet-progress']:
progress_hook=None
elif o in ['--add-self','-s']:
add_self=a
elif o in ['--install-optional','-i']:
install_optional=a
if install_optional == 'always':
global_always_do = 'install/compile'
elif o in ['--batch', '-b']:
install_optional = 'always'
global_always_do = 'install/compile'
elif o in ['--no-web', '-W']:
noWeb = True
elif o in ['--no-blacklist', '-B']:
global_dependencies_blacklist = []
elif o in ['--blacklist']:
global_dependencies_blacklist = a.split(',')
for i in range(len(global_dependencies_blacklist)):
global_dependencies_blacklist[i] = global_dependencies_blacklist[i].lower()
elif o in ['--no-compatlist', '-C']:
no_compatlist = True
elif o in ['--cross-compile']:
cross_compile = True
elif o in ['--file', '-f']:
depfile = a
elif o == '--local-dirs' :
localdirs = a.split(',')
elif o == '--no-prompt' :
ask_if_install = None # This is a bit of a hack.
elif o in ['--gobo-programs', '-p']:
goboPrograms = a
elif o in ['--help', '-h']:
print """
CheckDependencies
Check dependencies. No decent help yet.
Options:
-t [t1,t2,...]
--types=[t1,t2,...] Sets what kind of packages repositories that can be
searched to match the dependencies.
Default list is set at Settings/Scripts/FindPackage.conf
-s
--add-self= Tell if the program passed as parameter should be
returned too.
Can be set to:
never - do not return the passed program
always - return the passed program
if_required - return the passed program iff type or
version from the program was not passed
as paramater (default)
-i
--install-optional= Install optional dependencies? 'always', 'never', 'ask'
-b
--batch Same as --install-optional=always
-m, --mode= Can be set to:
missing - report matches only for missing packages
updating - report all packages (dependencies from the
passed program) that can be updated
all - report matches for all dependencies, even
it they are already installed
list - only list the dependencies, without printing
matches
convert - convert a Dependencies file of a recipe to
the coresponding Dependencies file for the
compiled binary
-W, --no-web Do not access the internet.
-R
--no-recursive Only the direct dependencies are considered
-B
--no-blacklist Do not skip packages listed at Dependencies.blacklist
--blacklist= List of application names to blacklist
--no-prompt Do not prompt to install anything
--quiet-progress Do not show progress indicator
--cross-compile Check dependencies for cross compilation
-f
--file Check for the dependencies listed in the given file.
-p
--gobo-programs= Override default """+getGoboVariable("goboPrograms")+""" as path of installed packages
--local-dirs=[d1,..] Where to look for local binary packages. By default,
uses the paths defined at GetAvailable.conf.
Examples of usage:
CheckDependencies kde-libs 3.5.0
CheckDependencies kde-libs 3.5.0 recipe
CheckDependencies -t official_package,recipe kde-libs 3.5.0 recipe
CheckDependencies -t official_package,recipe kde-libs 3.5.0 recipe
"""
sys.exit(0)
if len(args) >= 1: p = args[0]
else: p = None
if len(args) >= 2: vr = args[1]
else: vr = None
if len(args) >= 3: t = args[2]
else: t = None
if len(args) >= 4: u = args[3]
else: u = None
if vr:
v,r = Split_Version_Revision(vr)
else:
v,r = '',''
if mode == 'list':
print ListDependencies(p,v,r,t,u,types=types,recursive=recursive,hook=progress_hook,noWeb=noWeb,cross_compile=cross_compile, depfile=depfile, goboPrograms=goboPrograms, localdirs=localdirs)
elif mode == 'convert':
print ConvertRecipeToBinary(p, v, r, t, u, depfile=depfile),
else:
rules, matches = get_all_dependencies_and_matches_for(p, v, r, t, u, types, mode=mode, recursive=recursive,
noWeb=noWeb, hook=progress_hook, add_self=add_self, ask_hook=ask_if_install,
no_compatlist=no_compatlist, cross_compile=cross_compile, depfile=depfile, goboPrograms=goboPrograms,
localdirs=localdirs)
if rules:
for rule,match in zip(rules,matches):
pp,vv,rr,tt,uu=match
print pp, Join_Version_Revision(vv,rr), tt, uu
sys.exit(0)
except ParseError, e:
Log_Error(e.message, 'CheckDependencies')
sys.exit(1)
except KeyboardInterrupt:
sys.exit(1)