|
Michal Marek |
411abb |
#!/bin/sh
|
|
Michal Marek |
411abb |
#
|
|
Michal Marek |
411abb |
# Given a series.conf file and a directory with patches, applies them to the
|
|
Michal Marek |
411abb |
# current directory.
|
|
Michal Marek |
411abb |
# Used by kernel-source.spec.in and kernel-binary.spec.in
|
|
Michal Marek |
411abb |
|
|
Michal Marek |
411abb |
USAGE="$0 [--vanilla] <series.conf> <patchdir> [symbol ...]"
|
|
Michal Marek |
411abb |
|
|
Michal Marek |
411abb |
set -e
|
|
Michal Marek |
411abb |
set -o pipefail
|
|
Michal Marek |
411abb |
vanilla=false
|
|
Michal Marek |
411abb |
if test "$1" == "--vanilla"; then
|
|
Michal Marek |
411abb |
vanilla=true
|
|
Michal Marek |
411abb |
shift
|
|
Michal Marek |
411abb |
fi
|
|
Michal Marek |
411abb |
if test $# -lt 2; then
|
|
Michal Marek |
411abb |
echo "$USAGE" >&2
|
|
Michal Marek |
411abb |
exit 1
|
|
Michal Marek |
411abb |
fi
|
|
Michal Marek |
411abb |
DIR="${0%/*}"
|
|
Michal Marek |
411abb |
SERIES_CONF=$1
|
|
Michal Marek |
411abb |
PATCH_DIR=$2
|
|
Michal Marek |
411abb |
shift 2
|
|
Michal Marek |
411abb |
|
|
Michal Marek |
411abb |
trap 'rm -f "$series"' EXIT
|
|
Michal Marek |
411abb |
series=$(mktemp)
|
|
Michal Marek |
411abb |
# support for patches in patches.addon/series
|
|
Michal Marek |
411abb |
cp "$SERIES_CONF" "$series"
|
|
Michal Marek |
411abb |
if ! $vanilla && test -e "$PATCH_DIR/patches.addon/series"; then
|
|
Michal Marek |
411abb |
# make it user-friendly and automatically prepend "patches.addon/"
|
|
Michal Marek |
411abb |
# if there is no "/"
|
|
Michal Marek |
411abb |
sed -r 's|^([[:space:]]*)([^#[:space:]][^/]*)$|\1patches.addon/\2|' \
|
|
Michal Marek |
411abb |
"$PATCH_DIR/patches.addon/series" >>"$series"
|
|
Michal Marek |
411abb |
fi
|
|
Michal Marek |
411abb |
|
|
Michal Marek |
411abb |
(
|
|
Michal Marek |
411abb |
echo "trap 'echo \"*** patch \$_ failed ***\"' ERR"
|
|
Michal Marek |
411abb |
echo "set -ex"
|
|
Michal Marek |
411abb |
"$DIR"/guards "$@" <"$series" | \
|
|
Michal Marek |
411abb |
if $vanilla; then
|
|
Michal Marek |
6dc70d |
sed -rn '/^patches\.(kernel\.org|rpmify)\//p'
|
|
Michal Marek |
411abb |
else
|
|
Michal Marek |
411abb |
cat
|
|
Michal Marek |
411abb |
fi |\
|
|
Michal Marek |
411abb |
sed "s|^|patch -s -F0 -E -p1 --no-backup-if-mismatch -i $PATCH_DIR/|"
|
|
Michal Marek |
411abb |
) | sh
|
|
Michal Marek |
411abb |
|