brp-mangle-shebangs: speed up finding of "text executables" (scripts)
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
		
							parent
							
								
									6335a7ff4a
								
							
						
					
					
						commit
						63d7e4dc11
					
				| @ -74,9 +74,17 @@ trim() { | ||||
|   printf '%s' "$*" | ||||
| } | ||||
| 
 | ||||
| # Large packages such as kernel can have thousands of executable files. | ||||
| # We take care to not fork/exec thousands of "file"s and "grep"s, | ||||
| # but run just two of them. | ||||
| # (Take care to exclude filenames which would mangle "file" output). | ||||
| find -executable -type f ! -path '*:*' ! -path $'*\n*' \ | ||||
| | file -N --mime-type -f - \ | ||||
| | grep -P ".+(?=: text/)" \ | ||||
| | { | ||||
| fail=0 | ||||
| while IFS= read -r -d $'\0' f; do | ||||
|   file -N --mime-type "$f" | grep -q -P ".+(?=: text/)" || continue | ||||
| while IFS= read -r line; do | ||||
|   f=${line%%:*} | ||||
| 
 | ||||
|   # Remove the dot | ||||
|   path="${f#.}" | ||||
| @ -137,6 +145,7 @@ while IFS= read -r -d $'\0' f; do | ||||
|   fi | ||||
| 
 | ||||
|   touch -d "$ts" "$f" | ||||
| done < <(find -executable -type f -print0) | ||||
| done | ||||
| 
 | ||||
| exit $fail | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user