Add definition for the STEVAL-PCC010 board with the STM32F207
[openocd/ntfreak.git] / tools / release.sh
blob12dfdb6ab093ac6874832ac14323d9ec8992d83b
1 #!/bin/bash
2 # release.sh: openocd release process automation
3 # Copyright (C) 2009 by Zachary T Welch <zw@superlucidity.net>
4 # Release under the GNU GPL v2 (or later versions).
6 # FIXME Remove more bash-isms. Fix errors making "ash -e" lose.
8 ## set these to control the build process
9 #CONFIG_OPTS=""
10 #MAKE_OPTS=""
12 ## specifies the --next release type: major, minor, micro, rc, tag
13 #RELEASE_TYPE=tag
14 ## For tag release type, specifies the name of the tag (e.g. "foo").
15 ## The default is the current user name, as found by the 'id' command.
16 #RELEASE_TAG="$(id -un)"
18 . "tools/release/helpers.sh"
20 VERSION_SH="tools/release/version.sh"
22 usage() {
23 cat << USAGE
24 usage: $0 <command> ...
25 Command Options:
26 --next name The branch's next release type: major, minor, micro, rc, tag.
27 --next-tag name The name for the package version tag.
28 --live Perform the actions in the repository.
30 Main Commands:
31 info Show a summary of the next pending release.
32 release Release the current tree as an archive.
34 Build Commands:
35 bootstrap Prepare the working copy for configuration and building.
36 configure Configures the package; runs bootstrap, if needed.
37 build Compiles the project; runs configure, if needed.
39 Packaging Commands:
40 package Produce new distributable source archives.
41 stage Move archives to staging area for upload.
43 Other Commands:
44 clean Forces regeneration of results.
45 clean_all Removes all traces of the release process.
46 help Provides this list of commands.
48 For more information about this script, see the Release Processes page
49 in the OpenOCD Developer's Manual (doc/manual/release.txt).
50 USAGE
51 exit 0
53 do_usage() { usage; }
54 do_help() { usage; }
56 do_info() {
57 echo "Current Release Analysis:"
58 package_info_show
61 do_bootstrap() {
62 echo -n "Bootstrapping..."
63 ./bootstrap 2>&1 | perl tools/logger.pl > "release-bootstrap.log"
65 maybe_bootstrap() { [ -f "configure" ] || do_bootstrap; }
67 do_configure() {
68 maybe_bootstrap
69 echo -n "Configuring..."
70 ./configure ${CONFIG_OPTS} 2>&1 | perl tools/logger.pl > "release-config.log"
72 maybe_configure() { [ -f "Makefile" ] || do_configure; }
74 do_build() {
75 maybe_configure
76 echo -n "Compiling OpenOCD ${PACKAGE_VERSION}"
77 make ${MAKE_OPTS} -C doc stamp-vti 2>&1 \
78 | perl tools/logger.pl > "release-version.log"
79 make ${MAKE_OPTS} 2>&1 \
80 | perl tools/logger.pl > "release-make.log"
82 maybe_build() { [ -f "src/openocd" ] || do_build; }
83 do_build_clean() { [ -f Makefile ] && make maintainer-clean >/dev/null; }
86 do_package() {
87 maybe_build
88 echo "Building distribution packages..."
89 make ${MAKE_OPTS} distcheck 2>&1 | perl tools/logger.pl > "release-pkg.log"
91 maybe_package() { [ -f "${PACKAGE_RELEASE}.zip" ] || do_package; }
92 do_package_clean() {
93 for EXT in tar.gz tar.bz2 zip; do
94 rm -v -f *.${EXT}
95 done
98 do_stage() {
99 maybe_package
100 echo "Staging package archives:"
101 mkdir -p archives
102 for EXT in tar.gz tar.bz2 zip; do
103 local FILE="${PACKAGE_RELEASE}.${EXT}"
104 # create archive signatures
105 for HASH in md5 sha1; do
106 echo "sign: ${FILE}.${HASH}"
107 ${HASH}sum "${FILE}" > "archives/${FILE}.${HASH}"
108 done
109 # save archive
110 mv -v "${FILE}" archives/
111 done
112 cp -a NEWS archives/
114 do_stage_clean() { rm -v -f -r archives; }
116 do_clean() {
117 do_build_clean
118 do_package_clean
119 rm -v -f release-*.log
121 do_clean_all() {
122 do_clean
123 do_stage_clean
126 do_version_commit() {
127 [ "$*" ] || die "usage: $0 commit <message>"
128 git add configure.in || die "error: no version changes to commit"
129 git commit -q -m "$*" configure.in
132 do_version_finalize() {
133 echo "The ${PACKAGE_NAME} ${RELEASE_VERSION} release."
134 echo
135 ${VERSION_SH} tag remove dev
136 [ -z "${RELEASE_FINAL}" ] || ${VERSION_SH} bump final rc
138 has_dev_tag() {
139 [ "${PACKAGE_VERSION/dev/}" != "${PACKAGE_VERSION}" ]
141 do_release_step_branch() {
142 git checkout -b "v${RELEASE_VERSION}-release"
145 do_release_step_tag() {
146 do_version_commit "$(do_version_finalize)"
147 package_info_load
148 [ "${PACKAGE_VERSION/dev/}" = "${PACKAGE_VERSION}" ] || \
149 die "'${PACKAGE_NAME}-${PACKAGE_VERSION}' should not be tagged"
150 local MSG="The ${PACKAGE_STRING} release."
151 git tag -m "${MSG}" "v${PACKAGE_VERSION}"
154 do_bump_version() {
155 echo -n "Bump ${RELEASE_TYPE} "
156 [ -z "${RELEASE_TAG}" ] || echo -n "-${RELEASE_TAG} "
157 echo -n "version and add "
158 [ -z "${RELEASE_START_RC}" ] || echo -n "-rc0"
159 echo "-dev tag."
160 echo
161 ${VERSION_SH} bump "${RELEASE_TYPE}" "${RELEASE_TAG}"
162 [ -z "${RELEASE_START_RC}" ] || ${VERSION_SH} bump tag rc
163 ${VERSION_SH} tag add dev
165 do_release_step_bump() {
166 # bump the version number
167 do_version_commit "$(do_bump_version)"
170 do_release_step_news_msg() {
171 cat <<MSG
172 Archive and recreate NEWS file.
174 Archive released NEWS file as NEWS-${RELEASE_VERSION}.
175 Create new NEWS file from release script template.
178 do_release_step_news() {
179 # only archive the NEWS file for major/minor releases
180 [ "${RELEASE_TYPE}" = "major" -o "${RELEASE_TYPE}" = "minor" ] || \
181 return 0
182 # archive NEWS and create new one from template
183 git mv "NEWS" "NEWS-${RELEASE_VERSION}"
185 cat >NEWS <<NEWS
186 This file includes highlights of the changes made in the
187 OpenOCD ${NEXT_RELEASE_VERSION} source archive release. See the
188 repository history for details about what changed, including
189 bugfixes and other issues not mentioned here.
191 JTAG Layer:
192 Boundary Scan:
193 Target Layer:
194 Flash Layer:
195 Board, Target, and Interface Configuration Scripts:
196 Documentation:
197 Build and Release:
199 For more details about what has changed since the last release,
200 see the git repository history. With gitweb, you can browse that
201 in various levels of detail.
203 For older NEWS, see the NEWS files associated with each release
204 (i.e. NEWS-<version>).
206 For more information about contributing test reports, bug fixes, or new
207 features and device support, please read the new Developer Manual (or
208 the BUGS and PATCHES.txt files in the source archive).
209 NEWS
210 git add NEWS
212 local MSG="$(do_release_step_news_msg)"
213 git commit -q -m "${MSG}" NEWS "NEWS-${RELEASE_VERSION}"
216 do_release_step_package() {
217 [ -z "${RELEASE_FAST}" ] || return 0
219 git checkout -q "v${RELEASE_VERSION}"
220 do_stage
221 do_clean
224 do_release_step_rebranch() {
225 # return to the new development head
226 local OLD_BRANCH="v${RELEASE_VERSION}-release"
227 git checkout "${OLD_BRANCH}"
229 # create new branch with new version information
230 package_info_load
231 git checkout -b "v${PACKAGE_VERSION}"
232 git branch -d "${OLD_BRANCH}"
235 do_release_setup() {
236 echo "Starting $CMD for ${RELEASE_VERSION}..."
237 [ "${RELEASE_TYPE}" ] || \
238 die "The --next release type must be provided. See --help."
241 do_release_check() {
242 [ -z "${RELEASE_FAST}" ] || return 0
243 echo "Are you sure you want to ${CMD} '${PACKAGE_RELEASE}', "
244 echo -n " to start a new ${RELEASE_TYPE} development cycle? (y/N) "
245 read ANSWER
246 if [ "${ANSWER}" != 'y' ]; then
247 echo "Live release aborted!"
248 exit 0
250 do_countdown "Starting live release"
252 do_countdown() {
253 echo -n "$1 in "
254 for i in $(seq 5 -1 1); do
255 echo -n "$i, "
256 sleep 1
257 done
258 echo "go!"
261 do_branch() {
262 do_release_setup
263 local i=
264 for i in branch bump rebranch; do
265 "do_release_step_${i}"
266 done
269 do_release() {
270 local CMD='release'
271 do_release_setup
272 do_release_check
273 local i=
274 for i in branch tag bump news package rebranch; do
275 "do_release_step_${i}"
276 done
278 do_all() { do_release "$@"; }
280 do_reset() {
281 maybe_bootstrap
282 maybe_configure
283 do_clean_all
284 git checkout configure.in
287 LONGOPTS="fast,final,start-rc,next-tag:,next:,help"
288 OPTIONS=$(getopt -o 'V,n:' --long "${LONGOPTS}" -n $0 -- "$@")
289 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
290 eval set -- "${OPTIONS}"
291 while true; do
292 case "$1" in
293 --fast)
294 RELEASE_FAST=yes
295 shift
297 --final)
298 RELEASE_FINAL=yes
299 shift
301 --start-rc)
302 RELEASE_START_RC=yes
303 shift
305 -n|--next)
306 export RELEASE_TYPE="$2"
307 shift 2
309 --next-tag)
310 export RELEASE_TAG="$2"
311 shift 2
314 exec $0 info
317 shift
318 break
320 --help)
321 usage
322 shift
325 echo "Internal error"
326 exit 1
328 esac
329 done
331 case "${RELEASE_TYPE}" in
332 major|minor|micro|rc)
334 tag)
335 [ "${RELEASE_TAG}" ] || RELEASE_TAG="$(id -u -n)"
340 die "Unknown release type '${RELEASE_TYPE}'"
342 esac
344 CMD=$1
345 [ "${CMD}" ] || usage
346 shift
348 ACTION_CMDS="bootstrap|configure|build|package|stage|clean"
349 MISC_CMDS="all|info|release|branch|reset|help|usage"
350 CLEAN_CMDS="build_clean|package_clean|stage_clean|clean_all"
351 CMDS="|${ACTION_CMDS}|${CLEAN_CMDS}|${MISC_CMDS}|"
352 is_command() { echo "${CMDS}" | grep "|$1|" >/dev/null; }
354 package_info_load
355 if is_command "${CMD}"; then
356 "do_${CMD}" "$@"
357 echo "Done with '${CMD}'." >&2
358 else
359 echo "error: unknown command: '${CMD}'"
360 usage