]> git.sur5r.net Git - openocd/blob - tools/release/helpers.sh
Change checkpatch.pl tab expanding to 4 characters.
[openocd] / tools / release / helpers.sh
1 #!/bin/sh -e
2
3 die() {
4         echo "$@" >&2
5         exit 1
6 }
7
8 package_info_load_name() {
9         grep AC_INIT configure.in | perl -ne 's/^.+\(\[([-\w]*)\],.+$/$1/ and print'
10 }
11 package_info_load_version() {
12         grep AC_INIT configure.in | perl -ne 's/^.+\[([-\w\.]*)\],$/$1/ and print'
13 }
14
15 package_info_load() {
16         [ -f "configure.in" ] || \
17                 die "package_info_load: configure.in is missing"
18
19         PACKAGE_NAME="$(package_info_load_name)"
20         # todo: fix this
21         PACKAGE_TARNAME="${PACKAGE_NAME}"
22
23         PACKAGE_VERSION="$(package_info_load_version)"
24
25         [ "${PACKAGE_NAME}" -a "${PACKAGE_VERSION}" ] || \
26                 die "package information is missing from configure script"
27
28         PACKAGE_VERSION_TAGS=
29         [ "${PACKAGE_VERSION/-/}" = "${PACKAGE_VERSION}" ] || \
30                 PACKAGE_VERSION_TAGS="-${PACKAGE_VERSION#*-}"
31         PACKAGE_VERSION_BASE="${PACKAGE_VERSION%%-*}"
32         PACKAGE_MICRO="${PACKAGE_VERSION_BASE##*.}"
33         PACKAGE_MAJOR_AND_MINOR="${PACKAGE_VERSION_BASE%.*}"
34         PACKAGE_MAJOR="${PACKAGE_MAJOR_AND_MINOR%.*}"
35         PACKAGE_MINOR="${PACKAGE_MAJOR_AND_MINOR#*.}"
36
37         [ "${RELEASE_FINAL}" ] \
38                 && RELEASE_VERSION="${PACKAGE_VERSION_BASE}" \
39                 || RELEASE_VERSION="${PACKAGE_VERSION/-dev/}"
40         PACKAGE_RELEASE="${PACKAGE_TARNAME}-${RELEASE_VERSION}"
41         PACKAGE_STRING="${PACKAGE_NAME} ${PACKAGE_VERSION}"
42 }
43
44 package_info_show() {
45         cat <<INFO
46 Name: ${PACKAGE_TARNAME}
47 Version: ${PACKAGE_VERSION}
48 Release: ${RELEASE_VERSION}
49    Number: ${PACKAGE_VERSION_BASE}
50    Series: ${PACKAGE_MAJOR_AND_MINOR}
51     Major: ${PACKAGE_MAJOR}
52     Minor: ${PACKAGE_MINOR}
53     Micro: ${PACKAGE_MICRO}
54      Tags: ${PACKAGE_VERSION_TAGS}
55    Full: ${PACKAGE_TARNAME}-${PACKAGE_VERSION_BASE}${PACKAGE_VERSION_TAGS}
56 Release: ${PACKAGE_RELEASE}
57    Type: ${RELEASE_TYPE}
58 INFO
59 }
60