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()
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
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()
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
def __init__(self, name=None, version=None, tag=None, build_dir=None, pkg_config=None, global_config=None, user_config=None, options=None): self.git_root = find_git_root() self.rel_eng_dir = os.path.join(self.git_root, "rel-eng") self.project_name = name self.build_tag = tag self.build_version = version self.config = global_config self.user_config = user_config self.no_cleanup = False # Probably not a great idea to be passing in CLI options directly to # an object that gets re-used. This is however optional. if options is not None: self.dist = options.dist self.test = options.test self.offline = options.offline self.auto_install = options.auto_install self.rpmbuild_options = options.rpmbuild_options else: self.dist = self.test = self.offline = self.auto_install = \ self.rpmbuild_options = None self.dist = None self.test = False self.offline = False if not self.rpmbuild_options: self.rpmbuild_options = '' # Override global configurations using local configurations for section in pkg_config.sections(): for options in pkg_config.options(section): if not self.config.has_section(section): self.config.add_section(section) self.config.set(section, options, pkg_config.get(section, 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 = [] temp_dir = "rpmbuild-%s" % self.project_name_and_sha1 self.rpmbuild_dir = os.path.join(self.rpmbuild_basedir, temp_dir) if os.path.exists(self.rpmbuild_dir): print("WARNING: rpmbuild directory already exists, removing...") run_command("rm -rf 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
def __init__( self, name=None, version=None, tag=None, build_dir=None, pkg_config=None, global_config=None, user_config=None, options=None, args=None, ): """ 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. options - Parsed CLI options. 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. """ self.git_root = find_git_root() self.rel_eng_dir = os.path.join(self.git_root, "rel-eng") self.project_name = name self.build_tag = tag self.build_version = version self.config = global_config self.user_config = user_config self.no_cleanup = False self.args = args # Probably not a great idea to be passing in CLI options directly to # an object that gets re-used. This is however optional. if options is not None: self.dist = options.dist self.test = options.test self.offline = options.offline self.auto_install = options.auto_install self.rpmbuild_options = options.rpmbuild_options else: self.dist = self.test = self.offline = self.auto_install = self.rpmbuild_options = None self.dist = None self.test = False self.offline = False if not self.rpmbuild_options: self.rpmbuild_options = "" # Override global configurations using local configurations for section in pkg_config.sections(): for options in pkg_config.options(section): if not self.config.has_section(section): self.config.add_section(section) self.config.set(section, options, pkg_config.get(section, 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()