diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2019-11-21 17:05:52 +0100 |
---|---|---|
committer | Thierry Vignaud <thierry.vignaud@gmail.com> | 2019-12-23 16:05:32 +0100 |
commit | 747658f85331c90df8bafc55f7cdb6d3bd3519eb (patch) | |
tree | 7147bc4d77dc9d5ae5229fe7b2971802b1d7b823 | |
parent | 8ecaeab1b79c20f83eda540e39f31e6a73018d7f (diff) | |
download | rpm-setup-747658f85331c90df8bafc55f7cdb6d3bd3519eb.tar rpm-setup-747658f85331c90df8bafc55f7cdb6d3bd3519eb.tar.gz rpm-setup-747658f85331c90df8bafc55f7cdb6d3bd3519eb.tar.bz2 rpm-setup-747658f85331c90df8bafc55f7cdb6d3bd3519eb.tar.xz rpm-setup-747658f85331c90df8bafc55f7cdb6d3bd3519eb.zip |
brp-mangle-shebangs: do not stat / touch files needlessly
Run "stat" to get mtime, and "touch -d $saved_mtime"
only if we indeed modify file's shebang.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | NEWS | 6 | ||||
-rwxr-xr-x | brp-mangle-shebangs | 8 |
2 files changed, 11 insertions, 3 deletions
@@ -1,3 +1,9 @@ +- sync brp-mangle-shebangs with FC: + o do not stat / touch files needlessly + o fix unsafe/incorrect command expansion + o brp-mangle-shebangs: speed up finding of "text executables" (scripts) + o Make ambiguous python shebangs error + Version 2.44 - 15 October 2019, by Pascal Terjan - previous change worked manually on my mga7 but doesn't seem to work in cauldron diff --git a/brp-mangle-shebangs b/brp-mangle-shebangs index 11809b4..98990c0 100755 --- a/brp-mangle-shebangs +++ b/brp-mangle-shebangs @@ -92,12 +92,12 @@ while IFS= read -r line; do echo "$path" | grep -q -E -f "$exclude_files_from" && continue fi - ts=$(stat -c %y "$f") read shebang_line < "$f" orig_shebang="${shebang_line#\#!}" if [ "$orig_shebang" = "$shebang_line" ]; then echo >&2 "*** WARNING: $f is executable but has no shebang, removing executable bit" + ts=$(stat -c %y "$f") chmod -x "$f" touch -d "$ts" "$f" continue @@ -114,6 +114,7 @@ while IFS= read -r line; do if [ -z "$shebang" ]; then echo >&2 "*** WARNING: $f is executable but has empty shebang, removing executable bit" + ts=$(stat -c %y "$f") chmod -x "$f" touch -d "$ts" "$f" continue @@ -145,11 +146,12 @@ while IFS= read -r line; do echo >&2 "*** ERROR: ambiguous python shebang in $path: #!$orig_shebang. Change it to python3 (or python2) explicitly." fail=1 elif [ "#!$shebang" != "#!$orig_shebang" ]; then - sed -i -e "1c #!$shebang" "$f" echo "mangling shebang in $path from $orig_shebang to #!$shebang" + ts=$(stat -c %y "$f") + sed -i -e "1c #!$shebang" "$f" + touch -d "$ts" "$f" fi - touch -d "$ts" "$f" done exit $fail |