Add numeric version tag support to release script.
[fw/openocd] / tools / release.sh
index 5511f101e7e0e9f01e6c245d5f859a512b3a57a2..de0946b78b33f7e1391c6e78bb4fe1db5d274d1e 100755 (executable)
@@ -212,19 +212,6 @@ do_build() {
 maybe_build() { [ -f "src/openocd" ] || do_build; }
 do_build_clean() { [ -f Makefile ] && make maintainer-clean >/dev/null; }
 
-maybe_rebuild() {
-       if [ -f "configure" ]; then
-               echo "Re-running autoconf..."
-               autoconf
-               echo "Re-running automake..."
-               automake
-       fi
-       if [ -f "Makefile" ]; then
-               do_configure
-               do_build
-       fi
-}
-
 do_changelog() {
        echo "Updating working copy to HEAD..."
        do_svn update
@@ -262,7 +249,14 @@ do_stage() {
        echo "Staging package archives:"
        mkdir -p archives
        for EXT in tar.gz tar.bz2 zip; do
-               mv -v "${PACKAGE_RELEASE}.${EXT}" archives/
+               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/
@@ -312,7 +306,6 @@ do_version_bump_sed() {
                "Bump ${CMD} package version number"
 }
 do_version_bump_major() {
-       has_version_tag 'rc\d' do_version_
        do_version_bump_sed "$((PACKAGE_MAJOR + 1)).0.0"
 }
 do_version_bump_minor() {
@@ -321,15 +314,27 @@ do_version_bump_minor() {
 do_version_bump_micro() {
        do_version_bump_sed "${PACKAGE_MAJOR_AND_MINOR}.$((PACKAGE_MICRO + 1))"
 }
-do_version_bump_rc() {
-       die "patch missing: -rc support is not implemented"
+do_version_bump_tag() {
+       local TAG="$1"
+       [ "${TAG}" ] || die "TAG argument is missing"
+       local TAGS="${PACKAGE_VERSION_TAGS}"
+       if has_version_tag "${TAG}"; then
+               local RC=$(echo ${TAGS} | perl -ne "/-${TAG}"'(\d+)/ && print $1')
+               RC=$((${RC} + 1))
+               TAGS=$(echo ${TAGS} | perl -npe "s/-${TAG}[\\d]*/-${TAG}${RC}/")
+       else
+               TAGS="-${TAG}1${PACKAGE_VERSION_TAGS}"
+       fi
+       PACKAGE_VERSION_TAGS="${TAGS}"
+       do_version_bump_sed "${PACKAGE_VERSION_BASE}"
 }
+do_version_bump_rc() { do_version_bump_tag 'rc'; }
 do_version_bump() {
        CMD="$1"
        shift
        case "${CMD}" in
-       major|minor|micro|rc)
-               eval "do_version_bump_${CMD}"
+       major|minor|micro|rc|tag)
+               eval "do_version_bump_${CMD}" "$@"
                ;;
        *)
                do_version_usage
@@ -338,18 +343,20 @@ do_version_bump() {
 }
 
 has_version_tag() {
-       test "${PACKAGE_VERSION/-${TAG}/}" != "${PACKAGE_VERSION}"
+       test "${PACKAGE_VERSION/-${1}/}" != "${PACKAGE_VERSION}"
 }
 
 do_version_tag_add() {
        local TAG="$1"
-       has_version_tag && die "error: tag '-${TAG}' exists in '${PACKAGE_VERSION}'"
+       has_version_tag "${TAG}" && \
+               die "error: tag '-${TAG}' exists in '${PACKAGE_VERSION}'"
        do_version_sed "${PACKAGE_VERSION}-${TAG}" \
                "Add '-${TAG}' version tag"
 }
 do_version_tag_remove() {
        local TAG="$1"
-       has_version_tag || die "error: tag '-${TAG}' missing from '${PACKAGE_VERSION}'"
+       has_version_tag "${TAG}" || \
+               die "error: tag '-${TAG}' missing from '${PACKAGE_VERSION}'"
        do_version_sed "${PACKAGE_VERSION/-${TAG}/}" \
                "Remove '-${TAG}' version tag"
 }
@@ -382,13 +389,11 @@ do_version() {
        case "${CMD}" in
        tag|bump)
                do_version_commit "$(eval "do_version_${CMD}" "$@")"
-               maybe_rebuild
                ;;
        commit)
                local MSG="$1"
                [ "${MSG}" ] || die "usage: $0 version commit <message>"
                do_version_commit "${MSG}"
-               maybe_rebuild
                ;;
        *)
                do_version_usage
@@ -488,10 +493,17 @@ do_release_step_package() {
        local A=${PACKAGE_TAG}
        local B=${A/https/http}
        local PACKAGE_BUILD=${B/${USER}@/}
+
        do_svn_switch "${PACKAGE_TAG}"
        do_svn_switch --relocate "${PACKAGE_TAG}" "${PACKAGE_BUILD}"
+
+       # required to force SVN to update the in-source URL keyword
+       [ "${RELEASE_DRY_RUN}" ] || rm -v -f src/openocd.c
+       do_svn revert src/openocd.c
+
        do_stage
        do_clean
+
        do_svn_switch --relocate "${PACKAGE_BUILD}" "${PACKAGE_TAG}"
        do_svn_switch "${SVN_URL}"
 }