Browse Source

Use the just-built file executable only if it exists

It seems the file program is used (via some other tools) on mips64 at
configure time. Of course, the just built file program does not exist
yet, leading to a build failure.

So probe for that program first, and silently fall back to the regular
program in /usr/bin/.
Christoph Biedl 1 year ago
parent
commit
2a9181daa4
1 changed files with 12 additions and 5 deletions
  1. 12 5
      debian/run-file/file

+ 12 - 5
debian/run-file/file

@@ -2,9 +2,16 @@
 
 set -e
 
-echo "Just-built file called, args: $@" >&2
+REGULAR_FILE=/usr/bin/file
+BUILT_FILE="$CURDIR/debian/tmp/usr/bin/file"
 
-export LD_LIBRARY_PATH="$CURDIR/debian/tmp/usr/lib/$DEB_HOST_MULTIARCH"
-exec "$CURDIR/debian/tmp/usr/bin/file" \
-    -m "$CURDIR/debian/tmp/usr/share/file/magic.mgc" \
-    "$@"
+if [ -x "$BUILT_FILE" ] ; then
+    echo "Running just-built file, args: $@" >&2
+
+    export LD_LIBRARY_PATH="$CURDIR/debian/tmp/usr/lib/$DEB_HOST_MULTIARCH"
+    exec "$BUILT_FILE" \
+        -m "$CURDIR/debian/tmp/usr/share/file/magic.mgc" \
+        "$@"
+else
+    exec "$REGULAR_FILE" "$@"
+fi