summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2012-08-24 07:59:29 (GMT)
committer Thomas Petazzoni <thomas.petazzoni@free-electrons.com>2012-08-24 21:43:35 (GMT)
commitc557c28e6948435de2af73c7814403c3c88a382b (patch)
tree0c85615e77f698b8d85e24b41de14b9110f4ba16
parentd660fa32ad67b861ccb30d50a58c511b7999a6cc (diff)
downloadbuildroot-c557c28e6948435de2af73c7814403c3c88a382b.tar.gz
buildroot-c557c28e6948435de2af73c7814403c3c88a382b.tar.bz2
gpsd: Fix lacking simplejson module error at build
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
-rw-r--r--package/gpsd/gpsd-05-fix-leapsecond-script-python2.5.patch71
1 files changed, 71 insertions, 0 deletions
diff --git a/package/gpsd/gpsd-05-fix-leapsecond-script-python2.5.patch b/package/gpsd/gpsd-05-fix-leapsecond-script-python2.5.patch
new file mode 100644
index 0000000..8866b81
--- /dev/null
+++ b/package/gpsd/gpsd-05-fix-leapsecond-script-python2.5.patch
@@ -0,0 +1,71 @@
+the json module was added with python2.6, so a regular python 2.5
+machine will lack this module and won't probably have the simplejson
+module imported by the leapsecond.py script.
+
+Since the only function used is the isotime function, which is
+self-contained and quite trivial, only copy this function into the
+leapsecond script to avoid the import of the gps.misc module, which
+needs simplejson.
+
+Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
+---
+ leapsecond.py | 27 ++++++++++++++++++++++++---
+ 1 file changed, 24 insertions(+), 3 deletions(-)
+
+diff --git a/leapsecond.py b/leapsecond.py
+index 2059f6c..cdacdb4 100755
+--- a/leapsecond.py
++++ b/leapsecond.py
+@@ -24,7 +24,6 @@
+ # BSD terms apply: see the file COPYING in the distribution root for details.
+ #
+ import os, urllib, re, random, time, calendar, math, sys
+-import gps.misc
+
+ __locations = [
+ (
+@@ -48,6 +47,28 @@ __locations = [
+ # between times it might change, in seconds since Unix epoch GMT.
+ __cachepath = "/var/run/leapsecond"
+
++def isotime(s):
++ "Convert timestamps in ISO8661 format to and from Unix time."
++ if type(s) == type(1):
++ return time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s))
++ elif type(s) == type(1.0):
++ date = int(s)
++ msec = s - date
++ date = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(s))
++ return date + "." + repr(msec)[3:]
++ elif type(s) == type("") or type(s) == type(u""):
++ if s[-1] == "Z":
++ s = s[:-1]
++ if "." in s:
++ (date, msec) = s.split(".")
++ else:
++ date = s
++ msec = "0"
++ # Note: no leap-second correction!
++ return calendar.timegm(time.strptime(date, "%Y-%m-%dT%H:%M:%S")) + float("0." + msec)
++ else:
++ raise TypeError
++
+ def retrieve():
+ "Retrieve current leap-second from Web sources."
+ random.shuffle(__locations) # To spread the load
+@@ -261,10 +282,10 @@ if __name__ == '__main__':
+ print unix_to_rfc822(float(val))
+ raise SystemExit, 0
+ elif (switch == '-I'): # Compute Unix time from ISO8601 date
+- print gps.misc.isotime(val)
++ print isotime(val)
+ raise SystemExit, 0
+ elif (switch == '-O'): # Compute ISO8601 date from Unix time
+- print gps.misc.isotime(float(val))
++ print isotime(float(val))
+ raise SystemExit, 0
+
+ print "Current leap second:", retrieve()
+--
+1.7.9.5
+