Systemd/tools/find-build-dir.sh
Zbigniew Jędrzejewski-Szmek ded65775a2 tests: try to autodetect directory better
Ignore mkosi.builddir. In the future we can also add other patterns
if necessary.

run-intergration-tests.sh is updated to use the new script, and modified
to work from arbitrary directory.

Follow-up for #7494.
2017-12-06 15:16:35 +01:00

32 lines
743 B
Bash
Executable file

#!/bin/sh -e
# Try to guess the build directory:
# we look for subdirectories of the parent directory that look like ninja build dirs.
if [ -n "$BUILD_DIR" ]; then
echo "$(realpath "$BUILD_DIR")"
exit 0
fi
root="$(dirname "$(realpath "$0")")"
found=
for i in "$root"/../*/build.ninja; do
c="$(dirname $i)"
[ -d "$c" ] || continue
[ "$(basename "$c")" != mkosi.builddir ] || continue
if [ -n "$found" ]; then
echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
exit 2
fi
found="$c"
done
if [ -z "$found" ]; then
echo 'Specify build directory with $BUILD_DIR' >&2
exit 1
fi
echo "$(realpath $found)"