]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
generate-version: Fix script inside of a tarball
authorRay Strode <rstrode@redhat.com>
Fri, 22 Dec 2023 15:18:59 +0000 (10:18 -0500)
committerRay Strode <rstrode@redhat.com>
Fri, 22 Dec 2023 15:36:40 +0000 (10:36 -0500)
The heuristic to check whether or not we're inside of a git checkout
or a tarball isn't working properly.

This commit changes it to use git rev-parse --is-inside-git-dir which
is pretty specifically designed for this use case.

Closes: https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/232
scripts/generate-version.sh

index 83553ad93bffeddc58394491543b153cf62597f7..c61cb54d0811e8da9551c078d1a2db076c441192 100755 (executable)
@@ -1,14 +1,12 @@
 #!/bin/sh
 exec 3>&2 2> /dev/null
-SRCDIR=$(dirname "$0")
+SRCDIR=$(dirname "$0")/..
 cd "$SRCDIR"
 CWD=$(realpath "$PWD")
-TOPLEVEL_WORKING_DIR=$(realpath "$(git rev-parse --show-toplevel)")
-SCRIPTDIR=${SRCDIR#"${TOPLEVEL_WORKING_DIR}/"}
 exec 2>&3
 
 # If it's not from a git checkout, assume it's from a tarball
-if [ "${TOPLEVEL_WORKING_DIR}/${SCRIPTDIR}" != "$CWD" ]; then
+if ! git rev-parse --is-inside-git-dir > /dev/null 2>&1; then
     VERSION_FROM_DIR_NAME=$(basename "$CWD" | sed -n 's/^plymouth-\([^-]*\)$/\1/p')
 
     if [ -n "$VERSION_FROM_DIR_NAME" ]; then