gnu: opencv: Use 'git-fetch'.

* gnu/packages/image-processing.scm (opencv)[source]: Use 'git-fetch'.
[native-inputs]: Use 'git-fetch' for opencv_extras and opencv_contrib.
Remove unzip.
[arguments]: Update custom 'unpack-submodule-sources accordingly. Update
paths in configure-flags, 'diable-broken-tests phase.
This commit is contained in:
Efraim Flashner 2019-01-14 11:47:00 +02:00
parent 7b28210531
commit 6c56e9c493
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351

View file

@ -29,6 +29,7 @@ (define-module (gnu packages image-processing)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix utils) #:use-module (guix utils)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix git-download)
#:use-module (guix build-system cmake) #:use-module (guix build-system cmake)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages) #:use-module (gnu packages)
@ -211,13 +212,14 @@ (define-public opencv
(name "opencv") (name "opencv")
(version "3.4.3") (version "3.4.3")
(source (origin (source (origin
(method url-fetch) (method git-fetch)
(uri (string-append "https://github.com/opencv/opencv/archive/" (uri (git-reference
version ".zip")) (url "https://github.com/opencv/opencv")
(file-name (string-append name "-" version ".zip")) (commit version)))
(file-name (git-file-name name version))
(sha256 (sha256
(base32 (base32
"0pycx1pz8lj794q32mlalyc3ijqxwsyin65r26nh4yc0p71xiirp")) "06bc61r8myym4s8im10brdjfg4wxkrvsbhhl7vr1msdan2xddzi3"))
(modules '((guix build utils))) (modules '((guix build utils)))
(snippet (snippet
'(begin '(begin
@ -230,7 +232,8 @@ (define-public opencv
;; Some jars found: ;; Some jars found:
(for-each delete-file (for-each delete-file
'("modules/java/test/pure_test/lib/junit-4.11.jar" '("modules/java/test/pure_test/lib/junit-4.11.jar"
"samples/java/sbt/sbt/sbt-launch.jar")))))) "samples/java/sbt/sbt/sbt-launch.jar"))
#t))))
(build-system cmake-build-system) (build-system cmake-build-system)
(arguments (arguments
`(#:configure-flags `(#:configure-flags
@ -257,13 +260,11 @@ (define-public opencv
"-DBUILD_TESTS=ON" "-DBUILD_TESTS=ON"
(string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd) (string-append "-DOPENCV_EXTRA_MODULES_PATH=" (getcwd)
"/opencv-contrib/opencv_contrib-" ,version "/opencv-contrib/modules")
"/modules")
;;Define test data: ;;Define test data:
(string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd) (string-append "-DOPENCV_TEST_DATA_PATH=" (getcwd)
"/opencv-extra/opencv_extra-" ,version "/opencv-extra/testdata")
"/testdata")
;; Is ON by default and would try to rebuild 3rd-party protobuf, ;; Is ON by default and would try to rebuild 3rd-party protobuf,
;; which we had removed, which would lead to an error: ;; which we had removed, which would lead to an error:
@ -296,39 +297,28 @@ (define-public opencv
;; This one fails with "unknown file: Failure" ;; This one fails with "unknown file: Failure"
;; But I couldn't figure out which file was missing: ;; But I couldn't figure out which file was missing:
(substitute* (list (string-append (substitute* "../opencv-contrib/modules/face/test/test_face_align.cpp"
"../opencv-contrib/opencv_contrib-"
,version
"/modules/face/test/test_face_align.cpp"))
(("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)" (("(TEST\\(CV_Face_FacemarkKazemi, )(can_detect_landmarks\\).*)"
all pre post) all pre post)
(string-append pre "DISABLED_" post))) (string-append pre "DISABLED_" post)))
;; Failure reason: Bad accuracy ;; Failure reason: Bad accuracy
;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000 ;; Incorrect count of accurate poses [2nd case]: 90.000000 / 94.000000
(substitute* (list (string-append (substitute* "../opencv-contrib/modules/rgbd/test/test_odometry.cpp"
"../opencv-contrib/opencv_contrib-"
,version
"/modules/rgbd/test/test_odometry.cpp"))
(("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post) (("(TEST\\(RGBD_Odometry_Rgbd, )(algorithmic\\).*)" all pre post)
(string-append pre "DISABLED_" post))) (string-append pre "DISABLED_" post)))
#t)) #t))
;; Idea copied from ldc.scm (ldc-bootstrap):
(add-after 'unpack 'unpack-submodule-sources (add-after 'unpack 'unpack-submodule-sources
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(mkdir "../opencv-extra") (mkdir "../opencv-extra")
(mkdir "../opencv-contrib") (mkdir "../opencv-contrib")
(let ((unpack (lambda (source target) (copy-recursively (assoc-ref inputs "opencv-extra")
(with-directory-excursion target "../opencv-extra")
(apply invoke "unzip" (invoke "tar" "xvf"
(list (assoc-ref inputs source)))))) (assoc-ref inputs "opencv-contrib")
(untar (lambda (source target) "--strip-components=1"
(with-directory-excursion target "-C" "../opencv-contrib")))
(apply invoke "tar" "xvf"
(list (assoc-ref inputs source)))))))
(unpack "opencv-extra" "../opencv-extra")
(untar "opencv-contrib" "../opencv-contrib"))))
(add-after 'set-paths 'add-ilmbase-include-path (add-after 'set-paths 'add-ilmbase-include-path
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
@ -350,26 +340,27 @@ (define-public opencv
;; Therefore we must do it. ;; Therefore we must do it.
(zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp))))))))) (zero? (system (format #f "~a/bin/Xvfb ~a &" xorg-server disp)))))))))
(native-inputs (native-inputs
`(("unzip" ,unzip) `(("pkg-config" ,pkg-config)
("pkg-config" ,pkg-config)
("xorg-server" ,xorg-server) ; For running the tests ("xorg-server" ,xorg-server) ; For running the tests
("opencv-extra" ("opencv-extra"
,(origin ,(origin
(method url-fetch) (method git-fetch)
(uri (string-append "https://codeload.github.com/" (uri (git-reference
"opencv/opencv_extra/zip/" version)) (url "https://github.com/opencv/opencv_extra")
(file-name (string-append "opencv-extra-" version ".zip")) (commit version)))
(file-name (git-file-name "opencv_extra" version))
(sha256 (sha256
(base32 "0yd1vidzbg6himxyh4yzivywijg8548kfmcn421khabnipm7l74y")))) (base32 "08p5xnq8n1jw8svvz0fnirfg7q8dm3p4a5dl7527s5xj0f9qn7lp"))))
("opencv-contrib" ("opencv-contrib"
,(origin ,(origin
(method url-fetch) (method git-fetch)
(uri (string-append "https://codeload.github.com/" (uri (git-reference
"opencv/opencv_contrib/zip/" version)) (url "https://github.com/opencv/opencv_contrib")
(file-name (string-append "opencv-contrib-" version ".zip")) (commit version)))
(file-name (git-file-name "opencv_contrib" version))
(patches (search-patches "opencv-rgbd-aarch64-test-fix.patch")) (patches (search-patches "opencv-rgbd-aarch64-test-fix.patch"))
(sha256 (sha256
(base32 "0j0ci6ia1qwklp9hq07ypl0vkngj1wrgh6n98n657m5d0pyp4m0g")))))) (base32 "1f334glf39nk42mpqq6j732h3ql2mpz89jd4mcl678s8n73nfjh2"))))))
(inputs `(("libjpeg" ,libjpeg) (inputs `(("libjpeg" ,libjpeg)
("libpng" ,libpng) ("libpng" ,libpng)
("jasper" ,jasper) ("jasper" ,jasper)