unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Jelle Licht <jlicht@fsfe.org>
Cc: 23723@debbugs.gnu.org
Subject: bug#23723: patch-shebang phase breaks symlinks
Date: Sun, 12 Jun 2016 12:29:52 +0200	[thread overview]
Message-ID: <8737oiog2n.fsf@gnu.org> (raw)
In-Reply-To: <87r3c33l79.fsf@fsfe.org> (Jelle Licht's message of "Sat, 11 Jun 2016 15:32:26 +0200")

[-- Attachment #1: Type: text/plain, Size: 1704 bytes --]

Jelle Licht <jlicht@fsfe.org> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>> Hello!
>>
>> Jelle Licht <jlicht@fsfe.org> skribis:
>>
>>> It seems that the patch-shebang functionality does not deal gracefully
>>> with symlinks: it just overwrites them!
>>>
>>> After struggling somewhat with getting the recently packaged node 6.0.0
>>> to behave, I found out that `patch-shebang' in (guix build
>>> gnu-build-system) does not work properly on symlinks.
>>
>> There’s ‘patch-shebangs’ (plural) in this file, but it explicitly
>> touches only regular files (see ‘list-of-files’).
>>
>
> It seems I made a mistake when writing the bug report; I am talking
> about the `patch-shebang' defined in (guix build utils). My apologies.
>
> Also, seeing as my experience with the stat utility and similarly styled
> programming libraries was lacking, I decided to play around with the
> definition of `list-of-files': It actually does include symlinks, as
> (stat:type (stat "some-symlinked-file")) gives us a plain old 'regular.
> Looking into this a bit more, it seems that calling `stat' gives the
> exact same results on both the linked-to-file and the symlink to that
> file.
>
> For the particular problem I ran into to be fixed, it is imperative that
> `list-of-files' of `patch-shebangs' includes the symlink; it does after
> all need to be patched. The way this patching currently happens just
> clobbers symlinks.

My bad, indeed, ‘list-of-files’ should use ‘lstat’ instead of ‘stat’.

I think a patch like attached should solve the problem.  WDYT?

We can apply it to core-updates-next if that’s fine with you.

Thanks,
Ludo’.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1101 bytes --]

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 2abaa6e..299eb5d 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -172,9 +172,8 @@ files such as `.in' templates.  Most scripts honor $SHELL and
 $CONFIG_SHELL, but some don't, such as `mkinstalldirs' or Automake's
 `missing' script."
   (for-each patch-shebang
-            (remove (lambda (file)
-                      (or (not (file-exists? file)) ;dangling symlink
-                          (file-is-directory? file)))
+            (filter (lambda (file)
+                      (eq? 'regular (lstat file)))
                     (find-files "."))))
 
 (define (patch-generated-file-shebangs . rest)
@@ -303,7 +302,7 @@ makefiles."
   (define (list-of-files dir)
     (map (cut string-append dir "/" <>)
          (or (scandir dir (lambda (f)
-                            (let ((s (stat (string-append dir "/" f))))
+                            (let ((s (lstat (string-append dir "/" f))))
                               (eq? 'regular (stat:type s)))))
              '())))
 

  reply	other threads:[~2016-06-12 10:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07 23:42 bug#23723: patch-shebang phase breaks symlinks Jelle Licht
2016-06-10 12:42 ` Ludovic Courtès
2016-06-11 13:32   ` Jelle Licht
2016-06-12 10:29     ` Ludovic Courtès [this message]
2016-06-13 19:50       ` Jelle Licht
2016-06-14  7:56         ` Ludovic Courtès
2016-06-14  8:22           ` Jelle Licht
2016-06-16  5:15       ` Danny Milosavljevic
2016-06-16  8:16         ` Ludovic Courtès
2016-09-12 19:37       ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8737oiog2n.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=23723@debbugs.gnu.org \
    --cc=jlicht@fsfe.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).