Fixes: fakevim: implement 'z.'
[qt-creator-color-themes.git] / replaceVersion.sh
blob3e1eff015bda9dca4178342383ecb1ed298d8718
1 #! /usr/bin/env bash
3 ## Command line parameters
4 if [[ $# != 2 ]]; then
5 cat <<USAGE
6 usage:
7 $0 <old> <new>
8 example:
9 $0 '1.2.3' '1.2.4'
10 USAGE
11 exit 1
15 ## Process and show version
16 OLD=`sed 's/\./\\\\./g' <<<"$1"`
17 NEW=`sed 's/\./\\\\./g' <<<"$2"`
19 OLD_MAJOR=`sed 's/^\([0-9]\+\)\.[0-9]\+\.[0-9]\+$/\1/' <<<"$1"`
20 NEW_MAJOR=`sed 's/^\([0-9]\+\)\.[0-9]\+\.[0-9]\+$/\1/' <<<"$2"`
22 OLD_MINOR=`sed 's/^[0-9]\+\.\([0-9]\+\)\.[0-9]\+$/\1/' <<<"$1"`
23 NEW_MINOR=`sed 's/^[0-9]\+\.\([0-9]\+\)\.[0-9]\+$/\1/' <<<"$2"`
25 OLD_RELEASE=`sed 's/^[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/\1/' <<<"$1"`
26 NEW_RELEASE=`sed 's/^[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/\1/' <<<"$2"`
28 OLD_THREE="${OLD_MAJOR}${OLD_MINOR}${OLD_RELEASE}"
29 NEW_THREE="${NEW_MAJOR}${NEW_MINOR}${NEW_RELEASE}"
31 OLD_DOT_THREE="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}"
32 NEW_DOT_THREE="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}"
34 OLD_DOT_FOUR="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}\\.0"
35 NEW_DOT_FOUR="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}\\.0"
37 OLD_COMMA_FOUR="${OLD_MAJOR},${OLD_MINOR},${OLD_RELEASE},0"
38 NEW_COMMA_FOUR="${NEW_MAJOR},${NEW_MINOR},${NEW_RELEASE},0"
40 echo "#==============================================="
41 echo "# Plain '${OLD}' -> '${NEW}'"
42 echo "#-----------------------------------------------"
43 echo "# Major '${OLD_MAJOR}' -> '${NEW_MAJOR}'"
44 echo "# Minor '${OLD_MINOR}' -> '${NEW_MINOR}'"
45 echo "# Release '${OLD_RELEASE}' -> '${NEW_RELEASE}'"
46 echo "#-----------------------------------------------"
47 echo "# 3 '${OLD_THREE}' -> '${NEW_THREE}'"
48 echo "# Dot 3 '${OLD_DOT_THREE}' -> '${NEW_DOT_THREE}'"
49 echo "# Dot 4 '${OLD_DOT_FOUR}' -> '${NEW_DOT_FOUR}'"
50 echo "# Comma 4 '${OLD_COMMA_FOUR}' -> '${NEW_COMMA_FOUR}'"
51 echo "#==============================================="
52 echo
55 ## Make script safe to call from anywhere by going home first
56 SCRIPT_DIR=`dirname "${PWD}/$0"`
57 echo "Entering directory \`${SCRIPT_DIR}'"
58 pushd "${SCRIPT_DIR}" &>/dev/null || exit 1
61 ## Patch *.pluginspec
62 while read i ; do
63 echo "Patching \`$i'"
64 TMPFILE=`mktemp`
65 sed -e 's/version="'"${OLD}"'"/version="'"${NEW}"'"/' \
66 -e 's/compatVersion="'"${OLD}"'"/compatVersion="'"${NEW}"'"/' \
67 "${i}" > "${TMPFILE}"
68 mv -f "${TMPFILE}" "${i}"
69 done < <(find . -name '*.pluginspec')
72 ## Patch coreconstants.h
73 TMPFILE=`mktemp`
74 CORE_CONSTANT_H="${SCRIPT_DIR}/src/plugins/coreplugin/coreconstants.h"
75 echo "Patching \`${CORE_CONSTANT_H}'"
76 sed \
77 -e 's/^\(#define IDE_VERSION_MAJOR \)'"${OLD_MAJOR}"'/\1'"${NEW_MAJOR}"'/' \
78 -e 's/^\(#define IDE_VERSION_MINOR \)'"${OLD_MINOR}"'/\1'"${NEW_MINOR}"'/' \
79 -e 's/^\(#define IDE_VERSION_RELEASE \)'"${OLD_RELEASE}"'/\1'"${NEW_RELEASE}"'/' \
80 "${CORE_CONSTANT_H}" > "${TMPFILE}"
81 mv -f "${TMPFILE}" "${CORE_CONSTANT_H}"
84 ## Patch installer.rc
85 TMPFILE=`mktemp`
86 INSTALLER_RC="${SCRIPT_DIR}/../ide/nightly_builds/installer/installer.rc"
87 echo "Patching \`${INSTALLER_RC}'"
88 sed \
89 -e "s/"${OLD_DOT_FOUR}"/"${NEW_DOT_FOUR}"/" \
90 -e "s/"${OLD_COMMA_FOUR}"/"${NEW_COMMA_FOUR}"/" \
91 "${INSTALLER_RC}" > "${TMPFILE}"
92 p4 edit `sed -e 's/\/\.\//\//g' -e 's/\/[^\/]\+\/\.\.\//\//g' <<<"${INSTALLER_RC}"`
93 mv -f "${TMPFILE}" "${INSTALLER_RC}"
96 ## Patch Info.plist
97 TMPFILE=`mktemp`
98 INFO_PLIST="${SCRIPT_DIR}/src/app/Info.plist"
99 echo "Patching \`${INFO_PLIST}'"
100 sed \
101 -e "s/"${OLD}"/"${NEW}"/" \
102 "${INFO_PLIST}" > "${TMPFILE}"
103 mv -f "${TMPFILE}" "${INFO_PLIST}"
106 ## Patch qtcreator.qdocconf
107 TMPFILE=`mktemp`
108 QDOCCONF="${SCRIPT_DIR}/doc/qtcreator.qdocconf"
109 echo "Patching \`${QDOCCONF}'"
110 sed \
111 -e "s/"${OLD_DOT_THREE}"/"${NEW_DOT_THREE}"/" \
112 -e "s/"${OLD_THREE}"/"${NEW_THREE}"/" \
113 "${QDOCCONF}" > "${TMPFILE}"
114 mv -f "${TMPFILE}" "${QDOCCONF}"
117 ## Patch qtcreator.qdoc
118 TMPFILE=`mktemp`
119 QDOC="${SCRIPT_DIR}/doc/qtcreator.qdoc"
120 echo "Patching \`${QDOC}'"
121 sed \
122 -e 's/\(The current version of Qt Creator is \)'${OLD_DOT_THREE}'/\1'${NEW_DOT_THREE}'/' \
123 "${QDOC}" > "${TMPFILE}"
124 mv -f "${TMPFILE}" "${QDOC}"
127 ## Go back to original $PWD
128 echo "Leaving directory \`${SCRIPT_DIR}'"
129 popd &>/dev/null || exit 1
130 exit 0