unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#28281] [PATCH] gnu: Add os-prober.
       [not found] <20170909171635.7968-1-arunisaac@systemreboot.net>
@ 2017-09-09 17:24 ` Arun Isaac
       [not found] ` <e7d9c9ca.AEQAP00oGCwAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtCPY@mailjet.com>
  1 sibling, 0 replies; 9+ messages in thread
From: Arun Isaac @ 2017-09-09 17:24 UTC (permalink / raw)
  To: 28281


Here's an updated patch.

> +         (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?

> +             (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))))))

I have used `find-files' instead of `ftw', as you suggested. The install
procedure is clearer now. but still remains quite messy. It is not
simple enough to separate the "candidate-files" and "install-file"
logic.

WDYT? Will the above code do?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#28281] [PATCH] gnu: Add os-prober.
       [not found] ` <e7d9c9ca.AEQAP00oGCwAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtCPY@mailjet.com>
@ 2017-09-10 13:05   ` Ludovic Courtès
  2017-09-10 16:02     ` Arun Isaac
       [not found]     ` <403302d1.ADkAAC_e-_IAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtWIT@mailjet.com>
  0 siblings, 2 replies; 9+ messages in thread
From: Ludovic Courtès @ 2017-09-10 13:05 UTC (permalink / raw)
  To: Arun Isaac; +Cc: 28281

Heya,

Arun Isaac <arunisaac@systemreboot.net> skribis:

> Here's an updated patch.
>
>> +         (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?

If it does, then ‘scandir’ from (ice-9 ftw) would be the thing.  Sorry
if I led you in the wrong direction.  :-/

>> +             (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))))))
>
> I have used `find-files' instead of `ftw', as you suggested. The install
> procedure is clearer now. but still remains quite messy. It is not
> simple enough to separate the "candidate-files" and "install-file"
> logic.
>
> WDYT? Will the above code do?

Sure.  I mean, we should try our best to make things clearer, while not
losing our hairs on it.  Sometimes it just has to be messy.

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#28281] [PATCH] gnu: Add os-prober.
  2017-09-10 13:05   ` Ludovic Courtès
@ 2017-09-10 16:02     ` Arun Isaac
       [not found]     ` <403302d1.ADkAAC_e-_IAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtWIT@mailjet.com>
  1 sibling, 0 replies; 9+ messages in thread
From: Arun Isaac @ 2017-09-10 16:02 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 28281


>>> +         (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))))))

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#28281] [PATCH] gnu: Add os-prober.
       [not found]     ` <403302d1.ADkAAC_e-_IAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtWIT@mailjet.com>
@ 2017-09-10 20:41       ` Ludovic Courtès
  2017-09-10 23:35         ` Arun Isaac
       [not found]         ` <5dc91a20.AEAAPzHdNuYAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtcxv@mailjet.com>
  0 siblings, 2 replies; 9+ messages in thread
From: Ludovic Courtès @ 2017-09-10 20:41 UTC (permalink / raw)
  To: Arun Isaac; +Cc: 28281

Arun Isaac <arunisaac@systemreboot.net> skribis:

>>>> +         (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?

Would (copy-recursively "/some/directory" destination) work for you?

>> 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.

Yeah, looks like none of the options is a perfect match.

HTH,
LUdo’.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#28281] [PATCH] gnu: Add os-prober.
  2017-09-10 20:41       ` Ludovic Courtès
@ 2017-09-10 23:35         ` Arun Isaac
       [not found]         ` <5dc91a20.AEAAPzHdNuYAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtcxv@mailjet.com>
  1 sibling, 0 replies; 9+ messages in thread
From: Arun Isaac @ 2017-09-10 23:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 28281


>> 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?
>
> Would (copy-recursively "/some/directory" destination) work for you?

No, it wouldn't. That would recreate /some/directory at the
destination. I only want the files inside /some/directory to be copied,
not /some/directory itself.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#28281] [PATCH] gnu: Add os-prober.
       [not found]         ` <5dc91a20.AEAAPzHdNuYAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtcxv@mailjet.com>
@ 2017-09-11  7:28           ` Ludovic Courtès
  2017-09-11 17:23             ` Arun Isaac
       [not found]             ` <207deec4.AEAAP2Xyu24AAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtsaB@mailjet.com>
  0 siblings, 2 replies; 9+ messages in thread
From: Ludovic Courtès @ 2017-09-11  7:28 UTC (permalink / raw)
  To: Arun Isaac; +Cc: 28281

Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> skribis:

>>> 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?
>>
>> Would (copy-recursively "/some/directory" destination) work for you?
>
> No, it wouldn't. That would recreate /some/directory at the
> destination. I only want the files inside /some/directory to be copied,
> not /some/directory itself.

Ah sorry.  Then yeah, either ‘scandir’ or ‘find-files’, whichever you
find is the least cumbersome.

Feel free to push something along these lines!

Ludo’.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#28281] [PATCH] gnu: Add os-prober.
  2017-09-11  7:28           ` Ludovic Courtès
@ 2017-09-11 17:23             ` Arun Isaac
       [not found]             ` <207deec4.AEAAP2Xyu24AAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtsaB@mailjet.com>
  1 sibling, 0 replies; 9+ messages in thread
From: Arun Isaac @ 2017-09-11 17:23 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 28281


>>> Would (copy-recursively "/some/directory" destination) work for you?
>>
>> No, it wouldn't. That would recreate /some/directory at the
>> destination. I only want the files inside /some/directory to be copied,
>> not /some/directory itself.
>
> Ah sorry.  Then yeah, either ‘scandir’ or ‘find-files’, whichever you
> find is the least cumbersome.
>
> Feel free to push something along these lines!

Not sure I follow you. Should I

1. push the patch I sent most recently

OR

2. or add a #:recursive? argument to `find-files', and push a patch
which uses this new `find-files'?

IMO, approach 2 is a better idea, though it could be that we are adding
too many keyword arguments to `find-files'.

WDYT?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [bug#28281] [PATCH] gnu: Add os-prober.
       [not found]             ` <207deec4.AEAAP2Xyu24AAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtsaB@mailjet.com>
@ 2017-09-11 20:20               ` Ludovic Courtès
  2017-09-13 23:22                 ` bug#28281: " Arun Isaac
  0 siblings, 1 reply; 9+ messages in thread
From: Ludovic Courtès @ 2017-09-11 20:20 UTC (permalink / raw)
  To: Arun Isaac; +Cc: 28281

Arun Isaac <arunisaac@systemreboot.net> skribis:

>>>> Would (copy-recursively "/some/directory" destination) work for you?
>>>
>>> No, it wouldn't. That would recreate /some/directory at the
>>> destination. I only want the files inside /some/directory to be copied,
>>> not /some/directory itself.
>>
>> Ah sorry.  Then yeah, either ‘scandir’ or ‘find-files’, whichever you
>> find is the least cumbersome.
>>
>> Feel free to push something along these lines!
>
> Not sure I follow you. Should I
>
> 1. push the patch I sent most recently
>
> OR
>
> 2. or add a #:recursive? argument to `find-files', and push a patch
> which uses this new `find-files'?
>
> IMO, approach 2 is a better idea, though it could be that we are adding
> too many keyword arguments to `find-files'.
>
> WDYT?

I’m for approach #1, go for it!  :-)

Approach #2 would take a full rebuild, and it would make ‘find-files’
equivalent to ‘scandir’, so not worth it IMO.

Sorry for being unclear!

Ludo’.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#28281: [PATCH] gnu: Add os-prober.
  2017-09-11 20:20               ` Ludovic Courtès
@ 2017-09-13 23:22                 ` Arun Isaac
  0 siblings, 0 replies; 9+ messages in thread
From: Arun Isaac @ 2017-09-13 23:22 UTC (permalink / raw)
  To: 28281-done


>> Should I
>>
>> 1. push the patch I sent most recently
>>
>> OR
>>
>> 2. or add a #:recursive? argument to `find-files', and push a patch
>> which uses this new `find-files'?
>>
>> IMO, approach 2 is a better idea, though it could be that we are adding
>> too many keyword arguments to `find-files'.
>>
>> WDYT?
>
> I’m for approach #1, go for it!  :-)

Ok, pushed!

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-09-13 23:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20170909171635.7968-1-arunisaac@systemreboot.net>
2017-09-09 17:24 ` [bug#28281] [PATCH] gnu: Add os-prober Arun Isaac
     [not found] ` <e7d9c9ca.AEQAP00oGCwAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtCPY@mailjet.com>
2017-09-10 13:05   ` Ludovic Courtès
2017-09-10 16:02     ` Arun Isaac
     [not found]     ` <403302d1.ADkAAC_e-_IAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtWIT@mailjet.com>
2017-09-10 20:41       ` Ludovic Courtès
2017-09-10 23:35         ` Arun Isaac
     [not found]         ` <5dc91a20.AEAAPzHdNuYAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtcxv@mailjet.com>
2017-09-11  7:28           ` Ludovic Courtès
2017-09-11 17:23             ` Arun Isaac
     [not found]             ` <207deec4.AEAAP2Xyu24AAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZtsaB@mailjet.com>
2017-09-11 20:20               ` Ludovic Courtès
2017-09-13 23:22                 ` bug#28281: " Arun Isaac

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).