File apply-patches of Package kernel-docs
48
1
#!/bin/sh
2
#
3
# Given a series.conf file and a directory with patches, applies them to the
4
# current directory.
5
# Used by kernel-source.spec.in and kernel-binary.spec.in
6
7
USAGE="$0 [--vanilla] <series.conf> <patchdir> [symbol ...]"
8
9
set -e
10
set -o pipefail
11
vanilla=false
12
if test "$1" == "--vanilla"; then
13
vanilla=true
14
shift
15
fi
16
if test $# -lt 2; then
17
echo "$USAGE" >&2
18
exit 1
19
fi
20
DIR="${0%/*}"
21
SERIES_CONF=$1
22
PATCH_DIR=$2
23
shift 2
24
25
trap 'rm -f "$series"' EXIT
26
series=$(mktemp)
27
# support for patches in patches.addon/series
28
cp "$SERIES_CONF" "$series"
29
if ! $vanilla && test -e "$PATCH_DIR/patches.addon/series"; then
30
# make it user-friendly and automatically prepend "patches.addon/"
31
# if there is no "/"
32
sed -r 's|^([[:space:]]*)([^#[:space:]][^/]*)$|\1patches.addon/\2|' \
33
"$PATCH_DIR/patches.addon/series" >>"$series"
34
fi
35
36
(
37
echo "trap 'echo \"*** patch \$_ failed ***\"' ERR"
38
echo "set -ex"
39
"$DIR"/guards "$@" <"$series" | \
40
if $vanilla; then
41
sed -rn '/^patches\.(kernel\.org|rpmify)\//p'
42
else
43
cat
44
fi |\
45
sed "s|^|patch -s -F0 -E -p1 --no-backup-if-mismatch -i $PATCH_DIR/|"
46
) | sh
47
48