| 1 |
#!/usr/bin/bash |
| 2 |
|
| 3 |
set -e # exit on error |
| 4 |
|
| 5 |
function determine_apply_diff() { |
| 6 |
|
| 7 |
read ANSWER |
| 8 |
if [ "$ANSWER" == "no" ] |
| 9 |
then |
| 10 |
return 1 |
| 11 |
elif [ "$ANSWER" == "yes" ] |
| 12 |
then |
| 13 |
return 0 |
| 14 |
else |
| 15 |
echo "Please answer \"yes\" or \"no\"" |
| 16 |
determine_apply_diff |
| 17 |
return $? |
| 18 |
fi |
| 19 |
|
| 20 |
} |
| 21 |
|
| 22 |
### Create the directory we'll be working in### |
| 23 |
|
| 24 |
SRCDIR=`dirname $0`/..; SRCDIR=`realpath $SRCDIR` |
| 25 |
DIR=`mktemp -d stapXXX -p /tmp/`; cd $DIR |
| 26 |
|
| 27 |
echo "Working in $DIR" |
| 28 |
trap 'rm -rf $DIR' 0 1 2 3 5 15 |
| 29 |
|
| 30 |
# We need to differenciate between upstream sources and the later used distro sources |
| 31 |
# hence the specific checkout to systemtap-git |
| 32 |
|
| 33 |
git clone --reference $SRCDIR git://sourceware.org/git/systemtap.git systemtap-git |
| 34 |
cd systemtap-git |
| 35 |
|
| 36 |
# We need to use --global for the NAME and USER vars as we're |
| 37 |
# assuming this script can be run from anywhere (ie, not in an |
| 38 |
# already existing git repo) |
| 39 |
APPLY_DIFF=1 |
| 40 |
DATE=`date +"%a %b %d %Y"` |
| 41 |
NAME=`git config --get-all user.name` |
| 42 |
EMAIL=`git config --get-all user.email` |
| 43 |
STAP_MAJOR_VERSION=`grep "^Version:" systemtap.spec` |
| 44 |
CHANGELOG_VERSION=`echo $STAP_MAJOR_VERSION | cut -f2 -d" "` |
| 45 |
TAG_DATE=$(expr `date +%s` / 100) # short: 100-second blocks since epoch |
| 46 |
GIT_DESCRIBE=`git rev-parse HEAD | cut -c1-8` |
| 47 |
GIT_VERSION_TAG=`echo ${TAG_DATE}g${GIT_DESCRIBE}` |
| 48 |
FINAL_VERSION="$CHANGELOG_VERSION~pre$GIT_VERSION_TAG" # the resulting Version: / Source: identifier |
| 49 |
|
| 50 |
### lets do a sanity check first |
| 51 |
if which fedpkg &>/dev/null; then |
| 52 |
: |
| 53 |
else |
| 54 |
echo "Please install the fedpkg package" |
| 55 |
exit |
| 56 |
fi |
| 57 |
|
| 58 |
# Checkout the fedora sources systemtap |
| 59 |
cd .. |
| 60 |
fedpkg co systemtap |
| 61 |
|
| 62 |
# Diff and check the differences between the two spec files, |
| 63 |
cd systemtap |
| 64 |
|
| 65 |
git diff systemtap.spec ../systemtap-git/systemtap.spec > ../spec-diff || true |
| 66 |
|
| 67 |
if [ -s ../spec-diff ]; then |
| 68 |
CHANGELOG_PRESENT=`grep \%changelog ../spec-diff || true` |
| 69 |
# the space in front of %changelog is because its a diff context line |
| 70 |
if [ "$CHANGELOG_PRESENT" == " %changelog" ]; then |
| 71 |
# We don't need to know the difference in spec changelogs |
| 72 |
# changelogs should only ever grow, make sure we also trim the %changelog |
| 73 |
# context lines as well |
| 74 |
sed -i '/\%changelog/,$d' ../spec-diff |
| 75 |
tac ../spec-diff | sed '1,3d' | tac > spec-diff |
| 76 |
mv spec-diff ../spec-diff |
| 77 |
fi |
| 78 |
# end changelog diff if |
| 79 |
cat ../spec-diff |
| 80 |
echo "The above changes will apply to the fedora git tree," |
| 81 |
echo "would you like to apply the patch? (yes/no):" |
| 82 |
determine_apply_diff |
| 83 |
APPLY_DIFF=$? |
| 84 |
if [ "$APPLY_DIFF" == 0 ]; then |
| 85 |
patch -p1 systemtap.spec < ../spec-diff |
| 86 |
fi |
| 87 |
cd .. |
| 88 |
fi |
| 89 |
|
| 90 |
# create a tar.gz of the latest git sources from HEAD |
| 91 |
cd systemtap-git |
| 92 |
|
| 93 |
git archive --prefix=systemtap-$FINAL_VERSION/ -o ../systemtap/systemtap-$FINAL_VERSION.tar.gz HEAD |
| 94 |
|
| 95 |
# fedpackage stuff |
| 96 |
|
| 97 |
cd ../systemtap |
| 98 |
|
| 99 |
sed -i "s/^Version:.*/Version: $FINAL_VERSION/" systemtap.spec |
| 100 |
sed -i "s/^Source:.*/Source: %{name}-%{version}.tar.gz/" systemtap.spec |
| 101 |
|
| 102 |
# make note in the comments if any differences from upstream systemtap.spec have been merged |
| 103 |
if [ "$APPLY_DIFF" == 0 ]; then |
| 104 |
sed -i "s/\%changelog/\%changelog\n* $DATE $NAME <$EMAIL> - $CHANGELOG_VERSION-$GIT_VERSION_TAG\n- Automated weekly rawhide release\n- Applied spec changes from upstream git\n/" systemtap.spec |
| 105 |
else |
| 106 |
sed -i "s/\%changelog/\%changelog\n* $DATE $NAME <$EMAIL> - $FINAL_VERSION\n- Automated weekly rawhide release\n/" systemtap.spec |
| 107 |
fi |
| 108 |
|
| 109 |
echo "Please ensure that you have an up to date fedoraproject krb5 ticket, else kinit `whoami`@FEDORAPROJECT.ORG" |
| 110 |
klist |
| 111 |
|
| 112 |
fedpkg new-sources systemtap-$FINAL_VERSION.tar.gz |
| 113 |
|
| 114 |
fedpkg commit -m "Automated weekly systemtap rawhide release: $FINAL_VERSION" -p |
| 115 |
|
| 116 |
fedpkg build |