#!/bin/sh -e # release.sh: openocd release process automation # Copyright (C) 2009 by Zachary T Welch # Release under the GNU GPL v2 (or later versions). ## set these to control the build process #CONFIG_OPTS="" #MAKE_OPTS="" ## DO NOT PERFORM LIVE RELEASES UNLESS YOU ARE THE RELEASE MANAGER!!! RELEASE_DRY_RUN=1 ## set this to perform individual steps on past releases RELEASE_VERSION= die() { echo "$@" >&2 exit 1 } svn_info_get() { svn info | grep "$1" | cut -d':' -f2- | cut -c2- } svn_setup_load() { SVN_ROOT="$(svn_info_get 'Repository Root')" SVN_URL="$(svn_info_get 'URL')" SVN_TRUNK="${SVN_ROOT}/trunk" SVN_BRANCHES="${SVN_ROOT}/branches" PACKAGE_BRANCH="${SVN_BRANCHES}/${PACKAGE_RELEASE}" SVN_TAGS="${SVN_ROOT}/tags" PACKAGE_TAG="${SVN_TAGS}/${PACKAGE_RELEASE}" if [ "${SVN_URL}" = "${SVN_TRUNK}" ]; then RELEASE_TYPE=minor elif [ "${SVN_URL/${SVN_BRANCHES}/}" != "${SVN_URL}" ]; then RELEASE_TYPE=micro else echo "error: bad URL: ${SVN_URL}" >&2 die "unable to branch from the current location" fi } svn_setup_show() { cat < Main Commands: info Show a summary of the next pending release. release Release the current tree as an archive. upload Upload archives to berliOS project site Build Commands: bootstrap Prepare the working copy for configuration and building. configure Configures the package; runs bootstrap, if needed. build Compiles the project; runs configure, if needed. Packaging Commands: changelog Generate a new ChangeLog using svn2cl. package Produce new distributable source archives. stage Move archives to staging area for upload. Repository Commands: commit Perform branch and tag, as appropriate for the version. branch Create a release branch from the project trunk. tag Create a tag for the current release branch. Other Commands: version ... Perform version number and tag manipulations. maryslamb Mary had a little lamb, but no one noticed. clean Forces regeneration of results. clean_all Removes all traces of the release process. help Provides this list of commands. For more information about this script, see the Release Processes page in the OpenOCD Developer's Manual (doc/manual/release.txt). WARNING: This script should be used by the Release Manager ONLY. USAGE exit 0 } do_usage() { usage; } do_help() { usage; } do_info_show() { echo "Current Release Analysis:" package_info_show svn_setup_show } do_info() { package_info_load svn_setup_load do_info_show } do_bootstrap() { echo -n "Bootstrapping..." ./bootstrap 2>&1 | perl tools/logger.pl > "release-bootstrap.log" } maybe_bootstrap() { [ -f "configure" ] || do_bootstrap; } do_configure() { maybe_bootstrap echo -n "Configuring..." ./configure ${CONFIG_OPTS} 2>&1 | perl tools/logger.pl > "release-config.log" } maybe_configure() { [ -f "Makefile" ] || do_configure; } do_build() { maybe_configure echo -n "Compiling OpenOCD ${PACKAGE_VERSION}" make ${MAKE_OPTS} -C doc stamp-vti 2>&1 \ | perl tools/logger.pl > "release-version.log" make ${MAKE_OPTS} 2>&1 \ | perl tools/logger.pl > "release-make.log" } maybe_build() { [ -f "src/openocd" ] || do_build; } do_build_clean() { [ -f Makefile ] && make maintainer-clean >/dev/null; } do_changelog() { echo "Updating working copy to HEAD..." do_svn update echo "Creating ChangeLog..." svn2cl -i --authors AUTHORS.ChangeLog } maybe_changelog() { if [ -z "${RELEASE_DRY_RUN}" ] \ || [ ! -f ChangeLog ] \ || [ "$(cat ChangeLog | wc -l)" -lt 2 ] then do_changelog fi } do_changelog_clean() { do_svn revert ChangeLog } do_package() { package_info_load maybe_changelog maybe_build echo "Building distribution packages..." make ${MAKE_OPTS} distcheck 2>&1 | perl tools/logger.pl > "release-pkg.log" } maybe_package() { [ -f "${PACKAGE_RELEASE}.zip" ] || do_package; } do_package_clean() { for EXT in tar.gz tar.bz2 zip; do rm -v -f *.${EXT} done } do_stage() { maybe_package echo "Staging package archives:" mkdir -p archives for EXT in tar.gz tar.bz2 zip; do local FILE="${PACKAGE_RELEASE}.${EXT}" # create archive signatures for HASH in md5 sha1; do echo "sign: ${FILE}.${HASH}" ${HASH}sum "${FILE}" > "archives/${FILE}.${HASH}" done # save archive mv -v "${FILE}" archives/ done cp -a NEWS archives/ cp -a ChangeLog archives/ } do_stage_clean() { rm -v -f -r archives; } do_clean() { do_build_clean do_package_clean rm -v -f configure svn revert configure.in rm -v -f release-*.log } do_clean_all() { do_clean do_changelog_clean do_stage_clean } do_version_usage() { cat << USAGE usage: $0 version Version Commands: tag {add|remove}