* Add a generalized git-file? to Guix?
[not found] ` <CAJ=RwfZXpvZ-DVq4G7M=bExonU2gWe-fOFsk8eaQJU40Z1+fNA@mail.gmail.com>
@ 2017-01-11 15:29 ` Christopher Allan Webber
2017-01-11 17:47 ` Mathieu Lirzin
0 siblings, 1 reply; 7+ messages in thread
From: Christopher Allan Webber @ 2017-01-11 15:29 UTC (permalink / raw)
To: Guix-devel
Thompson, David writes:
> Hi Christopher and Jan,
>
> On Tue, Jan 10, 2017 at 11:28 AM, Christopher Allan Webber
> <cwebber@dustycloud.org> wrote:
>> Jan Nieuwenhuizen writes:
>>
>>> Christopher Allan Webber writes:
>>>
>>>> Thanks!
>>>>
>>>> The file is updated, and even nicer now, since I'm using a hack from
>>>> guile-sdl2 which allows you to set the source to the whole checkout.
>>>
>>> Ohh! That needs to go in the Guix manual... could git-file? be added
>>> to guix/utils?
>>
>> Maybe! I think David knows more about the provenance?
>
> I took this code from Ludovic. See make-git-predicate in
> gnu/packages/package-management.scm in the Guix source tree.
>
>> I agree it would be nice to have in Guix itself.
>
> Agreed. A generalized and publicly available procedure would be great.
>
> - Dave
Hello! See the above conversation... 8sync now uses `git-file?' in its
guix.scm, a predicate check which allows for checking out the whole
local directory as a "source" for testing a package. I borrowed it from
Dave who originally adapted it from some code in Guix itself. See:
http://git.savannah.gnu.org/cgit/8sync.git/tree/guix.scm#n62
This is pretty handy; probably other projects would like to make use of
it. What do we think of making it a generally available utility?
- Chris
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add a generalized git-file? to Guix?
2017-01-11 15:29 ` Add a generalized git-file? to Guix? Christopher Allan Webber
@ 2017-01-11 17:47 ` Mathieu Lirzin
2017-01-12 14:32 ` Ludovic Courtès
0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Lirzin @ 2017-01-11 17:47 UTC (permalink / raw)
To: Christopher Allan Webber; +Cc: Guix-devel
Hi,
Christopher Allan Webber <cwebber@dustycloud.org> writes:
> Thompson, David writes:
>
>> Hi Christopher and Jan,
>>
>> On Tue, Jan 10, 2017 at 11:28 AM, Christopher Allan Webber
>> <cwebber@dustycloud.org> wrote:
>>> Jan Nieuwenhuizen writes:
>>>
>>>> Christopher Allan Webber writes:
>>>>
>>>>> Thanks!
>>>>>
>>>>> The file is updated, and even nicer now, since I'm using a hack from
>>>>> guile-sdl2 which allows you to set the source to the whole checkout.
>>>>
>>>> Ohh! That needs to go in the Guix manual... could git-file? be added
>>>> to guix/utils?
>>>
>>> Maybe! I think David knows more about the provenance?
>>
>> I took this code from Ludovic. See make-git-predicate in
>> gnu/packages/package-management.scm in the Guix source tree.
>>
>>> I agree it would be nice to have in Guix itself.
>>
>> Agreed. A generalized and publicly available procedure would be great.
>>
>> - Dave
>
> Hello! See the above conversation... 8sync now uses `git-file?' in its
> guix.scm, a predicate check which allows for checking out the whole
> local directory as a "source" for testing a package. I borrowed it from
> Dave who originally adapted it from some code in Guix itself. See:
>
> http://git.savannah.gnu.org/cgit/8sync.git/tree/guix.scm#n62
>
> This is pretty handy; probably other projects would like to make use of
> it. What do we think of making it a generally available utility?
I would make use of it and I am in favour of adding it to Guix.
Thanks.
--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add a generalized git-file? to Guix?
2017-01-11 17:47 ` Mathieu Lirzin
@ 2017-01-12 14:32 ` Ludovic Courtès
2017-01-28 23:50 ` Mathieu Lirzin
0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2017-01-12 14:32 UTC (permalink / raw)
To: Mathieu Lirzin; +Cc: Guix-devel
Howdy!
Mathieu Lirzin <mthl@gnu.org> skribis:
> Christopher Allan Webber <cwebber@dustycloud.org> writes:
>
>> Thompson, David writes:
>>
>>> Hi Christopher and Jan,
>>>
>>> On Tue, Jan 10, 2017 at 11:28 AM, Christopher Allan Webber
>>> <cwebber@dustycloud.org> wrote:
>>>> Jan Nieuwenhuizen writes:
>>>>
>>>>> Christopher Allan Webber writes:
>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> The file is updated, and even nicer now, since I'm using a hack from
>>>>>> guile-sdl2 which allows you to set the source to the whole checkout.
>>>>>
>>>>> Ohh! That needs to go in the Guix manual... could git-file? be added
>>>>> to guix/utils?
>>>>
>>>> Maybe! I think David knows more about the provenance?
>>>
>>> I took this code from Ludovic. See make-git-predicate in
>>> gnu/packages/package-management.scm in the Guix source tree.
>>>
>>>> I agree it would be nice to have in Guix itself.
>>>
>>> Agreed. A generalized and publicly available procedure would be great.
>>>
>>> - Dave
>>
>> Hello! See the above conversation... 8sync now uses `git-file?' in its
>> guix.scm, a predicate check which allows for checking out the whole
>> local directory as a "source" for testing a package. I borrowed it from
>> Dave who originally adapted it from some code in Guix itself. See:
>>
>> http://git.savannah.gnu.org/cgit/8sync.git/tree/guix.scm#n62
>>
>> This is pretty handy; probably other projects would like to make use of
>> it. What do we think of making it a generally available utility?
>
> I would make use of it and I am in favour of adding it to Guix.
I think it comes from ‘current-guix’ in package-management.scm, and yes,
we should probably make it public.
Would someone like to submit a patch? The most difficult issue is
finding in file in which to store it. ;-) Maybe git-download.scm?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add a generalized git-file? to Guix?
2017-01-12 14:32 ` Ludovic Courtès
@ 2017-01-28 23:50 ` Mathieu Lirzin
2017-01-30 22:46 ` Ludovic Courtès
0 siblings, 1 reply; 7+ messages in thread
From: Mathieu Lirzin @ 2017-01-28 23:50 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
[-- Attachment #1: Type: text/plain, Size: 1099 bytes --]
Hello,
ludo@gnu.org (Ludovic Courtès) writes:
> Mathieu Lirzin <mthl@gnu.org> skribis:
>
>> Christopher Allan Webber <cwebber@dustycloud.org> writes:
>>
>>> 8sync now uses `git-file?' in its guix.scm, a predicate check which
>>> allows for checking out the whole local directory as a "source" for
>>> testing a package. I borrowed it from Dave who originally adapted
>>> it from some code in Guix itself. See:
>>>
>>> http://git.savannah.gnu.org/cgit/8sync.git/tree/guix.scm#n62
>>>
>>> This is pretty handy; probably other projects would like to make use of
>>> it. What do we think of making it a generally available utility?
>>
>> I would make use of it and I am in favour of adding it to Guix.
>
> I think it comes from ‘current-guix’ in package-management.scm, and yes,
> we should probably make it public.
>
> Would someone like to submit a patch? The most difficult issue is
> finding in file in which to store it. ;-) Maybe git-download.scm?
Here is a patch renaming 'make-git-predicate' to 'git-predicate' and
moving it to (guix git-download).
[-- Attachment #2: 0001-git-download-Add-git-predicate.patch --]
[-- Type: text/x-diff, Size: 6156 bytes --]
From f104b3745097746d6ef89b6198ec7b81e8b679f4 Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl@gnu.org>
Date: Sun, 29 Jan 2017 00:34:48 +0100
Subject: [PATCH] git-download: Add 'git-predicate'.
* guix/git-download.scm (git-predicate): New procedure.
* gnu/packages/package-management.scm (current-guix): Use it.
(make-git-predicate): Remove.
---
gnu/packages/package-management.scm | 37 +------------------------------
guix/git-download.scm | 43 ++++++++++++++++++++++++++++++++++++-
2 files changed, 43 insertions(+), 37 deletions(-)
diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 92787d76c..272fc6ab0 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -25,7 +25,6 @@
#:use-module (guix utils)
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
- #:use-module ((guix build utils) #:select (with-directory-excursion))
#:use-module ((guix licenses) #:select (gpl2+ gpl3+ lgpl2.1+ asl2.0))
#:use-module (gnu packages)
#:use-module (gnu packages guile)
@@ -53,10 +52,6 @@
#:use-module (gnu packages tls)
#:use-module (gnu packages ssh)
#:use-module (gnu packages vim)
- #:use-module (srfi srfi-1)
- #:use-module (srfi srfi-26)
- #:use-module (ice-9 popen)
- #:use-module (ice-9 rdelim)
#:use-module (ice-9 match))
(define (boot-guile-uri arch)
@@ -275,38 +270,8 @@ generated file."
(_
#t)))
-(define (make-git-predicate directory)
- "Return a predicate that returns true if a file is part of the Git checkout
-living at DIRECTORY. Upon Git failure, return #f instead of a predicate."
- (define (parent-directory? thing directory)
- ;; Return #t if DIRECTORY is the parent of THING.
- (or (string-suffix? thing directory)
- (and (string-index thing #\/)
- (parent-directory? (dirname thing) directory))))
-
- (let* ((pipe (with-directory-excursion directory
- (open-pipe* OPEN_READ "git" "ls-files")))
- (files (let loop ((lines '()))
- (match (read-line pipe)
- ((? eof-object?)
- (reverse lines))
- (line
- (loop (cons line lines))))))
- (status (close-pipe pipe)))
- (and (zero? status)
- (lambda (file stat)
- (match (stat:type stat)
- ('directory
- ;; 'git ls-files' does not list directories, only regular files,
- ;; so we need this special trick.
- (any (cut parent-directory? <> file) files))
- ((or 'regular 'symlink)
- (any (cut string-suffix? <> file) files))
- (_
- #f))))))
-
(define-public current-guix
- (let ((select? (delay (or (make-git-predicate
+ (let ((select? (delay (or (git-predicate
(string-append (current-source-directory)
"/../.."))
source-file?))))
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 62e625c71..5d86ab2b6 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017 Mathieu Lirzin <mthl@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -17,6 +18,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix git-download)
+ #:use-module (guix build utils)
#:use-module (guix gexp)
#:use-module (guix store)
#:use-module (guix monads)
@@ -24,6 +26,9 @@
#:use-module (guix packages)
#:autoload (guix build-system gnu) (standard-packages)
#:use-module (ice-9 match)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 rdelim)
+ #:use-module (srfi srfi-1)
#:export (git-reference
git-reference?
git-reference-url
@@ -32,7 +37,8 @@
git-fetch
git-version
- git-file-name))
+ git-file-name
+ git-predicate))
;;; Commentary:
;;;
@@ -119,4 +125,39 @@ HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
"Return the file-name for packages using git-download."
(string-append name "-" version "-checkout"))
+(define (git-predicate directory)
+ "Return a predicate that returns true if a file is part of the Git checkout
+living at DIRECTORY. Upon Git failure, return #f instead of a predicate.
+
+The returned predicate takes two arguments FILE and STAT where FILE is an
+absolute file name and STAT is the result of 'lstat'."
+ (define (parent-directory? thing directory)
+ ;; Return #t if DIRECTORY is the parent of THING.
+ (or (string-suffix? thing directory)
+ (and (string-index thing #\/)
+ (parent-directory? (dirname thing) directory))))
+
+ (let* ((pipe (with-directory-excursion directory
+ (open-pipe* OPEN_READ "git" "ls-files")))
+ (files (let loop ((lines '()))
+ (match (read-line pipe)
+ ((? eof-object?)
+ (reverse lines))
+ (line
+ (loop (cons line lines))))))
+ (status (close-pipe pipe)))
+ (and (zero? status)
+ (lambda (file stat)
+ (match (stat:type stat)
+ ('directory
+ ;; 'git ls-files' does not list directories, only regular files,
+ ;; so we need this special trick.
+ (any (lambda (f) (parent-directory? f file))
+ files))
+ ((or 'regular 'symlink)
+ (any (lambda (f) (string-suffix? f file))
+ files))
+ (_
+ #f))))))
+
;;; git-download.scm ends here
--
2.11.0
[-- Attachment #3: Type: text/plain, Size: 85 bytes --]
Thanks.
--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Add a generalized git-file? to Guix?
2017-01-28 23:50 ` Mathieu Lirzin
@ 2017-01-30 22:46 ` Ludovic Courtès
2017-02-09 19:58 ` Christopher Allan Webber
0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2017-01-30 22:46 UTC (permalink / raw)
To: Mathieu Lirzin; +Cc: Guix-devel
Mathieu Lirzin <mthl@gnu.org> skribis:
> From f104b3745097746d6ef89b6198ec7b81e8b679f4 Mon Sep 17 00:00:00 2001
> From: Mathieu Lirzin <mthl@gnu.org>
> Date: Sun, 29 Jan 2017 00:34:48 +0100
> Subject: [PATCH] git-download: Add 'git-predicate'.
>
> * guix/git-download.scm (git-predicate): New procedure.
> * gnu/packages/package-management.scm (current-guix): Use it.
> (make-git-predicate): Remove.
LGTM, thanks!
Ludo'.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add a generalized git-file? to Guix?
2017-01-30 22:46 ` Ludovic Courtès
@ 2017-02-09 19:58 ` Christopher Allan Webber
2017-02-09 20:33 ` Mathieu Lirzin
0 siblings, 1 reply; 7+ messages in thread
From: Christopher Allan Webber @ 2017-02-09 19:58 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: Guix-devel
Ludovic Courtès writes:
> Mathieu Lirzin <mthl@gnu.org> skribis:
>
>> From f104b3745097746d6ef89b6198ec7b81e8b679f4 Mon Sep 17 00:00:00 2001
>> From: Mathieu Lirzin <mthl@gnu.org>
>> Date: Sun, 29 Jan 2017 00:34:48 +0100
>> Subject: [PATCH] git-download: Add 'git-predicate'.
>>
>> * guix/git-download.scm (git-predicate): New procedure.
>> * gnu/packages/package-management.scm (current-guix): Use it.
>> (make-git-predicate): Remove.
>
> LGTM, thanks!
>
> Ludo'.
I just pushed this. Switching my various projects over to using it now.
Thank you for doing the work to abstract it out Mathieu!
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add a generalized git-file? to Guix?
2017-02-09 19:58 ` Christopher Allan Webber
@ 2017-02-09 20:33 ` Mathieu Lirzin
0 siblings, 0 replies; 7+ messages in thread
From: Mathieu Lirzin @ 2017-02-09 20:33 UTC (permalink / raw)
To: Christopher Allan Webber; +Cc: Guix-devel
Christopher Allan Webber <cwebber@dustycloud.org> writes:
> Ludovic Courtès writes:
>
>> Mathieu Lirzin <mthl@gnu.org> skribis:
>>
>>> From f104b3745097746d6ef89b6198ec7b81e8b679f4 Mon Sep 17 00:00:00 2001
>>> From: Mathieu Lirzin <mthl@gnu.org>
>>> Date: Sun, 29 Jan 2017 00:34:48 +0100
>>> Subject: [PATCH] git-download: Add 'git-predicate'.
>>>
>>> * guix/git-download.scm (git-predicate): New procedure.
>>> * gnu/packages/package-management.scm (current-guix): Use it.
>>> (make-git-predicate): Remove.
>>
>> LGTM, thanks!
>>
>> Ludo'.
>
> I just pushed this. Switching my various projects over to using it now.
> Thank you for doing the work to abstract it out Mathieu!
Thank you for pushing it.
--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761 070D 0ADE E100 9460 4D37
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-02-09 20:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <87twkpkdpw.fsf@drakenvlieg.flower>
[not found] ` <87eg0eouv6.fsf@gnu.org>
[not found] ` <87a8b1fg7q.fsf@dustycloud.org>
[not found] ` <871swbe7ev.fsf@gnu.org>
[not found] ` <87eg0ag9q8.fsf@dustycloud.org>
[not found] ` <CAJ=RwfZXpvZ-DVq4G7M=bExonU2gWe-fOFsk8eaQJU40Z1+fNA@mail.gmail.com>
2017-01-11 15:29 ` Add a generalized git-file? to Guix? Christopher Allan Webber
2017-01-11 17:47 ` Mathieu Lirzin
2017-01-12 14:32 ` Ludovic Courtès
2017-01-28 23:50 ` Mathieu Lirzin
2017-01-30 22:46 ` Ludovic Courtès
2017-02-09 19:58 ` Christopher Allan Webber
2017-02-09 20:33 ` Mathieu Lirzin
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).