diff options
author | Miguel Flores Silverio <floresmigu3l@gmail.com> | 2016-07-27 11:10:00 -0700 |
---|---|---|
committer | Laura Abbott <labbott@fedoraproject.org> | 2016-08-03 05:03:59 -0700 |
commit | 77180b86902b1836c655213fd603ff657303ff35 (patch) | |
tree | 9bce5b18e0ba46bad9224d7af372c02bc5577f45 /scripts/newpatch.sh | |
parent | 86429d3fcb9b8907e6c43a2c504d605e1ac18358 (diff) | |
download | kernel-77180b86902b1836c655213fd603ff657303ff35.tar.gz kernel-77180b86902b1836c655213fd603ff657303ff35.tar.xz kernel-77180b86902b1836c655213fd603ff657303ff35.zip |
update script to add a new patch
It enables the builid macro and uses the name of the patch as
label instead of using rpmdev-bumpspec.
Signed-off-by: Miguel Flores Silverio <floresmigu3l@gmail.com>
Diffstat (limited to 'scripts/newpatch.sh')
-rwxr-xr-x | scripts/newpatch.sh | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/scripts/newpatch.sh b/scripts/newpatch.sh index 0dc2e837c..2d7498655 100755 --- a/scripts/newpatch.sh +++ b/scripts/newpatch.sh @@ -1,21 +1,42 @@ #!/bin/sh -# Easy application of new patches. -# Always adds to the very end. (Bumps last patch nr by 100) -# Parameters: -# $1 - patch filename -# $2 - description -OLD=$(grep ^Patch kernel.spec | tail -n1 | awk '{ print $1 }' | sed s/Patch// | sed s/://) -NEW=$(($OLD/100*100+100)) +# 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 +# -- change buildid macro to the name of the patch being added -sed -i "/^Patch$OLD:\ /a#\ $2\nPatch$NEW:\ $1" kernel.spec - -LAST=$(grep ^ApplyPatch kernel.spec | tail -n1 | awk '{ print $2 }') - -sed -i "/^ApplyPatch $LAST/aApplyPatch $1" kernel.spec - -cvs add $1 - -scripts/bumpspecfile.py kernel.spec "- $2" -make clog +# Base directory is relative to where the script is. +BASEDIR="$(dirname "$(cd $(dirname $BASH_SOURCE[0]) && pwd)")" +pushd $BASEDIR > /dev/null +# Check for at least patch +if [ "$#" -lt 1 ]; then + echo "usage: $0 [ /path/to/patch/ ] [ description ]" + exit 1 +fi +PATCHDIR=$1 +DESC=$2 +PATCH="$(basename "$PATCHDIR")" +# Kernel.spec file in the current tree +SPECFILE="$BASEDIR/kernel.spec" +# If adding patch from outside the source tree move it to the source tree +if [ -z "$(ls | grep $PATCH)" ]; then + cp $PATCHDIR $BASEDIR/ +fi +if [ ! -z "$(grep $PATCH $SPECFILE)" ] +then + echo "$PATCH already in kernel.spec" + exit 1 +fi +# 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#\ $DESC\nPatch$NPATCH_ID:\ $PATCH" $SPECFILE +# Add it to git +git add $PATCH +BUILDID_PATCH="$(echo $PATCH | sed 's/\-/\_/g' )" +sed -i "s/^.*define buildid .*$/%define buildid .$BUILDID_PATCH/" $SPECFILE +popd > /dev/null |