Exemplo n.º 1
0
    def _run_untagged_report(self, 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, tito_config_dir())
        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(" ")

                # Hack for single project git repos:
                if relative_dir == '/':
                    relative_dir = ""

                project_dir = os.path.join(git_root, relative_dir)
                self._print_diff(config, md_file, version, project_dir,
                        relative_dir)
Exemplo n.º 2
0
    def _run_untagged_report(self, 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, tito_config_dir())
        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(" ")

                # Hack for single project git repos:
                if relative_dir == '/':
                    relative_dir = ""

                project_dir = os.path.join(git_root, relative_dir)
                self._print_diff(config, md_file, version, project_dir,
                                 relative_dir)
Exemplo n.º 3
0
def main():
    """The main function allows converting a git repo the is stup for "normal"
    tito to use classed defined here instead
    """
    options = parse_args()
    rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
    releasers_filename = os.path.join(rel_eng_dir, RELEASERS_CONF_FILENAME)
    releasers_config = RawConfigParser()
    releasers_config.read(releasers_filename)
    print("Read configuration file: {0}".format(releasers_filename))
    for section in releasers_config.sections():
        print("  found section: {0}".format(section))
        if releasers_config.has_option(section, 'releaser'):
            old_releaser = releasers_config.get(section, 'releaser')
            print("  releaser is set to: {0}".format(old_releaser))
            if old_releaser.startswith('tito.release.'):
                new_releaser = old_releaser.replace('tito.release.',
                                                    'mocktito.', 1)
                print("  replaced with: {0}".format(new_releaser))
                releasers_config.set(section, 'releaser', new_releaser)
            elif old_releaser.startswith('mocktito.'):
                pass
            else:
                stderr.write("Found a releaser type I don't know, aborting\n")
                exit(1)
            if options.extra_yum_repos:
                print("  adding extra yum repos")
                releasers_config.set(section, EXTRA_YUM_REPOS,
                                     "\n".join(options.extra_yum_repos))
            if options.extra_yum_repos_for:
                print("  adding extra yum repos for branches")
                releasers_config.set(section, EXTRA_YUM_REPOS_FOR,
                                     json.dumps(options.extra_yum_repos_for))
    with open(releasers_filename, 'w') as rfp:
        releasers_config.write(rfp)
Exemplo n.º 4
0
def main():
    """The main function allows converting a git repo the is stup for "normal"
    tito to use classed defined here instead
    """
    options = parse_args()
    rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
    releasers_filename = os.path.join(rel_eng_dir, RELEASERS_CONF_FILENAME)
    releasers_config = RawConfigParser()
    releasers_config.read(releasers_filename)
    print("Read configuration file: {0}".format(releasers_filename))
    for section in releasers_config.sections():
        print("  found section: {0}".format(section))
        if releasers_config.has_option(section, "releaser"):
            old_releaser = releasers_config.get(section, "releaser")
            print("  releaser is set to: {0}".format(old_releaser))
            if old_releaser.startswith("tito.release."):
                new_releaser = old_releaser.replace("tito.release.", "mocktito.", 1)
                print("  replaced with: {0}".format(new_releaser))
                releasers_config.set(section, "releaser", new_releaser)
            elif old_releaser.startswith("mocktito."):
                pass
            else:
                stderr.write("Found a releaser type I don't know, aborting\n")
                exit(1)
            if options.extra_yum_repos:
                print("  adding extra yum repos")
                releasers_config.set(section, EXTRA_YUM_REPOS, "\n".join(options.extra_yum_repos))
            if options.extra_yum_repos_for:
                print("  adding extra yum repos for branches")
                releasers_config.set(section, EXTRA_YUM_REPOS_FOR, json.dumps(options.extra_yum_repos_for))
    with open(releasers_filename, "w") as rfp:
        releasers_config.write(rfp)
Exemplo n.º 5
0
 def _read_releaser_config(self):
     """
     Read the releaser targets from .tito/releasers.conf.
     """
     rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
     filename = os.path.join(rel_eng_dir, RELEASERS_CONF_FILENAME)
     config = RawConfigParser()
     config.read(filename)
     return config
Exemplo n.º 6
0
 def _read_releaser_config(self):
     """
     Read the releaser targets from .tito/releasers.conf.
     """
     rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
     filename = os.path.join(rel_eng_dir, RELEASERS_CONF_FILENAME)
     config = RawConfigParser()
     config.read(filename)
     return config
Exemplo n.º 7
0
    def __init__(self, config=None):
        """
        config - Merged configuration. (global plus package specific)
        """
        self.config = config

        # Override global configurations using local configurations
        for section in config.sections():
            for options in config.options(section):
                if not self.config.has_section(section):
                    self.config.add_section(section)
                self.config.set(section, options, config.get(section, options))

        self.git_root = find_git_root()
        self.rel_eng_dir = os.path.join(self.git_root, tito_config_dir())
Exemplo n.º 8
0
    def __init__(self, config=None):
        """
        config - Merged configuration. (global plus package specific)
        """
        self.config = config

        # Override global configurations using local configurations
        for section in config.sections():
            for options in config.options(section):
                if not self.config.has_section(section):
                    self.config.add_section(section)
                self.config.set(section, options,
                        config.get(section, options))

        self.git_root = find_git_root()
        self.rel_eng_dir = os.path.join(self.git_root, tito_config_dir())
Exemplo n.º 9
0
    def get_latest_tagged_version(package_name):
        """
        Return the latest git tag for this package in the current branch.
        Uses the info in .tito/packages/package-name.

        Returns None if file does not exist.
        """
        git_root = find_git_root()
        rel_eng_dir = os.path.join(git_root, tito_config_dir())
        file_path = "{0}/packages/{1}".format(rel_eng_dir, package_name)
        debug("Getting latest package info from: {0}".format(file_path))
        if not os.path.exists(file_path):
            return None

        output = run_command("awk '{ print $1 ; exit }' {0}".format(file_path))
        if output is None or output.strip() == "":
            error_out("Error looking up latest tagged version in: {0}".format(file_path))

        return output
Exemplo n.º 10
0
    def get_latest_tagged_version(package_name):
        """
        Return the latest git tag for this package in the current branch.
        Uses the info in .tito/packages/package-name.

        Returns None if file does not exist.
        """
        git_root = find_git_root()
        rel_eng_dir = os.path.join(git_root, tito_config_dir())
        file_path = "{0}/packages/{1}".format(rel_eng_dir, package_name)
        debug("Getting latest package info from: {0}".format(file_path))
        if not os.path.exists(file_path):
            return None

        output = run_command("awk '{ print $1 ; exit }' {0}".format(file_path))
        if output is None or output.strip() == "":
            error_out("Error looking up latest tagged version in: {0}".format(
                file_path))

        return output
Exemplo n.º 11
0
    def _read_config(self):
        """
        Read global build.py configuration from the .tito dir of the git
        repository we're being run from.

        NOTE: We always load the latest config file, not tito.props as it
        was for the tag being operated on.
        """
        # List of filepaths to config files we'll be loading:
        rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
        filename = os.path.join(rel_eng_dir, TITO_PROPS)
        if not os.path.exists(filename):
            error_out("Unable to locate branch configuration: %s"
                "\nPlease run 'tito init'" % filename)

        # Load the global config. Later, when we know what tag/package we're
        # building, we may also load that and potentially override some global
        # settings.
        config = RawConfigParser()
        config.read(filename)

        self._check_legacy_globalconfig(config)
        return config
Exemplo n.º 12
0
    def _read_config(self):
        """
        Read global build.py configuration from the .tito dir of the git
        repository we're being run from.

        NOTE: We always load the latest config file, not tito.props as it
        was for the tag being operated on.
        """
        # List of filepaths to config files we'll be loading:
        rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
        filename = os.path.join(rel_eng_dir, TITO_PROPS)
        if not os.path.exists(filename):
            error_out("Unable to locate branch configuration: %s"
                      "\nPlease run 'tito init'" % filename)

        # Load the global config. Later, when we know what tag/package we're
        # building, we may also load that and potentially override some global
        # settings.
        config = RawConfigParser()
        config.read(filename)

        self._check_legacy_globalconfig(config)
        return config