diff --git a/check_config.py b/check_config.py new file mode 100644 index 0000000..2963e28 --- /dev/null +++ b/check_config.py @@ -0,0 +1,84 @@ +''' + + check_config.py + + +"This is a tool for developers constructing build configuration files for +SeattleTestbed repositories. After running initialize.py and build.py on +your current init/build config for your repository, this script checks for +all of the dependencies you listed whether they require further repos checked +out and files copied, and prints a message for each missing sub-dependency. +See also https://seattle.poly.edu/wiki/BuildInstructions for a description of +the SeattleTestbed build process." + + + python check_config.py + +''' + +import os + +def read_initconfig(filename): + content =[] + for line in open(filename, 'r'): + if line.startswith('#') or line.strip() == '': + continue + content.append(line.strip()) + return content + +def read_buildconfig(filename, repo): + content =[] + for line in open(filename, 'r'): + if line.startswith('#') or line.strip() == '' or line.startswith('test'): + continue + if line.startswith("./"): + line = line.replace("./","DEPENDENCIES"+ os.sep + repo + os.sep) + content.append(line.strip()) + return content + +def main(): + # Set current_repo to the name of this repository's base directory. (This should be the repo's name.) + current_repo = os.path.basename(os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) + + init_dependencies = read_initconfig('config_initialize.txt') + init_dependencies.append('https://github.com/SeattleTestbed/' + current_repo + ' ../DEPENDENCIES/' + current_repo) + + init_result = {} + for repo in os.listdir("../DEPENDENCIES"): + if os.path.isdir("../DEPENDENCIES" + os.sep + repo): + for line in read_initconfig("../DEPENDENCIES"+ os.sep + repo + os.sep +"scripts/config_initialize.txt"): + url = line.strip() + if url not in init_dependencies: + try: + init_result[repo].append(url) + except KeyError: + init_result[repo] = [url] + + print "Additionally required in config_initialize.txt\n" + + for dependency,config in init_result.items(): + print "# Additionally required by dependency " + dependency + ":" + for setting in config: + print setting + + build_dependencies = read_buildconfig('config_build.txt',current_repo) + + build_result = {} + for repo in os.listdir("../DEPENDENCIES"): + if os.path.isdir("../DEPENDENCIES" + os.sep + repo): + for line in read_buildconfig("../DEPENDENCIES"+ os.sep + repo + os.sep +"scripts/config_build.txt",repo): + if line.strip() not in build_dependencies: + try: + build_result[repo].append(line) + except KeyError: + build_result[repo] = [line] + + print "\nAdditionally required in config_build.txt\n" + + for dependency,config in build_result.items(): + print "# Additionally required by dependency " + dependency + ":" + for setting in config: + print setting + +if __name__ == '__main__': + main()