commit 02bc4ed52c77090fc9d6caf35642a2dc11195406
Author: Jacek Konieczny <[email protected]>
Date:   Sun Nov 29 17:31:36 2015 +0100

    __spec_install_post_check_shebangs
    
    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 |  2 +-
 rpm.macros            | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/rpm-build-macros.spec b/rpm-build-macros.spec
index e6fe49a..542ca5f 100644
--- a/rpm-build-macros.spec
+++ b/rpm-build-macros.spec
@@ -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
diff --git a/rpm.macros b/rpm.macros
index 1a3e4c8..e354123 100644
--- a/rpm.macros
+++ b/rpm.macros
@@ -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: \
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-macros.git/commitdiff/02bc4ed52c77090fc9d6caf35642a2dc11195406

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to