On 06/13/2016 12:45 PM, Miguel Flores Silverio wrote:
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?
Not for now. We can add that later if we decide that automating it is something we want to do.
+ + +# 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
This misses the case of no description since $1 will be defined and the && will fail. Try counting the number of arguments with $# instead of checking each one individually.
+ echo "usage: $0 [ /path/to/patch/ ] [ description ]" + exit 1 +fi +
You don't actually get the right behavior most places if $1 exists outside the tree. If I test with ./scripts/newpatch.sh ~/Downloads/some-patch.patch "A new patch" ...
+# 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
...this check is not going to find problems because the spec file only contains file names not paths.
+ 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/ +
This gives an error of the patch is already in the directory.
+# 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 +
Same problem here if $1 is out of tree.
+rpmdev-bumpspec $SPECFILE
_______________________________________________ kernel mailing list kernel@xxxxxxxxxxxxxxxxxxxxxxx https://lists.fedoraproject.org/admin/lists/kernel@xxxxxxxxxxxxxxxxxxxxxxx