]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
Handle whitespaces in shebang.
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Mon, 23 Dec 2019 10:17:44 +0000 (11:17 +0100)
committerArkadiusz Miśkiewicz <arekm@maven.pl>
Mon, 23 Dec 2019 10:17:44 +0000 (11:17 +0100)
check-shebang.py

index 6de4fc16f4d0e2f4c47386d8414bdb2df4e4eb54..a93657508684f84c2b7f25d4b0def8aeb3d25c79 100755 (executable)
@@ -56,13 +56,13 @@ for root, dirs, files in os.walk(args.sourcedir):
             except UnicodeDecodeError as e:
                 print("%s: skipping file `%s': %s" % (sys.argv[0], fpath, e), file=sys.stderr)
                 continue
-            if re.compile(r'^#!/usr/bin/env python\s').match(shebang) \
-                    or re.compile(r'^#!/usr/bin/env python2\s').match(shebang) \
-                    or re.compile(r'^#!/usr/bin/python\s').match(shebang):
+            if re.compile(r'^#!\s*/usr/bin/env python\s').match(shebang) \
+                    or re.compile(r'^#!\s*/usr/bin/env\s+python2\s').match(shebang) \
+                    or re.compile(r'^#!\s*/usr/bin/python\s').match(shebang):
                 rep['python2'].append(fpath)
-            elif re.compile(r'^#!/usr/bin/env python3\s').match(shebang):
+            elif re.compile(r'^#!\s*/usr/bin/env\s+python3\s').match(shebang):
                 rep['python3'].append(fpath)
-            elif re.compile(r'^#!/usr/bin/env perl\s').match(shebang):
+            elif re.compile(r'^#!\s*/usr/bin/env\s+perl\s').match(shebang):
                 rep['perl'].append(fpath)
 
 def gf(cmd, files):
@@ -84,7 +84,7 @@ if args.buildroot:
     print("--root=%s " % args.buildroot, end='')
 print("%s\n" % args.sourcedir)
 
-gf("sed -i -e '1s,#!/usr/bin/env python2,%{__python},' -e '1s,#!/usr/bin/env python,%{__python},' -e '1s,#!/usr/bin/python,%{__python},' \\",
+gf("sed -i -e '1s,#![[:space:]]*/usr/bin/env[[:space:]]+python2,#!%{__python},' -e '1s,#![[:space:]]*/usr/bin/env[[:space:]]+python,#!%{__python},' -e '1s,#![[:space:]]*/usr/bin/python,#!%{__python},' \\",
    rep['python2'])
-gf("sed -i -e '1s,#!/usr/bin/env python3,%{__python3},' \\", rep['python3'])
-gf("sed -i -e '1s,#!/usr/bin/env perl,%{__perl},' \\", rep['perl'])
+gf("sed -i -e '1s,#![[:space:]]*/usr/bin/env[[:space:]]+python3,#!%{__python3},' \\", rep['python3'])
+gf("sed -i -e '1s,#![[:space:]]*/usr/bin/env[[:space:]]+perl,#!%{__perl},' \\", rep['perl'])
This page took 0.02945 seconds and 4 git commands to generate.