2016-05-10 10:04:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# puts the public files online after a release
|
|
|
|
# Copyright (c) 2006-2016 Willy Tarreau <w@1wt.eu>
|
|
|
|
#
|
|
|
|
# In short :
|
|
|
|
# - requires git
|
|
|
|
# - no restriction to master, uses last tag
|
|
|
|
# - copies & compresses files, changelog & docs to the final destination
|
|
|
|
# - shows a listing of the final file
|
|
|
|
|
2017-06-09 13:57:31 +00:00
|
|
|
USAGE="Usage: ${0##*/} [-a] [-q] [-y] [-b branch] [-n newver] DIR"
|
2016-05-10 10:04:13 +00:00
|
|
|
TARGET_DIR=
|
|
|
|
OUTPUT=
|
|
|
|
SAYYES=
|
|
|
|
BRANCH=
|
|
|
|
DEVEL=
|
2017-06-09 13:57:31 +00:00
|
|
|
QUIET=
|
2017-06-09 13:54:39 +00:00
|
|
|
AUTO=
|
2016-05-10 10:04:13 +00:00
|
|
|
NEW=
|
|
|
|
DIR=
|
|
|
|
DOC=( )
|
|
|
|
|
|
|
|
die() {
|
|
|
|
[ "$#" -eq 0 ] || echo "$*" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
err() {
|
|
|
|
echo "$*" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
quit() {
|
2017-06-09 13:57:31 +00:00
|
|
|
[ "$#" -eq 0 -o -n "$QUIET" ] || echo "$*"
|
2016-05-10 10:04:13 +00:00
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ -n "$1" -a -z "${1##-*}" ]; do
|
|
|
|
case "$1" in
|
2017-06-09 13:54:39 +00:00
|
|
|
-a) AUTO=1 ; shift ;;
|
2017-06-09 13:57:31 +00:00
|
|
|
-q) QUIET=1 ; shift ;;
|
2016-05-10 10:04:13 +00:00
|
|
|
-y) SAYYES=1 ; shift ;;
|
|
|
|
-b) BRANCH="$2" ; shift 2 ;;
|
|
|
|
-n) NEW="$2" ; shift 2 ;;
|
|
|
|
-h|--help) quit "$USAGE" ;;
|
|
|
|
*) die "$USAGE" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
die "$USAGE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
DIR="$1" ; shift
|
|
|
|
if [ -z "$DIR" ]; then
|
|
|
|
die "Missing target directory name."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${DIR##/*}" ]; then
|
|
|
|
DIR="$PWD/$DIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$DIR/." ]; then
|
|
|
|
die "Target directory doesn't exist : $DIR"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! git rev-parse --verify -q HEAD >/dev/null; then
|
|
|
|
die "Failed to check git HEAD."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we want to go to the git top dir
|
2017-06-09 13:36:02 +00:00
|
|
|
toplvl=$(git rev-parse --show-toplevel)
|
|
|
|
if [ -n "$toplvl" ]; then
|
|
|
|
cd "$toplvl"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# ensure that a master branch exists here
|
|
|
|
if [ -z "$(git rev-parse --verify -q master 2>/dev/null)" ]; then
|
|
|
|
die "Current directory doesn't seem to be a valid git directory (no master branch)."
|
|
|
|
fi
|
2016-05-10 10:04:13 +00:00
|
|
|
|
|
|
|
if [ "$(git rev-parse --verify -q HEAD)" != "$(git rev-parse --verify -q master)" ]; then
|
|
|
|
die "git HEAD doesn't match master branch."
|
|
|
|
fi
|
|
|
|
|
2017-06-09 13:36:02 +00:00
|
|
|
if [ "$(git diff HEAD 2>/dev/null |wc -c)" != 0 ]; then
|
2016-05-10 10:04:13 +00:00
|
|
|
err "You appear to have uncommitted local changes, please commit them first :"
|
|
|
|
git status -s -uno >&2
|
|
|
|
die
|
|
|
|
fi
|
|
|
|
|
2017-06-09 13:54:39 +00:00
|
|
|
if [ -z "$NEW" -o -n "$AUTO" ]; then
|
2016-05-10 10:04:13 +00:00
|
|
|
if [ -z "$NEW" ]; then
|
2017-06-09 13:54:39 +00:00
|
|
|
NEW="$(git describe --tags HEAD --abbrev=0)"
|
|
|
|
NEW="${NEW#v}"
|
|
|
|
if [ -z "$NEW" ]; then
|
|
|
|
die "Fatal: cannot determine new version, please specify it."
|
|
|
|
fi
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
2017-06-09 13:54:39 +00:00
|
|
|
|
2016-05-10 10:04:13 +00:00
|
|
|
if [ "$(git describe --tags HEAD)" != "v$NEW" ]; then
|
2017-06-09 13:54:39 +00:00
|
|
|
if [ -n "$AUTO" ]; then
|
|
|
|
quit "Not tagged, nothing to do."
|
|
|
|
fi
|
2016-05-10 10:04:13 +00:00
|
|
|
die "Current version doesn't seem tagged, it reports $(git describe --tags "v$NEW"). Did you release it ?"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! git show-ref --tags "v$NEW" >/dev/null; then
|
|
|
|
die "git tag v$NEW doesn't exist, did you create the release ?"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# determine the product branch from the new release
|
|
|
|
if [ -z "$BRANCH" ]; then
|
|
|
|
subvers=${NEW#[0-9]*.[0-9]*[-.]*[0-9].}
|
|
|
|
[ "${subvers}" = "${NEW}" ] && subvers=""
|
|
|
|
major=${NEW%.$subvers}
|
|
|
|
branch_ext=${major#*[0-9].*[0-9]}
|
|
|
|
BRANCH=${major%${branch_ext}}
|
|
|
|
fi
|
|
|
|
|
|
|
|
TARGET_DIR="$DIR/$BRANCH"
|
|
|
|
if [ ! -d "$TARGET_DIR/." ]; then
|
|
|
|
die "Target directory doesn't contain branch $BRANCH. You may have to create it in $DIR."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${NEW##*-dev*}" ]; then
|
|
|
|
DEVEL="/devel"
|
|
|
|
fi
|
|
|
|
|
2017-06-09 13:54:39 +00:00
|
|
|
if [ -n "$AUTO" -a -e "$TARGET_DIR/src${DEVEL}/haproxy-$NEW.tar.gz.md5" ]; then
|
|
|
|
quit "Version $NEW Already released."
|
|
|
|
fi
|
|
|
|
|
2016-05-10 10:04:13 +00:00
|
|
|
if ! mkdir -p "$TARGET_DIR/src$DEVEL" "$TARGET_DIR/doc"; then
|
|
|
|
die "failed to create target directories."
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$BRANCH" in
|
|
|
|
1.3) DOC=( doc/{haproxy-en,haproxy-fr,configuration,architecture}.txt ) ;;
|
|
|
|
1.4) DOC=( doc/{haproxy-en,haproxy-fr,configuration}.txt ) ;;
|
|
|
|
1.5) DOC=( doc/{coding-style,configuration,proxy-protocol}.txt ) ;;
|
|
|
|
1.6) DOC=( doc/{coding-style,intro,management,configuration,proxy-protocol,lua}.txt ) ;;
|
2016-11-09 22:21:47 +00:00
|
|
|
*) DOC=( doc/{coding-style,intro,management,configuration,proxy-protocol,lua,SPOE}.txt ) ;;
|
2016-05-10 10:04:13 +00:00
|
|
|
esac
|
|
|
|
|
2017-06-09 13:54:39 +00:00
|
|
|
if [ -z "$AUTO" ]; then
|
|
|
|
echo "Ready to produce the following files in $TARGET_DIR/ :"
|
|
|
|
echo " haproxy-$NEW.tar.gz -> src${DEVEL}/"
|
|
|
|
echo " CHANGELOG -> src/CHANGELOG"
|
|
|
|
echo " ${DOC[@]} -> doc/*{,.gz}"
|
|
|
|
echo
|
2016-05-10 10:04:13 +00:00
|
|
|
|
2017-06-09 13:54:39 +00:00
|
|
|
git ls-tree -l --abbrev=12 "v$NEW" -- CHANGELOG "${DOC[@]}"
|
2016-05-10 10:04:13 +00:00
|
|
|
|
2017-06-09 13:54:39 +00:00
|
|
|
if [ -z "$SAYYES" ]; then
|
|
|
|
echo "Press ENTER to continue or Ctrl-C to abort now!"
|
|
|
|
read
|
|
|
|
fi
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Archiving sources for version $NEW ..."
|
2018-07-19 21:57:56 +00:00
|
|
|
rm -f "${TARGET_DIR}/src${DEVEL}/haproxy-${NEW}.tar.gz"{,.md5,.sha256}
|
2016-05-10 10:04:13 +00:00
|
|
|
if ! git archive --format=tar --prefix="haproxy-${NEW}/" "v$NEW" | \
|
|
|
|
gzip -9 > "${TARGET_DIR}/src${DEVEL}/haproxy-${NEW}.tar.gz"; then
|
|
|
|
die "Failed to produce the tar.gz archive"
|
|
|
|
fi
|
|
|
|
|
|
|
|
( cd "$TARGET_DIR/src${DEVEL}" ; \
|
2018-07-19 21:57:56 +00:00
|
|
|
md5sum haproxy-$NEW.tar.gz > haproxy-$NEW.tar.gz.md5 ; \
|
|
|
|
sha256sum haproxy-$NEW.tar.gz > haproxy-$NEW.tar.gz.sha256 )
|
2016-05-10 10:04:13 +00:00
|
|
|
|
|
|
|
echo "Extracting doc ..."
|
|
|
|
git show "v$NEW:CHANGELOG" > "$TARGET_DIR/src/CHANGELOG"
|
|
|
|
|
|
|
|
for i in "${DOC[@]}"; do
|
|
|
|
git show "v$NEW:$i" > "$TARGET_DIR/doc/${i#doc/}"
|
|
|
|
gzip -c9 < "$TARGET_DIR/doc/${i#doc/}" > "$TARGET_DIR/doc/${i#doc/}.gz"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Done : ls -l ${TARGET_DIR}"
|
|
|
|
( cd "$TARGET_DIR" ;
|
2018-07-19 21:57:56 +00:00
|
|
|
ls -l src/CHANGELOG "src${DEVEL}/haproxy-${NEW}".tar.gz{,.md5,.sha256} $(for i in "${DOC[@]}"; do echo "doc/${i#doc/}"{,.gz}; done)
|
2016-05-10 10:04:13 +00:00
|
|
|
)
|
|
|
|
echo
|