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