From patchwork Fri Jun 19 00:41:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danny Milosavljevic X-Patchwork-Id: 22775 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 C8C7127BBE3; Fri, 19 Jun 2020 01:43:08 +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 296FF27BBE1 for ; Fri, 19 Jun 2020 01:43:08 +0100 (BST) Received: from localhost ([::1]:49458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jm57b-0004Rz-O0 for patchwork@mira.cbaines.net; Thu, 18 Jun 2020 20:43:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jm57W-0004Rl-OG for guix-patches@gnu.org; Thu, 18 Jun 2020 20:43:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jm57W-0004Y6-F1 for guix-patches@gnu.org; Thu, 18 Jun 2020 20:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jm57W-0008Ly-D0 for guix-patches@gnu.org; Thu, 18 Jun 2020 20:43:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41942] [PATCH v2] gnu: Add qdk. Resent-From: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 19 Jun 2020 00:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41942 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 41942@debbugs.gnu.org Cc: Danny Milosavljevic Received: via spool by 41942-submit@debbugs.gnu.org id=B41942.159252732232017 (code B ref 41942); Fri, 19 Jun 2020 00:43:02 +0000 Received: (at 41942) by debbugs.gnu.org; 19 Jun 2020 00:42:02 +0000 Received: from localhost ([127.0.0.1]:54721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jm56X-0008KE-DT for submit@debbugs.gnu.org; Thu, 18 Jun 2020 20:42:02 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:38570) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jm56V-0008K6-Nc for 41942@debbugs.gnu.org; Thu, 18 Jun 2020 20:42:00 -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 017E833687BB; Fri, 19 Jun 2020 02:41:58 +0200 (CEST) From: Danny Milosavljevic Date: Fri, 19 Jun 2020 02:41:54 +0200 Message-Id: <20200619004154.10013-1-dannym@scratchpost.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200619003913.9790-1-dannym@scratchpost.org> References: <20200619003913.9790-1-dannym@scratchpost.org> MIME-Version: 1.0 Tags: patch 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 | 259 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm index 9be1065de2..e24054543e 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,257 @@ 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) + (if (string-contains line "<<-EOF") + #t + (if (string-contains line "EOF") + #f + in-HERE?)))))))))) +;; 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@")) + ("\\