From 25dc78f57160314288c69e757c9d626c27474a74 Mon Sep 17 00:00:00 2001 From: no92 Date: Tue, 11 Apr 2023 14:29:37 +0200 Subject: [PATCH 1/4] meta: fix formatting with latest black --- xbstrap/base.py | 14 +++++++------- xbstrap/pipeline/__init__.py | 4 ++-- xbstrap/util.py | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/xbstrap/base.py b/xbstrap/base.py index b94cba6..db4c578 100644 --- a/xbstrap/base.py +++ b/xbstrap/base.py @@ -2836,7 +2836,7 @@ def add_source_dependencies(s): item.require_edges.add((action.PATCH_SRC, dep_source)) def add_tool_dependencies(s): - for (tool_name, stage_name) in s.tool_stage_dependencies: + for tool_name, stage_name in s.tool_stage_dependencies: dep_tool = self._cfg.get_tool_pkg(tool_name) if self.build_scope is not None and dep_tool not in self.build_scope: item.require_edges.add((action.WANT_TOOL, dep_tool)) @@ -3073,14 +3073,14 @@ def activate(root_action, root_subject): visit(item.require_edges) # Activate wanted items. - for (action, subject) in self.wanted: + for action, subject in self.wanted: item = self._items[(action, subject)] item.build_span = True if not self.check or item.is_missing: activate(action, subject) # Discover all items reachable by build edges. - for (action, subject) in reversed(self._order): + for action, subject in reversed(self._order): item = self._items[(action, subject)] if not item.build_span: continue @@ -3098,7 +3098,7 @@ def is_outdated(item, dep_item): return False return dep_ts > ts - for (action, subject) in self._order: + for action, subject in self._order: item = self._items[(action, subject)] # Unless we're doing a recursive update, we only follow check items # that are reachable by build edges. @@ -3160,7 +3160,7 @@ def run_plan(self): _util.log_info("Running the following plan:") else: _util.log_info("Nothing to do") - for (action, subject) in scheduled: + for action, subject in scheduled: if isinstance(subject, HostStage): if subject.stage_name: eprint( @@ -3199,7 +3199,7 @@ def run_plan(self): return any_failed_items = False - for (n, (action, subject)) in enumerate(scheduled): + for n, (action, subject) in enumerate(scheduled): item = self._items[(action, subject)] # Check if any prerequisites failed; this can generally only happen with --keep-going. @@ -3329,7 +3329,7 @@ def emit_progress(status): if any_failed_items: _util.log_info("The following steps failed:") - for (action, subject) in scheduled: + for action, subject in scheduled: item = self._items[(action, subject)] assert item.exec_status != ExecutionStatus.NULL if item.exec_status == ExecutionStatus.SUCCESS: diff --git a/xbstrap/pipeline/__init__.py b/xbstrap/pipeline/__init__.py index 21ba5ca..56803eb 100755 --- a/xbstrap/pipeline/__init__.py +++ b/xbstrap/pipeline/__init__.py @@ -182,7 +182,7 @@ def do_compute_graph(args): "architecture": af.architecture, } ) - for (action, subject) in plan.materialized_steps(): + for action, subject in plan.materialized_steps(): if action == xbstrap.base.Action.WANT_TOOL: if subject in job.tools: continue @@ -237,7 +237,7 @@ def do_compute_graph(args): plan.wanted.update([(xbstrap.base.Action.RUN, task)]) plan.compute_plan(no_ordering=True) - for (action, subject) in plan.materialized_steps(): + for action, subject in plan.materialized_steps(): if action == xbstrap.base.Action.WANT_TOOL: if subject in item.job.tools: continue diff --git a/xbstrap/util.py b/xbstrap/util.py index a679f58..3b0990d 100644 --- a/xbstrap/util.py +++ b/xbstrap/util.py @@ -72,7 +72,6 @@ def build_environ_paths(environ, varname, prepend): def interactive_download(url, path): - istty = os.isatty(1) # This is stdout. if istty: eprint("...", end="") # This will become the status line. From d573036997d2000e623c90f0c646950a8633f611 Mon Sep 17 00:00:00 2001 From: no92 Date: Fri, 10 Jun 2022 02:03:40 +0200 Subject: [PATCH 2/4] vcs: print error message with context when checkout fails --- xbstrap/base.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xbstrap/base.py b/xbstrap/base.py index db4c578..c54ea82 100644 --- a/xbstrap/base.py +++ b/xbstrap/base.py @@ -2086,10 +2086,15 @@ def checkout_src(cfg, src, settings): if fixed_commit is not None: commit = fixed_commit if init or settings.reset != ResetMode.NONE: - subprocess.check_call( - ["git", "checkout", "--no-track", "-B", source["branch"], commit], - cwd=src.source_dir, - ) + try: + subprocess.check_call( + ["git", "checkout", "--no-track", "-B", source["branch"], commit], + cwd=src.source_dir, + ) + except subprocess.CalledProcessError: + raise GenericError( + "git checkout of '{}' failed for source '{}'".format(commit, src.name) + ) subprocess.call( ["git", "branch", "-u", "refs/remotes/origin/" + source["branch"]], cwd=src.source_dir, From 7e1374a6272a83c5641e13cbf3c93e4ba762b09d Mon Sep 17 00:00:00 2001 From: no92 Date: Mon, 23 Jan 2023 21:36:58 +0100 Subject: [PATCH 3/4] xbstrap: print help when no command is provided --- xbstrap/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xbstrap/__init__.py b/xbstrap/__init__.py index ef5c7d4..3b5b09b 100755 --- a/xbstrap/__init__.py +++ b/xbstrap/__init__.py @@ -991,7 +991,9 @@ def main(): elif args.command == "lsp": do_lsp(args) else: - assert not "Unexpected command" + # invalid command are already handled by argparse; + # this only gets tripped with no command provided + main_parser.print_help() except ( xbstrap.base.ExecutionFailureError, xbstrap.base.PlanFailureError, From fb03ee7f759d0a1b6b430ae5367d470d6f4506df Mon Sep 17 00:00:00 2001 From: no92 Date: Wed, 9 Aug 2023 14:45:53 +0200 Subject: [PATCH 4/4] schema: catch invalid configurations --- xbstrap/schema.yml | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/xbstrap/schema.yml b/xbstrap/schema.yml index 7b02c6c..38599a5 100644 --- a/xbstrap/schema.yml +++ b/xbstrap/schema.yml @@ -101,6 +101,50 @@ definitions: 'sources_required': { $ref: '#/definitions/source_deps' } 'tools_required': { $ref: '#/definitions/tool_deps' } + # keep this in sync with the `sources` definition, as this apparently can't be $ref'ed + dependencies: + # when `git` is used, disallow `svn`, `hg` and `url` + git: + not: + anyOf: + - required: + - hg + - required: + - svn + - required: + - url + + # when `tag` is used, disallow `branch` and `commit` + tag: + not: + anyOf: + - required: + - branch + - required: + - commit + + branch: + # require any of `commit` or `rolling_version` to be present + anyOf: + - required: + - commit + - required: + - rolling_version + # when branch is used, disallow `tag` + not: + required: + - tag + + # when commit is used, branch is required + commit: + required: + - branch + + # when rolling_version is used, branch is required + rolling_version: + required: + - branch + 'nested_task': type: object additionalProperties: false @@ -253,6 +297,50 @@ properties: 'regenerate': { $ref: '#/definitions/build_steps' } 'sources_required': { $ref: '#/definitions/source_deps' } 'tools_required': { $ref: '#/definitions/tool_deps' } + + # keep this in sync with the `nested_sources` definition, as this apparently can't be $ref'ed + dependencies: + # when `git` is used, disallow `svn`, `hg` and `url` + git: + not: + anyOf: + - required: + - hg + - required: + - svn + - required: + - url + + # when `tag` is used, disallow `branch` and `commit` + tag: + not: + anyOf: + - required: + - branch + - required: + - commit + + branch: + # require any of `commit` or `rolling_version` to be present + anyOf: + - required: + - commit + - required: + - rolling_version + # when branch is used, disallow `tag` + not: + required: + - tag + + # when commit is used, branch is required + commit: + required: + - branch + + # when rolling_version is used, branch is required + rolling_version: + required: + - branch 'tools': type: array items: