replaceVersion.sh 4.14 KB
Newer Older
con's avatar
con committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#! /usr/bin/env bash

## Command line parameters
if [[ $# != 2 ]]; then
    cat <<USAGE
usage:
  $0 <old> <new>
example:
  $0 '1.2.3' '1.2.4'
USAGE
    exit 1
fi


## Process and show version
OLD=`sed 's/\./\\\\./g' <<<"$1"`
NEW=`sed 's/\./\\\\./g' <<<"$2"`

19 20
OLD_MAJOR=`sed 's/^\([0-9]\)\.[0-9]\.[0-9]$/\1/' <<<"$1"`
NEW_MAJOR=`sed 's/^\([0-9]\)\.[0-9]\.[0-9]$/\1/' <<<"$2"`
con's avatar
con committed
21

22 23
OLD_MINOR=`sed 's/^[0-9]\.\([0-9]\)\.[0-9]$/\1/' <<<"$1"`
NEW_MINOR=`sed 's/^[0-9]\.\([0-9]\)\.[0-9]$/\1/' <<<"$2"`
con's avatar
con committed
24

25 26
OLD_RELEASE=`sed 's/^[0-9]\.[0-9]\.\([0-9]\)$/\1/' <<<"$1"`
NEW_RELEASE=`sed 's/^[0-9]\.[0-9]\.\([0-9]\)$/\1/' <<<"$2"`
con's avatar
con committed
27

28 29 30 31 32 33
OLD_THREE="${OLD_MAJOR}${OLD_MINOR}${OLD_RELEASE}"
NEW_THREE="${NEW_MAJOR}${NEW_MINOR}${NEW_RELEASE}"

OLD_DOT_THREE="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}"
NEW_DOT_THREE="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}"

con's avatar
con committed
34 35 36 37 38 39 40 41 42 43 44 45 46
OLD_DOT_FOUR="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}\\.0"
NEW_DOT_FOUR="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}\\.0"

OLD_COMMA_FOUR="${OLD_MAJOR},${OLD_MINOR},${OLD_RELEASE},0"
NEW_COMMA_FOUR="${NEW_MAJOR},${NEW_MINOR},${NEW_RELEASE},0"

echo "#==============================================="
echo "# Plain    '${OLD}'     -> '${NEW}'"
echo "#-----------------------------------------------"
echo "# Major    '${OLD_MAJOR}'           -> '${NEW_MAJOR}'"
echo "# Minor    '${OLD_MINOR}'           -> '${NEW_MINOR}'"
echo "# Release  '${OLD_RELEASE}'           -> '${NEW_RELEASE}'"
echo "#-----------------------------------------------"
47 48 49 50
echo "# 3        '${OLD_THREE}'         -> '${NEW_THREE}'"
echo "# Dot 3    '${OLD_DOT_THREE}'     -> '${NEW_DOT_THREE}'"
echo "# Dot 4    '${OLD_DOT_FOUR}'  -> '${NEW_DOT_FOUR}'"
echo "# Comma 4  '${OLD_COMMA_FOUR}'     -> '${NEW_COMMA_FOUR}'"
con's avatar
con committed
51 52 53 54 55
echo "#==============================================="
echo


## Make script safe to call from anywhere by going home first
con's avatar
con committed
56
SCRIPT_DIR=`dirname "${PWD}/$0"`/..
con's avatar
con committed
57 58 59 60 61 62 63
echo "Entering directory \`${SCRIPT_DIR}'"
pushd "${SCRIPT_DIR}" &>/dev/null || exit 1


## Patch *.pluginspec
while read i ; do
    echo "Patching \`$i'"
64
    TMPFILE=`mktemp versionPatch.XXXXXX`
con's avatar
con committed
65 66 67 68 69 70 71 72
    sed -e 's/version="'"${OLD}"'"/version="'"${NEW}"'"/' \
            -e 's/compatVersion="'"${OLD}"'"/compatVersion="'"${NEW}"'"/' \
            "${i}" > "${TMPFILE}"
    mv -f "${TMPFILE}" "${i}"
done < <(find . -name '*.pluginspec')


## Patch coreconstants.h
73
TMPFILE=`mktemp versionPatch.XXXXXX`
con's avatar
con committed
74 75 76 77 78 79 80 81 82 83 84
CORE_CONSTANT_H="${SCRIPT_DIR}/src/plugins/coreplugin/coreconstants.h"
echo "Patching \`${CORE_CONSTANT_H}'"
sed \
        -e 's/^\(#define IDE_VERSION_MAJOR \)'"${OLD_MAJOR}"'/\1'"${NEW_MAJOR}"'/' \
        -e 's/^\(#define IDE_VERSION_MINOR \)'"${OLD_MINOR}"'/\1'"${NEW_MINOR}"'/' \
        -e 's/^\(#define IDE_VERSION_RELEASE \)'"${OLD_RELEASE}"'/\1'"${NEW_RELEASE}"'/' \
    "${CORE_CONSTANT_H}" > "${TMPFILE}"
mv -f "${TMPFILE}" "${CORE_CONSTANT_H}"


## Patch installer.rc
85
TMPFILE=`mktemp versionPatch.XXXXXX`
con's avatar
con committed
86
INSTALLER_RC="${SCRIPT_DIR}/../../dev/ide/nightly_builds/installer/installer.rc"
con's avatar
con committed
87 88 89 90 91 92 93 94 95
echo "Patching \`${INSTALLER_RC}'"
sed \
        -e "s/"${OLD_DOT_FOUR}"/"${NEW_DOT_FOUR}"/" \
        -e "s/"${OLD_COMMA_FOUR}"/"${NEW_COMMA_FOUR}"/" \
    "${INSTALLER_RC}" > "${TMPFILE}"
    p4 edit `sed -e 's/\/\.\//\//g' -e 's/\/[^\/]\+\/\.\.\//\//g' <<<"${INSTALLER_RC}"`
mv -f "${TMPFILE}" "${INSTALLER_RC}"


96
## Patch Info.plist
97
TMPFILE=`mktemp versionPatch.XXXXXX`
con's avatar
con committed
98
INFO_PLIST="${SCRIPT_DIR}/share/qtcreator/Info.plist"
con's avatar
con committed
99 100 101 102 103 104 105
echo "Patching \`${INFO_PLIST}'"
sed \
        -e "s/"${OLD}"/"${NEW}"/" \
    "${INFO_PLIST}" > "${TMPFILE}"
mv -f "${TMPFILE}" "${INFO_PLIST}"


106
## Patch qtcreator.qdocconf
107
TMPFILE=`mktemp versionPatch.XXXXXX`
108 109 110 111 112 113 114 115 116 117
QDOCCONF="${SCRIPT_DIR}/doc/qtcreator.qdocconf"
echo "Patching \`${QDOCCONF}'"
sed \
        -e "s/"${OLD_DOT_THREE}"/"${NEW_DOT_THREE}"/" \
        -e "s/"${OLD_THREE}"/"${NEW_THREE}"/" \
    "${QDOCCONF}" > "${TMPFILE}"
mv -f "${TMPFILE}" "${QDOCCONF}"


## Patch qtcreator.qdoc
118
TMPFILE=`mktemp versionPatch.XXXXXX`
119 120 121
QDOC="${SCRIPT_DIR}/doc/qtcreator.qdoc"
echo "Patching \`${QDOC}'"
sed \
122
        -e 's/'${OLD_DOT_THREE}'/'${NEW_DOT_THREE}'/' \
123 124 125 126
    "${QDOC}" > "${TMPFILE}"
mv -f "${TMPFILE}" "${QDOC}"


con's avatar
con committed
127 128 129 130
## Go back to original $PWD
echo "Leaving directory \`${SCRIPT_DIR}'"
popd &>/dev/null || exit 1
exit 0