From a42899064c7d3bb4c706cd9e9d1c49eb68cd2762 Mon Sep 17 00:00:00 2001
From: Greg Hogan <code@greghogan.com>
Date: Fri, 30 Apr 2021 14:00:27 +0000
Subject: [PATCH 08/12] gnu: Add aws-c-auth.

* gnu/packages/c.scm (aws-c-auth): New variable.
* gnu/packages/patches/aws-c-auth-cmake-prefix.patch,
gnu/packages/patches/aws-c-auth-disable-networking-tests.patch: New files.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                  |  2 +
 gnu/packages/c.scm                            | 33 ++++++++++
 .../patches/aws-c-auth-cmake-prefix.patch     | 13 ++++
 .../aws-c-auth-disable-networking-tests.patch | 64 +++++++++++++++++++
 4 files changed, 112 insertions(+)
 create mode 100644 gnu/packages/patches/aws-c-auth-cmake-prefix.patch
 create mode 100644 gnu/packages/patches/aws-c-auth-disable-networking-tests.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 5c163b7dc7..0220ff9391 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -863,6 +863,8 @@ dist_patch_DATA =						\
   %D%/packages/patches/avahi-localstatedir.patch		\
   %D%/packages/patches/avidemux-install-to-lib.patch		\
   %D%/packages/patches/awesome-reproducible-png.patch		\
+  %D%/packages/patches/aws-c-auth-cmake-prefix.patch		\
+  %D%/packages/patches/aws-c-auth-disable-networking-tests.patch\
   %D%/packages/patches/aws-c-cal-cmake-prefix.patch		\
   %D%/packages/patches/aws-c-compression-cmake-prefix.patch	\
   %D%/packages/patches/aws-c-event-stream-cmake-prefix.patch  \
diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index a9b92cb6a1..94e731c9bf 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -770,3 +770,36 @@ specifications.")
 currently limited to Huffman encoding and decoding.")
     (home-page "https://github.com/awslabs/aws-c-compression")
     (license license:asl2.0)))
+
+(define-public aws-c-auth
+  (package
+    (name "aws-c-auth")
+    (version "0.6.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url (string-append "https://github.com/awslabs/" name))
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0yh9s6q3ahq39xgvihp2a5cn9h39qlq8wfjc32m0ayi9x739rbqg"))
+              (patches
+               (search-patches
+                "aws-c-auth-cmake-prefix.patch"
+                "aws-c-auth-disable-networking-tests.patch"))))
+    (build-system cmake-build-system)
+    (arguments
+     '(#:configure-flags
+       '("-DBUILD_SHARED_LIBS=ON")))
+    (propagated-inputs
+     `(("aws-c-cal" ,aws-c-cal)
+       ("aws-c-common" ,aws-c-common)
+       ("aws-c-http" ,aws-c-http)
+       ("aws-c-io" ,aws-c-io)))
+    (synopsis "Amazon Web Services client-side authentication library")
+    (description
+     "This library provides a C99 implementation for AWS client-side
+authentication.")
+    (home-page "https://github.com/awslabs/aws-c-auth")
+    (license license:asl2.0)))
diff --git a/gnu/packages/patches/aws-c-auth-cmake-prefix.patch b/gnu/packages/patches/aws-c-auth-cmake-prefix.patch
new file mode 100644
index 0000000000..da3e4eb4a5
--- /dev/null
+++ b/gnu/packages/patches/aws-c-auth-cmake-prefix.patch
@@ -0,0 +1,13 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -6,6 +6,10 @@ if (POLICY CMP0069)
+     cmake_policy(SET CMP0069 NEW) # Enable LTO/IPO if available in the compiler, see AwsCFlags
+ endif()
+ 
++if (DEFINED ENV{CMAKE_PREFIX_PATH})
++    set(CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
++endif()
++
+ if (DEFINED CMAKE_PREFIX_PATH)
+     file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
+ endif()
diff --git a/gnu/packages/patches/aws-c-auth-disable-networking-tests.patch b/gnu/packages/patches/aws-c-auth-disable-networking-tests.patch
new file mode 100644
index 0000000000..905247f528
--- /dev/null
+++ b/gnu/packages/patches/aws-c-auth-disable-networking-tests.patch
@@ -0,0 +1,64 @@
+--- a/tests/CMakeLists.txt
++++ b/tests/CMakeLists.txt
+@@ -19,8 +19,8 @@ add_test_case(profile_credentials_provider_environment_test)
+ add_test_case(credentials_provider_first_in_chain_test)
+ add_test_case(credentials_provider_second_in_chain_test)
+ add_test_case(credentials_provider_null_chain_test)
+-add_test_case(credentials_provider_default_basic_test)
+-add_test_case(credentials_provider_default_manual_tls_test)
++#add_test_case(credentials_provider_default_basic_test)
++#add_test_case(credentials_provider_default_manual_tls_test)
+ add_test_case(credentials_provider_imds_new_destroy)
+ add_test_case(credentials_provider_imds_connect_failure)
+ add_test_case(credentials_provider_imds_token_request_failure)
+@@ -58,28 +58,28 @@ add_test_case(credentials_provider_x509_basic_success)
+ add_test_case(credentials_provider_x509_success_multi_part_doc)
+ add_test_case(credentials_provider_x509_real_new_destroy)
+ 
+-add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_env)
+-add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_config)
+-add_net_test_case(credentials_provider_sts_web_identity_new_failed_without_env_and_config)
+-add_net_test_case(credentials_provider_sts_web_identity_connect_failure)
+-add_net_test_case(credentials_provider_sts_web_identity_request_failure)
+-add_net_test_case(credentials_provider_sts_web_identity_bad_document_failure)
+-add_net_test_case(credentials_provider_sts_web_identity_test_retry_error1)
+-add_net_test_case(credentials_provider_sts_web_identity_test_retry_error2)
+-add_net_test_case(credentials_provider_sts_web_identity_basic_success_env)
+-add_net_test_case(credentials_provider_sts_web_identity_basic_success_config)
+-add_net_test_case(credentials_provider_sts_web_identity_success_multi_part_doc)
+-add_net_test_case(credentials_provider_sts_web_identity_real_new_destroy)
+-
+-add_net_test_case(credentials_provider_sts_direct_config_succeeds)
+-add_net_test_case(credentials_provider_sts_direct_config_succeeds_after_retry)
+-add_net_test_case(credentials_provider_sts_direct_config_invalid_doc)
+-add_net_test_case(credentials_provider_sts_direct_config_connection_failed)
+-add_net_test_case(credentials_provider_sts_direct_config_service_fails)
+-add_net_test_case(credentials_provider_sts_from_profile_config_succeeds)
+-add_net_test_case(credentials_provider_sts_from_profile_config_manual_tls_succeeds)
+-add_net_test_case(credentials_provider_sts_from_profile_config_environment_succeeds)
+-add_net_test_case(credentials_provider_sts_cache_expiration_conflict)
++#add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_env)
++#add_net_test_case(credentials_provider_sts_web_identity_new_destroy_from_config)
++#add_net_test_case(credentials_provider_sts_web_identity_new_failed_without_env_and_config)
++#add_net_test_case(credentials_provider_sts_web_identity_connect_failure)
++#add_net_test_case(credentials_provider_sts_web_identity_request_failure)
++#add_net_test_case(credentials_provider_sts_web_identity_bad_document_failure)
++#add_net_test_case(credentials_provider_sts_web_identity_test_retry_error1)
++#add_net_test_case(credentials_provider_sts_web_identity_test_retry_error2)
++#add_net_test_case(credentials_provider_sts_web_identity_basic_success_env)
++#add_net_test_case(credentials_provider_sts_web_identity_basic_success_config)
++#add_net_test_case(credentials_provider_sts_web_identity_success_multi_part_doc)
++#add_net_test_case(credentials_provider_sts_web_identity_real_new_destroy)
++
++#add_net_test_case(credentials_provider_sts_direct_config_succeeds)
++#add_net_test_case(credentials_provider_sts_direct_config_succeeds_after_retry)
++#add_net_test_case(credentials_provider_sts_direct_config_invalid_doc)
++#add_net_test_case(credentials_provider_sts_direct_config_connection_failed)
++#add_net_test_case(credentials_provider_sts_direct_config_service_fails)
++#add_net_test_case(credentials_provider_sts_from_profile_config_succeeds)
++#add_net_test_case(credentials_provider_sts_from_profile_config_manual_tls_succeeds)
++#add_net_test_case(credentials_provider_sts_from_profile_config_environment_succeeds)
++#add_net_test_case(credentials_provider_sts_cache_expiration_conflict)
+ 
+ add_test_case(credentials_provider_process_new_destroy_from_config)
+ add_test_case(credentials_provider_process_new_failed)
-- 
2.33.0

