diff options
Diffstat (limited to 'debian/patches')
-rw-r--r-- | debian/patches/remove_vendored_code.patch | 67 | ||||
-rw-r--r-- | debian/patches/remove_version_check.patch | 74 | ||||
-rw-r--r-- | debian/patches/series | 2 |
3 files changed, 143 insertions, 0 deletions
diff --git a/debian/patches/remove_vendored_code.patch b/debian/patches/remove_vendored_code.patch new file mode 100644 index 0000000..c494771 --- /dev/null +++ b/debian/patches/remove_vendored_code.patch @@ -0,0 +1,67 @@ +Index: ansible-lint/src/ansiblelint/_vendor/__init__.py +=================================================================== +--- ansible-lint.orig/src/ansiblelint/_vendor/__init__.py ++++ /dev/null +@@ -1,48 +0,0 @@ +-import os +-import pkgutil +-import sys +-import warnings +- +-# This package exists to host vendored top-level Python packages for downstream packaging. Any Python packages +-# installed beneath this one will be masked from the Ansible loader, and available from the front of sys.path. +-# It is expected that the vendored packages will be loaded very early, so a warning will be fired on import of +-# the top-level ansible package if any packages beneath this are already loaded at that point. +-# +-# Python packages may be installed here during downstream packaging using something like: +-# pip install --upgrade -t (path to this dir) cryptography pyyaml packaging jinja2 +- +-# mask vendored content below this package from being accessed as a subpackage +-__path__ = [] +- +- +-def _ensure_vendored_path_entry() -> None: +- """ +- Ensure that any downstream-bundled content beneath this package is available at the top of sys.path +- """ +- # patch our vendored dir onto sys.path +- vendored_path_entry = os.path.dirname(__file__) +- vendored_module_names = { +- m[1] for m in pkgutil.iter_modules([vendored_path_entry], "") +- } # m[1] == m.name +- +- if vendored_module_names: +- # patch us early to load vendored deps transparently +- if vendored_path_entry in sys.path: +- # handle reload case by removing the existing entry, wherever it might be +- sys.path.remove(vendored_path_entry) +- sys.path.insert(0, vendored_path_entry) +- +- already_loaded_vendored_modules = set(sys.modules.keys()).intersection( +- vendored_module_names +- ) +- +- if already_loaded_vendored_modules: +- warnings.warn( +- "One or more Python packages bundled by this ansible-lint distribution were already " +- "loaded ({}). This may result in undefined behavior.".format( +- ", ".join(sorted(already_loaded_vendored_modules)) +- ) +- ) +- +- +-_ensure_vendored_path_entry() +Index: ansible-lint/src/ansiblelint/__init__.py +=================================================================== +--- ansible-lint.orig/src/ansiblelint/__init__.py ++++ ansible-lint/src/ansiblelint/__init__.py +@@ -20,7 +20,8 @@ + """Main ansible-lint package.""" + from __future__ import annotations + +-import ansiblelint._vendor ++# Patched on Debian to remove vendored code. ++#import ansiblelint._vendor + from ansiblelint.version import __version__ + + # make vendored top-level modules accessible EARLY diff --git a/debian/patches/remove_version_check.patch b/debian/patches/remove_version_check.patch new file mode 100644 index 0000000..8935b30 --- /dev/null +++ b/debian/patches/remove_version_check.patch @@ -0,0 +1,74 @@ +Description: Remove version check at runtime +Author: Samuel Henrique <samueloph@debian.org> +Forwarded: not-needed +Index: ansible-lint/src/ansiblelint/config.py +=================================================================== +--- ansible-lint.orig/src/ansiblelint/config.py ++++ ansible-lint/src/ansiblelint/config.py +@@ -216,51 +216,5 @@ def guess_install_method() -> str: + + + def get_version_warning() -> str: +- """Display warning if current version is outdated.""" +- # 0.1dev1 is special fallback version +- if __version__ == "0.1.dev1": # pragma: no cover +- return "" +- +- msg = "" +- data = {} +- current_version = Version(__version__) +- +- if not os.path.exists(CACHE_DIR): # pragma: no cover +- os.makedirs(CACHE_DIR) +- cache_file = f"{CACHE_DIR}/latest.json" +- refresh = True +- if os.path.exists(cache_file): +- age = time.time() - os.path.getmtime(cache_file) +- if age < 24 * 60 * 60: +- refresh = False +- with open(cache_file, encoding="utf-8") as f: +- data = json.load(f) +- +- if refresh or not data: +- release_url = ( +- "https://api.github.com/repos/ansible/ansible-lint/releases/latest" +- ) +- try: +- with urllib.request.urlopen(release_url) as url: +- data = json.load(url) +- with open(cache_file, "w", encoding="utf-8") as f: +- json.dump(data, f) +- except (URLError, HTTPError) as exc: # pragma: no cover +- _logger.debug( +- "Unable to fetch latest version from %s due to: %s", release_url, exc +- ) +- return "" +- +- html_url = data["html_url"] +- new_version = Version(data["tag_name"][1:]) # removing v prefix from tag +- +- if current_version > new_version: +- msg = "[dim]You are using a pre-release version of ansible-lint.[/]" +- elif current_version < new_version: +- msg = f"""[warning]A new release of ansible-lint is available: [red]{current_version}[/] → [green][link={html_url}]{new_version}[/][/][/]""" +- +- pip = guess_install_method() +- if pip: +- msg += f" Upgrade by running: [info]{pip}[/]" +- +- return msg ++ """Patched on Debian to not download release information from third parties""" ++ return "" +Index: ansible-lint/test/test_main.py +=================================================================== +--- ansible-lint.orig/test/test_main.py ++++ ansible-lint/test/test_main.py +@@ -46,7 +46,7 @@ def test_call_from_outside_venv(expected + warning_found = "PATH altered to include" in proc.stderr + assert warning_found is expected_warning + +- ++@pytest.mark.skip(reason="This functionality is disabled on Debian") + @pytest.mark.parametrize( + ("ver_diff", "found", "check", "outlen"), + ( diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..e2ec076 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1,2 @@ +remove_version_check.patch +remove_vendored_code.patch |