generic/setup.sh: handle $sourceRoot that starts with dash

Without the change `runPhase` fails on tarballs like
`diffoscope-269` that contain single top-level `-269` root as:

    diffoscope> unpacking source archive /nix/store/p620nidkm73vrp0z6kk5krmrm4vg7bxd-diffoscope-269.tar.bz2
    diffoscope> source root is -269
    diffoscope> setting SOURCE_DATE_EPOCH to timestamp 1717143039 of file ./-269/tests/utils/versions.py
    diffoscope> chmod: invalid mode: ‘-269’
    diffoscope> Try 'chmod --help' for more information.

Currently `diffoscope-269` has a `sourceRoot = "./-269";` workaround to
bypass the failure.
This commit is contained in:
Sergei Trofimovich 2024-06-03 18:40:23 +01:00
parent a3f1b476c7
commit 193fd8a237

View File

@ -1577,9 +1577,9 @@ runPhase() {
if [ "$curPhase" = unpackPhase ]; then
# make sure we can cd into the directory
[ -n "${sourceRoot:-}" ] && chmod +x "${sourceRoot}"
[ -n "${sourceRoot:-}" ] && chmod +x -- "${sourceRoot}"
cd "${sourceRoot:-.}"
cd -- "${sourceRoot:-.}"
fi
}