Justin Vreeland 794d92
#!/bin/sh
Justin Vreeland 794d92
# A coffeeproof rawhide script. You should be able to run this before the
Justin Vreeland 794d92
# coffee has kicked in and generate a good rawhide commit.
Justin Vreeland 794d92
#
Justin Vreeland 794d92
# - Updates the local Fedora tree to master and verifies that you are working
Justin Vreeland 794d92
#   off of the correct master
Justin Vreeland 794d92
# - Updates the upstream tree to the latest master.
Justin Vreeland 794d92
# - Generates a git snapshot via generate-git-snapshot.sh
Justin Vreeland 794d92
# - Clears out old git snapshots from the sources
Justin Vreeland 794d92
# - Uploads the new snapshot
Justin Vreeland 794d92
Justin Vreeland 794d92
source scripts/kernel-version.sh
Justin Vreeland 794d92
Justin Vreeland 794d92
klist -s
Justin Vreeland 794d92
if [ ! $? -eq 0 ]; then
Justin Vreeland 794d92
	echo "klist couldn't read the credential cache."
Justin Vreeland 794d92
	echo "Do you need to fix your kerberos tokens?"
Justin Vreeland 794d92
	exit 1
Justin Vreeland 794d92
fi
Justin Vreeland 794d92
Justin Vreeland 794d92
git fetch origin
Justin Vreeland 794d92
if [ "$(git rev-parse origin/master)" != "$(git rev-parse HEAD)" ]; then
Justin Vreeland 794d92
	echo "I just did a git fetch and this branch does not match master"
Justin Vreeland 794d92
	echo "Re-check out this branch to work off of the latest master"
Justin Vreeland 794d92
	exit 1
Justin Vreeland 794d92
fi
Justin Vreeland 794d92
Justin Vreeland 794d92
if [ ! -d "$LINUX_GIT" ]; then
Justin Vreeland 794d92
	echo "error: set \$LINUX_GIT to point at an upstream git tree"
Justin Vreeland 794d92
	exit 1
Justin Vreeland 794d92
fi
Justin Vreeland 794d92
Justin Vreeland 794d92
git -C $LINUX_GIT pull
Justin Vreeland 794d92
if [ ! $? -eq 0 ]; then
Justin Vreeland 794d92
	echo "Git pull failed. Is your tree clean/correct?"
Justin Vreeland 794d92
	exit 1
Justin Vreeland 794d92
fi
Justin Vreeland 794d92
Justin Vreeland 794d92
git -C $LINUX_GIT describe --tags HEAD | grep -q "\-g"
Justin Vreeland 794d92
if [ ! $? -eq 0 ]; then
Justin Vreeland 794d92
	echo "Trying to snapshot off of a tagged git."
Justin Vreeland 794d92
	echo "I don't think this is what you want"
Justin Vreeland 794d92
	exit 1
Justin Vreeland 794d92
fi
Justin Vreeland 794d92
Justin Vreeland 794d92
if [ "$(git -C $LINUX_GIT rev-parse origin/master)" == `cat gitrev` ]; then
Justin Vreeland 794d92
	echo "Last snapshot commit matches current master. Nothing to do"
Justin Vreeland 794d92
	echo "\o/"
Justin Vreeland 794d92
	exit 0
Justin Vreeland 794d92
fi
Justin Vreeland 794d92
Justin Vreeland 794d92
GIT=`grep "%define gitrev" kernel.spec | cut -d ' ' -f 3`
Justin Vreeland 794d92
if [ "$GIT" -eq 0 ]; then
Justin Vreeland 794d92
	make debug
Justin Vreeland 794d92
	./scripts/fixup-bumpspec.sh
Justin Vreeland 794d92
	fedpkg commit -c
Justin Vreeland 794d92
fi
Justin Vreeland 794d92
Justin Vreeland 794d92
./scripts/generate-git-snapshot.sh
Justin Vreeland 794d92
Justin Vreeland 794d92
#Nuke the old patch from the source
Justin Vreeland 794d92
awk '!/git/ { print $0 }' < sources > sources.tmp
Justin Vreeland 794d92
mv sources.tmp sources
Justin Vreeland 794d92
Justin Vreeland 794d92
GIT=`grep "%define gitrev" kernel.spec | cut -d ' ' -f 3`
Justin Vreeland 794d92
fedpkg upload patch-$VER-git$GIT.xz