From 53e1810c55152c06442aedb169147420ae5f137e Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Wed, 1 May 2024 09:10:37 -0500 Subject: [PATCH] Initial package Resolves: RHEL-14523 Signed-off-by: Major Hayden --- .gitignore | 1 + awscli2-remove-colorama.patch | 269 ++++++++++++++++++++++++++++++++++ awscli2.spec | 126 ++++++++++++++++ gating.yaml | 6 + sources | 1 + 5 files changed, 403 insertions(+) create mode 100644 awscli2-remove-colorama.patch create mode 100644 awscli2.spec create mode 100644 gating.yaml create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..04b91d1 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/aws-cli-2.15.31.tar.gz diff --git a/awscli2-remove-colorama.patch b/awscli2-remove-colorama.patch new file mode 100644 index 0000000..1a42374 --- /dev/null +++ b/awscli2-remove-colorama.patch @@ -0,0 +1,269 @@ +From 0fd1ede2fd0c1898ff8360afd210c4ff3d22034f Mon Sep 17 00:00:00 2001 +From: Major Hayden +Date: Wed, 1 May 2024 08:42:55 -0500 +Subject: [PATCH] Remove colorama + +--- + awscli/customizations/configure/sso.py | 5 ++-- + awscli/customizations/history/show.py | 11 +------ + awscli/customizations/logs/tail.py | 10 ++----- + awscli/formatter.py | 3 +- + awscli/table.py | 29 +------------------ + exe/pyinstaller/hook-awscli.py | 1 - + pyproject.toml | 3 +- + .../build_system/functional/test_utils.py | 4 --- + tests/backends/test_pep517.py | 1 - + tests/dependencies/test_closure.py | 1 - + 10 files changed, 8 insertions(+), 60 deletions(-) + +diff --git a/awscli/customizations/configure/sso.py b/awscli/customizations/configure/sso.py +index 5a650a367..881cc9bd5 100644 +--- a/awscli/customizations/configure/sso.py ++++ b/awscli/customizations/configure/sso.py +@@ -17,7 +17,6 @@ import os + import logging + import re + +-import colorama + from botocore import UNSIGNED + from botocore.config import Config + from botocore.configprovider import ConstantProvider +@@ -619,10 +618,10 @@ class ConfigureSSOCommand(BaseSSOConfigurationCommand): + + def _warn_configuring_using_legacy_format(self): + uni_print( +- f'{colorama.Style.BRIGHT}WARNING: Configuring using legacy format ' ++ f'WARNING: Configuring using legacy format ' + f'(e.g. without an SSO session).\n' + f'Consider re-running "configure sso" command and providing ' +- f'a session name.\n{colorama.Style.RESET_ALL}' ++ f'a session name.\n' + ) + + def _prompt_for_sso_account_and_role(self, sso, sso_token): +diff --git a/awscli/customizations/history/show.py b/awscli/customizations/history/show.py +index 587bc13de..0eac9f7db 100644 +--- a/awscli/customizations/history/show.py ++++ b/awscli/customizations/history/show.py +@@ -16,8 +16,6 @@ import sys + import xml.parsers.expat + import xml.dom.minidom + +-import colorama +- + from awscli.table import COLORAMA_KWARGS + from awscli.compat import six + from awscli.customizations.history.commands import HistorySubcommand +@@ -169,19 +167,12 @@ class DetailedFormatter(Formatter): + }, + } + +- _COMPONENT_COLORS = { +- 'title': colorama.Style.BRIGHT, +- 'description': colorama.Fore.CYAN +- } +- + def __init__(self, output=None, include=None, exclude=None, colorize=True): + super(DetailedFormatter, self).__init__(output, include, exclude) + self._request_id_to_api_num = {} + self._num_api_calls = 0 + self._colorize = colorize + self._value_pformatter = SectionValuePrettyFormatter() +- if self._colorize: +- colorama.init(**COLORAMA_KWARGS) + + def _display(self, event_record): + section_definition = self._SECTIONS.get(event_record['event_type']) +@@ -254,7 +245,7 @@ class DetailedFormatter(Formatter): + def _color_if_configured(self, text, component): + if self._colorize: + color = self._COMPONENT_COLORS[component] +- return color + text + colorama.Style.RESET_ALL ++ return color + text + return text + + +diff --git a/awscli/customizations/logs/tail.py b/awscli/customizations/logs/tail.py +index cb3151003..3a26827c5 100644 +--- a/awscli/customizations/logs/tail.py ++++ b/awscli/customizations/logs/tail.py +@@ -18,7 +18,6 @@ import time + + from botocore.utils import parse_timestamp, datetime2timestamp + from dateutil import tz +-import colorama + + from awscli.compat import get_stdout_text_writer + from awscli.utils import is_a_tty +@@ -27,21 +26,16 @@ from awscli.customizations.commands import BasicCommand + + class BaseLogEventsFormatter(object): + +- _TIMESTAMP_COLOR = colorama.Fore.GREEN +- _STREAM_NAME_COLOR = colorama.Fore.CYAN +- +- def __init__(self, output, colorize=True): ++ def __init__(self, output, colorize=False): + self._output = output + self._colorize = colorize +- if self._colorize: +- colorama.init(autoreset=True, strip=False) + + def display_log_event(self, log_event): + raise NotImplementedError('display_log_event()') + + def _color_if_configured(self, text, color): + if self._colorize: +- return color + text + colorama.Style.RESET_ALL ++ return color + text + return text + + def _write_log_event(self, log_event): +diff --git a/awscli/formatter.py b/awscli/formatter.py +index 78566dd35..38f003859 100644 +--- a/awscli/formatter.py ++++ b/awscli/formatter.py +@@ -18,7 +18,7 @@ from botocore.utils import set_value_from_jmespath + from botocore.paginate import PageIterator + from ruamel.yaml import YAML + +-from awscli.table import MultiTable, Styler, ColorizedStyler ++from awscli.table import MultiTable, Styler + from awscli import text + from awscli import compat + from awscli.utils import json_encoder +@@ -206,7 +206,6 @@ class TableFormatter(FullyBufferedFormatter): + self.table = MultiTable(initial_section=False, + column_separator='|', styler=styler) + elif args.color == 'on': +- styler = ColorizedStyler() + self.table = MultiTable(initial_section=False, + column_separator='|', styler=styler) + else: +diff --git a/awscli/table.py b/awscli/table.py +index df96392fc..ba3cfb9d0 100644 +--- a/awscli/table.py ++++ b/awscli/table.py +@@ -14,8 +14,6 @@ import sys + import struct + import unicodedata + +-import colorama +- + from awscli.utils import is_a_tty + from awscli.compat import six + +@@ -161,28 +159,6 @@ class Styler(object): + return text + + +-class ColorizedStyler(Styler): +- def __init__(self): +- colorama.init(**COLORAMA_KWARGS) +- +- def style_title(self, text): +- # Originally bold + underline +- return text +- #return colorama.Style.BOLD + text + colorama.Style.RESET_ALL +- +- def style_header_column(self, text): +- # Originally underline +- return text +- +- def style_row_element(self, text): +- return (colorama.Style.BRIGHT + colorama.Fore.BLUE + +- text + colorama.Style.RESET_ALL) +- +- def style_indentation_char(self, text): +- return (colorama.Style.DIM + colorama.Fore.YELLOW + +- text + colorama.Style.RESET_ALL) +- +- + class MultiTable(object): + def __init__(self, terminal_width=None, initial_section=True, + column_separator='|', terminal=None, +@@ -196,10 +172,7 @@ class MultiTable(object): + self._sections = [] + if styler is None: + # Move out to factory. +- if is_a_tty(): +- self._styler = ColorizedStyler() +- else: +- self._styler = Styler() ++ self._styler = Styler() + else: + self._styler = styler + self._rendering_index = 0 +diff --git a/exe/pyinstaller/hook-awscli.py b/exe/pyinstaller/hook-awscli.py +index 617b71d92..2ea109556 100644 +--- a/exe/pyinstaller/hook-awscli.py ++++ b/exe/pyinstaller/hook-awscli.py +@@ -9,7 +9,6 @@ hiddenimports = [ + 'configparser', + 'xml.etree', + 'pipes', +- 'colorama', + 'awscli.handlers', + # NOTE: This can be removed once this hidden import issue related to + # setuptools and PyInstaller is resolved: +diff --git a/pyproject.toml b/pyproject.toml +index 76c757b68..4d4165444 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -28,7 +28,6 @@ classifiers = [ + "Programming Language :: Python :: 3.11", + ] + dependencies = [ +- "colorama>=0.2.5,<0.4.7", + "docutils>=0.10,<0.20", + "cryptography>=3.3.2,<40.0.2", + "ruamel.yaml>=0.15.0,<=0.17.21", +@@ -98,4 +97,4 @@ filterwarnings = [ + ] + + [tool.black] +-line-length = 80 +\ No newline at end of file ++line-length = 80 +diff --git a/tests/backends/build_system/functional/test_utils.py b/tests/backends/build_system/functional/test_utils.py +index 683cc7ab2..c93b0074e 100644 +--- a/tests/backends/build_system/functional/test_utils.py ++++ b/tests/backends/build_system/functional/test_utils.py +@@ -39,10 +39,6 @@ def utils(): + "flit_core>=3.7.1,<3.7.2", + Requirement("flit_core", ">=3.7.1", "<3.7.2"), + ), +- ( +- "colorama>=0.2.5,<0.4.4", +- Requirement("colorama", ">=0.2.5", "<0.4.4"), +- ), + ("docutils>=0.10,<0.16", Requirement("docutils", ">=0.10", "<0.16")), + ( + "cryptography>=3.3.2,<37.0.0", +diff --git a/tests/backends/test_pep517.py b/tests/backends/test_pep517.py +index 5f60e04eb..ef763c81a 100644 +--- a/tests/backends/test_pep517.py ++++ b/tests/backends/test_pep517.py +@@ -242,7 +242,6 @@ def test_get_requires_for_build_wheel(config_settings, repo_root): + config_settings + ) + expected_requirements = [ +- "colorama", + "docutils", + "cryptography", + "ruamel.yaml", +diff --git a/tests/dependencies/test_closure.py b/tests/dependencies/test_closure.py +index 6231438cd..fcb38c591 100644 +--- a/tests/dependencies/test_closure.py ++++ b/tests/dependencies/test_closure.py +@@ -139,7 +139,6 @@ class TestDependencyClosure: + expected_dependencies = { + "awscrt", + "cffi", +- "colorama", + "cryptography", + "distro", + "docutils", +-- +2.44.0 + diff --git a/awscli2.spec b/awscli2.spec new file mode 100644 index 0000000..986966e --- /dev/null +++ b/awscli2.spec @@ -0,0 +1,126 @@ +%bcond tests 1 + +%global pkgname aws-cli + +Name: awscli2 +Version: 2.15.31 +Release: 1%{?dist} + +Summary: Universal Command Line Environment for AWS, version 2 +# all files are licensed under Apache-2.0, except: +# - awscli/topictags.py is MIT +# - awscli/botocore/vendored/six.py is MIT +License: Apache-2.0 AND MIT +URL: https://github.com/aws/aws-cli/tree/v2 +Source0: https://github.com/aws/aws-cli/archive/%{version}/%{pkgname}-%{version}.tar.gz + +# Remove colorama dependency. +Patch: awscli2-remove-colorama.patch + +BuildArch: noarch + +BuildRequires: pyproject-rpm-macros +BuildRequires: python3-devel +BuildRequires: python3-pip +BuildRequires: python-unversioned-command +BuildRequires: procps-ng + +BuildRequires: python3dist(awscrt) +BuildRequires: python3dist(cryptography) +BuildRequires: python3dist(distro) +BuildRequires: python3dist(docutils) +BuildRequires: python3dist(flit-core) +BuildRequires: python3dist(jmespath) +BuildRequires: python3dist(prompt-toolkit) +BuildRequires: python3dist(python-dateutil) +BuildRequires: python3dist(ruamel-yaml-clib) +BuildRequires: python3dist(urllib3) + +%if %{with tests} +BuildRequires: python3dist(pytest) +%endif + +Recommends: groff + +# python-awscrt does not build on s390x +ExcludeArch: s390x + + +%description +This package provides version 2 of the unified command line +interface to Amazon Web Services. + + +%prep +%autosetup -p1 -n %{pkgname}-%{version} + +# fix permissions +find awscli/examples/ -type f -name '*.rst' -executable -exec chmod -x '{}' + + +# use unittest.mock +find -type f -name '*.py' -exec sed \ + -e 's/^\( *\)import mock$/\1from unittest import mock/' \ + -e 's/^\( *\)from mock import mock/\1from unittest import mock/' \ + -e 's/^\( *\)from mock import/\1from unittest.mock import/' \ + -i '{}' + + + +%build +%pyproject_wheel + + +%install +%pyproject_install +%pyproject_save_files awscli + +# remove unnecessary scripts +rm -vf %{buildroot}%{_bindir}/{aws_bash_completer,aws_zsh_completer.sh,aws.cmd} + +# install shell completion +install -Dpm0644 bin/aws_bash_completer \ + %{buildroot}%{_datadir}/bash-completion/completions/aws +install -Dpm0644 bin/aws_zsh_completer.sh \ + %{buildroot}%{_datadir}/zsh/site-functions/_awscli + + +%check +export OPENSSL_ENABLE_SHA1_SIGNATURES=yes + +%pyproject_check_import + +%if %{with tests} +# Upstream also treats some warnings, such as DeprecationWarning, as a failure, but the +# code has deprecation warnings in it. So, we disable warnings as errors for both +# sets of tests below. Also skip tests that depend on colorama. +%pytest tests/unit \ + --disable-pytest-warnings -Wd \ + -k "not test_non_aggregate_keys and not test_can_use_color" \ + --ignore tests/unit/output/test_yaml_output.py \ + --ignore tests/unit/customizations/logs/test_tail.py + +# awscli has some command runners built into tests and some of them eat the environment +# variables, especially PYTHONPATH, and cause awscli to fail to import. Also skip tests +# that depend on colorama. +%pytest tests/functional \ + --disable-pytest-warnings -Wd \ + --ignore tests/functional/autocomplete/test_completion_files.py \ + --ignore tests/functional/botocore/test_waiter_config.py \ + --ignore tests/functional/botocore/leak/test_resource_leaks.py \ + --ignore tests/functional/dependencies/test_colorama.py \ + --ignore tests/functional/logs/test_tail.py \ + -k "not test_smoke_test_completer and not test_pipe_color" +%endif + + +%files -f %{pyproject_files} +%license LICENSE.txt +%doc README.rst +%{_bindir}/aws +%{_bindir}/aws_completer +%{_datadir}/bash-completion/completions/aws +%{_datadir}/zsh/site-functions/_awscli + + +%changelog +* Wed Jan 31 2024 Major Hayden - 2.15.31-1 +- Initial RHEL 9 package. diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..648918d --- /dev/null +++ b/gating.yaml @@ -0,0 +1,6 @@ +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/sources b/sources new file mode 100644 index 0000000..d9cdd8b --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (aws-cli-2.15.31.tar.gz) = 3600409edf0218254f8dfc4346cd0e1df3af2d4047fca2e021f655a48344ec3f058a48258d830b150ed92ede98e723d164a200fcbd519fd8a1002bc6d0c0294d