From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] gnu-build-system: do not patch symlinks. Fixes location-aware scripts. Date: Tue, 09 Feb 2016 21:59:43 +0100 Message-ID: <87io1xr45c.fsf@gnu.org> References: <87egcpeono.fsf@gnu.org> <87egcmkvwr.fsf@gnu.org> <87ziv9elo2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTFOI-0003Sf-1n for guix-devel@gnu.org; Tue, 09 Feb 2016 16:00:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTFOE-0003ta-2A for guix-devel@gnu.org; Tue, 09 Feb 2016 16:00:06 -0500 In-Reply-To: <87ziv9elo2.fsf@gnu.org> (Jan Nieuwenhuizen's message of "Tue, 09 Feb 2016 20:19:41 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Jan Nieuwenhuizen Cc: guix-devel@gnu.org Jan Nieuwenhuizen skribis: > Ludovic Court=C3=A8s writes: > >> Out of curiosity, what package was this? > > I encountered it first in jison, a javascript parser generator. How does the script determines its location? Using $0 is unreliable, and using /proc/self/exe is non portable. >> Since this is a rebuild-the-world change, I applied to to a new >> =E2=80=98core-updates=E2=80=99 branch (and adjusted the commit log.) > > Yes, I got bitten by that, trying to test it. I had an interesting > learning experience getting to know guix and getting this to work and > reverted to using > > (#phases > (replace 'patch-source-shebangs > ;;patch-source-shebangs-no-symlinks > (lambda* (#:key outputs #:allow-other-keys) > (for-each patch-shebang > (remove (lambda (file) > (or (not (file-exists? file)) ;dangli= ng symlink > ;;(file-is-symlink? file) > (and (file-exists? file) > (eq? 'symlink (stat:type (ls= tat file)))) > (file-is-directory? file))) > (find-files "."))))) > > in the package itself. Rebuilding the world is no fun when you want to > get things done. Yeah. In such cases it=E2=80=99s easier to simply delete or customize the faulty phase like you did above. > When I actually got to test it, it appears that something like the above > is still necessary. It seems that the previous patch merely avoids > visiting any symlinked directories, while this version actually looks > at the script to be patched. [...] > diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-syste= m.scm > index 2abaa6e..34edff7 100644 > --- a/guix/build/gnu-build-system.scm > +++ b/guix/build/gnu-build-system.scm > @@ -303,7 +303,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))))) > '()))) This is exactly what the previous patch does (applied as c13a9feb.) Am I missing something? Anyway, it seems clear enough that the effect of this one-liner is to prevent symlinks from being patched. :-) Ludo=E2=80=99.