diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-06-21 16:26:21 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-07-23 17:11:49 +0100 |
commit | 2004d03037bbb2bb72de7a49ba501a7b5f6e2f92 (patch) | |
tree | dd22834c5b786764298a0ab28adb73f09a2b94c9 | |
parent | 1c3225c7cffafbcfdf711ed33c69e6e1f974745d (diff) |
Add AG_GST_SET_PACKAGE_RELEASE_DATETIME and _DATETIME_WITH_NANO macros for configure
Sets GST_PACKAGE_RELEASE_DATETIME, either to the current date and time, or
to the specified datetime, or to the date of the current release based on
the .doap file.
In a GStreamer module context, one could use it like this:
AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO([$PACKAGE_VERSION_NANO],
["${srcdir}/$PACKAGE.doap"],
[$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_MICRO])
https://bugzilla.gnome.org/show_bug.cgi?id=623040
-rw-r--r-- | Makefile.am | 1 | ||||
-rwxr-xr-x | extract-release-date-from-doap-file | 32 | ||||
-rw-r--r-- | m4/Makefile.am | 1 | ||||
-rw-r--r-- | m4/gst-package-release-datetime.m4 | 89 |
4 files changed, 123 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 63e2224..25966fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,5 +17,6 @@ EXTRA_DIST = \ coverage/coverage-report.xsl \ coverage/coverage-report-entry.pl \ download-translations \ + extract-release-date-from-doap-file \ gst-indent \ orc.mak diff --git a/extract-release-date-from-doap-file b/extract-release-date-from-doap-file new file mode 100755 index 0000000..f2bc418 --- /dev/null +++ b/extract-release-date-from-doap-file @@ -0,0 +1,32 @@ +#!/bin/sh +# Shell script to extract the date given a release version and a .doap file + +if test "x$1" = "x" -o "x$2" = "x" -o ! -s "$2"; then + echo "Usage: $0 RELEASE-VERSION-NUMBER DOAP-FILE" >&2; + exit 1 +fi + +if ! grep '<Project' "$2" >/dev/null ; then + echo "$2 does not look lika a .doap file" >&2; + exit 1 +fi + +if ! grep "$1" "$2" >/dev/null ; then + echo "$2 contains no reference to a version $1" >&2; + exit 1 +fi + +awk 'BEGIN {x=0} +{ +if ($0~"<release>") {x=1; chunk=""} +if (x==1) { + if ($0~"<revision>") { chunk = chunk $0 } + if ($0~"<created>") { chunk = chunk $0 } +} +if ($0~"</release>") {x=0; print chunk} +}' < "$2" | \ +\ +grep '<revision>'"$1"'</revision>' | \ +\ +sed -e 's/^.*<created>//' -e 's/<\/created>.*$//' + diff --git a/m4/Makefile.am b/m4/Makefile.am index 4f89f97..2ddb8a7 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -28,6 +28,7 @@ EXTRA_DIST = \ gst-glib2.m4 \ gst-libxml2.m4 \ gst-parser.m4 \ + gst-package-release-datetime.m4 \ gst-platform.m4 \ gst-plugindir.m4 \ gst-plugin-docs.m4 \ diff --git a/m4/gst-package-release-datetime.m4 b/m4/gst-package-release-datetime.m4 new file mode 100644 index 0000000..e0b9334 --- /dev/null +++ b/m4/gst-package-release-datetime.m4 @@ -0,0 +1,89 @@ +dnl macros to set GST_PACKAGE_RELEASE_DATETIME + +dnl =========================================================================== +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME +dnl +dnl Usage: +dnl +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME() +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([no]...) +dnl sets the release datetime to the current date +dnl (no = this is not a release, but git or prerelease) +dnl +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([YYYY-MM-DD]) +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes], [YYYY-MM-DD]) +dnl sets the release datetime to the specified date (and time, if given) +dnl (yes = this is a release, not git or prerelease) +dnl +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes], [DOAP-FILE], [RELEASE-VERSION]) +dnl sets the release date to the release date associated with version +dnl RELEASE-VERSION in the .doap file DOAP-FILE +dnl (yes = this is a release, not git or prerelease) +dnl +dnl We need to treat pre-releases like git because there won't be an entry +dnl in the .doap file for pre-releases yet, and we don't want to use the +dnl date of the last release either. +dnl =========================================================================== +AC_DEFUN([AG_GST_SET_PACKAGE_RELEASE_DATETIME], +[ + dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME() + dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes]...) + if test "x$1" = "xno" -o "x$1" = "x"; then + GST_PACKAGE_RELEASE_DATETIME=`date -u "+%Y-%m-%dT%H:%MZ"` + elif test "x$1" = "xyes"; then + dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([no], ["YYYY-MM-DD"]) + dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([no], [DOAP-FILE], [RELEASE-VERSION]) + if ( echo $1 | grep -e '^20[1-9][0-9]-[0-1][0-9]-[0-3][0-9]' >/dev/null ) ; then + GST_PACKAGE_RELEASE_DATETIME=$1 + else + dnl we assume the .doap file contains the date as YYYY-MM-DD + YYYY_MM_DD=`. "${srcdir}/common/extract-release-date-from-doap-file" $3 $2`; + if test "x$YYYY_MM_DD" != "x"; then + GST_PACKAGE_RELEASE_DATETIME=$YYYY_MM_DD + else + AC_MSG_ERROR([SET_PACKAGE_RELEASE_DATETIME: could not extract + release date for release version $3 from $2]) + GST_PACKAGE_RELEASE_DATETIME="" + fi + fi + dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([YYYY-MM-DD]) + elif ( echo $1 | grep -e '^20[1-9][0-9]-[0-1][0-9]-[0-3][0-9]' >/dev/null ) ; then + GST_PACKAGE_RELEASE_DATETIME=$1 + else + AC_MSG_WARN([SET_PACKAGE_RELEASE_DATETIME: invalid first argument]) + GST_PACKAGE_RELEASE_DATETIME="" + fi + + if test "x$GST_PACKAGE_RELEASE_DATETIME" = "x"; then + AC_MSG_WARN([Invalid package release date time: $GST_PACKAGE_RELEASE_DATETIME]) + else + AC_MSG_NOTICE([Setting GST_PACKAGE_RELEASE_DATETIME to $GST_PACKAGE_RELEASE_DATETIME]) + + AC_DEFINE_UNQUOTED([GST_PACKAGE_RELEASE_DATETIME], + ["$GST_PACKAGE_RELEASE_DATETIME"], + [GStreamer package release date/time for plugins as YYYY-MM-DD]) + fi +]) + +dnl =========================================================================== +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO +dnl +dnl Usage: +dnl +dnl AG_GST_SET_PACKAGE_RELEASE_DATETIME([NANO-VERSION], [DOAP-FILE], [RELEASE-VERSION]) +dnl if NANO-VERSION is 0, sets the release date to the release date associated +dnl with version RELEASE-VERSION in the .doap file DOAP-FILE, otherwise sets +dnl the release date and time to the current date/time. +dnl +dnl We need to treat pre-releases like git because there won't be an entry +dnl in the .doap file for pre-releases yet, and we don't want to use the +dnl date of the last release either. +dnl =========================================================================== +AC_DEFUN([AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO], +[ + if test "x$1" = "x0"; then + AG_GST_SET_PACKAGE_RELEASE_DATETIME([yes], [ $2 ], [ $3 ]) + else + AG_GST_SET_PACKAGE_RELEASE_DATETIME([no]) + fi +]) |