Files
asterisk/third-party/apply_patches
George Joseph 3a045074ff apply_patches: Sort patch list before applying
The apply_patches script wasn't sorting the list of patches in
the "patches" directory before applying them. This left the list
in an indeterminate order. In most cases, the list is actually
sorted but rarely, they can be out of order and cause dependent
patches to fail to apply.

We now sort the list but the "sort" program wasn't in the
configure scripts so we needed to add that and regenerate
the scripts as well.

Resolves: #193
2023-07-07 13:31:53 -06:00

37 lines
698 B
Bash
Executable File

#!/bin/sh
if [ "$1" = "-q" ] ; then
quiet=1
shift
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}
if [ ! -d "$patchdir" ] ; then
echo "$patchdir is not a directory" >&2
exit 1
fi
if [ ! -d "$sourcedir" ] ; then
echo "$sourcedir is not a directory" >&2
exit 1
fi
patches=$(${FIND} "$patchdir" -name "*.patch" | ${SORT})
if [ x"$patches" = x"" ] ; then
echo "No patches in $patchdir" >&2
exit 0
fi
for patchfile in ${patches} ; do
[ -z $quiet ] && echo "Applying patch $(basename $patchfile)"
${PATCH} -d "$sourcedir" -p1 -s -i "$patchfile" || exit 1
done
exit 0