summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:23:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-26 10:23:10 +0000
commite51eaffe9a6ee6539362cfc25ea8f2c1eace29b5 (patch)
treed651f7897fa5efa574d04fe0a3dc7e7d77084da0 /src
parentAdding debian version 0.1.46. (diff)
downloaddebputy-e51eaffe9a6ee6539362cfc25ea8f2c1eace29b5.tar.xz
debputy-e51eaffe9a6ee6539362cfc25ea8f2c1eace29b5.zip
Merging upstream version 0.1.47.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src')
-rw-r--r--src/debputy/commands/debputy_cmd/__main__.py3
-rw-r--r--src/debputy/commands/debputy_cmd/output.py29
-rw-r--r--src/debputy/dh_migration/migration.py27
-rw-r--r--src/debputy/dh_migration/migrators.py3
-rw-r--r--src/debputy/dh_migration/migrators_impl.py8
-rw-r--r--src/debputy/dh_migration/models.py2
-rw-r--r--src/debputy/linting/lint_report_junit.py3
-rw-r--r--src/debputy/linting/lint_util.py5
-rw-r--r--src/debputy/lsp/lsp_debian_changelog.py2
-rw-r--r--src/debputy/lsp/lsp_debian_control.py29
-rw-r--r--src/debputy/lsp/lsp_debian_control_reference_data.py8
-rw-r--r--src/debputy/lsp/lsp_generic_deb822.py10
-rw-r--r--src/debputy/plugin/debputy/build_system_rules.py2
-rw-r--r--src/debputy/util.py1
14 files changed, 112 insertions, 20 deletions
diff --git a/src/debputy/commands/debputy_cmd/__main__.py b/src/debputy/commands/debputy_cmd/__main__.py
index 1432327..58a6fb4 100644
--- a/src/debputy/commands/debputy_cmd/__main__.py
+++ b/src/debputy/commands/debputy_cmd/__main__.py
@@ -32,7 +32,7 @@ from debputy.commands.debputy_cmd.context import (
ROOT_COMMAND,
CommandArg,
)
-from debputy.commands.debputy_cmd.output import _stream_to_pager
+from debputy.commands.debputy_cmd.output import _stream_to_pager, _output_styling
from debputy.dh_migration.migrators import MIGRATORS
from debputy.exceptions import (
DebputyRuntimeError,
@@ -1002,6 +1002,7 @@ def _migrate_from_dh(context: CommandContext) -> None:
)
)
migrate_from_dh(
+ _output_styling(context.parsed_args, sys.stdout),
manifest,
acceptable_migration_issues,
parsed_args.destructive,
diff --git a/src/debputy/commands/debputy_cmd/output.py b/src/debputy/commands/debputy_cmd/output.py
index 5159980..334eab4 100644
--- a/src/debputy/commands/debputy_cmd/output.py
+++ b/src/debputy/commands/debputy_cmd/output.py
@@ -192,6 +192,9 @@ class OutputStylingBase:
def render_url(self, link_url: str) -> str:
return link_url
+ def bts(self, bugno) -> str:
+ return f"https://bugs.debian.org/{bugno}"
+
class ANSIOutputStylingBase(OutputStylingBase):
def __init__(
@@ -260,6 +263,25 @@ class ANSIOutputStylingBase(OutputStylingBase):
link_url = f"https://manpages.debian.org/{page}.{section}"
return URL_START + f"{link_url}\a{link_text}" + URL_END
+ def bts(self, bugno) -> str:
+ if not self._support_clickable_urls:
+ return super().bts(bugno)
+ return self.render_url(f"https://bugs.debian.org/{bugno}")
+
+
+def no_fancy_output(
+ stream: IO[str] = None,
+ output_format: str = str,
+ optimize_for_screen_reader: bool = False,
+) -> OutputStylingBase:
+ if stream is None:
+ stream = sys.stdout
+ return OutputStylingBase(
+ stream,
+ output_format,
+ optimize_for_screen_reader=optimize_for_screen_reader,
+ )
+
def _output_styling(
parsed_args: argparse.Namespace,
@@ -270,9 +292,12 @@ def _output_styling(
output_format = "text"
optimize_for_screen_reader = os.environ.get("OPTIMIZE_FOR_SCREEN_READER", "") != ""
if not stream.isatty():
- return OutputStylingBase(
- stream, output_format, optimize_for_screen_reader=optimize_for_screen_reader
+ return no_fancy_output(
+ stream,
+ output_format,
+ optimize_for_screen_reader=optimize_for_screen_reader,
)
+
return ANSIOutputStylingBase(
stream, output_format, optimize_for_screen_reader=optimize_for_screen_reader
)
diff --git a/src/debputy/dh_migration/migration.py b/src/debputy/dh_migration/migration.py
index 62f739e..7b06135 100644
--- a/src/debputy/dh_migration/migration.py
+++ b/src/debputy/dh_migration/migration.py
@@ -8,6 +8,7 @@ from typing import Optional, List, Callable, Set, Container, Mapping, FrozenSet
from debian.deb822 import Deb822
from debputy.commands.debputy_cmd.context import CommandContext
+from debputy.commands.debputy_cmd.output import OutputStylingBase
from debputy.dh.debhelper_emulation import CannotEmulateExecutableDHConfigFile
from debputy.dh_migration.migrators import MIGRATORS
from debputy.dh_migration.migrators_impl import (
@@ -46,6 +47,7 @@ SUPPORTED_MIGRATIONS: Mapping[
def _print_migration_summary(
+ fo: OutputStylingBase,
migrations: List[FeatureMigration],
compat: int,
min_compat_level: int,
@@ -59,9 +61,11 @@ def _print_migration_summary(
continue
underline = "-" * len(migration.tagline)
if migration.warnings:
+ if warning_count:
+ _warn("")
_warn(f"Summary for migration: {migration.tagline}")
- _warn(f"-----------------------{underline}")
- _warn(" /!\\ ATTENTION /!\\")
+ if not fo.optimize_for_screen_reader:
+ _warn(f"-----------------------{underline}")
warning_count += len(migration.warnings)
for warning in migration.warnings:
_warn(f" * {warning}")
@@ -70,7 +74,8 @@ def _print_migration_summary(
if warning_count:
_warn("")
_warn("Supported debhelper compat check")
- _warn("--------------------------------")
+ if not fo.optimize_for_screen_reader:
+ _warn("--------------------------------")
warning_count += 1
_warn(
f"The migration tool assumes debhelper compat {min_compat_level}+ semantics, but this package"
@@ -85,7 +90,8 @@ def _print_migration_summary(
if warning_count:
_warn("")
_warn("Missing debputy plugin check")
- _warn("----------------------------")
+ if not fo.optimize_for_screen_reader:
+ _warn("----------------------------")
_warn(
f"The migration tool could not read d/control and therefore cannot tell if all the required"
f" plugins have been requested. Please ensure that the package Build-Depends on: {needed_plugins}"
@@ -100,7 +106,8 @@ def _print_migration_summary(
if warning_count:
_warn("")
_warn("Missing debputy plugin check")
- _warn("----------------------------")
+ if not fo.optimize_for_screen_reader:
+ _warn("----------------------------")
_warn(
f"The migration tool asserted that the following `debputy` plugins would be required, which"
f" are not explicitly requested. Please add the following to Build-Depends: {needed_plugins}"
@@ -207,6 +214,7 @@ def _check_migration_target(
def migrate_from_dh(
+ fo: OutputStylingBase,
manifest: HighLevelManifest,
acceptable_migration_issues: AcceptableMigrationIssues,
permit_destructive_changes: Optional[bool],
@@ -225,7 +233,7 @@ def migrate_from_dh(
try:
for migrator in MIGRATORS[migration_target]:
- feature_migration = FeatureMigration(migrator.__name__)
+ feature_migration = FeatureMigration(migrator.__name__, fo)
migrator(
debian_dir,
manifest,
@@ -291,7 +299,12 @@ def migrate_from_dh(
)
_print_migration_summary(
- migrations, compat, min_compat, required_plugins, requested_plugins
+ fo,
+ migrations,
+ compat,
+ min_compat,
+ required_plugins,
+ requested_plugins,
)
migration_count = sum((m.performed_changes for m in migrations), 0)
diff --git a/src/debputy/dh_migration/migrators.py b/src/debputy/dh_migration/migrators.py
index 8a057b7..3c2d6e0 100644
--- a/src/debputy/dh_migration/migrators.py
+++ b/src/debputy/dh_migration/migrators.py
@@ -1,5 +1,6 @@
-from typing import Callable, List, Mapping
+from typing import Callable, List, Mapping, Protocol, Optional
+from debputy.commands.debputy_cmd.output import OutputStylingBase
from debputy.dh_migration.migrators_impl import (
migrate_links_files,
migrate_maintscript,
diff --git a/src/debputy/dh_migration/migrators_impl.py b/src/debputy/dh_migration/migrators_impl.py
index 97b0fd2..ca44b68 100644
--- a/src/debputy/dh_migration/migrators_impl.py
+++ b/src/debputy/dh_migration/migrators_impl.py
@@ -24,6 +24,7 @@ from debian.deb822 import Deb822
from debputy import DEBPUTY_DOC_ROOT_DIR
from debputy.architecture_support import dpkg_architecture_table
+from debputy.commands.debputy_cmd.output import OutputStylingBase
from debputy.deb_packaging_support import dpkg_field_list_pkg_dep
from debputy.dh.debhelper_emulation import (
dhe_filedoublearray,
@@ -1500,16 +1501,18 @@ def detect_obsolete_substvars(
seen_obsolete_relationship_substvars.update(obsolete_substvars_in_field)
package = p.get("Package", "(Missing package name!?)")
+ fo = feature_migration.fo
if obsolete_fields:
fields = ", ".join(obsolete_fields)
feature_migration.warn(
f"The following relationship fields can be removed from {package}: {fields}."
- f" (The content in them would be applied automatically.)"
+ f" (The content in them would be applied automatically. Note: {fo.bts('1067653')})"
)
if seen_obsolete_relationship_substvars:
v = ", ".join(sorted(seen_obsolete_relationship_substvars))
feature_migration.warn(
f"The following relationship substitution variables can be removed from {package}: {v}"
+ f" (Note: {fo.bts('1067653')})"
)
@@ -1552,6 +1555,9 @@ def detect_dh_addons_with_full_integration(
feature_migration.warn(
"TODO: Not implemented: Please ensure there is a Build-Dependency on `debputy (>= 0.1.45~)"
)
+ feature_migration.warn(
+ "TODO: Not implemented: Please ensure there is a Build-Dependency on `dpkg-dev (>= 1.22.7~)"
+ )
def detect_dh_addons_with_zz_integration(
diff --git a/src/debputy/dh_migration/models.py b/src/debputy/dh_migration/models.py
index ace4185..c093633 100644
--- a/src/debputy/dh_migration/models.py
+++ b/src/debputy/dh_migration/models.py
@@ -3,6 +3,7 @@ import re
from typing import Sequence, Optional, FrozenSet, Tuple, List, cast
from debputy.architecture_support import DpkgArchitectureBuildProcessValuesTable
+from debputy.commands.debputy_cmd.output import OutputStylingBase
from debputy.highlevel_manifest import MutableYAMLManifest
from debputy.substitution import Substitution
@@ -38,6 +39,7 @@ class ConflictingChange(RuntimeError):
@dataclasses.dataclass(slots=True)
class FeatureMigration:
tagline: str
+ fo: OutputStylingBase
successful_manifest_changes: int = 0
already_present: int = 0
warnings: List[str] = dataclasses.field(default_factory=list)
diff --git a/src/debputy/linting/lint_report_junit.py b/src/debputy/linting/lint_report_junit.py
index 2ad993a..4df6879 100644
--- a/src/debputy/linting/lint_report_junit.py
+++ b/src/debputy/linting/lint_report_junit.py
@@ -69,9 +69,10 @@ class JunitLintReport(LintReport):
range_desc = "entire file"
else:
range_desc = str(diagnostic.range)
+ code = f" [{diagnostic.code}]" if diagnostic.code else ""
output = textwrap.dedent(
f"""\
- {filename} [{severity}] ({range_desc}): {diagnostic.message}
+ {filename}{code} ({severity}) {range_desc}: {diagnostic.message}
"""
)
case.add_failure_info(
diff --git a/src/debputy/linting/lint_util.py b/src/debputy/linting/lint_util.py
index 017a1dc..feca476 100644
--- a/src/debputy/linting/lint_util.py
+++ b/src/debputy/linting/lint_util.py
@@ -431,8 +431,11 @@ class TermLintReport(LintReport):
if diagnostic_result.result_state == LintDiagnosticResultState.FIXABLE:
has_fixit = " [Correctable via --auto-fix]"
+
+ code = f"[{diagnostic.code}]: " if diagnostic.code else ""
+ msg = f"{code}{diagnostic.message}"
print(
- f"{tag}: File: {filename}:{start_line+1}:{start_position}:{end_line+1}:{end_position}: {diagnostic.message}{has_fixit}",
+ f"{tag}: File: {filename}:{start_line+1}:{start_position}:{end_line+1}:{end_position}: {msg}{has_fixit}",
)
if diagnostic_result.missing_severity:
_warn(
diff --git a/src/debputy/lsp/lsp_debian_changelog.py b/src/debputy/lsp/lsp_debian_changelog.py
index bde15b5..e3d2154 100644
--- a/src/debputy/lsp/lsp_debian_changelog.py
+++ b/src/debputy/lsp/lsp_debian_changelog.py
@@ -142,7 +142,7 @@ def _check_footer_line(
if day_name not in _KNOWN_WEEK_DAYS:
yield Diagnostic(
position_codec.range_to_client_units(lines, day_name_range_server_units),
- "Expected a three letter date here (Mon, Tue, ..., Sun).",
+ "Expected a three letter date here using US English format (Mon, Tue, ..., Sun).",
severity=DiagnosticSeverity.Error,
source="debputy",
)
diff --git a/src/debputy/lsp/lsp_debian_control.py b/src/debputy/lsp/lsp_debian_control.py
index ac08266..e33292d 100644
--- a/src/debputy/lsp/lsp_debian_control.py
+++ b/src/debputy/lsp/lsp_debian_control.py
@@ -432,6 +432,18 @@ def _render_package_lookup(
f"This build-dependency will activate the `dh` sequence called `{sequence}`."
)
segments.append("")
+
+ elif (
+ known_field.name == "Build-Depends"
+ and name.startswith("debputy-plugin-")
+ and len(name) > 15
+ ):
+ plugin_name = name[15:]
+ segments.append(
+ f"This build-dependency will activate the `debputy` plugin called `{plugin_name}`."
+ )
+ segments.append("")
+
segments.extend(
[
f"Synopsis: {provider.synopsis}",
@@ -492,6 +504,23 @@ def _render_package_by_name(
)
+ _disclaimer(is_empty)
)
+ if (
+ known_field.name == "Build-Depends"
+ and name.startswith("debputy-plugin-")
+ and len(name) > 15
+ ):
+ plugin_name = name[15:]
+ return (
+ textwrap.dedent(
+ f"""\
+ # {name}
+
+ This build-dependency will activate the `debputy` plugin called `{plugin_name}`.
+
+ """
+ )
+ + _disclaimer(is_empty)
+ )
return (
textwrap.dedent(
f"""\
diff --git a/src/debputy/lsp/lsp_debian_control_reference_data.py b/src/debputy/lsp/lsp_debian_control_reference_data.py
index 91eb6c2..8f8fb10 100644
--- a/src/debputy/lsp/lsp_debian_control_reference_data.py
+++ b/src/debputy/lsp/lsp_debian_control_reference_data.py
@@ -314,7 +314,7 @@ ALL_PRIORITIES = allowed_values(
),
Keyword(
"important",
- synopsis_doc="[RARE]: Bare minimum of bare minimum of commonly-expected and necessary tools",
+ synopsis_doc="[RARE]: Bare minimum of commonly-expected and necessary tools",
hover_text=textwrap.dedent(
"""\
The *important* packages are a bare minimum of commonly-expected and necessary tools.
@@ -4339,7 +4339,8 @@ _DTESTSCTRL_FIELDS = _fields(
FieldValueClass.COMMA_SEPARATED_LIST,
default_value="@",
synopsis_doc="Dependencies for running the tests",
- hover_text="""\
+ hover_text=textwrap.dedent(
+ """\
Declares that the specified packages must be installed for the test
to go ahead. This supports all features of dpkg dependencies, including
the architecture qualifiers (see
@@ -4372,7 +4373,8 @@ _DTESTSCTRL_FIELDS = _fields(
the source tree's Build-Dependencies are *not* necessarily
installed, and if you specify any Depends, no binary packages from
the source are installed unless explicitly requested.
- """,
+ """
+ ),
),
DTestsCtrlKnownField(
"Features",
diff --git a/src/debputy/lsp/lsp_generic_deb822.py b/src/debputy/lsp/lsp_generic_deb822.py
index 4340abc..cde6e8b 100644
--- a/src/debputy/lsp/lsp_generic_deb822.py
+++ b/src/debputy/lsp/lsp_generic_deb822.py
@@ -380,11 +380,17 @@ def deb822_hover(
return None
hover_text = keyword.hover_text
if hover_text is not None:
- hover_text = f"# Value `{keyword.value}` (Field: {known_field.name})\n\n{hover_text}"
+ header = "`{VALUE}` (Field: {FIELD_NAME})".format(
+ VALUE=keyword.value,
+ FIELD_NAME=known_field.name,
+ )
+ hover_text = f"# {header})\n\n{hover_text}"
else:
hover_text = known_field.hover_text
if hover_text is None:
- hover_text = f"The field {current_field} had no documentation."
+ hover_text = (
+ f"No documentation is available for the field {current_field}."
+ )
hover_text = f"# {known_field.name}\n\n{hover_text}"
if hover_text is None:
diff --git a/src/debputy/plugin/debputy/build_system_rules.py b/src/debputy/plugin/debputy/build_system_rules.py
index 454b2db..043b8fa 100644
--- a/src/debputy/plugin/debputy/build_system_rules.py
+++ b/src/debputy/plugin/debputy/build_system_rules.py
@@ -930,6 +930,8 @@ class DebhelperBuildSystemRule(StepBasedBuildSystemRule):
try:
v = subprocess.check_output(
["dh_assistant", "which-build-system"],
+ # Packages without `debhelper-compat` will trigger an error, which will just be noise
+ stderr=subprocess.DEVNULL,
cwd=source_root.fs_path,
)
except subprocess.CalledProcessError:
diff --git a/src/debputy/util.py b/src/debputy/util.py
index 0824569..76f4076 100644
--- a/src/debputy/util.py
+++ b/src/debputy/util.py
@@ -863,6 +863,7 @@ def change_log_level(
) -> None:
if _DEFAULT_LOGGER is not None:
_DEFAULT_LOGGER.setLevel(log_level)
+ logging.getLogger("").setLevel(log_level)
def current_log_level() -> Optional[int]: