Files
aws-cli-cmd/aws-cli-cmd.spec
Robert Schweikert b7f99067e8 RPM Update Fix
During package update the postun scriptlet of the old package runs after the
post section of the new package. The postun unregistered the flake
unconditionally thus removing the command that was just set up by the
new package, (bsc#1253743). Make postun conditional such that the flake
deregistration does not happen on package update but only when the package
is being completely removed. Further safeguard the flake artifacts and restore
them if they have disappeared due to an unguarded postun. Last but not least
fix the dependency to ensure we have the proper sdk container image.
2025-11-19 12:29:12 -05:00

116 lines
3.9 KiB
RPMSpec

#
# 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.2
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 [ -L /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"
# bsc#1253743 older packages did not differentiate between upgrade
# and package removal as such on upgrade the command disappeared.
# Save the newly registered flake and restore it posttrans if it was
# deleted by the postun in th eold package.
# Remove this hack on or after 2026-11-30
if [ "$1" -ge 2 ]; then
cp -P /usr/bin/aws /usr/bin/aws.bck
cp /usr/share/flakes/aws.yaml /usr/share/flakes/aws.yaml.bck
fi
fi
%postun
if [ "$YAST_IS_RUNNING" != "instsys" ] ; then
if [ "$1" -eq 0 ]; then
flake-ctl podman remove --app /usr/bin/aws
fi
fi
%posttrans
# bsc#1253743 older packages did not differentiate between upgrade
# and package removal as such on upgrade the command disappeared.
# Restore the command set up in post of this package if it got wiped
# out by the postun of the old package.
# The posttrans can be removed on or after 2026-11-30
if [ ! -f /usr/bin/aws ] && [ -f /usr/bin/aws.bck ]; then
echo "Restoring aws command"
cp -P /usr/bin/aws.bck /usr/bin/aws
mv /usr/share/flakes/aws.yaml.bck /usr/share/flakes/aws.yaml
rm /usr/bin/aws.bck
fi
%files
%ghost %{_bindir}/aws