Signed-off-by: Miguel Flores Silverio <floresmigu3l@xxxxxxxxx> --- scripts/newpatch.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 scripts/newpatch.sh diff --git a/scripts/newpatch.sh b/scripts/newpatch.sh new file mode 100755 index 0000000..254827f --- /dev/null +++ b/scripts/newpatch.sh @@ -0,0 +1,42 @@ +#! /bin/sh +# +#This script facilitates the addition of a new patch to the source tree. +# -- Moves patch to tree +# -- Adds patch to kernel.spec list of patches +# -- Adds patch to git +# -- Bumps kernel.spec +# Should we also be adding patches to PatchList.txt? + + +# Base directory is relative to where the script is. +BASEDIR=$(dirname "$(cd $(dirname $BASH_SOURCE[0]) && pwd)") + +# Check for both a Patch and a description +if [ -z "$1" ] && [ -z "$2" ]; then + echo "usage: $0 [ /path/to/patch/ ] [ description ]" + exit 1 +fi + +# Kernel.spec file in the current tree +SPECFILE="$BASEDIR/kernel.spec" +# Check if trying to add a patch already in kernel.spec +if [ -n "$(grep $1 $SPECFILE)" ]; then + echo "Error: Patch already exists" + exit 1 +fi + +# If adding a patch outside the source tree move it to the source tree +mv $1 $BASEDIR/ + +# ID number of the last patch in kernel.spec +LPATCH_ID=$(grep ^Patch $SPECFILE | tail -n1 | awk '{ print $1 }' | sed s/Patch// | sed s/://) +# ID of the next patch to be added to kernel.spec +NPATCH_ID=$(($LPATCH_ID + 1 )) + +# Add patch with new id at the end of the list of patches +sed -i "/^Patch$LPATCH_ID:\ /a#\ $2\nPatch$NPATCH_ID:\ $1" $SPECFILE + +# Keep track of the patch +git add $1 + +rpmdev-bumpspec $SPECFILE -- 2.7.4 _______________________________________________ kernel mailing list kernel@xxxxxxxxxxxxxxxxxxxxxxx https://lists.fedoraproject.org/admin/lists/kernel@xxxxxxxxxxxxxxxxxxxxxxx