Dave Jones c325fa
#!/bin/sh
Miguel Flores Silverio fb65b0
# This script allows for the generation of a git snapshot between the upstream
Miguel Flores Silverio fb65b0
# git tree and the current tree.
Dave Jones c325fa
#
Miguel Flores Silverio fb65b0
# Prerequisites:
Miguel Flores Silverio fb65b0
#     Set LINUX_GIT to point to an upstream Linux git tree in your .bashrc
Miguel Flores Silverio fb65b0
#     or wherever.
Dave Jones c325fa
Miguel Flores Silverio fb65b0
# Look to see if LINUX_GIT is set in local .bashrc
Miguel Flores Silverio fb65b0
if [ -f ~/.bashrc  ]; then
Miguel Flores Silverio fb65b0
    source ~/.bashrc
Miguel Flores Silverio fb65b0
fi
Miguel Flores Silverio fb65b0
Miguel Flores Silverio fb65b0
if [ ! -d "$LINUX_GIT" ]; then
Miguel Flores Silverio fb65b0
    echo "error: set \$LINUX_GIT to point at upstream git tree"
Miguel Flores Silverio fb65b0
    exit 1
Miguel Flores Silverio fb65b0
fi
Kyle McMartin 5fda1e
6ff43e
VER=$(grep patch sources | head -n1 | awk '{ print $2 }' | sed s/patch-// | sed s/-git.*// | sed s/.xz// | sed s/[\(\)]//g)
Dave Jones c325fa
3c964a
if [ -z "$VER" ] ;
3c964a
then
2b2a5f
    VER=$(grep linux sources | head -1 | awk '{ print $2 }' | sed s/linux-// | sed s/.tar.xz// | sed s/[\(\)]//g)
3c964a
fi
3c964a
Dave Jones 80fb79
OLDGIT=$(grep gitrev kernel.spec | head -n1 | sed s/%define\ gitrev\ //)
Dave Jones 80fb79
export NEWGIT=$(($OLDGIT+1))
Dave Jones 80fb79
Dave Jones c325fa
pushd $LINUX_GIT
Dave Jones c325fa
2e4a6e
git diff v$VER.. > /tmp/patch-$VER-git$NEWGIT
Dave Jones 80fb79
xz -9 /tmp/patch-$VER-git$NEWGIT
Dave Jones c325fa
DESC=$(git describe)
eb17d7
git rev-list --max-count=1 HEAD > /tmp/gitrev
Dave Jones c325fa
popd
Dave Jones c325fa
Dave Jones 80fb79
mv /tmp/patch-$VER-git$NEWGIT.xz .
eb17d7
mv /tmp/gitrev .
Dave Jones 80fb79
Dave Jones 80fb79
perl -p -i -e 's|%global baserelease.*|%global baserelease 0|' kernel.spec
Dave Jones c325fa
Dave Jones 80fb79
perl -p -i -e 's|%define gitrev.*|%define gitrev $ENV{'NEWGIT'}|' kernel.spec
Dave Jones ac1a85
Dave Jones c325fa
rpmdev-bumpspec -c "Linux $DESC" kernel.spec