From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 14 00:03:24 2019 Received: (at submit) by debbugs.gnu.org; 14 Apr 2019 04:03:24 +0000 Received: from localhost ([127.0.0.1]:59638 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hFWMV-0001uy-Nj for submit@debbugs.gnu.org; Sun, 14 Apr 2019 00:03:24 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40847) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hFWMT-0001ul-UW for submit@debbugs.gnu.org; Sun, 14 Apr 2019 00:03:22 -0400 Received: from lists.gnu.org ([209.51.188.17]:47305) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hFWMM-0004WY-HS for submit@debbugs.gnu.org; Sun, 14 Apr 2019 00:03:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hFWML-0004vF-7L for guix-patches@gnu.org; Sun, 14 Apr 2019 00:03:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hFWMJ-0004Vu-OP for guix-patches@gnu.org; Sun, 14 Apr 2019 00:03:13 -0400 Received: from mail-qk1-x72c.google.com ([2607:f8b0:4864:20::72c]:44101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hFWMH-0004VG-GZ for guix-patches@gnu.org; Sun, 14 Apr 2019 00:03:11 -0400 Received: by mail-qk1-x72c.google.com with SMTP id y5so7990202qkc.11 for ; Sat, 13 Apr 2019 21:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version; bh=Dr0JfzDXWBOkheRrM0s8adsWkUEWG3aTHMkMZ+MOe7o=; b=sBN1kys42//CxifOE5FQU5vnwMZqNNcO6K7G5NskqsUbAPS9kDlGdHykRTNEcdsnCS JThY1hn2JMcRMo7dBbw0vHPkY4b9aw2ydHKZTShV+/6qqg201P7KpzTamIfZzchLl+DW snVBYP2BJmECC3QYfEuzs24d2cbczcLUuQm8XY0Ged0kU4LNx0LKBAKvU/Fj5Ffv55Y/ l6gTdebx+XIhSQB5hf3rLL+4MRDBVc8nXymssaQs06dKsrMy2X1boDum5n/Sc3F1+3vA rTN3XJwNMGjuWPwOzdmIPD8I9ekjw4jbAzNo/7GNe0qii/Kpbaso9G72cUGC1aGDncYq lr2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version; bh=Dr0JfzDXWBOkheRrM0s8adsWkUEWG3aTHMkMZ+MOe7o=; b=NpKx4BQEjgilFYDkvKuw1wa5VDHOJ+BehpX6HuxVx05RgzMQwoNc/H7oRax1StmIHx oV2uRKAHPUZe/SU/JviN2fBobgKQ1F8yG5nDJOOHN2W4CTxb/tJNEA1QE60HihS/iQD2 M5eUNSYyLJr+Rg5EFpqP60XxNxahrliSIRyJrRBigbNns92D5Ro6X/QOP+T8EmKiT76/ X17oczCGqNAJ92bHDXUjerExRyIqR7UPLqXIM0zmSbtpafB7IUUmGInT8KB2h97PcMyH bp/7J48DXE91rHr/kDmBk4oTAp02eMOHpkTAu6U4lTkyBZ6vdtCQ0wXb+Xcz/rYD+pP0 kuFA== X-Gm-Message-State: APjAAAX1anZH+1HFeD4SvKZ9YnqMi0g7X271o6wmEDVDyp5/ydYGqLAM xyzpwSA7nycrRRZ0QcbgtR97kNG0 X-Google-Smtp-Source: APXvYqzeM2umPyne+im9bHycFHeweAOZPStOIlYSdhTwWbW3/o740LBaIqhYvPvJ2rIxx5lpohwzsQ== X-Received: by 2002:a37:a797:: with SMTP id q145mr51239899qke.292.1555214587597; Sat, 13 Apr 2019 21:03:07 -0700 (PDT) Received: from kwak (dsl-205-236-230-30.b2b2c.ca. [205.236.230.30]) by smtp.gmail.com with ESMTPSA id m31sm32977806qtm.46.2019.04.13.21.03.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 13 Apr 2019 21:03:06 -0700 (PDT) From: Maxim Cournoyer To: guix-patches Subject: [PATCH] build: go-build-system: Ensure uniform unpacking directory. Date: Sun, 14 Apr 2019 00:03:05 -0400 Message-ID: <87tvf1nshy.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::72c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain This fixes a problem in the go-build-system's unpack phase. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-build-go-build-system-Re-ident.patch From b1474516120cdc843d7c59c4d9db4b9ed5e299bf Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Thu, 4 Apr 2019 23:24:57 -0400 Subject: [PATCH 1/3] build: go-build-system: Re-ident. * guix/build/go-build-system.scm (unpack): Fix indentation. --- guix/build/go-build-system.scm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index 1a716cea77..d03aefd018 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -161,12 +161,12 @@ unpacking." (let ((dest (string-append (getenv "GOPATH") "/src/" unpack-path))) (mkdir-p dest) (if (file-is-directory? source) - (begin - (copy-recursively source dest #:keep-mtime? #t) - #t) - (if (string-suffix? ".zip" source) - (invoke "unzip" "-d" dest source) - (invoke "tar" "-C" dest "-xvf" source))))) + (begin + (copy-recursively source dest #:keep-mtime? #t) + #t) + (if (string-suffix? ".zip" source) + (invoke "unzip" "-d" dest source) + (invoke "tar" "-C" dest "-xvf" source))))) (define (go-package? name) (string-prefix? "go-" name)) -- 2.20.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-build-go-build-system-Use-WHEN-for-side-effect-condi.patch From b7af3222730b20329e3b0da42e6cb591b9cd137c Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Thu, 4 Apr 2019 23:26:04 -0400 Subject: [PATCH 2/3] build: go-build-system: Use WHEN for side-effect conditionals. * guix/build/go-build-system.scm (unpack): Replace single branch `if' by `when'. --- guix/build/go-build-system.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index d03aefd018..e59aa59092 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -158,6 +158,10 @@ unpacking." ((display "WARNING: The Go import path is unset.\n"))) (if (string-null? unpack-path) (set! unpack-path import-path)) + (when (string-null? import-path) + ((display "WARNING: The Go import path is unset.\n"))) + (when (string-null? unpack-path) + (set! unpack-path import-path)) (let ((dest (string-append (getenv "GOPATH") "/src/" unpack-path))) (mkdir-p dest) (if (file-is-directory? source) -- 2.20.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-build-go-build-system-Ensure-uniform-unpacking-direc.patch From 1f7535fbe28f7ac96e824b792e9f1a140b8c54cd Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Fri, 5 Apr 2019 00:00:08 -0400 Subject: [PATCH 3/3] build: go-build-system: Ensure uniform unpacking directory. Depending on whether the source is a directory or an archive, we strip the source directory or preserve it, respectively. This change makes it so that whether the type of the source, it is unpacked at the expected location given by the IMPORT-PATH of the Go build system. * guix/build/go-build-system.scm: Add the (ice-9 ftw) module. (unpack): Add inner procedure to maybe strip the top level directory of an archive, document it and use it. --- guix/build/go-build-system.scm | 35 +++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index e59aa59092..c1a0d6441c 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -22,6 +22,7 @@ #:use-module (guix build union) #:use-module (guix build utils) #:use-module (ice-9 match) + #:use-module (ice-9 ftw) #:use-module (srfi srfi-1) #:use-module (rnrs io ports) #:use-module (rnrs bytevectors) @@ -151,13 +152,31 @@ dependencies, so it should be self-contained." #t) (define* (unpack #:key source import-path unpack-path #:allow-other-keys) - "Relative to $GOPATH, unpack SOURCE in the UNPACK-PATH, or the IMPORT-PATH is -the UNPACK-PATH is unset. When SOURCE is a directory, copy it instead of + "Relative to $GOPATH, unpack SOURCE in UNPACK-PATH, or IMPORT-PATH when +UNPACK-PATH is unset. If the SOURCE archive has a single top level directory, +it is stripped so that the sources appear directly under UNPACK-PATH. When +SOURCE is a directory, copy its content into UNPACK-PATH instead of unpacking." - (if (string-null? import-path) - ((display "WARNING: The Go import path is unset.\n"))) - (if (string-null? unpack-path) - (set! unpack-path import-path)) + (define (unpack-maybe-strip source dest) + (let* ((scratch-dir (string-append (or (getenv "TMPDIR") "/tmp") + "/scratch-dir")) + (out (mkdir-p scratch-dir))) + (with-directory-excursion scratch-dir + (if (string-suffix? ".zip" source) + (invoke "unzip" source) + (invoke "tar" "-xvf" source)) + (let ((top-level-files (remove (lambda (x) + (member x '("." ".."))) + (scandir ".")))) + (match top-level-files + ((top-level-file) + (when (file-is-directory? top-level-file) + (copy-recursively top-level-file dest #:keep-mtime? #t))) + (_ + (copy-recursively "." dest #:keep-mtime? #t))) + #t)) + (delete-file-recursively scratch-dir))) + (when (string-null? import-path) ((display "WARNING: The Go import path is unset.\n"))) (when (string-null? unpack-path) @@ -168,9 +187,7 @@ unpacking." (begin (copy-recursively source dest #:keep-mtime? #t) #t) - (if (string-suffix? ".zip" source) - (invoke "unzip" "-d" dest source) - (invoke "tar" "-C" dest "-xvf" source))))) + (unpack-maybe-strip source dest)))) (define (go-package? name) (string-prefix? "go-" name)) -- 2.20.1 --=-=-=--