2016-12-05 15:42:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2020-03-10 14:16:19 +00:00
|
|
|
# rebase a set of integration test patches
|
2016-12-05 15:42:25 +00:00
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
#
|
2020-03-10 14:16:19 +00:00
|
|
|
# 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}
|
2020-03-10 14:16:19 +00:00
|
|
|
mkdir -p "$OUTDIR"
|
2016-12-05 15:42:25 +00:00
|
|
|
|
|
|
|
echo "* Making backup copy of kernel sources"
|
2020-03-10 14:16:19 +00:00
|
|
|
rm -rf "${SRCDIR}.orig"
|
|
|
|
cp -r "$SRCDIR" "${SRCDIR}.orig"
|
2016-12-05 15:42:25 +00:00
|
|
|
|
2020-03-10 14:16:19 +00:00
|
|
|
for P in "$@"; do
|
2016-12-05 15:42:25 +00:00
|
|
|
|
|
|
|
echo
|
2020-03-10 14:16:19 +00:00
|
|
|
echo "* Patch: $(basename "$P")"
|
2016-12-05 15:42:25 +00:00
|
|
|
|
|
|
|
echo "** dry run..."
|
2020-03-10 14:16:19 +00:00
|
|
|
if ! patch -d "$SRCDIR" --dry-run --quiet -p1 < "$P"; then
|
|
|
|
echo "*** Skipping! ***" && continue
|
|
|
|
fi
|
2016-12-05 15:42:25 +00:00
|
|
|
|
|
|
|
echo "** patching..."
|
2020-03-10 14:16:19 +00:00
|
|
|
patch -d "$SRCDIR" -p1 --no-backup-if-mismatch < "$P"
|
2016-12-05 15:42:25 +00:00
|
|
|
|
2020-03-10 14:16:19 +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..."
|
2020-03-10 14:16:19 +00:00
|
|
|
patch -d "$SRCDIR" -p1 -R < "$NEWP"
|
2016-12-05 15:42:25 +00:00
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "*** Removing backup copy of kernel sources"
|
2020-03-10 14:16:19 +00:00
|
|
|
rm -rf "${SRCDIR}.orig"
|
2016-12-05 15:42:25 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo "*** Done"
|