Beispiel #1
0
    def __init__(self, global_config=None, keep_version=False, offline=False, user_config=None, pkg_config=None):
        """ 
        pkg_config - Package specific configuration.

        global_config - Global configuration from rel-eng/tito.props.
        """
        ConfigObject.__init__(self, pkg_config=pkg_config, global_config=global_config)
        self.user_config = user_config

        self.full_project_dir = os.getcwd()
        self.spec_file_name = find_spec_file()
        self.project_name = get_project_name(tag=None)

        self.relative_project_dir = self._get_relative_project_dir(
                self.git_root)  # i.e. java/

        self.spec_file = os.path.join(self.full_project_dir,
                self.spec_file_name)
        self.keep_version = keep_version

        self.today = strftime("%a %b %d %Y")
        (self.git_user, self.git_email) = self._get_git_user_info()
        git_email = self.git_email
        if git_email is None:
            git_email = ''
        self.changelog_regex = re.compile('\\*\s%s\s%s(\s<%s>)?' % (self.today,
            self.git_user, git_email.replace("+", "\+").replace(".", "\.")))

        self._no_auto_changelog = False
        self._accept_auto_changelog = False
        self._new_changelog_msg = "new package built with tito"
        self.offline = offline
Beispiel #2
0
    def __init__(self, config=None, keep_version=False, offline=False, user_config=None):
        ConfigObject.__init__(self, config=config)
        self.user_config = user_config

        self.full_project_dir = os.getcwd()
        self.spec_file_name = find_spec_like_file()
        self.project_name = get_project_name(tag=None)

        self.relative_project_dir = get_relative_project_dir_cwd(
            self.git_root)  # i.e. java/

        self.spec_file = os.path.join(self.full_project_dir,
                self.spec_file_name)
        self.keep_version = keep_version

        self.today = self._changelog_date()
        (self.git_user, self.git_email) = get_git_user_info()
        git_email = self.git_email
        if git_email is None:
            git_email = ''
        self.changelog_regex = re.compile('\\*\s%s\s%s(\s<%s>)?' % (self.today,
            self.git_user, git_email.replace("+", "\+").replace(".", "\.")))

        self._no_auto_changelog = False
        self._accept_auto_changelog = False
        self._new_changelog_msg = "new package built with tito"
        self._changelog = None
        self.offline = offline
Beispiel #3
0
    def __init__(self, global_config=None, keep_version=False, offline=False, user_config=None, pkg_config=None):
        """ 
        pkg_config - Package specific configuration.

        global_config - Global configuration from rel-eng/tito.props.
        """
        ConfigObject.__init__(self, pkg_config=pkg_config, global_config=global_config)
        self.user_config = user_config

        self.full_project_dir = os.getcwd()
        self.spec_file_name = find_spec_file()
        self.project_name = get_project_name(tag=None)

        self.relative_project_dir = self._get_relative_project_dir(
                self.git_root)  # i.e. java/

        self.spec_file = os.path.join(self.full_project_dir,
                self.spec_file_name)
        self.keep_version = keep_version

        self.today = strftime("%a %b %d %Y")
        (self.git_user, self.git_email) = self._get_git_user_info()
        git_email = self.git_email
        if git_email is None:
            git_email = ''
        self.changelog_regex = re.compile('\\*\s%s\s%s(\s<%s>)?' % (self.today,
            self.git_user, git_email.replace("+", "\+").replace(".", "\.")))

        self._no_auto_changelog = False
        self._accept_auto_changelog = False
        self._new_changelog_msg = "new package built with tito"
        self.offline = offline
Beispiel #4
0
    def __init__(self,
                 name=None,
                 tag=None,
                 build_dir=None,
                 config=None,
                 user_config=None,
                 target=None,
                 releaser_config=None,
                 no_cleanup=False,
                 test=False,
                 auto_accept=False,
                 **kwargs):

        ConfigObject.__init__(self, config=config)
        config_builder_args = self._parse_builder_args(releaser_config, target)
        if test:
            config_builder_args[
                'test'] = True  # builder must know to build from HEAD

        # Override with builder args from command line if any were given:
        if 'builder_args' in kwargs:
            # (in case of dupes, last one wins)
            self.builder_args = dictionary_override(config_builder_args,
                                                    kwargs['builder_args'])
        else:
            self.builder_args = config_builder_args

        # While we create a builder here, we don't actually call run on it
        # unless the releaser needs to:
        self.offline = False
        if 'offline' in kwargs:
            self.offline = kwargs['offline']
        self.builder = create_builder(name,
                                      tag,
                                      config,
                                      build_dir,
                                      user_config,
                                      self.builder_args,
                                      offline=self.offline)
        self.project_name = self.builder.project_name

        self.working_dir = mkdtemp(dir=self.builder.rpmbuild_basedir,
                                   prefix="release-%s" %
                                   self.builder.project_name)
        print("Working in: %s" % self.working_dir)

        # Config for all releasers:
        self.releaser_config = releaser_config

        # The actual release target we're building:
        self.target = target

        self.dry_run = False
        self.test = test  # releaser must know to use builder designation rather than tag
        self.auto_accept = auto_accept  # don't ask for input, just go ahead
        self.no_cleanup = no_cleanup

        self._check_releaser_config()
Beispiel #5
0
    def __init__(self, name=None, tag=None, build_dir=None,
            config=None, user_config=None,
            target=None, releaser_config=None, no_cleanup=False,
            test=False, auto_accept=False, **kwargs):

        ConfigObject.__init__(self, config=config)
        config_builder_args = self._parse_builder_args(releaser_config, target)
        if test:
            config_builder_args['test'] = [True]  # builder must know to build from HEAD

        # Override with builder args from command line if any were given:
        if 'builder_args' in kwargs:
            # (in case of dupes, last one wins)
            self.builder_args = dictionary_override(
                config_builder_args,
                kwargs['builder_args']
            )
        else:
            self.builder_args = config_builder_args

        # While we create a builder here, we don't actually call run on it
        # unless the releaser needs to:
        self.offline = False
        if 'offline' in kwargs:
            self.offline = kwargs['offline']

        # Config for all releasers:
        self.releaser_config = releaser_config

        # The actual release target we're building:
        self.target = target

        # Use the builder from the release target, rather than the default
        # one defined for this git repo or sub-package:
        builder_class = None
        if self.releaser_config.has_option(self.target, 'builder'):
            builder_class = self.releaser_config.get(self.target, 'builder')
        self.builder = create_builder(name, tag,
                config,
                build_dir, user_config, self.builder_args,
                builder_class=builder_class, offline=self.offline)

        self.project_name = self.builder.project_name

        self.working_dir = mkdtemp(dir=self.builder.rpmbuild_basedir,
                prefix="release-%s" % self.builder.project_name)
        print("Working in: %s" % self.working_dir)

        self.dry_run = False
        self.test = test  # releaser must know to use builder designation rather than tag
        self.auto_accept = auto_accept  # don't ask for input, just go ahead
        self.no_cleanup = no_cleanup

        self._check_releaser_config()
Beispiel #6
0
    def __init__(self,
                 name=None,
                 version=None,
                 tag=None,
                 build_dir=None,
                 pkg_config=None,
                 global_config=None,
                 user_config=None,
                 target=None,
                 releaser_config=None,
                 no_cleanup=False,
                 test=False,
                 auto_accept=False):

        ConfigObject.__init__(self,
                              pkg_config=pkg_config,
                              global_config=global_config)
        self.builder_args = self._parse_builder_args(releaser_config, target)
        if test:
            self.builder_args[
                'test'] = True  # builder must know to build from HEAD

        # While we create a builder here, we don't actually call run on it
        # unless the releaser needs to:
        self.builder = create_builder(name, tag, version, pkg_config,
                                      build_dir, global_config, user_config,
                                      self.builder_args)
        self.project_name = self.builder.project_name

        # TODO: if it looks like we need custom CVSROOT's for different users,
        # allow setting of a property to lookup in ~/.spacewalk-build-rc to
        # use instead. (if defined)
        self.working_dir = os.path.join(self.builder.rpmbuild_basedir,
                                        DEFAULT_CVS_BUILD_DIR)
        self.working_dir = mkdtemp(dir=self.builder.rpmbuild_basedir,
                                   prefix="release-%s" %
                                   self.builder.project_name_and_sha1)
        print("Working in: %s" % self.working_dir)

        # When syncing files with CVS, only copy files with these extensions:
        self.cvs_copy_extensions = (".spec", ".patch")

        # Config for all releasers:
        self.releaser_config = releaser_config

        # The actual release target we're building:
        self.target = target

        self.dry_run = False
        self.test = test  # releaser must know to use builder designation rather than tag
        self.auto_accept = auto_accept  # don't ask for input, just go ahead
        self.no_cleanup = no_cleanup

        self._check_releaser_config()
Beispiel #7
0
    def __init__(self, name=None, version=None, tag=None, build_dir=None,
            pkg_config=None, global_config=None, user_config=None,
            target=None, releaser_config=None, no_cleanup=False, test=False, auto_accept=False):

        ConfigObject.__init__(self, pkg_config=pkg_config, global_config=global_config)
        self.builder_args = self._parse_builder_args(releaser_config, target)
        if test:
            self.builder_args['test'] = True # builder must know to build from HEAD

        # While we create a builder here, we don't actually call run on it
        # unless the releaser needs to:
        self.builder = create_builder(name, tag,
                version, pkg_config,
                build_dir, global_config, user_config, self.builder_args)
        self.project_name = self.builder.project_name

        # TODO: if it looks like we need custom CVSROOT's for different users,
        # allow setting of a property to lookup in ~/.spacewalk-build-rc to
        # use instead. (if defined)
        self.working_dir = os.path.join(self.builder.rpmbuild_basedir,
                DEFAULT_CVS_BUILD_DIR)
        self.working_dir = mkdtemp(dir=self.builder.rpmbuild_basedir,
                prefix="release-%s" % self.builder.project_name_and_sha1)
        print("Working in: %s" % self.working_dir)

        # When syncing files with CVS, only copy files with these extensions:
        self.cvs_copy_extensions = (".spec", ".patch")

        # Config for all releasers:
        self.releaser_config = releaser_config

        # The actual release target we're building:
        self.target = target

        self.dry_run = False
        self.test = test # releaser must know to use builder designation rather than tag
        self.auto_accept = auto_accept # don't ask for input, just go ahead
        self.no_cleanup = no_cleanup

        self._check_releaser_config()
Beispiel #8
0
    def __init__(self,
                 name=None,
                 version=None,
                 tag=None,
                 build_dir=None,
                 pkg_config=None,
                 global_config=None,
                 user_config=None,
                 args=None,
                 **kwargs):
        """
        name - Package name that is being built.

        version - Version and release being built.

        tag - The git tag being built.

        build_dir - Temporary build directory where we can safely work.

        pkg_config - Package specific configuration.

        global_config - Global configuration from rel-eng/tito.props.

        user_config - User configuration from ~/.titorc.

        args - Optional arguments specific to each builder. Can be passed
        in explicitly by user on the CLI, or via a release target config
        entry. Only for things which vary on invocations of the builder,
        avoid using these if possible.
        """
        ConfigObject.__init__(self,
                              pkg_config=pkg_config,
                              global_config=global_config)

        self.project_name = name
        self.build_tag = tag
        self.build_version = version
        self.user_config = user_config
        self.no_cleanup = False
        self.args = args

        # Optional keyword arguments:
        self.dist = self._get_optional_arg(kwargs, 'dist', None)
        self.test = self._get_optional_arg(kwargs, 'test', False)
        self.offline = self._get_optional_arg(kwargs, 'offline', False)
        self.auto_install = self._get_optional_arg(kwargs, 'auto_install',
                                                   False)
        self.rpmbuild_options = self._get_optional_arg(kwargs,
                                                       'rpmbuild_options',
                                                       None)
        self.scl = self._get_optional_arg(kwargs, 'scl', '')

        # Allow a builder arg to override the test setting passed in, used by
        # releasers in their config sections.
        if args and 'test' in args:
            self.test = True

        if kwargs and 'options' in kwargs:
            print(
                "WARNING: 'options' no longer a supported builder "
                "constructor argument.")

        if not self.rpmbuild_options:
            self.rpmbuild_options = ''

        if self.config.has_section("requirements"):
            if self.config.has_option("requirements", "tito"):
                if loose_version(self.config.get("requirements", "tito")) > \
                        loose_version(require('tito')[0].version):
                    print(
                        "Error: tito version %s or later is needed to build this project."
                        % self.config.get("requirements", "tito"))
                    print("Your version: %s" % require('tito')[0].version)
                    sys.exit(-1)

        self.rpmbuild_basedir = build_dir
        self.display_version = self._get_display_version()

        self.git_commit_id = get_build_commit(tag=self.build_tag,
                                              test=self.test)
        self.project_name_and_sha1 = "%s-%s" % (self.project_name,
                                                self.git_commit_id)

        self.relative_project_dir = get_relative_project_dir(
            project_name=self.project_name, commit=self.git_commit_id)

        tgz_base = self._get_tgz_name_and_ver()
        self.tgz_filename = tgz_base + ".tar.gz"
        self.tgz_dir = tgz_base
        self.artifacts = []

        self.rpmbuild_dir = mkdtemp(dir=self.rpmbuild_basedir,
                                    prefix="rpmbuild-%s" %
                                    self.project_name_and_sha1)
        debug("Building in temp dir: %s" % self.rpmbuild_dir)
        self.rpmbuild_sourcedir = os.path.join(self.rpmbuild_dir, "SOURCES")
        self.rpmbuild_builddir = os.path.join(self.rpmbuild_dir, "BUILD")

        # A copy of the git code from commit we're building:
        self.rpmbuild_gitcopy = os.path.join(self.rpmbuild_sourcedir,
                                             self.tgz_dir)

        # Set to true if we've already created a tgz:
        self.ran_tgz = False

        # Used to make sure we only modify the spec file for a test build
        # once. The srpm method may be called multiple times during koji
        # releases to create the proper disttags, but we only want to modify
        # the spec file once.
        self.ran_setup_test_specfile = False

        # NOTE: These are defined later when/if we actually dump a copy of the
        # project source at the tag we're building. Only then can we search for
        # a spec file.
        self.spec_file_name = None
        self.spec_file = None

        # List of full path to all sources for this package.
        self.sources = []

        # Set to path to srpm once we build one.
        self.srpm_location = None

        self._check_required_args()
Beispiel #9
0
    def __init__(self,
                 name=None,
                 tag=None,
                 build_dir=None,
                 config=None,
                 user_config=None,
                 args=None,
                 **kwargs):
        """
        name - Package name that is being built.

        version - Version and release being built.

        tag - The git tag being built.

        build_dir - Temporary build directory where we can safely work.

        config - Merged configuration. (global plus package specific)

        user_config - User configuration from ~/.titorc.

        args - Optional arguments specific to each builder. Can be passed
        in explicitly by user on the CLI, or via a release target config
        entry. Only for things which vary on invocations of the builder,
        avoid using these if possible.  *Given in the format of a dictionary
        of lists.*
        """
        ConfigObject.__init__(self, config=config)
        BuilderBase.__init__(self,
                             name=name,
                             build_dir=build_dir,
                             config=config,
                             user_config=user_config,
                             args=args,
                             **kwargs)
        self.build_tag = tag

        self.build_version = self._get_build_version()
        self.git_commit_id = get_build_commit(tag=self.build_tag, test=True)

        if kwargs and 'options' in kwargs:
            warn_out(
                "'options' no longer a supported builder constructor argument."
            )

        if self.config.has_option("requirements", "tito"):
            if loose_version(self.config.get("requirements", "tito")) > \
                    loose_version(require('tito')[0].version):
                error_out([
                    "tito version %s or later is needed to build this project."
                    % self.config.get("requirements", "tito"),
                    "Your version: %s" % require('tito')[0].version
                ])

        self.display_version = self._get_display_version()

        self.relative_project_dir = get_relative_project_dir_cwd(self.git_root)

        tgz_base = self._get_tgz_name_and_ver()
        self.tgz_filename = tgz_base + ".tar.gz"
        self.tgz_dir = tgz_base
        self.artifacts = []

        self.rpmbuild_gitcopy = os.path.join(self.rpmbuild_sourcedir,
                                             self.tgz_dir)

        # Used to make sure we only modify the spec file for a test build
        # once. The srpm method may be called multiple times during koji
        # releases to create the proper disttags, but we only want to modify
        # the spec file once.
        self.ran_setup_test_specfile = False

        # NOTE: These are defined later when/if we actually dump a copy of the
        # project source at the tag we're building. Only then can we search for
        # a spec file.
        self.spec_file_name = None
        self.spec_file = None

        # Set to path to srpm once we build one.
        self.srpm_location = None
Beispiel #10
0
    def __init__(self, name=None, version=None, tag=None, build_dir=None,
            pkg_config=None, global_config=None, user_config=None,
            args=None, **kwargs):

        """
        name - Package name that is being built.

        version - Version and release being built.

        tag - The git tag being built.

        build_dir - Temporary build directory where we can safely work.

        pkg_config - Package specific configuration.

        global_config - Global configuration from rel-eng/tito.props.

        user_config - User configuration from ~/.titorc.

        args - Optional arguments specific to each builder. Can be passed
        in explicitly by user on the CLI, or via a release target config
        entry. Only for things which vary on invocations of the builder,
        avoid using these if possible.
        """
        ConfigObject.__init__(self, pkg_config=pkg_config, global_config=global_config)

        self.project_name = name
        self.build_tag = tag
        self.build_version = version
        self.user_config = user_config
        self.no_cleanup = False
        self.args = args

        # Optional keyword arguments:
        self.dist = self._get_optional_arg(kwargs, 'dist', None)
        self.test = self._get_optional_arg(kwargs, 'test', False)
        self.offline = self._get_optional_arg(kwargs, 'offline', False)
        self.auto_install = self._get_optional_arg(kwargs, 'auto_install',
                False)
        self.rpmbuild_options = self._get_optional_arg(kwargs,
                'rpmbuild_options', None)

        # Allow a builder arg to override the test setting passed in, used by
        # releasers in their config sections.
        if args and 'test' in args:
            self.test = True

        if kwargs and 'options' in kwargs:
            print("WARNING: 'options' no longer a supported builder "
                    "constructor argument.")

        if not self.rpmbuild_options:
            self.rpmbuild_options = ''

        if self.config.has_section("requirements"):
            if self.config.has_option("requirements", "tito"):
                if loose_version(self.config.get("requirements", "tito")) > \
                        loose_version(require('tito')[0].version):
                    print("Error: tito version %s or later is needed to build this project." %
                            self.config.get("requirements", "tito"))
                    print("Your version: %s" % require('tito')[0].version)
                    sys.exit(-1)

        self.rpmbuild_basedir = build_dir
        self.display_version = self._get_display_version()

        self.git_commit_id = get_build_commit(tag=self.build_tag,
                test=self.test)
        self.project_name_and_sha1 = "%s-%s" % (self.project_name,
                self.git_commit_id)

        self.relative_project_dir = get_relative_project_dir(
                project_name=self.project_name, commit=self.git_commit_id)

        tgz_base = self._get_tgz_name_and_ver()
        self.tgz_filename = tgz_base + ".tar.gz"
        self.tgz_dir = tgz_base
        self.artifacts = []

        self.rpmbuild_dir = mkdtemp(dir=self.rpmbuild_basedir,
                prefix="rpmbuild-%s" % self.project_name_and_sha1)
        debug("Building in temp dir: %s" % self.rpmbuild_dir)
        self.rpmbuild_sourcedir = os.path.join(self.rpmbuild_dir, "SOURCES")
        self.rpmbuild_builddir = os.path.join(self.rpmbuild_dir, "BUILD")

        # A copy of the git code from commit we're building:
        self.rpmbuild_gitcopy = os.path.join(self.rpmbuild_sourcedir,
                self.tgz_dir)

        # Set to true if we've already created a tgz:
        self.ran_tgz = False

        # Used to make sure we only modify the spec file for a test build
        # once. The srpm method may be called multiple times during koji
        # releases to create the proper disttags, but we only want to modify
        # the spec file once.
        self.ran_setup_test_specfile = False

        # NOTE: These are defined later when/if we actually dump a copy of the
        # project source at the tag we're building. Only then can we search for
        # a spec file.
        self.spec_file_name = None
        self.spec_file = None

        # List of full path to all sources for this package.
        self.sources = []

        # Set to path to srpm once we build one.
        self.srpm_location = None

        self._check_required_args()
Beispiel #11
0
    def __init__(self, name=None, tag=None, build_dir=None,
            config=None, user_config=None,
            args=None, **kwargs):

        """
        name - Package name that is being built.

        version - Version and release being built.

        tag - The git tag being built.

        build_dir - Temporary build directory where we can safely work.

        config - Merged configuration. (global plus package specific)

        user_config - User configuration from ~/.titorc.

        args - Optional arguments specific to each builder. Can be passed
        in explicitly by user on the CLI, or via a release target config
        entry. Only for things which vary on invocations of the builder,
        avoid using these if possible.  *Given in the format of a dictionary
        of lists.*
        """
        ConfigObject.__init__(self, config=config)
        BuilderBase.__init__(self, name=name, build_dir=build_dir, config=config,
                user_config=user_config, args=args, **kwargs)
        self.build_tag = tag

        self.build_version = self._get_build_version()

        if kwargs and 'options' in kwargs:
            warn_out("'options' no longer a supported builder constructor argument.")

        if self.config.has_section("requirements"):
            if self.config.has_option("requirements", "tito"):
                if loose_version(self.config.get("requirements", "tito")) > \
                        loose_version(require('tito')[0].version):
                    error_out([
                        "tito version %s or later is needed to build this project." %
                        self.config.get("requirements", "tito"),
                        "Your version: %s" % require('tito')[0].version
                    ])

        self.display_version = self._get_display_version()

        with chdir(find_git_root()):
            self.git_commit_id = get_build_commit(tag=self.build_tag,
                test=self.test)

        self.relative_project_dir = get_relative_project_dir(
            project_name=self.project_name, commit=self.git_commit_id)
        if self.relative_project_dir is None and self.test:
            warn_out(".tito/packages/%s doesn't exist "
                "in git, using current directory" % self.project_name)
            self.relative_project_dir = get_relative_project_dir_cwd(
                self.git_root)

        tgz_base = self._get_tgz_name_and_ver()
        self.tgz_filename = tgz_base + ".tar.gz"
        self.tgz_dir = tgz_base
        self.artifacts = []

        # A copy of the git code from commit we're building:
        self.rpmbuild_gitcopy = os.path.join(self.rpmbuild_sourcedir,
                self.tgz_dir)

        # Used to make sure we only modify the spec file for a test build
        # once. The srpm method may be called multiple times during koji
        # releases to create the proper disttags, but we only want to modify
        # the spec file once.
        self.ran_setup_test_specfile = False

        # NOTE: These are defined later when/if we actually dump a copy of the
        # project source at the tag we're building. Only then can we search for
        # a spec file.
        self.spec_file_name = None
        self.spec_file = None

        # Set to path to srpm once we build one.
        self.srpm_location = None