2019-05-30 09:26:44 +02:00
|
|
|
#!/usr/bin/python3
|
2018-12-04 14:29:12 +01:00
|
|
|
|
|
|
|
# TODO: solve all devel packages to include
|
|
|
|
|
2018-12-07 22:12:24 +01:00
|
|
|
import cmdln
|
2018-12-04 14:29:12 +01:00
|
|
|
import os
|
|
|
|
import re
|
2022-03-04 11:27:12 +01:00
|
|
|
|
2018-12-07 22:12:24 +01:00
|
|
|
import ToolBase
|
2019-01-15 19:04:07 +01:00
|
|
|
import logging
|
2018-12-04 14:29:12 +01:00
|
|
|
|
|
|
|
from osc import conf
|
2018-12-07 22:12:24 +01:00
|
|
|
from osclib.conf import Config
|
2018-12-04 14:29:12 +01:00
|
|
|
from osclib.stagingapi import StagingAPI
|
2022-03-05 08:21:19 +01:00
|
|
|
from pkglistgen.tool import PkgListGen, MismatchedRepoException
|
2022-02-24 09:23:05 +01:00
|
|
|
from pkglistgen.update_repo_handler import update_project
|
2018-12-04 14:29:12 +01:00
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2018-12-04 14:29:12 +01:00
|
|
|
class CommandLineInterface(ToolBase.CommandLineInterface):
|
2022-03-05 08:21:19 +01:00
|
|
|
SCOPES = ['target', 'ring1']
|
2018-12-04 14:29:12 +01:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
ToolBase.CommandLineInterface.__init__(self, args, kwargs)
|
|
|
|
|
|
|
|
def setup_tool(self):
|
|
|
|
tool = PkgListGen()
|
2019-01-15 19:04:07 +01:00
|
|
|
if self.options.debug:
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
|
|
|
elif self.options.verbose:
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
|
2018-12-04 14:29:12 +01:00
|
|
|
return tool
|
|
|
|
|
2022-02-24 09:23:05 +01:00
|
|
|
@cmdln.option('--fixate', help='Set category to fixed and merge remaining files')
|
2019-01-09 12:41:10 +01:00
|
|
|
def do_handle_update_repos(self, subcmd, opts, project):
|
|
|
|
"""${cmd_name}: Update 00update-repos
|
2018-12-04 14:29:12 +01:00
|
|
|
|
2019-01-09 12:41:10 +01:00
|
|
|
Reads config.yml from 00update-repos and will create required solv files
|
2018-12-04 14:29:12 +01:00
|
|
|
|
|
|
|
${cmd_usage}
|
|
|
|
${cmd_option_list}
|
|
|
|
"""
|
2022-02-24 09:23:05 +01:00
|
|
|
return update_project(conf.config['apiurl'], project, opts.fixate)
|
2020-08-31 10:37:57 +02:00
|
|
|
|
2018-12-04 14:29:12 +01:00
|
|
|
@cmdln.option('-f', '--force', action='store_true', help='continue even if build is in progress')
|
2024-02-02 11:42:44 +01:00
|
|
|
@cmdln.option('-d', '--dry', help='no modifications uploaded')
|
2018-12-04 14:29:12 +01:00
|
|
|
@cmdln.option('-p', '--project', help='target project')
|
2024-02-13 16:17:05 +01:00
|
|
|
@cmdln.option('-g', '--git-url', help='git repository for target project')
|
2024-05-07 17:55:17 +02:00
|
|
|
@cmdln.option('-s', '--scope', help=f"scope on which to operate ({', '.join(SCOPES)}, staging:$letter)")
|
2018-12-04 14:29:12 +01:00
|
|
|
@cmdln.option('--no-checkout', action='store_true', help='reuse checkout in cache')
|
|
|
|
@cmdln.option('--stop-after-solve', action='store_true', help='only create group files')
|
|
|
|
@cmdln.option('--staging', help='Only solve that one staging')
|
|
|
|
@cmdln.option('--only-release-packages', action='store_true', help='Generate 000release-packages only')
|
2022-08-03 13:32:36 -03:00
|
|
|
@cmdln.option('--custom-cache-tag', help='add custom tag to cache dir to avoid issues when running in parallel')
|
2018-12-04 14:29:12 +01:00
|
|
|
def do_update_and_solve(self, subcmd, opts):
|
|
|
|
"""${cmd_name}: update and solve for given scope
|
|
|
|
|
|
|
|
${cmd_usage}
|
|
|
|
${cmd_option_list}
|
|
|
|
"""
|
|
|
|
|
|
|
|
if opts.staging:
|
|
|
|
match = re.match('(.*):Staging:(.*)', opts.staging)
|
2022-03-05 08:21:19 +01:00
|
|
|
opts.scope = 'staging:' + match.group(2)
|
2018-12-07 22:12:24 +01:00
|
|
|
if opts.project:
|
|
|
|
raise ValueError('--staging and --project conflict')
|
2018-12-04 14:29:12 +01:00
|
|
|
opts.project = match.group(1)
|
2018-12-07 22:12:24 +01:00
|
|
|
elif not opts.project:
|
2018-12-04 14:29:12 +01:00
|
|
|
raise ValueError('project is required')
|
2022-03-04 11:27:12 +01:00
|
|
|
|
|
|
|
if not opts.scope:
|
2022-03-04 12:32:48 +01:00
|
|
|
raise ValueError('--scope or --staging required')
|
2018-12-04 14:29:12 +01:00
|
|
|
|
|
|
|
apiurl = conf.config['apiurl']
|
2018-12-08 12:04:36 +01:00
|
|
|
Config(apiurl, opts.project)
|
2018-12-04 14:29:12 +01:00
|
|
|
target_config = conf.config[opts.project]
|
|
|
|
|
|
|
|
# Store target project as opts.project will contain subprojects.
|
|
|
|
target_project = opts.project
|
|
|
|
|
|
|
|
api = StagingAPI(apiurl, target_project)
|
|
|
|
|
|
|
|
main_repo = target_config['main-repo']
|
|
|
|
|
2019-01-30 15:09:58 +01:00
|
|
|
# used by product converter
|
|
|
|
# these needs to be kept in sync with OBS config
|
2018-12-07 22:12:24 +01:00
|
|
|
if apiurl.find('suse.de') > 0:
|
|
|
|
os.environ['OBS_NAME'] = 'build.suse.de'
|
2019-01-30 15:09:58 +01:00
|
|
|
if apiurl.find('opensuse.org') > 0:
|
|
|
|
os.environ['OBS_NAME'] = 'build.opensuse.org'
|
2018-12-07 22:12:24 +01:00
|
|
|
|
2022-10-11 14:59:13 +02:00
|
|
|
def solve_project(project, scope: str):
|
2018-12-07 22:12:24 +01:00
|
|
|
try:
|
2019-01-17 20:39:02 +01:00
|
|
|
self.tool.reset()
|
2019-01-19 22:00:18 +01:00
|
|
|
self.tool.dry_run = self.options.dry
|
2022-03-05 08:21:19 +01:00
|
|
|
return self.tool.update_and_solve_target(api, target_project, target_config, main_repo,
|
2024-02-13 16:17:05 +01:00
|
|
|
git_url=opts.git_url, project=project, scope=scope,
|
|
|
|
force=opts.force, no_checkout=opts.no_checkout,
|
2022-03-05 08:21:19 +01:00
|
|
|
only_release_packages=opts.only_release_packages,
|
2022-08-03 13:32:36 -03:00
|
|
|
stop_after_solve=opts.stop_after_solve,
|
|
|
|
custom_cache_tag=opts.custom_cache_tag)
|
2022-03-05 08:21:19 +01:00
|
|
|
except MismatchedRepoException:
|
2024-02-13 16:17:05 +01:00
|
|
|
logging.error("Failed to create weakremovers.inc due to mismatch in repos - project most likey started building again!")
|
2022-03-11 15:42:56 +01:00
|
|
|
# for stagings we have to be strict on the exit value
|
|
|
|
if scope == 'staging':
|
|
|
|
return 1
|
2022-03-05 15:58:20 +01:00
|
|
|
return 0
|
2022-03-05 08:21:19 +01:00
|
|
|
|
|
|
|
scope = opts.scope
|
|
|
|
if scope.startswith('staging:'):
|
|
|
|
letter = re.match('staging:(.*)', scope).group(1)
|
|
|
|
return solve_project(api.prj_from_short(letter), 'staging')
|
|
|
|
elif scope == 'target':
|
|
|
|
return solve_project(target_project, scope)
|
|
|
|
elif scope == 'ring1':
|
|
|
|
return solve_project(api.rings[1], scope)
|
|
|
|
else:
|
2024-05-07 17:55:17 +02:00
|
|
|
raise ValueError(f"scope \"{scope}\" must be one of: {', '.join(self.SCOPES)}")
|