python3.11/python3.11-shebang-sanity.sh

14 lines
587 B
Bash
Raw Permalink Normal View History

#!/bin/sh
set -efu
find "$RPM_BUILD_ROOT" -type f -print | while read -r line ; do
if file "$line" | grep -q ELF ; then continue ; fi
if head -n 1 "$line" | grep -qE '([[:blank:]])*#([[:blank:]])*\!([[:blank:]])*.*python3' ; then
2023-04-19 21:45:06 +00:00
sed -i -e '1s,python3,python3.11,g' -e '1s,python3.11.11,python3.11,g' "$line"
sed -E -i "$line" \
2023-04-20 00:20:40 +03:00
-e '1s,([[:blank:]])*#([[:blank:]])*\!([[:blank:]])*/usr/bin/env([[:blank:]])*python3.11,#!/usr/libexec/python3.11,g' \
2023-04-19 21:45:06 +00:00
-e '1s,([[:blank:]])*#([[:blank:]])*\!([[:blank:]])*/usr/bin/python3.11,#!/usr/libexec/python3.11,g'
fi
done