From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jelle Licht Subject: bug#23723: patch-shebang phase breaks symlinks Date: Sat, 11 Jun 2016 15:32:26 +0200 Message-ID: <87r3c33l79.fsf@fsfe.org> References: <87fusowopk.fsf@fsfe.org> <87r3c51agw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBj2D-0006al-58 for bug-guix@gnu.org; Sat, 11 Jun 2016 09:33:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBj26-0000Z4-OV for bug-guix@gnu.org; Sat, 11 Jun 2016 09:33:08 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:52413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBj26-0000Yv-Lk for bug-guix@gnu.org; Sat, 11 Jun 2016 09:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bBj26-0006p2-By for bug-guix@gnu.org; Sat, 11 Jun 2016 09:33:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87r3c51agw.fsf@gnu.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 23723@debbugs.gnu.org, Jelle Licht Hi Ludovic Courtès writes: > Hello! > > Jelle Licht 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. > However, ‘patch-source-shebangs’ indeed overwrites symlinks. Is it the > one that’s causing problems? > >> To illustrate, in this specific case, there was an executable >> script included with the node tarball, namely >> `lib/node-modules/npm/bin/npm-cli.js' with an env-based shebang: >> `/usr/bin/env node'. >> >> As the `node' executable will only be available after the `install' >> phase of the build system, it is not patched before hand. During the >> `install' phase, a symlink is created from `bin/npm' to >> `lib/node-modules/npm/bin/npm-cli.js' (in the store output directory >> this time, of course). Then the `patch-shebangs' phase finds this >> symlink and proceeds to patch it. Instead of transparently following the >> symlink and patching the `npm-cli.js' script, the `npm' symlink is >> overwritten with a shebang-patched copy of `npm-cli.js'. > > I don’t think ‘patch-shebangs’ is to blame; could it be > ‘patch-source-shebangs’? AFAIK, it is definitely the 'patch-shebangs' phase that is to blame for my woes; removing it using modify-phases makes the issue disappear, when looking at the build dir in the store. > > Thanks! > > Ludo’. Looking forward to your thoughts on the matter - Jelle