def main(self): # DO NOT CALL BaseCliModule.main(self) # we are initializing tito to work in this module and # calling main will result in a configuration error. rel_eng_dir = os.path.join(find_git_root(), "rel-eng") filename = os.path.join(rel_eng_dir, GLOBAL_BUILD_PROPS_FILENAME) if not os.path.exists(filename): if not os.path.exists(rel_eng_dir): commands.getoutput("mkdir -p %s" % rel_eng_dir) # write out tito.props out_f = open(filename, 'w') out_f.write("[globalconfig]\n") out_f.write("default_builder = spacewalk.releng.builder.Builder\n") out_f.write("default_tagger = spacewalk.releng.tagger.VersionTagger\n") out_f.close() commands.getoutput('git commit -m "Initialized to use tito. "') pkg_dir = os.path.join(rel_eng_dir, "packages") if not os.path.exists(pkg_dir): commands.getoutput("mkdir -p %s" % pkg_dir) print("Initialized tito in %s" % rel_eng_dir)
def _read_global_config(self): """ Read global build.py configuration from the rel-eng dir of the git repository we're being run from. """ rel_eng_dir = os.path.join(find_git_root(), "rel-eng") filename = os.path.join(rel_eng_dir, GLOBAL_BUILD_PROPS_FILENAME) if not os.path.exists(filename): # HACK: Try the old filename location, pre-tito rename: oldfilename = os.path.join(rel_eng_dir, "global.build.py.props") if not os.path.exists(oldfilename): error_out("Unable to locate branch configuration: %s\nPlease run 'tito init'" % filename) config = ConfigParser.ConfigParser() config.read(filename) # Verify the config contains what we need from it: required_global_config = [ (GLOBALCONFIG_SECTION, DEFAULT_BUILDER), (GLOBALCONFIG_SECTION, DEFAULT_TAGGER), ] for section, option in required_global_config: if not config.has_section(section) or not \ config.has_option(section, option): error_out("%s missing required config: %s %s" % ( filename, section, option)) return config
def _run_untagged_commits(self, global_config): """ Display a report of all packages with differences between HEAD and their most recent tag, as well as a patch for that diff. Used to determine which packages are in need of a rebuild. """ print("Scanning for packages that may need to be tagged...") print("") git_root = find_git_root() rel_eng_dir = os.path.join(git_root, "rel-eng") os.chdir(git_root) package_metadata_dir = os.path.join(rel_eng_dir, "packages") for root, dirs, files in os.walk(package_metadata_dir): for md_file in files: if md_file[0] == '.': continue f = open(os.path.join(package_metadata_dir, md_file)) (version, relative_dir) = f.readline().strip().split(" ") project_dir = os.path.join(git_root, relative_dir) self._print_log(global_config, md_file, version, project_dir)