#
# spec file for package aws-cli-cmd
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%if 0%{?suse_version} >= 1600
%define pythons python313
%else
%define pythons python311
%endif
%global _sitelibdir %{%{pythons}_sitelib}

Name:           aws-cli-cmd
# We want the version to match the aws-cli version we ship
Version:        1.36.1
Release:        0
Summary:        Amazon Web Services Command Line Interface
License:        Apache-2.0
Group:          System/Management
URL:            some-github-project
Provides:       awscli = %{version}
Provides:       aws-cli = %{version}
Obsoletes:      aws-cli < %{version}
BuildArch:      noarch
# Package requirements on the system
Requires:       flake-pilot
Requires:       flake-pilot-podman
# Package requirements from runtime container
Requires:       (%{pythons}-PyYAML >= 3.10 with %{pythons}-PyYAML <= 6.1)
Requires:       (%{pythons}-colorama >= 0.2.5 with %{pythons}-colorama <= 0.5.0)
Requires:       (%{pythons}-docutils >= 0.10 with %{pythons}-docutils < 0.30)
Requires:       (%{pythons}-rsa >= 3.1.2 with %{pythons}-rsa < 5.0.0)
Requires:       %{pythons}-six
Requires:       %{pythons}-jmespath
Requires:       %{pythons}-python-dateutil
Requires:       %{pythons}-requests
Requires:       groff

# Dependent containers
Requires:       aws-sdk-image
# The command container
Requires:       aws-cli-image

%description
The AWS Command Line Interface (CLI) is a unified tool to manage AWS
services. With this tool, multiple AWS services can be controlled
from the command line and automated through scripts.

%prep

%build

%post
# The flake-ctl command comlains if the script to be created already exists.
# Remove the script from previous installations
if [ -e /usr/bin/aws ] ; then
    rm /usr/bin/aws
fi

if [ "$YAST_IS_RUNNING" != "instsys" ] ; then
    flake-ctl podman register \
        --app /usr/bin/aws \
        --container localhost/aws-cli \
        --base localhost/aws-sdk \
        --check-host-dependencies \
        --opt "\--interactive" \
        --opt "\--security-opt label=disable" \
        --opt "\--volume %HOME:/root" \
        --opt "\--volume /var/lib/ca-certificates:/var/lib/ca-certificates" \
        --opt "\-e HOME=/root"
fi

%postun
if [ "$YAST_IS_RUNNING" != "instsys" ] ; then
    flake-ctl podman remove --app /usr/bin/aws
fi

%files
