From patchwork Thu Feb 16 02:17:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lee, Chee Yang" X-Patchwork-Id: 19627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2096BC636D4 for ; Thu, 16 Feb 2023 02:18:16 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.1181.1676513887573049383 for ; Wed, 15 Feb 2023 18:18:08 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=JY+6R6F6; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: chee.yang.lee@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676513888; x=1708049888; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=4nSmtbFevBz41U59ZsCq2OwK0KlvdygTAqTDjs5729k=; b=JY+6R6F6mv+cBc6ZM2L9zXyE909LAt9JyO3BG6o/GbVktE4/6/2wo2w5 Chzwvp5BK8w7iRHrCpgbOmY2c4er0QO+N0wSkITliyO9rZ1nPtAIqDHzN EEOfPXSSD1f10TSNN5w7iw3S81taf389tPmZA3HgZMxt4KjWircAduw9Q n5Z2YIKT7OcglN8ofigZVz/lnVLW9YmCnXBTC8viR4AJ2UDiuzZG9gJ1c +2IidToMKB6DLrEQr/YD3tNdjEQQm7wurbH24l7wnDX7SZ2qamNBt1Lc6 jnCGnw4obSJdncX9oUisk8LHGa4dZKxq0/vaD2Luetk3cezUsRR0TOYRX g==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="311969526" X-IronPort-AV: E=Sophos;i="5.97,301,1669104000"; d="scan'208";a="311969526" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2023 18:18:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="915496221" X-IronPort-AV: E=Sophos;i="5.97,301,1669104000"; d="scan'208";a="915496221" Received: from andromeda02.png.intel.com ([10.221.253.198]) by fmsmga006.fm.intel.com with ESMTP; 15 Feb 2023 18:18:02 -0800 From: chee.yang.lee@intel.com To: openembedded-devel@lists.openembedded.org Subject: [langdale][meta-oe][PATCH] opencv: fix reproducible builds Date: Thu, 16 Feb 2023 10:17:54 +0800 Message-Id: <20230216021754.997745-1-chee.yang.lee@intel.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 16 Feb 2023 02:18:16 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-devel/message/101089 From: Chee Yang Lee Signed-off-by: Chee Yang Lee --- ...ot-embed-build-directory-in-binaries.patch | 138 ++++++++++++++++++ .../recipes-support/opencv/opencv_4.6.0.bb | 1 + 2 files changed, 139 insertions(+) create mode 100644 meta-oe/recipes-support/opencv/opencv/0008-Do-not-embed-build-directory-in-binaries.patch diff --git a/meta-oe/recipes-support/opencv/opencv/0008-Do-not-embed-build-directory-in-binaries.patch b/meta-oe/recipes-support/opencv/opencv/0008-Do-not-embed-build-directory-in-binaries.patch new file mode 100644 index 0000000000..8fda857080 --- /dev/null +++ b/meta-oe/recipes-support/opencv/opencv/0008-Do-not-embed-build-directory-in-binaries.patch @@ -0,0 +1,138 @@ +From: Victor Westerhuis +Date: Sat, 19 Nov 2022 21:45:39 +0100 +Subject: Do not embed build directory in binaries + +This makes the opencv core module build reproducibly. + +https://salsa.debian.org/science-team/opencv/-/raw/master/debian/patches/0008-Do-not-embed-build-directory-in-binaries.patch +Upstream-Status: Backport +Signed-off-by: Chee Yang Lee +--- + modules/core/CMakeLists.txt | 10 ------ + modules/core/include/opencv2/core/private.hpp | 4 +-- + modules/core/include/opencv2/core/utility.hpp | 4 +-- + modules/core/src/utils/datafile.cpp | 48 +-------------------------- + 4 files changed, 5 insertions(+), 61 deletions(-) + +diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt +index b78bb98..d96b669 100644 +--- a/modules/core/CMakeLists.txt ++++ b/modules/core/CMakeLists.txt +@@ -188,16 +188,6 @@ if(OPENCV_OTHER_INSTALL_PATH) + ") + endif() + +-set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR} +-#define OPENCV_BUILD_DIR \"${CMAKE_BINARY_DIR}\" +-") +- +-file(RELATIVE_PATH SOURCE_DIR_RELATIVE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) +-set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR} +-#define OPENCV_DATA_BUILD_DIR_SEARCH_PATHS \\ +- \"${SOURCE_DIR_RELATIVE}/\" +-") +- + if(WIN32) + file(RELATIVE_PATH INSTALL_DATA_DIR_RELATIVE "${CMAKE_INSTALL_PREFIX}/${OPENCV_BIN_INSTALL_PATH}" "${CMAKE_INSTALL_PREFIX}/${OPENCV_OTHER_INSTALL_PATH}") + else() +diff --git a/modules/core/include/opencv2/core/private.hpp b/modules/core/include/opencv2/core/private.hpp +index 146d37f..dd675bc 100644 +--- a/modules/core/include/opencv2/core/private.hpp ++++ b/modules/core/include/opencv2/core/private.hpp +@@ -818,10 +818,10 @@ Search directories: + 2. Check path specified by configuration parameter with "_HINT" suffix (name of environment variable). + 3. Check path specified by configuration parameter (name of environment variable). + If parameter value is not empty and nothing is found then stop searching. +-4. Detects build/install path based on: ++4. Detects install path based on: + a. current working directory (CWD) + b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage) +-5. Scan `/{,data}` directories if build directory is detected or the current directory is in source tree. ++5. Scan `/{,data}` directories if the current directory is in source tree. + 6. Scan `/share/OpenCV` directory if install directory is detected. + + @param relative_path Relative path to data file +diff --git a/modules/core/include/opencv2/core/utility.hpp b/modules/core/include/opencv2/core/utility.hpp +index 108c0d9..f15d9ea 100644 +--- a/modules/core/include/opencv2/core/utility.hpp ++++ b/modules/core/include/opencv2/core/utility.hpp +@@ -1163,10 +1163,10 @@ Search directories: + 2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable + 3. OPENCV_SAMPLES_DATA_PATH environment variable + If parameter value is not empty and nothing is found then stop searching. +-4. Detects build/install path based on: ++4. Detects install path based on: + a. current working directory (CWD) + b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage) +-5. Scan `/{,data,samples/data}` directories if build directory is detected or the current directory is in source tree. ++5. Scan `/{,data,samples/data}` directories if the current directory is in source tree. + 6. Scan `/share/OpenCV` directory if install directory is detected. + + @see cv::utils::findDataFile +diff --git a/modules/core/src/utils/datafile.cpp b/modules/core/src/utils/datafile.cpp +index 3af83a5..6bda857 100644 +--- a/modules/core/src/utils/datafile.cpp ++++ b/modules/core/src/utils/datafile.cpp +@@ -280,32 +280,8 @@ cv::String findDataFile(const cv::String& relative_path, + + + // Steps: 4, 5, 6 +- cv::String cwd = utils::fs::getcwd(); +- cv::String build_dir(OPENCV_BUILD_DIR); +- bool has_tested_build_directory = false; +- if (isSubDirectory(build_dir, cwd) || isSubDirectory(utils::fs::canonical(build_dir), utils::fs::canonical(cwd))) +- { +- CV_LOG_DEBUG(NULL, "utils::findDataFile(): the current directory is build sub-directory: " << cwd); +- const char* build_subdirs[] = { OPENCV_DATA_BUILD_DIR_SEARCH_PATHS }; +- for (size_t k = 0; k < sizeof(build_subdirs)/sizeof(build_subdirs[0]); k++) +- { +- CV_LOG_DEBUG(NULL, "utils::findDataFile(): /" << build_subdirs[k]); +- cv::String datapath = utils::fs::join(build_dir, build_subdirs[k]); +- if (utils::fs::isDirectory(datapath)) +- { +- for(size_t i = search_subdir.size(); i > 0; i--) +- { +- const cv::String& subdir = search_subdir[i - 1]; +- cv::String prefix = utils::fs::join(datapath, subdir); +- TRY_FILE_WITH_PREFIX(prefix); +- } +- } +- } +- has_tested_build_directory = true; +- } +- + cv::String source_dir; +- cv::String try_source_dir = cwd; ++ cv::String try_source_dir = utils::fs::getcwd(); + for (int levels = 0; levels < 3; ++levels) + { + if (utils::fs::exists(utils::fs::join(try_source_dir, "modules/core/include/opencv2/core/version.hpp"))) +@@ -341,28 +317,6 @@ cv::String findDataFile(const cv::String& relative_path, + CV_LOG_INFO(NULL, "Can't detect module binaries location"); + } + +- if (!has_tested_build_directory && +- (isSubDirectory(build_dir, module_path) || isSubDirectory(utils::fs::canonical(build_dir), utils::fs::canonical(module_path))) +- ) +- { +- CV_LOG_DEBUG(NULL, "utils::findDataFile(): the binary module directory is build sub-directory: " << module_path); +- const char* build_subdirs[] = { OPENCV_DATA_BUILD_DIR_SEARCH_PATHS }; +- for (size_t k = 0; k < sizeof(build_subdirs)/sizeof(build_subdirs[0]); k++) +- { +- CV_LOG_DEBUG(NULL, "utils::findDataFile(): /" << build_subdirs[k]); +- cv::String datapath = utils::fs::join(build_dir, build_subdirs[k]); +- if (utils::fs::isDirectory(datapath)) +- { +- for(size_t i = search_subdir.size(); i > 0; i--) +- { +- const cv::String& subdir = search_subdir[i - 1]; +- cv::String prefix = utils::fs::join(datapath, subdir); +- TRY_FILE_WITH_PREFIX(prefix); +- } +- } +- } +- } +- + #if defined OPENCV_INSTALL_DATA_DIR_RELATIVE + if (!module_path.empty()) // require module path + { diff --git a/meta-oe/recipes-support/opencv/opencv_4.6.0.bb b/meta-oe/recipes-support/opencv/opencv_4.6.0.bb index da1e659a4a..a60e711ce9 100644 --- a/meta-oe/recipes-support/opencv/opencv_4.6.0.bb +++ b/meta-oe/recipes-support/opencv/opencv_4.6.0.bb @@ -51,6 +51,7 @@ SRC_URI = "git://github.com/opencv/opencv.git;name=opencv;branch=master;protocol file://0001-Dont-use-isystem.patch \ file://download.patch \ file://0001-Make-ts-module-external.patch \ + file://0008-Do-not-embed-build-directory-in-binaries.patch \ " SRC_URI:append:riscv64 = " file://0001-Use-Os-to-compile-tinyxml2.cpp.patch;patchdir=contrib"