From: Jan Nieuwenhuizen <janneke@gnu.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] gnu-build-system: do not patch symlinks. Fixes location-aware scripts.
Date: Tue, 09 Feb 2016 23:15:40 +0100 [thread overview]
Message-ID: <87a8n9edir.fsf@gnu.org> (raw)
In-Reply-To: <87io1xr45c.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 09 Feb 2016 21:59:43 +0100")
[-- Attachment #1: Type: text/plain, Size: 954 bytes --]
Ludovic Courtès writes:
> How does the script determines its location? Using $0 is unreliable,
> and using /proc/self/exe is non portable.
It uses node.js's __dirname. I would have to dive into node.js
internals to figure that out... I would think it does /proc/self/exe
and has fallbacks for other platforms?
>> diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
>> index 2abaa6e..34edff7 100644
> This is exactly what the previous patch does (applied as c13a9feb.)
>
> Am I missing something?
Ah sorry.. Yes sent you the same patch, second patch attached now.
> Anyway, it seems clear enough that the effect of this one-liner is to
> prevent symlinks from being patched. :-)
Yes so I thought too, until I stumbled into this. Then I saw that
the first patch only considers what files to run scandir on ... any
of those files can be symlinks and those are caught here.
Greetings, Jan
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-build-system-gnu-Do-not-patch-symlinks-v2.patch --]
[-- Type: text/x-diff, Size: 1450 bytes --]
From 2d17c6bd7c7dd466c0aee14beaa47055af0ceb6d Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Sun, 7 Feb 2016 16:45:25 +0100
Subject: [PATCH] build-system/gnu: Do not patch symlinks, v2.
This fixes location-aware scripts.
* guix/build/gnu-build-system.scm (file-is-symlink?): new function.
(patch-source-shebangs): use it to skip symlinks.
---
guix/build/gnu-build-system.scm | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index 34edff7..427f020 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -166,6 +166,10 @@ things like the ABI being used."
(find-files "." "^configure$")))
#t)
+(define (file-is-symlink? file)
+ (and (file-exists? file)
+ (eq? 'symlink (stat:type (lstat file)))))
+
(define* (patch-source-shebangs #:key source #:allow-other-keys)
"Patch shebangs in all source files; this includes non-executable
files such as `.in' templates. Most scripts honor $SHELL and
@@ -174,6 +178,7 @@ $CONFIG_SHELL, but some don't, such as `mkinstalldirs' or Automake's
(for-each patch-shebang
(remove (lambda (file)
(or (not (file-exists? file)) ;dangling symlink
+ (file-is-symlink? file)
(file-is-directory? file)))
(find-files "."))))
--
2.1.4
[-- Attachment #3: Type: text/plain, Size: 154 bytes --]
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl
next prev parent reply other threads:[~2016-02-09 22:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-06 17:26 [PATCH] gnu-build-system: do not patch symlinks. Fixes location-aware scripts Jan Nieuwenhuizen
2016-02-09 10:41 ` Ludovic Courtès
2016-02-09 19:19 ` Jan Nieuwenhuizen
2016-02-09 20:59 ` Ludovic Courtès
2016-02-09 22:15 ` Jan Nieuwenhuizen [this message]
2016-02-10 21:30 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a8n9edir.fsf@gnu.org \
--to=janneke@gnu.org \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.