Blame scripts/newpatch.sh
|
Roland McGrath |
11487c5 |
#!/bin/sh
|
|
Roland McGrath |
11487c5 |
|
|
Miguel Flores Silverio |
77180b8 |
# Facilitates the addition of a new patch to the source tree.
|
|
Miguel Flores Silverio |
77180b8 |
# -- Moves patch to tree
|
|
Miguel Flores Silverio |
77180b8 |
# -- Adds patch to kernel.spec list of patches
|
|
Miguel Flores Silverio |
77180b8 |
# -- Adds patch to git
|
|
Miguel Flores Silverio |
77180b8 |
# -- change buildid macro to the name of the patch being added
|
|
Roland McGrath |
11487c5 |
|
|
Miguel Flores Silverio |
77180b8 |
# Base directory is relative to where the script is.
|
|
Miguel Flores Silverio |
77180b8 |
BASEDIR="$(dirname "$(cd $(dirname $BASH_SOURCE[0]) && pwd)")"
|
|
Miguel Flores Silverio |
77180b8 |
pushd $BASEDIR > /dev/null
|
|
Miguel Flores Silverio |
77180b8 |
# Check for at least patch
|
|
Miguel Flores Silverio |
77180b8 |
if [ "$#" -lt 1 ]; then
|
|
Miguel Flores Silverio |
77180b8 |
echo "usage: $0 [ /path/to/patch/ ] [ description ]"
|
|
Miguel Flores Silverio |
77180b8 |
exit 1
|
|
Miguel Flores Silverio |
77180b8 |
fi
|
|
Miguel Flores Silverio |
77180b8 |
PATCHDIR=$1
|
|
Miguel Flores Silverio |
77180b8 |
DESC=$2
|
|
Miguel Flores Silverio |
77180b8 |
PATCH="$(basename "$PATCHDIR")"
|
|
Miguel Flores Silverio |
77180b8 |
# Kernel.spec file in the current tree
|
|
Miguel Flores Silverio |
77180b8 |
SPECFILE="$BASEDIR/kernel.spec"
|
|
Miguel Flores Silverio |
77180b8 |
# If adding patch from outside the source tree move it to the source tree
|
|
Miguel Flores Silverio |
77180b8 |
if [ -z "$(ls | grep $PATCH)" ]; then
|
|
Miguel Flores Silverio |
77180b8 |
cp $PATCHDIR $BASEDIR/
|
|
Miguel Flores Silverio |
77180b8 |
fi
|
|
Roland McGrath |
11487c5 |
|
|
Miguel Flores Silverio |
77180b8 |
if [ ! -z "$(grep $PATCH $SPECFILE)" ]
|
|
Miguel Flores Silverio |
77180b8 |
then
|
|
Miguel Flores Silverio |
77180b8 |
echo "$PATCH already in kernel.spec"
|
|
Miguel Flores Silverio |
77180b8 |
exit 1
|
|
Miguel Flores Silverio |
77180b8 |
fi
|
|
Miguel Flores Silverio |
77180b8 |
# ID number of the last patch in kernel.spec
|
|
Miguel Flores Silverio |
77180b8 |
LPATCH_ID=$(grep ^Patch $SPECFILE | tail -n1 | awk '{ print $1 }' | sed s/Patch// | sed s/://)
|
|
Miguel Flores Silverio |
77180b8 |
# ID of the next patch to be added to kernel.spec
|
|
Miguel Flores Silverio |
77180b8 |
NPATCH_ID=$(($LPATCH_ID + 1 ))
|
|
Miguel Flores Silverio |
77180b8 |
# Add patch with new id at the end of the list of patches
|
|
Miguel Flores Silverio |
77180b8 |
sed -i "/^Patch$LPATCH_ID:\ /a#\ $DESC\nPatch$NPATCH_ID:\ $PATCH" $SPECFILE
|
|
Miguel Flores Silverio |
77180b8 |
# Add it to git
|
|
Miguel Flores Silverio |
77180b8 |
git add $PATCH
|
|
Miguel Flores Silverio |
77180b8 |
BUILDID_PATCH="$(echo $PATCH | sed 's/\-/\_/g' )"
|
|
Miguel Flores Silverio |
77180b8 |
sed -i "s/^.*define buildid .*$/%define buildid .$BUILDID_PATCH/" $SPECFILE
|
|
Miguel Flores Silverio |
77180b8 |
popd > /dev/null
|