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