Message ID | dwdu0IFP-FBpKY7y534ks2EfI-mzljVFIhzsFddw0aV0LiBC-4QVKl_rkYuoqO1vzW9-MlAE_IbnvdgGtlieqn1nyJNFuwPnlL3asTzvgts=@elenq.tech |
---|---|
State | Accepted |
Headers | show |
Series | [bug#41294] gnu: Add libfreenect. | expand |
Context | Check | Description |
---|---|---|
cbaines/applying patch | fail | View Laminar job |
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Tuesday, May 19, 2020 3:42 PM, Ekaitz Zarraga <ekaitz@elenq.tech> wrote: > Hi, > > > > There's some kind of weird magic I'm not getting. > > > > Hello, I don't know the whole detail too, but to build a package, guix likely: > > > > - Load and eval the package module, to get the package object. The > > 'arguments' field is a list. > > > > - Convert this package object to a derivation, and write it in store as > > a file (/gnu/store/*.drv). Where 'arguments' being part of the > > builder, serialize as string to the file, it dosen't do complex things > > for procedure bindings, only write their string descriptions... So > > when the builder file is loaded, you get `Unknown object` errors. > > Here, to avoid duplicating the code, you can: > > > > > > 1. Unquote list value into `arguments`. (eg: 'asdf-substitutions' in lisp.scm) > > This doesn't work for me. I don't know why. > > Just moved the lambda to a (define* deactivate-sources ...) and then when I try to put the name like > > (arguments `( #tests? .... ,deactivate-sources ...) > > Shoots an Unknown object error. I add a diff below to let you see the whole picture of what I did and doesn't work. > > > 2. Use `(package-arguments libfreenect-examples)` with > > `substitute-keyword-arguments` to reuse arguments, but modify > > `configure-flags` etc. (eg: qtx11extras) > > The build system can use 'imported-modules' to make a set of guile > > modules (which can contains useful procedures, etc.) available to the > > builder, but thas's overkill to be used here... > > > > I'll check that option too. > > Thank you for your help! > > diff --git a/gnu/local.mk b/gnu/local.mk > index ab2bac9bc5..b9c09cc5e3 100644 > --- a/gnu/local.mk > +++ b/gnu/local.mk > @@ -394,6 +394,7 @@ GNU_SYSTEM_MODULES = \ > %D%/packages/nvi.scm \ > %D%/packages/ocaml.scm \ > %D%/packages/ocr.scm \ > > - %D%/packages/openkinect.scm \ > %D%/packages/onc-rpc.scm \ > %D%/packages/opencl.scm \ > %D%/packages/openbox.scm \ > diff --git a/gnu/packages/openkinect.scm b/gnu/packages/openkinect.scm > new file mode 100644 > index 0000000000..5a17acef0e > --- /dev/null > +++ b/gnu/packages/openkinect.scm > @@ -0,0 +1,127 @@ > +(define-module (gnu packages openkinect) > > - #:use-module (guix packages) > - #:use-module (guix git-download) > - #:use-module (guix build-system cmake) > - #:use-module ((guix licenses) #:prefix license:) > - #:use-module (gnu packages pkg-config) > - #:use-module (gnu packages libusb) > - #:use-module (gnu packages python) > - #:use-module (gnu packages python-xyz) > - #:use-module (gnu packages gl) > - #:use-module (gnu packages pkg-config) > - #:use-module (gnu packages image-processing)) > - > > +(define-public libfreenect > > - (let ((version "0.6.1")) > - (package > - (name "libfreenect") > > > - (version version) > > > - (source (origin > > > - (method git-fetch) > > > - (uri (git-reference > > > - (url "https://github.com/OpenKinect/libfreenect") > > > - (commit (string-append "v" version)))) > > > - (sha256 > > > - (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr")))) > > > - (build-system cmake-build-system) > > > - (arguments > > > - '(#:tests? #f ; Project has not tests > > > - #:configure-flags > > > - '("-DBUILD_FAKENECT=ON" > > > - "-DBUILD_CPP=ON" > > > - "-DBUILD_EXAMPLES=OFF" ; Available in libfreenect-examples > > > - "-DBUILD_CV=OFF" ; Available in libfreenect-cv > > > - "-DBUILD_PYTHON=OFF" ; Available in libfreenect-python > > > - "-DBUILD_C_SYNC=ON") > > > - #:phases > > > - (modify-phases %standard-phases > > > - (add-after 'install 'install-udev-rules > > > - (lambda* (#:key outputs #:allow-other-keys) > > > - (let* ((out (assoc-ref outputs "out")) > > > - (rules-out (string-append out "/lib/udev/rules.d"))) > > > - (install-file "../source/platform/linux/udev/51-kinect.rules" > > > - (string-append rules-out "51-kinect.rules")) > > > - #t)))))) > > > - (native-inputs > > > - `(("pkg-config" ,pkg-config))) > > > - (inputs > > > - `(("libusb" ,libusb))) > > > - (synopsis "Drivers and libraries for the Xbox Kinect device") > > > - (description "libfreenect is a userspace driver for the Microsoft Kinect. > > > > +It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.") > > - (home-page "https://openkinect.org/") > > > - (license license:gpl2+)))) > > > - > > +(define (disable-sources) > > - (lambda* (#:key outputs #:allow-other-keys) > - (substitute* "CMakeLists.txt" > > > - ((".*libusb.*") "") > > > - (("add_subdirectory \\\\(src\\\\)") "") > > > - ((".*libfreenectConfig.cmake.*") "")))) > > > - > > +(define-public libfreenect-examples > > - (package > - (inherit libfreenect) > - (name "libfreenect-examples") > - (inputs > - `(("libfreenect" ,libfreenect) > > > - ("glut" ,freeglut))) > > > - (arguments > - `(#:tests? #f ; Project has not tests > > > - #:configure-flags '("-DBUILD_EXAMPLES=ON" > > > - "-DBUILD_FAKENECT=OFF" > > > - "-DBUILD_CPP=OFF" > > > - "-DBUILD_C_SYNC=OFF" > > > - "-DBUILD_CV=OFF") > > > - #:phases > > > - (modify-phases %standard-phases > > > - ;; Sources are already compiled in libfreenect input > > > - (add-after 'unpack 'disable-sources ,disable-sources)))) ;; UNKNOW OBJECT! > > > - (synopsis "Examples for libfreenect, the Xbox Kinect device library"))) > - > > +(define-public libfreenect-cv > > - (package > - (inherit libfreenect) > - (name "libfreenect-cv") > - (inputs > - `(("libfreenect" ,libfreenect) > > > - ("opencv" ,opencv))) > > > - (arguments > - `(#:tests? #f ; Project has not tests > > > - #:configure-flags '("-DBUILD_EXAMPLES=OFF" > > > - "-DBUILD_FAKENECT=OFF" > > > - "-DBUILD_CPP=OFF" > > > - "-DBUILD_C_SYNC=OFF" > > > - "-DBUILD_CV=ON") > > > - #:phases > > > - (modify-phases %standard-phases > > > - ;; Sources are already compiled in libfreenect input > > > - (add-after 'unpack 'disable-sources ,disable-sources)))) > > > - (synopsis "OpenCV wrapper for libfreenect, the Xbox Kinect device > +library"))) > > - > > +(define-public libfreenect-python > > - (package > - (inherit libfreenect) > - (name "libfreenect-python") > - (native-inputs > - `(("python-cython" ,python-cython))) > > > - (inputs > - `(("libfreenect" ,libfreenect))) > > > - (propagated-inputs > - `(("python" ,python) > > > - ("python-numpy" ,python-numpy))) > > > - (arguments > - `(#:tests? #f ; Project has not tests > > > - #:configure-flags '("-DBUILD_EXAMPLES=OFF" > > > - "-DBUILD_FAKENECT=OFF" > > > - "-DBUILD_CPP=OFF" > > > - "-DBUILD_C_SYNC=OFF" > > > - "-DBUILD_CV=OFF" > > > - "-DBUILD_PYTHON3=ON") > > > - #:phases > > > - (modify-phases %standard-phases > > > - ;; Sources are already compiled in libfreenect input > > > - (add-after 'unpack 'disable-sources ,disable-sources)))) > > > - (synopsis "Python wrapper for libfreenect, the Xbox Kinect device > +library"))) > oh, the code is wrong, there parenthesis on the define are making it a function but anyway: - Tested using ,(disable-sources) FAIL - Tested removing the parenthesis and leaving (define disable-sources (lambda*...)) There must be something I'm missing.
Ekaitz Zarraga <ekaitz@elenq.tech> writes: > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ > On Tuesday, May 19, 2020 3:42 PM, Ekaitz Zarraga <ekaitz@elenq.tech> wrote: > >> Hi, >> >> > > There's some kind of weird magic I'm not getting. >> > >> > Hello, I don't know the whole detail too, but to build a package, guix likely: >> > >> > - Load and eval the package module, to get the package object. The >> > 'arguments' field is a list. >> > >> > - Convert this package object to a derivation, and write it in store as >> > a file (/gnu/store/*.drv). Where 'arguments' being part of the >> > builder, serialize as string to the file, it dosen't do complex things >> > for procedure bindings, only write their string descriptions... So >> > when the builder file is loaded, you get `Unknown object` errors. >> > Here, to avoid duplicating the code, you can: >> > >> > >> > 1. Unquote list value into `arguments`. (eg: 'asdf-substitutions' in lisp.scm) >> >> This doesn't work for me. I don't know why. >> >> Just moved the lambda to a (define* deactivate-sources ...) and then when I try to put the name like >> >> (arguments `( #tests? .... ,deactivate-sources ...) >> >> Shoots an Unknown object error. I add a diff below to let you see the whole picture of what I did and doesn't work. >> >> > 2. Use `(package-arguments libfreenect-examples)` with >> > `substitute-keyword-arguments` to reuse arguments, but modify >> > `configure-flags` etc. (eg: qtx11extras) >> > The build system can use 'imported-modules' to make a set of guile >> > modules (which can contains useful procedures, etc.) available to the >> > builder, but thas's overkill to be used here... >> > >> [...] > > oh, > > the code is wrong, there parenthesis on the define are making it a function but anyway: > - Tested using ,(disable-sources) FAIL > - Tested removing the parenthesis and leaving (define disable-sources (lambda*...)) > > There must be something I'm missing. Um, I mean something like this: (define libfreenect-derived-phases '(modify-phases %standard-phases (lambda* (#:key outputs #:allow-other-keys) ...))) ... (arguments `(#:phases ,libfreenect-derived-phases)) ... Here 'libfreenect-derived-phases' is a list of symbols, the arguments field we want is a list of symbols too.
diff --git a/gnu/local.mk b/gnu/local.mk index ab2bac9bc5..b9c09cc5e3 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -394,6 +394,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/nvi.scm \ %D%/packages/ocaml.scm \ %D%/packages/ocr.scm \ + %D%/packages/openkinect.scm \ %D%/packages/onc-rpc.scm \ %D%/packages/opencl.scm \ %D%/packages/openbox.scm \ diff --git a/gnu/packages/openkinect.scm b/gnu/packages/openkinect.scm new file mode 100644 index 0000000000..5a17acef0e --- /dev/null +++ b/gnu/packages/openkinect.scm @@ -0,0 +1,127 @@ +(define-module (gnu packages openkinect) + #:use-module (guix packages) + #:use-module (guix git-download) + #:use-module (guix build-system cmake) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages libusb) + #:use-module (gnu packages python) + #:use-module (gnu packages python-xyz) + #:use-module (gnu packages gl) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages image-processing)) + +(define-public libfreenect + (let ((version "0.6.1")) + (package + (name "libfreenect") + (version version) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/OpenKinect/libfreenect") + (commit (string-append "v" version)))) + (sha256 + (base32 "0was1va167rqshmpn382h36yyprpfi9cwillb6ylppmnfdrfrhrr")))) + (build-system cmake-build-system) + (arguments + '(#:tests? #f ; Project has not tests + #:configure-flags + '("-DBUILD_FAKENECT=ON" + "-DBUILD_CPP=ON" + "-DBUILD_EXAMPLES=OFF" ; Available in libfreenect-examples + "-DBUILD_CV=OFF" ; Available in libfreenect-cv + "-DBUILD_PYTHON=OFF" ; Available in libfreenect-python + "-DBUILD_C_SYNC=ON") + #:phases + (modify-phases %standard-phases + (add-after 'install 'install-udev-rules + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (rules-out (string-append out "/lib/udev/rules.d"))) + (install-file "../source/platform/linux/udev/51-kinect.rules" + (string-append rules-out "51-kinect.rules")) + #t)))))) + (native-inputs + `(("pkg-config" ,pkg-config))) + (inputs + `(("libusb" ,libusb))) + (synopsis "Drivers and libraries for the Xbox Kinect device") + (description "libfreenect is a userspace driver for the Microsoft Kinect. +It supports: RGB and Depth Images, Motors, Accelerometer, LED and Audio.") + (home-page "https://openkinect.org/") + (license license:gpl2+)))) + +(define (disable-sources) + (lambda* (#:key outputs #:allow-other-keys) + (substitute* "CMakeLists.txt" + ((".*libusb.*") "") + (("add_subdirectory \\(src\\)") "") + ((".*libfreenectConfig.cmake.*") "")))) + +(define-public libfreenect-examples + (package + (inherit libfreenect) + (name "libfreenect-examples") + (inputs + `(("libfreenect" ,libfreenect) + ("glut" ,freeglut))) + (arguments + `(#:tests? #f ; Project has not tests + #:configure-flags '("-DBUILD_EXAMPLES=ON" + "-DBUILD_FAKENECT=OFF" + "-DBUILD_CPP=OFF" + "-DBUILD_C_SYNC=OFF" + "-DBUILD_CV=OFF") + #:phases + (modify-phases %standard-phases + ;; Sources are already compiled in libfreenect input + (add-after 'unpack 'disable-sources ,disable-sources)))) ;; UNKNOW OBJECT! + (synopsis "Examples for libfreenect, the Xbox Kinect device library"))) + +(define-public libfreenect-cv + (package + (inherit libfreenect) + (name "libfreenect-cv") + (inputs + `(("libfreenect" ,libfreenect) + ("opencv" ,opencv))) + (arguments + `(#:tests? #f ; Project has not tests + #:configure-flags '("-DBUILD_EXAMPLES=OFF" + "-DBUILD_FAKENECT=OFF" + "-DBUILD_CPP=OFF" + "-DBUILD_C_SYNC=OFF" + "-DBUILD_CV=ON") + #:phases + (modify-phases %standard-phases + ;; Sources are already compiled in libfreenect input + (add-after 'unpack 'disable-sources ,disable-sources)))) + (synopsis "OpenCV wrapper for libfreenect, the Xbox Kinect device +library"))) + +(define-public libfreenect-python + (package + (inherit libfreenect) + (name "libfreenect-python") + (native-inputs + `(("python-cython" ,python-cython))) + (inputs + `(("libfreenect" ,libfreenect))) + (propagated-inputs + `(("python" ,python) + ("python-numpy" ,python-numpy))) + (arguments + `(#:tests? #f ; Project has not tests + #:configure-flags '("-DBUILD_EXAMPLES=OFF" + "-DBUILD_FAKENECT=OFF" + "-DBUILD_CPP=OFF" + "-DBUILD_C_SYNC=OFF" + "-DBUILD_CV=OFF" + "-DBUILD_PYTHON3=ON") + #:phases + (modify-phases %standard-phases + ;; Sources are already compiled in libfreenect input + (add-after 'unpack 'disable-sources ,disable-sources)))) + (synopsis "Python wrapper for libfreenect, the Xbox Kinect device +library")))