3
# This script builds a snapshot: a lightweight tarball of the current
4
# bzr branch _without_ updating the changelog, docs, etc. Snapshots
5
# are meant to allow early access and real-world testing by Percona
6
# support staff. They're fetched from percona.com/trunk/.
8
# The current version of the tools is used plus "-snapshot-YYYY.MM.DD"
9
# to indicate that it's a snapshot, not a full release.
11
# ############################################################################
12
# Standard startup, find the branch's root directory
13
# ############################################################################
15
set -ue # bail out on errors, be strict
30
PERCONA_TOOLKIT_BRANCH=${PERCONA_TOOLKIT_BRANCH:-""}
31
if [ -n "$PERCONA_TOOLKIT_BRANCH" ]; then
32
BRANCH=$PERCONA_TOOLKIT_BRANCH
35
while [ ! -f Makefile.PL ] && [ $PWD != "/" ]; do
38
if [ ! -f Makefile.PL ]; then
39
die "Cannot find the root directory of the Percona Toolkit branch"
45
# ############################################################################
47
# ############################################################################
49
SNAPSHOT_DIR=$BRANCH/snapshot
51
# ############################################################################
52
# Programs and their options
53
# ############################################################################
57
# ############################################################################
59
# ############################################################################
62
echo -n "Preparing $SNAPSHOT_DIR... "
65
# Make temp snapshot dir so we can copy and modify files in it
66
# without affecting the underlying bzr branch because, unlike
67
# a release, we don't want to commit anything, but we do want
68
# to modify stuff, namely the tools' version.
69
if [ ! -d $SNAPSHOT_DIR ]; then
71
elif [ -d $SNAPSHOT_DIR/$PKG ]; then
72
rm -rf $SNAPSHOT_DIR/$PKG/*
75
# Copy the tools, of course.
76
mkdir -p $SNAPSHOT_DIR/$PKG/bin
77
cp bin/* $SNAPSHOT_DIR/$PKG/bin
79
# Copy the originals of these files for reference.
80
for file in Changelog COPYING README; do
81
cp $file $SNAPSHOT_DIR/$PKG
84
# Pretend that someone will actually read this special readme
85
# and discover that this isn't a full release.
86
echo >$SNAPSHOT_DIR/$PKG/README.SNAPSHOT <<README
87
This is a snapshot of Percona Toolkit created on $DATE, based on the full $VERSION release. Snapshots are previews of the current code and should only be used for testing. The code in this snapshot can change or be removed in later snapshots and is no guarantee of what will be included in the next full release. Contact Percona (http://www.percona.com/) if you have any questions.
89
The README and Changelog from the full $VERSION release are included for reference. See DIFF for a diff of all changes since the $VERSION release.
94
# Make a diff of all changes since the last full release.
95
# This may be long, but it shows what actually has changed
96
# in this snapshot (otherwise one needs access to lp/bzr).
97
# This can take a few seconds, so it gets its own status line.
98
local last_release_rev=$(bzr tags | tail -n 1 | awk '{print $2 + 1}')
99
local cmd="bzr log -r$last_release_rev.. --show-diff"
100
echo -n "Creating DIFF ($cmd)... "
101
$cmd > $SNAPSHOT_DIR/$PKG/DIFF
106
echo -n "Updating MANIFEST... "
107
# Just in case someone actually uses/trusts the manifest.
108
cd $SNAPSHOT_DIR/$PKG
110
for file in * bin/*; do
111
if [ -f $file ]; then
112
echo $file >> MANIFEST
119
echo -n "Updating version in tools... "
120
cd $SNAPSHOT_DIR/$PKG/bin
121
for tool_file in *; do
122
sed -i'.bak' -e "s/^$tool_file [0-9]\.[0-9][^ ]\+/$tool_file $SNAPSHOT_VERSION/" $tool_file
123
if [ $? -ne 0 ]; then
124
die "Error updating version in $tool_file"
129
local new_versions=$(grep --no-filename '^pt-[^ ]\+ [0-9]\.' * | cut -d' ' -f2 | sort -u)
130
if [ "$new_versions" != "$SNAPSHOT_VERSION" ]; then
131
die "The version in some tools did not update correctly"
137
echo -n "Building $PKG.tar.gz... "
139
$TAR czf "$PKG.tar.gz" $PKG
143
# ############################################################################
145
# ############################################################################
147
if [ $# -gt 0 ]; then
151
VERSION=$(awk '/VERSION/ {print $3; exit;}' $BRANCH/Makefile.PL | sed -e "s/[',]//g")
152
DATE=$(date -u +'%Y.%m.%d')
153
SNAPSHOT_VERSION="$VERSION-snapshot-$DATE"
154
PKG="percona-toolkit-$SNAPSHOT_VERSION"
161
if [ -d $SNAPSHOT_DIR/$PKG ]; then
162
rm -rf $SNAPSHOT_DIR/$PKG
165
if [ $EXIT_STATUS -eq 0 ] && [ -f "$SNAPSHOT_DIR/$PKG.tar.gz" ]; then
166
echo "Snapshot built successfully:"
167
echo "$SNAPSHOT_DIR/$PKG.tar.gz"
169
warn "Error building snapshot"