brp-mangle-shebangs: add support for whitespaces in file names

Now it starts requiring bash instead of POSIX-compatible shell, but this
is not a problem since other scripts in here do same.

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Gnatenko 2018-02-15 10:02:44 +01:00
parent fb05a239d2
commit 40990bb864
No known key found for this signature in database
GPG Key ID: 695714BD1BBC5F4C

View File

@ -1,4 +1,4 @@
#!/bin/sh -eu #!/bin/bash -eu
# If using normal root, avoid changing anything. # If using normal root, avoid changing anything.
if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then
@ -15,7 +15,8 @@ trim() {
} }
fail=0 fail=0
for f in $(find -executable -type f | xargs --no-run-if-empty file -N --mime-type | grep -Po "^\K.+(?=: text/)"); do while IFS= read -r -d $'\0' f; do
file -N --mime-type "$f" | grep -q -P ".+(?=: text/)" || continue
# Remove the dot # Remove the dot
path="${f#.}" path="${f#.}"
@ -65,6 +66,6 @@ for f in $(find -executable -type f | xargs --no-run-if-empty file -N --mime-typ
fi fi
touch -d "$ts" "$f" touch -d "$ts" "$f"
done done < <(find -executable -type f -print0)
exit $fail exit $fail