mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Marian Cichy <m.cichy@pengutronix.de>
To: ptxdist@pengutronix.de
Cc: Marian Cichy <m.cichy@pengutronix.de>
Subject: [ptxdist] [PATCH v2 7/7] OpenCV: fix download in PTXDist prepare stage
Date: Thu, 23 Jan 2020 15:23:15 +0100	[thread overview]
Message-ID: <20200123142315.10466-7-m.cichy@pengutronix.de> (raw)
In-Reply-To: <20200123142315.10466-1-m.cichy@pengutronix.de>

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.

Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>
---
 ...option-to-disallow-download-of-files.patch | 42 +++++++++++
 patches/opencv-4.1.2/series                   |  1 +
 rules/opencv.make                             | 70 +++++++++++++++----
 3 files changed, 100 insertions(+), 13 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 <m.cichy@pengutronix.de>
+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 <opencv>/.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..29261329f 100644
--- a/rules/opencv.make
+++ b/rules/opencv.make
@@ -17,25 +17,69 @@ 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 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 \
@@ -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

      parent reply	other threads:[~2020-01-23 14:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-23 14:23 [ptxdist] [PATCH v2 1/7] OpenCV: Update to Version 4.1.2 Marian Cichy
2020-01-23 14:23 ` [ptxdist] [PATCH v2 2/7] OpenCV: Added flag to build and integrate Examples Marian Cichy
2020-01-23 14:23 ` [ptxdist] [PATCH v2 3/7] OpenCV: Clean up configure_helper output Marian Cichy
2020-01-23 14:23 ` [ptxdist] [PATCH v2 4/7] OpenCV: Changed QT-Support from 4 to 5 Marian Cichy
2020-01-23 14:23 ` [ptxdist] [PATCH v2 5/7] OpenCV: added switch to turn on/off DNN support Marian Cichy
2020-01-23 14:23 ` [ptxdist] [PATCH v2 6/7] OpenCV: changed ptx/ifdef usage to ptx/onoff Marian Cichy
2020-01-23 14:23 ` Marian Cichy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200123142315.10466-7-m.cichy@pengutronix.de \
    --to=m.cichy@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox