]> git.pld-linux.org Git - packages/rpm-build-macros.git/commitdiff
__spec_install_post_check_shebangs
authorJacek Konieczny <jajcus@jajcus.net>
Sun, 29 Nov 2015 16:31:36 +0000 (17:31 +0100)
committerJacek Konieczny <jajcus@jajcus.net>
Sun, 29 Nov 2015 16:34:31 +0000 (17:34 +0100)
Check script shebangs. Currently only for python and a generic
"#!/usr/bin/env interpreter" check. Checks for other interpreters may
easily be added.

For Python – check if /usr/bin/python2 or /usr/bin/python3 is used, so
we don't run Python3-compatible software with Python 2 just because it
is our /usr/bin/python.

Version: 1.712

rpm-build-macros.spec
rpm.macros

index e6fe49a2a681645a1a1a94f90a5f4363c4c2ce3d..542ca5fca30ad6be09fa3a6958a0d87bd0f5095f 100644 (file)
@@ -1,4 +1,4 @@
-%define                rpm_macros_rev  1.711
+%define                rpm_macros_rev  1.712
 %define                find_lang_rev   1.37
 Summary:       PLD Linux RPM build macros
 Summary(pl.UTF-8):     Makra do budowania pakietów RPM dla Linuksa PLD
index 1a3e4c8abaf9ca92dd2b4ec16158167aa8c438ca..e3541239e55698bff121d487c7a437cf2e2c0097 100644 (file)
@@ -727,6 +727,36 @@ __spec_install_post_check_tmpfiles() { \
        %{!?no_install_post_check_tmpfiles:return $fail;} \
 }; __spec_install_post_check_tmpfiles }}
 
+#-----------------------------------------------------------------
+# Verify that scripts have reasonable shebangs
+#
+#%no_install_post_check_shebangs 1
+#
+%__spec_install_post_check_shebangs { \
+__spec_install_post_check_shebangs() { \
+%{!?debug:set +x;} \
+       fail=0; \
+       echo "Checking script shebangs..."; \
+       for f in $(find $RPM_BUILD_ROOT -type f -perm -500 -print) ; do \
+               shebang=$(sed -e'1s/#! *\(.*\)/\1/;t;d;q' "$f") ; \
+               f=${f##$RPM_BUILD_ROOT}; \
+               case "$shebang" in \
+                       "%{__python}"|"%{__python3}"|"%{__python} "*|"%{__python3} ") \
+                               ;; \
+                       "/usr/bin/env python"*|"/usr/bin/python"|"/usr/bin/python "*) \
+                               echo "$f starts with '#!$shebang', should be '#!%{__python}' or '#!%{__python3}'" >&2;\
+                               fail=1 ; \
+                               ;; \
+                       "/usr/bin/env "*) \
+                               echo "$f starts with '#!$shebang', should be explicit interpreter path" >&2;\
+                               fail=1 ; \
+                               ;; \
+                       *) ;;\
+               esac ; \
+       done ; \
+       echo " DONE" ; \
+}; %{!?no_install_post_check_shebangs:__spec_install_post_check_shebangs} }
+
 # Remove common Perl files we don't package
 %__spec_install_post_perl_clean {\
 %{!?no_install_post_perl_clean: \
This page took 0.041778 seconds and 4 git commands to generate.