From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: From: Marian Cichy Date: Wed, 22 Jan 2020 17:48:45 +0100 Message-Id: <20200122164845.22356-1-m.cichy@pengutronix.de> MIME-Version: 1.0 Subject: [ptxdist] [PATCH] OpenCV: fix download in PTXDist prepare stage List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de Cc: Marian Cichy OpenCV wants to download the additional framework ADE while executing CMake. Therefore, files will be downloaded during PTXDist's prepare stage. This is not wanted. We now try to download the files during the Get stage and copy the files to the same locations at the Extract.post stage. If we cannot download the files during the Get stage, a new CMake Flag can be used to abort during the prepare stage if download is tried again. --- ...option-to-disallow-download-of-files.patch | 42 +++++++++++ patches/opencv-4.1.2/series | 1 + rules/opencv.make | 74 +++++++++++++++---- 3 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 patches/opencv-4.1.2/0001-add-option-to-disallow-download-of-files.patch create mode 100644 patches/opencv-4.1.2/series diff --git a/patches/opencv-4.1.2/0001-add-option-to-disallow-download-of-files.patch b/patches/opencv-4.1.2/0001-add-option-to-disallow-download-of-files.patch new file mode 100644 index 000000000..0e1504a96 --- /dev/null +++ b/patches/opencv-4.1.2/0001-add-option-to-disallow-download-of-files.patch @@ -0,0 +1,42 @@ +From b71bfe426a68a4603c9b814da68b117602a8b55f Mon Sep 17 00:00:00 2001 +From: Marian Cichy +Date: Wed, 22 Jan 2020 17:14:05 +0100 +Subject: [PATCH] add option to disallow download of files + +OpenCV wants to download files for the ADE Framework when it is at +the prepare stage of PTXDist. This is not wanted. The PTXDist rule +will download the file during the Get stage and put it at the same +location where OpenCV would put it. If the Download at the Get stage +does not succeed and if OPENCV_ALLOW_DOWNLOADS is OFF, OpenCV will abort +with this patch at the Prepare stage. +--- + cmake/OpenCVDownload.cmake | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake +index 63cf6d3238b1..cd7e50b4edf1 100644 +--- a/cmake/OpenCVDownload.cmake ++++ b/cmake/OpenCVDownload.cmake +@@ -14,6 +14,7 @@ + # RELATIVE_URL - if set, then URL is treated as a base, and FILENAME will be appended to it + # Note: uses OPENCV_DOWNLOAD_PATH folder as cache, default is /.cache + ++set(OPENCV_ALLOW_DOWNLOADS ON CACHE BOOL "Allow downloads") + set(HELP_OPENCV_DOWNLOAD_PATH "Cache directory for downloaded files") + if(DEFINED ENV{OPENCV_DOWNLOAD_PATH}) + set(OPENCV_DOWNLOAD_PATH "$ENV{OPENCV_DOWNLOAD_PATH}" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}") +@@ -156,6 +157,11 @@ function(ocv_download) + + # Download + if(NOT EXISTS "${CACHE_CANDIDATE}") ++ if(NOT OPENCV_ALLOW_DOWNLOADS) ++ message(FATAL_ERROR "Not going to download ${DL_FILENAME}") ++ return() ++ endif() ++ + ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"") + foreach(try ${OPENCV_DOWNLOAD_TRIES_LIST}) + ocv_download_log("#try ${try}") +-- +2.20.1 + diff --git a/patches/opencv-4.1.2/series b/patches/opencv-4.1.2/series new file mode 100644 index 000000000..aaa28ce52 --- /dev/null +++ b/patches/opencv-4.1.2/series @@ -0,0 +1 @@ +0001-add-option-to-disallow-download-of-files.patch diff --git a/rules/opencv.make b/rules/opencv.make index 0a6fd7a12..2eab4c9ea 100644 --- a/rules/opencv.make +++ b/rules/opencv.make @@ -17,25 +17,70 @@ PACKAGES-$(PTXCONF_OPENCV) += opencv # Paths and names # -OPENCV_VERSION := 4.1.2 -OPENCV_MD5 := 6b390578d57131ae9d6c2a183257399d -OPENCV := opencv-$(OPENCV_VERSION) -OPENCV_SUFFIX := zip -OPENCV_URL := \ - $(call ptx/mirror, SF, opencvlibrary/opencv-unix/$(OPENCV_VERSION)/$(OPENCV).$(OPENCV_SUFFIX)) \ - https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).$(OPENCV_SUFFIX) -OPENCV_SOURCE := $(SRCDIR)/$(OPENCV).$(OPENCV_SUFFIX) -OPENCV_DIR := $(BUILDDIR)/$(OPENCV) -OPENCV_LICENSE := BSD -OPENCV_BUILD_DIR := $(OPENCV_DIR)-build +OPENCV_VERSION := 4.1.2 +OPENCV_MD5 := 6b390578d57131ae9d6c2a183257399d +OPENCV := opencv-$(OPENCV_VERSION) +OPENCV_SUFFIX := zip +OPENCV_URL := \ + $(call ptx/mirror, SF, opencvlibrary/opencv-unix/$(OPENCV_VERSION)/$(OPENCV).$(OPENCV_SUFFIX)) \ + https://github.com/opencv/opencv/archive/$(OPENCV_VERSION).$(OPENCV_SUFFIX) +OPENCV_SOURCE := $(SRCDIR)/$(OPENCV).$(OPENCV_SUFFIX) +OPENCV_DIR := $(BUILDDIR)/$(OPENCV) +OPENCV_LICENSE := BSD +OPENCV_BUILD_DIR := $(OPENCV_DIR)-build + +OPENCV_ADE_VERSION := v0.1.1f +OPENCV_ADE_MD5 := b624b995ec9c439cbc2e9e6ee940d3a2 +OPENCV_ADE := opencv-ade-$(OPENCV_ADE_VERSION) +OPENCV_ADE_SUFFIX := zip +OPENCV_ADE_URL := https://github.com/opencv/ade/archive/$(OPENCV_ADE_VERSION).$(OPENCV_ADE_SUFFIX) +OPENCV_ADE_SOURCE := $(SRCDIR)/$(OPENCV_ADE).$(OPENCV_ADE_SUFFIX) +$(OPENCV_ADE_SOURCE) := OPENCV_ADE +#OPENCV_ADE_DIR := $(OPENCV_DIR)/ade +OPENCV_ADE_LICENSE := Apache-2.0 + +OPENCV_SOURCES := $(OPENCV_SOURCE) $(OPENCV_ADE_SOURCE) + + +OPENCV_DL_DIR := $(OPENCV_DIR)/.cache +OPENCV_DL_DIR_ADE := $(OPENCV_DL_DIR)/ade + +# ---------------------------------------------------------------------------- +# Extract +# ---------------------------------------------------------------------------- + +$(STATEDIR)/opencv.extract: + @$(call targetinfo) + @$(call clean, $(OPENCV_DIR)) + @$(call extract, OPENCV) +# @$(call extract, OPENCV_ADE) + @$(call patchin, OPENCV) + @$(call touch) + + +# ---------------------------------------------------------------------------- +# Extract.post +# ---------------------------------------------------------------------------- + +$(STATEDIR)/opencv.extract.post: + @$(call targetinfo) + mkdir $(OPENCV_DL_DIR) + mkdir $(OPENCV_DL_DIR_ADE) + cp $(OPENCV_ADE_SOURCE) $(OPENCV_DL_DIR_ADE)/$(OPENCV_ADE_MD5)-$(OPENCV_ADE_VERSION).$(OPENCV_ADE_SUFFIX) + @$(call touch) + # ---------------------------------------------------------------------------- # Prepare # ---------------------------------------------------------------------------- OPENCV_CONF_TOOL := cmake + +EXTRA_CMAKE := -DOPENCV_ALLOW_DOWNLOADS=OFF \ + OPENCV_CONF_OPT := \ $(CROSS_CMAKE_USR) \ + $(EXTRA_CMAKE) \ -DANT_EXECUTABLE:FILEPATH= \ -DBUILD_CUDA_STUBS:BOOL=OFF \ -DBUILD_DOCS:BOOL=OFF \ @@ -48,7 +93,7 @@ OPENCV_CONF_OPT := \ -DBUILD_OPENEXR=OFF \ -DBUILD_PACKAGE:BOOL=OFF \ -DBUILD_PERF_TESTS=OFF \ - -DBUILD_PNG=OFF \ + -DBUILD_PNG=ON \ -DBUILD_PROTOBUF=ON \ -DBUILD_SHARED_LIBS:BOOL=ON \ -DBUILD_TBB=OFF \ @@ -58,7 +103,6 @@ OPENCV_CONF_OPT := \ -DBUILD_WEBP=OFF \ -DBUILD_WITH_DEBUG_INFO=OFF \ -DBUILD_WITH_DYNAMIC_IPP=OFF \ - -DBUILD_ZLIB=OFF \ -DBUILD_opencv_apps:BOOL=OFF \ -DBUILD_opencv_calib3d:BOOL=$(call ptx/onoff,PTXCONF_OPENCV_CALIB3D) \ -DBUILD_opencv_core:BOOL=ON \ @@ -110,7 +154,7 @@ OPENCV_CONF_OPT := \ -DINSTALL_TO_MANGLED_PATHS:BOOL=OFF \ -DMKL_WITH_OPENMP=OFF \ -DMKL_WITH_TBB=OFF \ - -DOPENCV_DOWNLOAD_PATH=$(OPENCV_DIR)/.cache \ + -DOPENCV_DOWNLOAD_PATH=$(OPENCV_DL_DIR) \ -DOPENCV_DUMP_HOOKS_FLOW=OFF \ -DOPENCV_ENABLE_MEMALIGN=ON \ -DOPENCV_ENABLE_MEMORY_SANITIZER=OFF \ @@ -182,7 +226,6 @@ OPENCV_CONF_OPT := \ -DWITH_XIMEA:BOOL=OFF \ -DWITH_XINE:BOOL=OFF \ - $(STATEDIR)/opencv.install: @$(call targetinfo) @$(call world/install, OPENCV) @@ -194,6 +237,7 @@ ifdef PTXCONF_OPENCV_EXAMPLES endif @$(call touch) + # ---------------------------------------------------------------------------- # Target-Install # ---------------------------------------------------------------------------- -- 2.20.1 _______________________________________________ ptxdist mailing list ptxdist@pengutronix.de