;;; Copyright © 2022 Petr Hodina ;;; ;;; This program is free software: you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation, either version 3 of the License, or ;;; (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program. If not, see . (define-module (nongnu packages electronics) #:use-module (guix packages) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) #:use-module (gnu packages compression) #:use-module (gnu packages cups) #:use-module (gnu packages elf) #:use-module (gnu packages fontutils) #:use-module (gnu packages gcc) #:use-module (gnu packages gl) #:use-module (gnu packages glib) #:use-module (gnu packages gstreamer) #:use-module (gnu packages gtk) #:use-module (gnu packages libusb) #:use-module (gnu packages linux) #:use-module (gnu packages nss) #:use-module (gnu packages maths) #:use-module (gnu packages pulseaudio) #:use-module (gnu packages qt) #:use-module (gnu packages video) #:use-module (gnu packages xml) #:use-module (gnu packages xdisorg) #:use-module (gnu packages xorg) #:use-module (guix download) #:use-module (guix gexp) #:use-module (nonguix build-system binary) #:use-module ((nonguix licenses) #:prefix license:)) (define-public saleae-logic2 (package (name "saleae-logic2") (version "2.3.58") (source (origin (method url-fetch) (uri (string-append "https://downloads.saleae.com/logic2/Logic-" version "-master.AppImage")) (sha256 (base32 "1yi9157gjs1hcm1rz6a65wgiyilfrf9mcm41v29mzvyax8kvs1jr")))) (build-system binary-build-system) (arguments (list #:install-plan #~`(("squashfs-root/Logic" "bin/") ("squashfs-root/libGLESv2.so" "bin/") ("squashfs-root/libEGL.so" "bin/") ("squashfs-root/resources" "bin/") ("squashfs-root/icudtl.dat" "bin/") ("squashfs-root/v8_context_snapshot.bin" "bin/") ("squashfs-root/resources.pak" "bin/") ("squashfs-root/chrome_100_percent.pak" "bin/") ("squashfs-root/libffmpeg.so" "lib/")) #:phases #~(modify-phases %standard-phases (replace 'unpack (lambda* (#:key inputs #:allow-other-keys) (let* ((logic (string-append "/Logic-" #$(package-version saleae-logic2) "-master.AppImage")) (tmp (string-append (getenv "TMPDIR") "/tmp")) (appimage (string-append tmp "/" logic)) (rpath (string-join (list "$ORIGIN" (string-append #$glibc "/lib") (string-append #$zlib "/lib")) ":")) (ld-so (string-append #$glibc #$(glibc-dynamic-linker)))) (mkdir-p tmp) (copy-file #$source (string-append tmp "/" logic)) (chmod appimage 493) (invoke "patchelf" "--set-rpath" rpath appimage) (invoke "patchelf" "--set-interpreter" ld-so appimage) (invoke appimage "--appimage-extract")))) (add-after 'install 'wrap-logic-and-shared-objects (lambda* (#:key inputs outpus #:allow-other-keys) (use-modules (ice-9 ftw) (ice-9 regex) (ice-9 textual-ports)) (let* ((Logic (string-append #$output "/bin/Logic")) (resources (string-append #$output "/bin/resources/linux")) (node (string-append #$output "/bin/resources/app.asar.unpacked/node_modules/@saleae/graph-interface/bin/linux-x64-106/graph-interface.node")) (python-libs (string-append resources "/pythonlibs/lib/python3.8/site-packages/numpy")) (libstdcpp (string-append resources "/optional/libstdc++/libstdc++.so.6")) (analyzers (string-append resources "/Analyzers")) (libffmpeg (string-append #$output "/lib/libffmpeg.so")) (libglesv2 (string-append #$output "/bin/libGLESv2.so")) (libegl (string-append #$output "/bin/libEGL.so")) (libanalyzer (string-append resources "/libAnalyzer.so")) (libgraph (string-append resources "/libgraph_server_shared.so")) (rpath-so (string-append (apply string-append (map (lambda (pkg) (string-append (assoc-ref inputs pkg) "/lib:")) '("gcc" "glibc"))) resources)) (rpath (string-append (apply string-append (map (lambda (pkg) (string-append (assoc-ref inputs pkg) "/lib:")) '("alsa-lib" "at-spi2-atk" "at-spi2-core" "atk" "gcc" "cairo" "cups" "dbus" "expat" "ffmpeg" "glib" "glibc" "gtk+" "libdrm" "libxkbcommon" "libxcb" "libxcomposite" "libxdamage" "libxext" "libxfixes" "libxrandr" "libx11" "mesa" "nspr" "pango" "zlib"))) #$nss "/lib/nss:" #$output "/lib")) (ld-so (string-append #$glibc #$(glibc-dynamic-linker)))) (delete-file libstdcpp) (delete-file-recursively python-libs) (invoke "patchelf" "--set-rpath" rpath libffmpeg) (invoke "patchelf" "--set-rpath" rpath libglesv2) (invoke "patchelf" "--set-rpath" rpath libegl) (invoke "patchelf" "--set-rpath" rpath-so node) (invoke "patchelf" "--set-rpath" rpath-so libanalyzer) (invoke "patchelf" "--set-rpath" rpath-so libgraph) (for-each (lambda (file) (invoke "patchelf" "--set-rpath" rpath-so (string-append analyzers "/" file))) (scandir analyzers (lambda (name) (string-contains name ".so")))) (copy-recursively (string-append #$output "/bin/resources/app.asar.unpacked/node_modules") (string-append #$output "/bin/resources/node_modules")) ; (delete-file-recursively (string-append #$output ; "/bin/resources/app.asar.unpacked")) ; (mkdir-p (string-append #$output ; "/bin/resources/app.asar.unpacked/node_modules/@saleae")) ; (copy-recursively (string-append #$output ; "/bin/resources/node_modules/@saleae/graph-interface") ; (string-append #$output ; "/bin/resources/app.asar.unpacked/node_modules/@saleae/graph-interface")) (invoke "patchelf" "--set-rpath" rpath Logic) (invoke "patchelf" "--set-interpreter" ld-so Logic))))))) (supported-systems '("x86_64-linux")) (native-inputs (list glibc zlib)) (inputs (list alsa-lib at-spi2-core at-spi2-atk atk cairo cups dbus expat ffmpeg `(,gcc "lib") glib gtk+ libdrm libxkbcommon libxcb libxcomposite libxdamage libxext libxfixes libxrandr libx11 mesa nspr nss pango)) (synopsis "") (description "") (home-page "") (license license:nonfree)))