From patchwork Fri Jun 19 00:39:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danny Milosavljevic X-Patchwork-Id: 22774 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 26B8227BBE1; Fri, 19 Jun 2020 01:40:09 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 60B2027BBE3 for ; Fri, 19 Jun 2020 01:40:08 +0100 (BST) Received: from localhost ([::1]:49156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jm54h-0002vr-SN for patchwork@mira.cbaines.net; Thu, 18 Jun 2020 20:40:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jm54c-0002vh-5E for guix-patches@gnu.org; Thu, 18 Jun 2020 20:40:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jm54b-0003w6-RG for guix-patches@gnu.org; Thu, 18 Jun 2020 20:40:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jm54b-0008Gv-O1 for guix-patches@gnu.org; Thu, 18 Jun 2020 20:40:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41942] [PATCH] gnu: Add qdk. Resent-From: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 Jun 2020 00:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41942 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41942@debbugs.gnu.org Cc: Danny Milosavljevic X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.159252716631747 (code B ref -1); Fri, 19 Jun 2020 00:40:01 +0000 Received: (at submit) by debbugs.gnu.org; 19 Jun 2020 00:39:26 +0000 Received: from localhost ([127.0.0.1]:54716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jm541-0008Fy-Lv for submit@debbugs.gnu.org; Thu, 18 Jun 2020 20:39:26 -0400 Received: from lists.gnu.org ([209.51.188.17]:47848) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jm53z-0008Fr-Ua for submit@debbugs.gnu.org; Thu, 18 Jun 2020 20:39:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jm53z-0002rN-NS for guix-patches@gnu.org; Thu, 18 Jun 2020 20:39:23 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:60728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jm53w-0003od-CE for guix-patches@gnu.org; Thu, 18 Jun 2020 20:39:23 -0400 Received: from dayas.lan (80-110-127-207.cgn.dynamic.surfer.at [80.110.127.207]) by dd26836.kasserver.com (Postfix) with ESMTPSA id CE25433687BB; Fri, 19 Jun 2020 02:39:15 +0200 (CEST) From: Danny Milosavljevic Date: Fri, 19 Jun 2020 02:39:13 +0200 Message-Id: <20200619003913.9790-1-dannym@scratchpost.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Tags: patch Received-SPF: none client-ip=85.13.145.193; envelope-from=dannym@scratchpost.org; helo=dd26836.kasserver.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/18 20:39:16 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/embedded.scm (qdk): New variable. --- gnu/packages/embedded.scm | 256 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm index 9be1065de2..c0fc534320 100644 --- a/gnu/packages/embedded.scm +++ b/gnu/packages/embedded.scm @@ -39,18 +39,23 @@ #:use-module (gnu packages autotools) #:use-module ((gnu packages base) #:prefix base:) #:use-module (gnu packages bison) + #:use-module (gnu packages compression) #:use-module (gnu packages cross-base) #:use-module (gnu packages dejagnu) #:use-module (gnu packages flex) + #:use-module (gnu packages gawk) #:use-module (gnu packages gcc) #:use-module (gnu packages gdb) + #:use-module (gnu packages gnupg) #:use-module (gnu packages guile) #:use-module (gnu packages libftdi) #:use-module (gnu packages libusb) + #:use-module (gnu packages linux) #:use-module (gnu packages perl) #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages python-xyz) + #:use-module (gnu packages rsync) #:use-module (gnu packages swig) #:use-module (gnu packages texinfo) #:use-module (gnu packages xorg) @@ -1352,3 +1357,254 @@ simplifies configuration and is also pluggable: you can write your own west this feature to provide conveniences for building applications, flashing and debugging them, and more.") (license license:expat))) + +(define-public qdk + (package + (name "qdk") + (version "2.3.11") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/qnap-dev/QDK.git") + (commit (string-append "v" version)))) + (file-name (string-append name "-" version "-checkout")) + (sha256 + (base32 + "1zp045b1wqwjq2aah46dv08bz9i841acrmy328q5i8filbndvjx1")))) + (build-system gnu-build-system) + (arguments + `(#:tests? #f ; No tests + #:make-flags '("CC=gcc") + #:modules + ((guix build gnu-build-system) + (guix build utils) + (ice-9 regex) + (ice-9 match) + (ice-9 rdelim) + (ice-9 textual-ports) + (srfi srfi-1)) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'patch-references + (lambda* (#:key inputs outputs #:allow-other-keys) + (define (substitute-without-HERE file pattern+procs) + "PATTERN+PROCS is a list of regexp/two-argument-procedure pairs. +For each line of FILE, and for each PATTERN that it matches, call the +corresponding PROC as (PROC LINE MATCHES); PROC must return the line that will +be written as a substitution of the original line. Be careful about using '$' +to match the end of a line; by itself it won't match the terminating newline +of a line. + +HERE document contents are ignored." + (let ((rx+proc (map (match-lambda + (((? regexp? pattern) . proc) + (cons pattern proc)) + ((pattern . proc) + (cons (make-regexp pattern regexp/extended) + proc))) + pattern+procs))) + (with-atomic-file-replacement file + (lambda (in out) + (let loop ((line (read-line in 'concat)) + (in-HERE? #f)) + (if (eof-object? line) + #t + (let ((line (fold (lambda (r+p line) + (match r+p + ((regexp . proc) + (match (list-matches regexp line) + ((and m+ (_ _ ...)) + (proc line m+)) + (_ line))))) + line + rx+proc))) + (display line out) + (loop (read-line in 'concat) + (or (and in-HERE? (not (string-contains line "EOF")) + (string-contains line "<<-EOF"))))))))))) +;; That was copied from guix/build/utils.scm. +(define-syntax let-matches + ;; Helper macro for `substitute*'. + (syntax-rules (_) + ((let-matches index match (_ vars ...) body ...) + (let-matches (+ 1 index) match (vars ...) + body ...)) + ((let-matches index match (var vars ...) body ...) + (let ((var (match:substring match index))) + (let-matches (+ 1 index) match (vars ...) + body ...))) + ((let-matches index match () body ...) + (begin body ...)))) + + (define (make-substitutor callback) + (lambda (l m+) + ;; Iterate over matches M+ and return the + ;; modified line based on L. + (let loop ((m* m+) ; matches + (o 0) ; offset in L + (r '())) ; result + (match m* + (() + (let ((r (cons (substring l o) r))) + (string-concatenate-reverse r))) + ((m . rest) + (let-matches 0 m (v) ; or () + (loop rest + (match:end m) + (cons* + (callback l m+) + (substring l o (match:start m)) + r)))))))) + (substitute-without-HERE "shared/bin/qbuild" + `(("command -v awk" . + ,(make-substitutor (lambda (line matches) + (string-append "command -v " (assoc-ref inputs "gawk") "/bin/gawk")))) + ("command -v cmp" . + ,(make-substitutor (lambda (line matches) + (string-append "command -v " (assoc-ref inputs "diffutils") + "/bin/cmp")))) + ("command -v python2" . + ,(make-substitutor (lambda (line matches) + (string-append "command -v " (assoc-ref inputs "python-2") "/bin/python2")))) + ("command -v md5sum" . + ,(make-substitutor (lambda (line matches) + (string-append "command -v " (assoc-ref inputs "coreutils") "/bin/md5sum")))) + ("command -v gpg2" . + ,(make-substitutor (lambda (line matches) + (string-append "command -v " (assoc-ref inputs "gnupg") "/bin/gpg")))) + ("qpkg_encrypt " . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref outputs "out") + "/share/QDK/bin/qpkg_encrypt ")))) + ;("/usr/bin" . ,(lambda (line matches) + ; "/bin")) + ("/usr/bin/hexdump\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "util-linux") + "/bin/hexdump")))) + ("/usr/bin/rsync\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "rsync") "/bin/rsync")))) + ("/usr/bin/expr\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/expr")))) + ("/usr/bin/bunzip2\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "bzip2") + "/bin/bunzip2")))) + ("/usr/local/sbin/7z\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "p7zip") "/bin/7z")))) + ("/usr/bin/whoami\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/whoami")))) + ("/usr/bin/tail\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/tail")))) + ("/usr/bin/basename\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/basename")))) + ("/bin/grep\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "grep") "/bin/grep")))) + ("/bin/sed\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "sed") "/bin/sed")))) + ("/bin/dd\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") "/bin/dd")))) + ("/bin/ls\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") "/bin/ls")))) + ("/bin/rm\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") "/bin/rm")))) + ("/bin/cp\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") "/bin/cp")))) + ("/bin/cut\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/cut")))) + ("/bin/tar\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "tar") "/bin/tar")))) + ("/bin/gzip\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "gzip") "/bin/gzip")))) + ("/bin/mkdir\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/mkdir")))) + ("/bin/cat\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/cat")))) + ("/bin/echo\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/echo")))) + ("/bin/uname\\>" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref inputs "coreutils") + "/bin/uname")))) + ("/etc/config/qdk.conf" . + ,(make-substitutor (lambda (line matches) + (string-append (assoc-ref outputs "out") + "/etc/config/qdk.conf")))) + ("/usr/bin" . + ,(lambda (line matches) + "@ERROR@")) + ("\\