From 74c6555c719e685d225baa00670ee12779bdeff1 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 25 Apr 2018 14:20:19 +0200 Subject: [PATCH] index: ensure index.xml timestamp is in UTC, closes #481 use verbose but safe syntax so this works with all versions of sed, e.g. osx --- fdroidserver/index.py | 4 ++-- tests/run-tests | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 61552138..56caaad1 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -32,7 +32,7 @@ import urllib.parse import zipfile import calendar from binascii import hexlify, unhexlify -from datetime import datetime +from datetime import datetime, timezone from xml.dom.minidom import Document from . import _ @@ -67,7 +67,7 @@ def make(apps, sortedids, apks, repodir, archive): common.assert_config_keystore(common.config) repodict = collections.OrderedDict() - repodict['timestamp'] = datetime.utcnow() + repodict['timestamp'] = datetime.utcnow().replace(tzinfo=timezone.utc) repodict['version'] = METADATA_VERSION if common.config['repo_maxage'] != 0: diff --git a/tests/run-tests b/tests/run-tests index aadd82f1..9ab5a9b6 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -258,6 +258,10 @@ if [ "$TRAVIS_OS_NAME" != "osx" ]; then ! test -e repo/index.xml.asc fi +v0timestamp=`$sed -n -e 's,.*timestamp="\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)".*,\1,p' repo/index.xml` +v1timestamp=`$sed -n -e 's,.*"timestamp": \([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*,\1,p' repo/index-v1.json` +test $v0timestamp -eq $v1timestamp + # we can't easily reproduce the timestamps for things, so just hardcode them $sed -i.tmp -e 's,timestamp="[0-9]*",timestamp="1480431575",' repo/index.xml diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml -- 2.30.2