diff --git a/brp-mangle-shebangs b/brp-mangle-shebangs index b9b22b8..6d65a82 100755 --- a/brp-mangle-shebangs +++ b/brp-mangle-shebangs @@ -5,8 +5,68 @@ if [ -z "$RPM_BUILD_ROOT" -o "$RPM_BUILD_ROOT" = "/" ]; then exit 0 fi -exclude_files="${1:-}" -exclude_shebangs="${2:-}" +exclude_files="" +exclude_files_from="" +exclude_shebangs="" +exclude_shebangs_from="" + +usage() { + local verbose=$1 && shift + local outfile=$1 && shift + local status=$1 && shift + + ( + echo 'usage: brp-mangle-shebangs [--files ] [--files-from ] [--shebangs ] [--shebangs-from ]' + if [ "${verbose}" == "yes" ]; then + echo ' --files: extended regexp of files to ignore' + echo ' --files-from: file containing a list of extended regexps of files to ignore' + echo ' --shebangs: extended regexp of shebangs to ignore' + echo ' --shebangs-from: file containing a list of extended regexps of shebangs to ignore' + fi + ) >>${outfile} + exit ${status} +} + +while [ $# -gt 0 ] ; do + case "$1" in + --files) + exclude_files="${2}" + shift + ;; + --files=*) + exclude_files="${1##--files=}" + ;; + --files-from) + exclude_files_from="${2}" + shift + ;; + --files-from=*) + exclude_files_from="${1##--files-from=}" + ;; + --shebangs) + exclude_shebangs="${2}" + shift + ;; + --shebangs=*) + exclude_shebangs="${1##--shebangs=}" + ;; + --shebangs-from) + exclude_shebangs_from="${2}" + shift + ;; + --shebangs-from=*) + exclude_shebangs_from="${1##--shebangs-from=}" + ;; + --help|--usage|"-?"|-h) + usage yes /dev/stdout 0 + ;; + *) + echo "Unknown option \"${1}\"" 1>&2 + usage no /dev/stderr 1 + ;; + esac + shift +done cd "$RPM_BUILD_ROOT" @@ -24,6 +84,9 @@ while IFS= read -r -d $'\0' f; do if [ -n "$exclude_files" ]; then echo "$path" | grep -q -E "$exclude_files" && continue fi + if [ -n "$exclude_files_from" ]; then + echo "$path" | grep -q -E -f "$exclude_files_from" && continue + fi ts=$(stat -c %y "$f") @@ -33,6 +96,9 @@ while IFS= read -r -d $'\0' f; do if [ -n "$exclude_shebangs" ]; then echo "$shebang" | grep -q -E "$exclude_shebangs" && continue fi + if [ -n "$exclude_shebangs_from" ]; then + echo "$shebang" | grep -q -E -f "$exclude_shebangs_from" && continue + fi if [ -z "$shebang" ]; then echo >&2 "*** WARNING: $f is executable but has empty or no shebang, removing executable bit" diff --git a/macros b/macros index 87b6815..548c52e 100644 --- a/macros +++ b/macros @@ -143,7 +143,11 @@ %__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip} %__brp_python_bytecompile /usr/lib/rpm/brp-python-bytecompile %{__python} %{?_python_bytecompile_errors_terminate_build} %__brp_python_hardlink /usr/lib/rpm/brp-python-hardlink -%__brp_mangle_shebangs /usr/lib/rpm/redhat/brp-mangle-shebangs "%{?__brp_mangle_shebangs_exclude_from}" "%{?__brp_mangle_shebangs_exclude}" +# __brp_mangle_shebangs_exclude - shebangs to exclude +# __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude +# __brp_mangle_shebangs_exclude_from - files to ignore +# __brp_mangle_shebangs_exclude_from_file - file from which to get files to ignore +%__brp_mangle_shebangs /usr/lib/rpm/redhat/brp-mangle-shebangs %{?__brp_mangle_shebangs_exclude:--shebangs "%{?__brp_mangle_shebangs_exclude}"} %{?__brp_mangle_shebangs_exclude_file:--shebangs-from "%{__brp_mangle_shebangs_exclude_file}"} %{?__brp_mangle_shebangs_exclude_from:--files "%{?__brp_mangle_shebangs_exclude_from}"} %{?__brp_mangle_shebangs_exclude_from_file:--files-from "%{__brp_mangle_shebangs_exclude_from_file}"} %__os_install_post \ %{?__brp_ldconfig} \ diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 5ddcae1..955f866 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 110 +Version: 111 Release: 1%{?dist} # No version specified. License: GPL+ @@ -184,6 +184,12 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Wed May 02 2018 Peter Jones - 111-1 +- brp-mangle-shebangs: add %%{__brp_mangle_shebangs_exclude_file} and + %%{__brp_mangle_shebangs_exclude_from_file} to allow you to specify files + containing the shebangs to be ignore and files to be ignored regexps, + respectively, so that they can be generated during the package build. + * Wed May 2 2018 Florian Weimer - 110-1 - Reflect -fasynchronous-unwind-tables GCC default on POWER (#1550914)