list-dependencies.py 2.67 KB
Newer Older
1 2 3 4 5 6 7 8 9
#!/usr/bin/python3
import os
import sys
import tarfile
import argparse
from helperslib import BuildSpecs, CommonUtils, Buildable, Packages

# Parse the command line arguments we've been given
parser = argparse.ArgumentParser(description='Utility to execute tests for a build.')
10
parser.add_argument('--product', type=str, required=True)
11 12 13 14 15 16 17 18
parser.add_argument('--project', type=str, required=True)
parser.add_argument('--branchGroup', type=str, required=True)
parser.add_argument('--platform', type=str, required=True)
parser.add_argument('--environment', type=str, required=True)
parser.add_argument('--installTo', type=str, required=True)
arguments = parser.parse_args()

# Load our build specification, which governs how we handle this build
19
buildSpecification = BuildSpecs.Loader( product=arguments.product, project=arguments.project, branchGroup=arguments.branchGroup, platform=arguments.platform )
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

# Initialise the dependnecy resolver
resolver = Buildable.DependencyResolver()

# Ask the resolver to load the list of projects...
projectsTreeLocation = os.path.join( CommonUtils.scriptsBaseDirectory(), 'repo-metadata', 'projects' )
resolver.loadProjectsFromTree( projectsTreeLocation )

# Now ask it to load the list of projects to ignore
ignoreFileLocation = os.path.join( CommonUtils.scriptsBaseDirectory(), 'kde-build-metadata', 'build-script-ignore' )
resolver.loadProjectsIgnoreList( ignoreFileLocation )
# As well as our local ignore file
ignoreFileLocation = os.path.join( CommonUtils.scriptsBaseDirectory(), 'local-metadata', 'ignored-projects' )
resolver.loadProjectsIgnoreList( ignoreFileLocation )

# Now get it to load the list of dependencies - we have first the common file...
dependenciesFile = os.path.join( CommonUtils.scriptsBaseDirectory(), 'kde-build-metadata', 'dependency-data-common' )
resolver.loadDependenciesFromFile( dependenciesFile )
# And then the branch group specific file...
dependenciesFile = os.path.join( CommonUtils.scriptsBaseDirectory(), 'kde-build-metadata', 'dependency-data-' + arguments.branchGroup )
resolver.loadDependenciesFromFile( dependenciesFile )
# And if it exists, we want the platform specific file as well
dependenciesFile = os.path.join( CommonUtils.scriptsBaseDirectory(), 'kde-build-metadata', 'dependency-data-' + arguments.platform )
if os.path.exists( dependenciesFile ):
	resolver.loadDependenciesFromFile( dependenciesFile )

# Now that we are all initialised, we can ask the resolver for the project we represent, then resolve it's dependencies
resolverProject = resolver.retrieveProject( arguments.project )
projectDependencies = resolver.forProject( resolverProject )

# Iterate over them and print details
for project in projectDependencies:
    print( project.name )