summaryrefslogtreecommitdiff
path: root/morphlib/app.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-08 14:55:43 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-10-08 14:55:43 +0100
commit4019372195cf50a00ff13e3a2dfa1b2781ea15e7 (patch)
treece51ea1296f112a8f9a9db6c1fc3704b5aa902f0 /morphlib/app.py
parent02887c0b0b5a44f94aed8ea77f3bae34ead485a4 (diff)
downloadmorph-4019372195cf50a00ff13e3a2dfa1b2781ea15e7.tar.gz
Change the time sanity check
We were having trouble with NTP setting the system time to be correct after .pyc files had already been created. The .pyc files got created at startup, before NTP had had a chance to run. This sometimes resulted in .pyc timestamps being wildly wrong and far in the future or past, and that would prevent morph from ever working again on the machine. We now just check that the system time is not far in the past. This is enough to make sure we don't create timestamps that break tar. Reviewed-By: Daniel Silverstone (on irc)
Diffstat (limited to 'morphlib/app.py')
-rwxr-xr-xmorphlib/app.py19
1 files changed, 6 insertions, 13 deletions
diff --git a/morphlib/app.py b/morphlib/app.py
index 7f2e01d5..f4dd3403 100755
--- a/morphlib/app.py
+++ b/morphlib/app.py
@@ -168,21 +168,14 @@ class Morph(cliapp.Application):
metavar='PREFIX',
default=defaults['build-ref-prefix'])
- def check_mtime(self):
- # Check the mtime for the file to make sure the system clock has been
- # set
- try:
- file_mtime = os.path.getmtime(__file__)
- except OSError as e:
- raise morphlib.Error('%s %s' % (e.strerror, e.filename))
-
- sys_time = time.time()
- if file_mtime > sys_time:
- raise morphlib.Error('mtime for %s is in the future, please set '
- 'your system clock' % __file__)
+ def check_time(self):
+ # Check that the current time is not far in the past.
+ if time.localtime(time.time()).tm_year < 2012:
+ raise morphlib.Error(
+ 'System time is far in the past, please set your system clock')
def process_args(self, args):
- self.check_mtime()
+ self.check_time()
# Combine the aliases into repo-alias before passing on to normal
# command processing. This means everything from here on down can