]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
make: correct path to 'bcachefs' in mkfs/fsck scripts
authorAustin Seipp <aseipp@pobox.com>
Fri, 15 Dec 2017 23:39:12 +0000 (17:39 -0600)
committerAustin Seipp <aseipp@pobox.com>
Sun, 17 Dec 2017 18:46:45 +0000 (12:46 -0600)
The fsck and bcachefs scripts simply worked by running 'exec bcachefs
...', but this executes whatever is out of `$PATH`, which is likely not
what a user expected when working inside the bcachefs-tools tree.

This replaces the local uses of 'exec bcachefs' to use bash's
readlink/dirname builtins in order to find the location of the currently
executing wrapper, and execute the 'bcachefs' tool from there.

This allows executing these wrappers from anywhere, provided 'bcachefs'
is just right next to them, with the correct semantics.

As a result, this also allows removing a tiny hack from the Nix
expressions, allowing the included default.nix to use completely
standard mkDerivation builders, with no extra patch/fixup phases.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
default.nix
fsck.bcachefs
mkfs.bcachefs

index 82d4a8528deb474741955c07b5593c04bd8cb6cb..f19ff1076ca200cb660cdadc83cd946d481d6799 100644 (file)
@@ -15,19 +15,6 @@ stdenv.mkDerivation rec {
       libsodium libscrypt
     ];
 
-  patchPhase = ''
-    # ensure the mkfs and fsck scripts, which are just wrappers around
-    # 'bcachefs', are patched to refer to the right location inside the
-    # nix store. (you wouldn't expect built tools to call random outside
-    # utilities, in general, but the exact tools they were built with.)
-    #
-    # TODO FIXME: it would be better to fix this in the 'install' target,
-    # however, so this works with any bog-standard installation
-
-    substituteInPlace fsck.bcachefs --replace bcachefs $out/bin/bcachefs
-    substituteInPlace mkfs.bcachefs --replace bcachefs $out/bin/bcachefs
-  '';
-
   enableParallelBuilding = true;
   makeFlags =
     [ "PREFIX=$(out)"
index e1d2a44c92346f5f2c8b8b5f3a566ca1fc57c9b5..1494e4c145f64f9793aa29adb9e810f4918d9ff9 100755 (executable)
@@ -1,3 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
-exec bcachefs fsck "$@"
+SDIR="$(dirname "$(readlink -f "$0")")"
+exec "$SDIR/bcachefs" fsck "$@"
index a1ce6159b36985dc7f460073954e166dc0b6cfad..a0541d5266f2e17ce3c9c5315be8b7a1e1c07fec 100755 (executable)
@@ -1,3 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
-exec bcachefs format "$@"
+SDIR="$(dirname "$(readlink -f "$0")")"
+exec "$SDIR/bcachefs" format "$@"