def retrieve_sources(): """Retrieve sources using spectool """ spectool = find_executable('spectool') if not spectool: log.warn('spectool is not installed') return try: specfile = spec_fn() except: return cmd = [spectool, "-g", specfile] output = subprocess.check_output(' '.join(cmd), shell=True) log.warn(output)
def retrieve_sources(): """Retrieve sources using spectool """ spectool = find_executable('spectool') if not spectool: log.warn('spectool is not installed') return try: specfile = spec_fn() except Exception: return cmd = [spectool, "-g", specfile] output = subprocess.check_output(' '.join(cmd), shell=True) log.warn(output)
def new_build(watch=True): modules_check() flog = setup_fedpkg_logger() fcmd = get_fedpkg_commands() target = fcmd.target task_id = fcmd.build() if watch: print('') try: cli = get_fedpkg_cli() r = cli._watch_koji_tasks(fcmd.kojisession, [task_id]) except ConfigParser.NoSectionError: # <C-C> causes this for some reason print('') except Exception as ex: log.warn(str(type(ex).__name__)) log.warn("Failed to get build status: %s" % ex) return fcmd.nvr
def new_build(watch=True): modules_check() flog = setup_fedpkg_logger() fcmd = get_fedpkg_commands() target = fcmd.target task_id = fcmd.build() if watch: print('') try: cli = get_fedpkg_cli() r = cli._watch_koji_tasks(fcmd.kojisession, [task_id]) except ConfigParser.NoSectionError: # <C-C> causes this for some reason print('') except Exception as ex: log.warn(str(type(ex).__name__)) log.warn("Failed to get build status: %s" % ex) return fcmd.nvr
def create_srpm(dist='el7'): """Create an srpm Requires that sources are available in local directory dist: set package dist tag (default: el7) """ if not RPM_AVAILABLE: raise exception.ModuleNotAvailable(module='rpm') path = os.getcwd() try: specfile = spec_fn() spec = Spec(specfile) except: return rpmdefines = [ "--define 'dist .{}'".format(dist), "--define '_sourcedir {}'".format(path), "--define '_srcrpmdir {}'".format(path) ] rpm.addMacro('_sourcedir', '.{}'.format(dist)) # FIXME: needs to be fixed in Spec rpm.addMacro('dist', '.{}'.format(dist)) module_name = spec.get_tag('Name', True) version = spec.get_tag('Version', True) release = spec.get_tag('Release', True) srpm = os.path.join( path, "{}-{}-{}.src.rpm".format(module_name, version, release)) # See if we need to build the srpm if os.path.exists(srpm): log.warn('Srpm found, rewriting it.') cmd = ['rpmbuild'] cmd.extend(rpmdefines) cmd.extend(['--nodeps', '-bs', specfile]) output = subprocess.check_output(' '.join(cmd), shell=True) log.warn(output) srpm = output.split()[1] return srpm
def create_srpm(dist='el7'): """Create an srpm Requires that sources are available in local directory dist: set package dist tag (default: el7) """ if not RPM_AVAILABLE: raise RpmModuleNotAvailable() path = os.getcwd() try: specfile = spec_fn() spec = Spec(specfile) except Exception: return rpmdefines = ["--define 'dist .{}'".format(dist), "--define '_sourcedir {}'".format(path), "--define '_srcrpmdir {}'".format(path)] rpm.addMacro('_sourcedir', '.{}'.format(dist)) # FIXME: needs to be fixed in Spec rpm.addMacro('dist', '.{}'.format(dist)) module_name = spec.get_tag('Name', True) version = spec.get_tag('Version', True) release = spec.get_tag('Release', True) srpm = os.path.join(path, "{}-{}-{}.src.rpm".format(module_name, version, release)) # See if we need to build the srpm if os.path.exists(srpm): log.warn('Srpm found, rewriting it.') cmd = ['rpmbuild'] cmd.extend(rpmdefines) cmd.extend(['--nodeps', '-bs', specfile]) output = subprocess.check_output(' '.join(cmd), shell=True) log.warn(output) srpm = output.split()[1] return srpm
def new_build(watch=True): modules_check() flog = setup_fedpkg_logger() # NOQA fcmd = get_fedpkg_commands() task_id = fcmd.build() if watch: print('') try: cli = get_fedpkg_cli() # TODO: might be good to push this return data back up # or check the status of the return r = cli._watch_koji_tasks(fcmd.kojisession, [task_id]) except configparser.NoSectionError: # <C-C> causes this for some reason print('') except Exception as ex: log.warn(str(type(ex).__name__)) log.warn("Failed to get build status: %s" % ex) return fcmd.nvr
def new_build(profile='cbs', scratch=True): # Very ugly: some utilities are only available in koji CLI # and not in the koji module if not KOJI_AVAILABLE: raise ModuleNotAvailable(module='koji') if not RPM_AVAILABLE: raise RpmModuleNotAvailable() import imp kojibin = find_executable('koji') kojicli = imp.load_source('kojicli', kojibin) # Koji 1.13 moves client internal API into another path try: from koji_cli.lib import _unique_path, _progress_callback, watch_tasks except ImportError: from kojicli import _unique_path, _progress_callback, watch_tasks kojiclient = setup_kojiclient(profile) # Note: required to make watch_tasks work kojicli.options = opts = bunchify(kojiclient.opts) build_target = guess_build() if not build_target: log.warn("failed to identify build tag from branch") return retrieve_sources() srpm = create_srpm() if not srpm: log.warn('No srpm available') return serverdir = _unique_path('cli-build') kojiclient.uploadWrapper(srpm, serverdir, callback=_progress_callback) source = "%s/%s" % (serverdir, os.path.basename(srpm)) task_id = kojiclient.build(source, build_target, {'scratch': scratch}) print("Created task:", task_id) print("Task info: {}/taskinfo?taskID={}".format(opts['weburl'], task_id)) kojiclient.logout() watch_tasks(kojiclient, [task_id])
def new_build(profile='cbs', scratch=True): # Very ugly: some utilities are only available in koji CLI # and not in the koji module if not KOJI_AVAILABLE: raise ModuleNotAvailable(module='koji') if not RPM_AVAILABLE: raise RpmModuleNotAvailable() import imp kojibin = find_executable('koji') kojicli = imp.load_source('kojicli', kojibin) # Koji 1.13 moves client internal API into another path try: from koji_cli.lib import _unique_path, _progress_callback, watch_tasks except ImportError: from kojicli import _unique_path, _progress_callback, watch_tasks kojiclient = setup_kojiclient(profile) # Note: required to make watch_tasks work kojicli.options = opts = munchify(kojiclient.opts) build_target = guess_build() if not build_target: log.warn("failed to identify build tag from branch") return retrieve_sources() srpm = create_srpm() if not srpm: log.warn('No srpm available') return serverdir = _unique_path('cli-build') kojiclient.uploadWrapper(srpm, serverdir, callback=_progress_callback) source = "%s/%s" % (serverdir, os.path.basename(srpm)) task_id = kojiclient.build(source, build_target, {'scratch': scratch}) print("Created task:", task_id) print("Task info: {}/taskinfo?taskID={}".format(opts['weburl'], task_id)) kojiclient.logout() watch_tasks(kojiclient, [task_id])
def new_build(profile='cbs', scratch=True): # Very ugly: some utilities are only available in koji CLI # and not in the koji module if not KOJI_AVAILABLE: raise exception.ModuleNotAvailable(module='koji') if not RPM_AVAILABLE: raise exception.ModuleNotAvailable(module='rpm') import imp kojibin = find_executable('koji') kojicli = imp.load_source('kojicli', kojibin) from kojicli import _unique_path, _progress_callback, watch_tasks build_target = guess_build() if not build_target: log.warn("failed to identify build tag from branch") return options = koji.read_config(profile) opts = KojiOpts(**options) # Note: required to make watch_tasks work kojicli.options, weburl = opts, opts.weburl kojiclient = koji.ClientSession(opts.server) kojiclient.ssl_login(opts.cert, None, opts.serverca) retrieve_sources() srpm = create_srpm() opts = {'scratch': scratch} if not srpm: log.warn('No srpm available') return serverdir = _unique_path('cli-build') kojiclient.uploadWrapper(srpm, serverdir, callback=_progress_callback) source = "%s/%s" % (serverdir, os.path.basename(srpm)) task_id = kojiclient.build(source, build_target, opts) print "Created task:", task_id print "Task info: {}/taskinfo?taskID={}".format(weburl, task_id) kojiclient.logout() watch_tasks(kojiclient, [task_id])