On 07/19/2016 04:32 PM, Laura Abbott wrote:
On 07/18/2016 08:31 PM, Miguel Flores Silverio wrote:
> Script helps add a new patch to the soruce tree. 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(a)gmail.com>
> ---
> * PATCHv2
> - Fix: Fail adding a patch with no description
> - Fix: Fail to add a patch outside the tree
> - Fix: Fail when adding a patch already in the tree directory
> - Fix: Fail to add to git when running script outside tree
> - enables the buildid and changes it to the patch name being added
> * PATCHv3
> - replaces "-" [dash] with "_"[uder score] to use patch name
> as builid
> 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..7322b70
> --- /dev/null
> +++ b/scripts/newpatch.sh
This doesn't apply properly against the master branch, did newpatch.sh
get deleted previously and I didn't apply or did this get misgenerated?
You are
right! I did send a patch to remove newpatch.sh, but I think it was
part of the application process for the internship and never applied to
rawhide.
I will send the incremental changes.
> @@ -0,0 +1,42 @@
> +#! /bin/sh
> +
> +# 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
> +
> +# 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
> + mv $PATCHDIR $BASEDIR/
Can you change this to cp instead of mv? It's safer.
> +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
> --
> 2.7.4
>
Other than that, looks good!