From 86fba13068f1e8111e7d885de2aef11378435139 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Sat, 14 Sep 2024 00:58:18 +0200 Subject: [PATCH] [libressl] Fail if openssl is installed (#40924) --- ports/libressl/portfile.cmake | 4 +-- ports/libressl/vcpkg.json | 1 + .../vcpkg-ci-libressl/portfile.cmake | 4 +++ .../vcpkg-ci-libressl/project/CMakeLists.txt | 33 +++++++++++++++++++ .../test_ports/vcpkg-ci-libressl/vcpkg.json | 12 +++++++ versions/baseline.json | 2 +- versions/l-/libressl.json | 5 +++ 7 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 scripts/test_ports/vcpkg-ci-libressl/portfile.cmake create mode 100644 scripts/test_ports/vcpkg-ci-libressl/project/CMakeLists.txt create mode 100644 scripts/test_ports/vcpkg-ci-libressl/vcpkg.json diff --git a/ports/libressl/portfile.cmake b/ports/libressl/portfile.cmake index ac420e9c0b..1d9c74e39b 100644 --- a/ports/libressl/portfile.cmake +++ b/ports/libressl/portfile.cmake @@ -1,7 +1,5 @@ if(EXISTS "${CURRENT_INSTALLED_DIR}/include/openssl/ssl.h") - message(WARNING "Can't build libressl if openssl is installed. Please remove openssl, and try install libressl again if you need it. Build will continue since libressl is a subset of openssl") - set(VCPKG_POLICY_EMPTY_PACKAGE enabled) - return() + message(FATAL_ERROR "Can't build libressl if openssl is installed. Please remove openssl, and try install libressl again if you need it.") endif() vcpkg_download_distfile( diff --git a/ports/libressl/vcpkg.json b/ports/libressl/vcpkg.json index 4cf57e548d..497e5effb8 100644 --- a/ports/libressl/vcpkg.json +++ b/ports/libressl/vcpkg.json @@ -1,6 +1,7 @@ { "name": "libressl", "version": "3.9.2", + "port-version": 1, "description": "LibreSSL is a version of the TLS/crypto stack forked from OpenSSL in 2014, with goals of modernizing the codebase, improving security, and applying best practice development processes.", "license": "ISC", "dependencies": [ diff --git a/scripts/test_ports/vcpkg-ci-libressl/portfile.cmake b/scripts/test_ports/vcpkg-ci-libressl/portfile.cmake new file mode 100644 index 0000000000..bc785962c8 --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-libressl/portfile.cmake @@ -0,0 +1,4 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) + +vcpkg_cmake_configure(SOURCE_PATH "${CURRENT_PORT_DIR}/project") +vcpkg_cmake_build() diff --git a/scripts/test_ports/vcpkg-ci-libressl/project/CMakeLists.txt b/scripts/test_ports/vcpkg-ci-libressl/project/CMakeLists.txt new file mode 100644 index 0000000000..ba70f6b1c3 --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-libressl/project/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.7) +project(libressl-test CXX) + +# libressl promises openssl compatibility +# NB: The port doesn't provide a wrapper, so there is no support +# for multi-config and for transitive usage requirements. +find_package(OpenSSL MODULE REQUIRED) +foreach(target IN ITEMS OpenSSL::SSL OpenSSL::Crypto) + set(location_found FALSE) + foreach(property IN ITEMS IMPORTED_LOCATION IMPORTED_LOCATION_DEBUG IMPORTED_LOCATION_RELEASE) + get_target_property(location ${target} ${property}) + if(NOT location) + continue() + endif() + set(location_found TRUE) + message(STATUS "${target} ${property}: ${location}") + string(FIND "${location}" "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" index) + if(NOT index STREQUAL "0") + message(SEND_ERROR "${target} ${property} is not from vcpkg.") + endif() + endforeach() + if(NOT location_found) + message(SEND_ERROR "No location for ${target} binary") + endif() +endforeach() + +# libressl provides cmake config +find_package(LibreSSL CONFIG REQUIRED) +message(STATUS "LibreSSL CONFIG: ${LibreSSL_DIR}") +string(FIND "${LibreSSL_DIR}" "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" index) +if(NOT index STREQUAL "0") + message(SEND_ERROR "LibreSSL CONFIG is not from vcpkg.") +endif() diff --git a/scripts/test_ports/vcpkg-ci-libressl/vcpkg.json b/scripts/test_ports/vcpkg-ci-libressl/vcpkg.json new file mode 100644 index 0000000000..3b04b3e8dd --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-libressl/vcpkg.json @@ -0,0 +1,12 @@ +{ + "name": "vcpkg-ci-libressl", + "version-string": "ci", + "description": "Validates libressl", + "dependencies": [ + "libressl", + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index dea541cf59..46a47f1705 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4986,7 +4986,7 @@ }, "libressl": { "baseline": "3.9.2", - "port-version": 0 + "port-version": 1 }, "librsvg": { "baseline": "2.40.20", diff --git a/versions/l-/libressl.json b/versions/l-/libressl.json index 379b126231..ba5ecdb46e 100644 --- a/versions/l-/libressl.json +++ b/versions/l-/libressl.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "f9e56b0af8f93ed5c5adc5e2ba1696e5c16420be", + "version": "3.9.2", + "port-version": 1 + }, { "git-tree": "212859e945d993b860716eaa47b8f83ef52efbb2", "version": "3.9.2",