From 8589b69f9ff283ec3ae990466bed3b84702eb8e1 Mon Sep 17 00:00:00 2001 From: Tim Orling Date: Sat, 15 Jan 2022 21:29:04 -0800 Subject: python3-cryptography: upgrade 3.3.2 -> 36.0.1 See https://github.com/pyca/cryptography/blob/main/CHANGELOG.rst#3601---2021-12-14 for changes * Add PSF-2.0 license and explicitly add checksums for the LICENSE files that are packaged. * RDEPENDS on python3-hypothesis (in oe-core) for ptest so we can drop the patch for skipping. * Drop backported patch for openssl3 support. * inherit new setuptools_rust class (which inherits new pyo3 class, which inherits cargo and python3-dir). * RDEPENDS on python3-pytest-subtests for ptest * Copy pyproject.toml for ptest as it defines the pytest.marker(s) needed * Cleanup and alphabetize the RDEPENDS * Use 'cargo bitbake' to generate the crate:// SRC_URIs - Needed some hacks to the Cargo.toml in src/rust/ to make this work (probably only package.repository was strictly required): [package] description = "cryptography includes both high level recipes and low level interfaces to common cryptographic algorithms such as symmetric ciphers, message digests, and key derivation functions." homepage = "https://github.com/pyca/cryptography" repository = "https://github.com/pyca/cryptography" * Add patches to src/rust/Cargo.toml to fix cargo errors including pem version * Add check-memfree.py to ptest to check for sufficient free memory Signed-off-by: Tim Orling Signed-off-by: Khem Raj Signed-off-by: Trevor Gamblin --- .../0001-Cargo.toml-specify-pem-version.patch | 31 +++++++++++ .../0002-Cargo.toml-edition-2018-2021.patch | 28 ++++++++++ .../python/python3-cryptography/check-memfree.py | 10 ++++ .../python/python3-cryptography/h-test.patch | 10 ---- .../python/python3-cryptography/openssl3.patch | 62 ---------------------- .../python/python3-cryptography/run-ptest | 4 +- 6 files changed, 72 insertions(+), 73 deletions(-) create mode 100644 meta-python/recipes-devtools/python/python3-cryptography/0001-Cargo.toml-specify-pem-version.patch create mode 100644 meta-python/recipes-devtools/python/python3-cryptography/0002-Cargo.toml-edition-2018-2021.patch create mode 100755 meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py delete mode 100644 meta-python/recipes-devtools/python/python3-cryptography/h-test.patch delete mode 100644 meta-python/recipes-devtools/python/python3-cryptography/openssl3.patch (limited to 'meta-python/recipes-devtools/python/python3-cryptography') diff --git a/meta-python/recipes-devtools/python/python3-cryptography/0001-Cargo.toml-specify-pem-version.patch b/meta-python/recipes-devtools/python/python3-cryptography/0001-Cargo.toml-specify-pem-version.patch new file mode 100644 index 0000000000..d7ab757bb5 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-cryptography/0001-Cargo.toml-specify-pem-version.patch @@ -0,0 +1,31 @@ +From ec8d3f3c61280c8140b34ed1479baef5e706f064 Mon Sep 17 00:00:00 2001 +From: Tim Orling +Date: Fri, 14 Jan 2022 22:02:25 -0800 +Subject: [PATCH] Cargo.toml: specify pem version + +pem = "1.0" is not resolving, specify the current +pem = { version: "1.0.2"} + +Upstream-Status: Pending + +Signed-off-by: Tim Orling +--- + src/rust/Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml +index 617167d0..174eaa80 100644 +--- a/src/rust/Cargo.toml ++++ b/src/rust/Cargo.toml +@@ -9,7 +9,7 @@ publish = false + lazy_static = "1" + pyo3 = { version = "0.15.1" } + asn1 = { version = "0.8.7", default-features = false, features = ["derive"] } +-pem = "1.0" ++pem = { version = "1.0.2" } + chrono = { version = "0.4", default-features = false, features = ["alloc", "clock"] } + ouroboros = "0.13" + +-- +2.30.2 + diff --git a/meta-python/recipes-devtools/python/python3-cryptography/0002-Cargo.toml-edition-2018-2021.patch b/meta-python/recipes-devtools/python/python3-cryptography/0002-Cargo.toml-edition-2018-2021.patch new file mode 100644 index 0000000000..366e3a4d39 --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-cryptography/0002-Cargo.toml-edition-2018-2021.patch @@ -0,0 +1,28 @@ +From 4b73298b214a5b69ea6edf3c2e21dd82b2b29708 Mon Sep 17 00:00:00 2001 +From: Tim Orling +Date: Fri, 14 Jan 2022 22:34:59 -0800 +Subject: [PATCH 2/2] Cargo.toml: edition 2018 -> 2021 + +Upstream-Status: Pending + +Signed-off-by: Tim Orling +--- + src/rust/Cargo.toml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml +index 174eaa80..7ad053d9 100644 +--- a/src/rust/Cargo.toml ++++ b/src/rust/Cargo.toml +@@ -2,7 +2,7 @@ + name = "cryptography-rust" + version = "0.1.0" + authors = ["The cryptography developers "] +-edition = "2018" ++edition = "2021" + publish = false + + [dependencies] +-- +2.30.2 + diff --git a/meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py b/meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py new file mode 100755 index 0000000000..c111a9074c --- /dev/null +++ b/meta-python/recipes-devtools/python/python3-cryptography/check-memfree.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +# https://stackoverflow.com/questions/22102999/get-total-physical-memory-in-python/28161352 +import sys +meminfo = dict((i.split()[0].rstrip(':'),int(i.split()[1])) for i in open('/proc/meminfo').readlines()) +mem_free = meminfo['MemTotal']/1024./1024. +if mem_free < 2.: + raise RuntimeError("Insufficient free memory({:.3f}): requires > 2 GB".format(mem_free)) + sys.exit(1) +else: + print("Free memory: {:.3f} GB".format(mem_free)) diff --git a/meta-python/recipes-devtools/python/python3-cryptography/h-test.patch b/meta-python/recipes-devtools/python/python3-cryptography/h-test.patch deleted file mode 100644 index 9f07c73803..0000000000 --- a/meta-python/recipes-devtools/python/python3-cryptography/h-test.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/tests/hypothesis/__init__.py -+++ b/tests/hypothesis/__init__.py -@@ -3,3 +3,7 @@ - # for complete details. - - from __future__ import absolute_import, division, print_function -+ -+import pytest -+hypothesis = pytest.importorskip("hypothesis") -+ diff --git a/meta-python/recipes-devtools/python/python3-cryptography/openssl3.patch b/meta-python/recipes-devtools/python/python3-cryptography/openssl3.patch deleted file mode 100644 index 25baa42cc9..0000000000 --- a/meta-python/recipes-devtools/python/python3-cryptography/openssl3.patch +++ /dev/null @@ -1,62 +0,0 @@ -Encourage our old python3-cryptography to at least start to work with OpenSSL 3. - -- Backport one patch to err.py to remove a symbol which has been removed in - OpenSSL 3, and isn't used in python3-cryptography. - (50ec692749b7e2e62685b443f5e629627b03987e) - -- Backport the detection of OpenSSL 3 and don't link to FIPS_mode/FIPS_mode_set - (parts of f08a7de651f9e6475c8c0a67d2a61ed8b669ddf6) - -This is *not* a complete backport of the 3.0 support, but is enough that packages -such as imgtool can import python3-cryptography and operate until the upgrade is -ready. - -Upstream-Status: Inappropriate -Signed-off-by: Ross Burton - -diff --git a/src/_cffi_src/openssl/cryptography.py b/src/_cffi_src/openssl/cryptography.py -index f24bee5a..920a86de 100644 ---- a/src/_cffi_src/openssl/cryptography.py -+++ b/src/_cffi_src/openssl/cryptography.py -@@ -35,6 +35,8 @@ INCLUDES = """ - - #define CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER \ - (OPENSSL_VERSION_NUMBER >= 0x1010006f && !CRYPTOGRAPHY_IS_LIBRESSL) -+#define CRYPTOGRAPHY_OPENSSL_300_OR_GREATER \ -+ (OPENSSL_VERSION_NUMBER >= 0x30000000 && !CRYPTOGRAPHY_IS_LIBRESSL) - - #define CRYPTOGRAPHY_OPENSSL_LESS_THAN_110J \ - (OPENSSL_VERSION_NUMBER < 0x101000af || CRYPTOGRAPHY_IS_LIBRESSL) -@@ -54,6 +56,7 @@ INCLUDES = """ - - TYPES = """ - static const int CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER; -+static const int CRYPTOGRAPHY_OPENSSL_300_OR_GREATER; - - static const int CRYPTOGRAPHY_OPENSSL_LESS_THAN_111; - static const int CRYPTOGRAPHY_OPENSSL_LESS_THAN_111B; -diff --git a/src/_cffi_src/openssl/err.py b/src/_cffi_src/openssl/err.py -index 0dd74146..42bab4d9 100644 ---- a/src/_cffi_src/openssl/err.py -+++ b/src/_cffi_src/openssl/err.py -@@ -40,7 +40,6 @@ void ERR_clear_error(void); - void ERR_put_error(int, int, int, const char *, int); - - int ERR_GET_LIB(unsigned long); --int ERR_GET_FUNC(unsigned long); - int ERR_GET_REASON(unsigned long); - - """ -diff --git a/src/_cffi_src/openssl/fips.py b/src/_cffi_src/openssl/fips.py -index c92bca49..38bfa231 100644 ---- a/src/_cffi_src/openssl/fips.py -+++ b/src/_cffi_src/openssl/fips.py -@@ -18,7 +18,7 @@ int FIPS_mode(void); - """ - - CUSTOMIZATIONS = """ --#if CRYPTOGRAPHY_IS_LIBRESSL -+#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_OPENSSL_300_OR_GREATER - static const long Cryptography_HAS_FIPS = 0; - int (*FIPS_mode_set)(int) = NULL; - int (*FIPS_mode)(void) = NULL; diff --git a/meta-python/recipes-devtools/python/python3-cryptography/run-ptest b/meta-python/recipes-devtools/python/python3-cryptography/run-ptest index 0ba239c2a4..1e97dda63e 100644 --- a/meta-python/recipes-devtools/python/python3-cryptography/run-ptest +++ b/meta-python/recipes-devtools/python/python3-cryptography/run-ptest @@ -1,2 +1,4 @@ #!/bin/sh -py.test +if ./check-memfree.py; then + pytest -vvvv tests/ +fi -- cgit v1.2.3-54-g00ecf