From 33ac7db028e88706ab9165e33583995f16d8f4ec Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Mon, 5 Dec 2016 10:42:25 -0500 Subject: [PATCH] testing: add rebase_patches tool --- test/integration/rebase-patches | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 test/integration/rebase-patches diff --git a/test/integration/rebase-patches b/test/integration/rebase-patches new file mode 100755 index 0000000..79d220c --- /dev/null +++ b/test/integration/rebase-patches @@ -0,0 +1,50 @@ +#!/bin/bash +# +# rebase a set of patches, assumes the kernel has already been downloaded into +# the kpatch $CACHEDIR.Output patches go into ./${ID}-${VERSION_ID}/ +# +# Example: +# +# ./rebase-patches old_dir/*.patch + +CACHEDIR="${CACHEDIR:-$HOME/.kpatch}" +SRCDIR="$CACHEDIR/src" + +source /etc/os-release +OUTDIR=$(pwd)/${ID}-${VERSION_ID} +mkdir -p $OUTDIR + +echo "* Making backup copy of kernel sources" +rm -rf ${SRCDIR}.orig +cp -r $SRCDIR ${SRCDIR}.orig + + +for P in $@; do + + echo + echo "* Patch: $(basename $P)" + + echo "** dry run..." + patch -d $CACHEDIR --dry-run --quiet -p0 < $P + [[ $? -ne 0 ]] && echo "*** Skipping! ***" && continue + + echo "** patching..." + patch -d $CACHEDIR -p0 --no-backup-if-mismatch < $P + + echo "** generating new $(basename $P)..." + NEWP=$OUTDIR/$(basename $P) + awk '/^diff|^patch/{exit} {print $LF}' $P > $NEWP + cd $CACHEDIR + diff -Nupr src.orig src >> $NEWP + cd - + + echo "** reversing patch to restore tree..." + patch -d $CACHEDIR -p0 -R < $NEWP + +done + +echo "*** Removing backup copy of kernel sources" +rm -rf ${SRCDIR}.orig + +echo +echo "*** Done"