kpatch/test/integration/rebase-patches

57 lines
1.3 KiB
Plaintext
Raw Normal View History

2016-12-05 15:42:25 +00:00
#!/bin/bash
#
# rebase a set of integration test patches
2016-12-05 15:42:25 +00:00
#
# Example:
#
# 1 - Extract kernel sources:
#
# % (rpm -ivh kernel-3.10.0-1127.el7.src.rpm; \
# cd ~/rpmbuild/SPECS; \
# rpmbuild --nodeps -bp kernel.spec)
#
#
# 2 - Rebase from previous release tests:
#
# % cd test/integration
# % SRCDIR="$HOME/rpmbuild/BUILD/kernel-3.10.0-1127.el7/linux-3.10.0-1127.el7.x86_64" \
# ID=rhel VERSION_ID=7.8 ./rebase-patches rhel-7.7/*{.patch,.disabled}
# % cp rhel-7.7/*.test rhel-7.8/
2016-12-05 15:42:25 +00:00
OUTDIR=$(pwd)/${ID}-${VERSION_ID}
mkdir -p "$OUTDIR"
2016-12-05 15:42:25 +00:00
echo "* Making backup copy of kernel sources"
rm -rf "${SRCDIR}.orig"
cp -r "$SRCDIR" "${SRCDIR}.orig"
2016-12-05 15:42:25 +00:00
for P in "$@"; do
2016-12-05 15:42:25 +00:00
echo
echo "* Patch: $(basename "$P")"
2016-12-05 15:42:25 +00:00
echo "** dry run..."
if ! patch -d "$SRCDIR" --dry-run --quiet -p1 < "$P"; then
echo "*** Skipping! ***" && continue
fi
2016-12-05 15:42:25 +00:00
echo "** patching..."
patch -d "$SRCDIR" -p1 --no-backup-if-mismatch < "$P"
2016-12-05 15:42:25 +00:00
echo "** generating new $(basename "$P")..."
NEWP="$OUTDIR"/$(basename "$P")
awk '/^Index|^diff|^patch/{exit} {print $LF}' "$P" > "$NEWP"
diff -Nupr "$SRCDIR.orig" "${SRCDIR}" >> "$NEWP"
sed -i "s#$SRCDIR#src#g" "$NEWP"
2016-12-05 15:42:25 +00:00
echo "** reversing patch to restore tree..."
patch -d "$SRCDIR" -p1 -R < "$NEWP"
2016-12-05 15:42:25 +00:00
done
echo "*** Removing backup copy of kernel sources"
rm -rf "${SRCDIR}.orig"
2016-12-05 15:42:25 +00:00
echo
echo "*** Done"