From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dr4iN-0001Ue-Et for guix-patches@gnu.org; Sun, 10 Sep 2017 12:04:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dr4iI-0005ft-Sv for guix-patches@gnu.org; Sun, 10 Sep 2017 12:04:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:50845) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dr4iI-0005fg-PC for guix-patches@gnu.org; Sun, 10 Sep 2017 12:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dr4iI-0002i0-A2 for guix-patches@gnu.org; Sun, 10 Sep 2017 12:04:02 -0400 Subject: [bug#28281] [PATCH] gnu: Add os-prober. Resent-Message-ID: Message-Id: MIME-Version: 1.0 From: Arun Isaac Date: Sun, 10 Sep 2017 21:32:19 +0530 In-reply-to: <874lsa900c.fsf@gnu.org> References: <20170909171635.7968-1-arunisaac@systemreboot.net> <874lsa900c.fsf@gnu.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 28281@debbugs.gnu.org >>> + (replace 'install >>> + (lambda* (#:key outputs #:allow-other-keys) >>> + (define (find-files-non-recursive directory) >>> + (find-files directory >>> + (lambda (file stat) >>> + (string-match (string-append "^" directory "/[^/]*$") >>> + file)) >>> + #:directories? #t)) >> >> Do you think it would be a good idea to add a #:recursive? keyword >> argument to `find-files' in (guix build utils), instead of creating this >> `find-files-non-recursive-function' here? > > Hmm I didn’t understand that it *had* to be non-recursive. Does it > really make a difference? I am trying to do cp -r /some/directory/* destination To do this, I used `find-files-non-recursive' to get all files in /some/directory/ and applied `copy-recursively' on each one of them. Do you have a better way of doing this in mind? > If it does, then ‘scandir’ from (ice-9 ftw) would be the thing. Sorry > if I led you in the wrong direction. :-/ Yes, scandir could be used. But, it also returns "." and "..", and I'll have to filter them out. So code length, or clarity-wise, it won't be much of an improvement. That is why I thought adding a #:recursive? argument to `find-files' would be nice. >>> + (let* ((out (assoc-ref outputs "out")) >>> + (bin (string-append out "/bin")) >>> + (lib (string-append out "/lib")) >>> + (share (string-append out "/share"))) >>> + (for-each (cut install-file <> bin) >>> + (list "linux-boot-prober" "os-prober")) >>> + (install-file "newns" (string-append lib "/os-prober")) >>> + (install-file "common.sh" (string-append share "/os-prober")) >>> + (install-file "os-probes/mounted/powerpc/20macosx" >>> + (string-append lib "/os-probes/mounted")) >>> + (for-each >>> + (lambda (directory) >>> + (for-each >>> + (lambda (file) >>> + (let ((destination (string-append lib "/" directory >>> + "/" (basename file)))) >>> + (mkdir-p (dirname destination)) >>> + (copy-recursively file destination))) >>> + (append (find-files-non-recursive (string-append directory "/common")) >>> + (find-files-non-recursive (string-append directory "/x86"))))) >>> + (list "os-probes" "os-probes/mounted" "os-probes/init" >>> + "linux-boot-probes" "linux-boot-probes/mounted")) >>> + #t))))))