Commit 2004d030 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller

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
parent 1c3225c7
......@@ -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
#!/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>.*$//'
......@@ -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 \
......
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
])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment