Debian Codegraph @

third-party/apply_patches

raw symbols SCIP
1 #!/bin/sh
2
3 if [ "$1" = "-q" ] ; then
4 quiet=1
5 shift
6 fi
7
8 PATCH=${PATCH:-patch}
9
10 patchdir=${1:?You must supply a patches directory}
11 sourcedir=${2?:You must supply a source directory}
12
13 if [ ! -d "$patchdir" ] ; then
14 echo "$patchdir is not a directory" >&2
15 exit 1
16 fi
17
18 if [ ! -d "$sourcedir" ] ; then
19 echo "$sourcedir is not a directory" >&2
20 exit 1
21 fi
22
23 # Patterns used in filename expansion (globs) are sorted according to the
24 # current locale, so there is no need to do it explicitly.
25 for patchfile in "$patchdir"/*.patch ; do
26 # A glob that doesn't match is not replaced, so we handle that here. We
27 # should only fail this test if there are no patch files.
28 [ -f "$patchfile" ] || {
29 echo "No patches in $patchdir" >&2
30 exit 0
31 }
32
33 [ -z "$quiet" ] && echo "Applying patch $(basename "$patchfile")"
34 ${PATCH} -d "$sourcedir" -p1 -i "$patchfile" >/dev/null || exit 1
35 done
36
37 exit 0