mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
apply_patches: Use globbing instead of file/sort.
This accomplishes the same thing as a `find ... | sort` but with the added benefit of clarity and avoiding a call to a subshell. Additionally drop the -s option from call to patch as it is not POSIX.
This commit is contained in:
committed by
George Joseph
parent
90069a94b0
commit
9ca24c9c2b
21
third-party/apply_patches
vendored
21
third-party/apply_patches
vendored
@@ -6,8 +6,6 @@ if [ "$1" = "-q" ] ; then
|
||||
fi
|
||||
|
||||
PATCH=${PATCH:-patch}
|
||||
FIND=${FIND:-find}
|
||||
SORT=${SORT:-sort}
|
||||
|
||||
patchdir=${1:?You must supply a patches directory}
|
||||
sourcedir=${2?:You must supply a source directory}
|
||||
@@ -22,15 +20,18 @@ if [ ! -d "$sourcedir" ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
patches=$(${FIND} "$patchdir" -name "*.patch" | ${SORT})
|
||||
if [ x"$patches" = x"" ] ; then
|
||||
echo "No patches in $patchdir" >&2
|
||||
exit 0
|
||||
fi
|
||||
# Patterns used in filename expansion (globs) are sorted according to the
|
||||
# current locale, so there is no need to do it explicitly.
|
||||
for patchfile in "$patchdir"/*.patch ; do
|
||||
# A glob that doesn't match is not replaced, so we handle that here. We
|
||||
# should only fail this test if there are no patch files.
|
||||
[ -f "$patchfile" ] || {
|
||||
echo "No patches in $patchdir" >&2
|
||||
exit 0
|
||||
}
|
||||
|
||||
for patchfile in ${patches} ; do
|
||||
[ -z $quiet ] && echo "Applying patch $(basename $patchfile)"
|
||||
${PATCH} -d "$sourcedir" -p1 -s -i "$patchfile" || exit 1
|
||||
[ -z "$quiet" ] && echo "Applying patch $(basename "$patchfile")"
|
||||
${PATCH} -d "$sourcedir" -p1 -i "$patchfile" >/dev/null || exit 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
Reference in New Issue
Block a user