Package: dislocker / 0.7.3+git20240607-3

detect-PolarSSL-version.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Description: Correct detection of PolarSSL version
 This patch contributes to making dislocker cross-buildable.
Author: Helmut Grohne <helmut@subdivi.de>
Origin: debian, https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=1087365;filename=cross.patch;msg=5
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087365
Forwarded: no
Reviewed-by: Sven Geuer <sge@debian.org>
Last-Update: 2025-02-10
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- dislocker-0.7.3+git20240607.orig/cmake/FindPolarSSL.cmake
+++ dislocker-0.7.3+git20240607/cmake/FindPolarSSL.cmake
@@ -11,6 +11,7 @@
 # POLARSSL_INC_FOLDER
 # POLARSSL_REAL_NAME
 
+include(FindPkgConfig)
 include(FindPackageHandleStandardArgs)
 
 find_path(POLARSSL_INCLUDE_DIRS NAMES mbedtls/ssl.h HINTS /usr/local/include)
@@ -41,7 +42,12 @@
   endif()
 endif()
 
-find_package_handle_standard_args(POLARSSL REQUIRED_VARS POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES)
+pkg_check_modules(POLARSSL mbedcrypto)
+if (POLARSSL_FOUND AND POLARSSL_LIBRARIES AND POLARSSL_INCLUDE_DIRS)
+  set(POLARSSL_VERSION_STRING "${POLARSSL_VERSION}")
+else()
+  find_package_handle_standard_args(POLARSSL VERSION_VAR POLARSSL_VERSION_STRING REQUIRED_VARS POLARSSL_INCLUDE_DIRS POLARSSL_LIBRARIES)
+endif()
 
 if( ${POLARSSL_LIBRARIES-NOTFOUND} )
   message(FATAL_ERROR "Failed to get info from PolarSSL library, check your PolarSSL installation")
@@ -62,7 +68,7 @@
   set(ENV{SDKROOT} "${envSdkRoot}")
 endif()
 
-if( NOT CMAKE_CROSSCOMPILING )
+if( NOT POLARSSL_VERSION_STRING )
   execute_process(
     COMMAND echo "#include <${POLARSSL_INC_FOLDER}/version.h>\n#include <stdio.h>\nint main(){printf(${POLARSSL_REAL_NAME}_VERSION_STRING);return 0;}"
     OUTPUT_FILE a.c
@@ -77,14 +83,6 @@
   execute_process(
     COMMAND ${CMAKE_COMMAND} -E remove a.c a.out
   )
-else()
-  execute_process(
-    COMMAND grep -w "MBEDTLS_VERSION_STRING" ${POLARSSL_INCLUDE_DIRS}/${POLARSSL_INC_FOLDER}/version.h
-    COMMAND sed -e "s@\s\+@ @g"
-    COMMAND cut -d\  -f3
-    COMMAND sed -e "s@\"@@g"
-    OUTPUT_VARIABLE POLARSSL_VERSION_STRING
-  )
 endif()
 
 message("PolarSSL/mbedTLS version: " ${POLARSSL_VERSION_STRING})