chiark / gitweb /
Improve http update check mode
authorCiaran Gultnieks <ciaran@ciarang.com>
Tue, 1 Oct 2013 14:06:02 +0000 (15:06 +0100)
committerCiaran Gultnieks <ciaran@ciarang.com>
Tue, 1 Oct 2013 14:06:02 +0000 (15:06 +0100)
docs/fdroid.texi
fdroidserver/checkupdates.py

index 771b5d9f7080296689fb152426008a16cb56db9b..3571a162e00ae5bf90ce2c7fff40087cb46ebee2 100644 (file)
@@ -1084,13 +1084,19 @@ It currently only works for git, hg and git-svn repositories. In the case of
 the latter, the repo URL must encode the path to the trunk and tags or else no
 tags will be found.
 @item
-@code{HTTP} - An HTTP request is performed, and the resulting document is
-scanned for two regular expressions, the first specifying the version name
-and the second the version code. The expression for the version name can be
-blank, but the version code must always be correct.
-
-The @code{Update Check Data} field is used to provide the url and the two
-regular expressions, in the form @code{url|ex1|ex2}.
+@code{HTTP} - HTTP requests are used to determine the current version code and
+version name. This is controlled by the @code{Update Check Data} field, which
+is of the form @code{urlcode|excode|urlver|exver}.
+
+Firstly, if @code{urlcode} is non-empty, the document from that URL is
+retrieved, and matched against the regular expression @code{excode}, with the
+first group becoming the version code.
+
+Secondly, if @code{urlver} is non-empty, the document from that URL is
+retrieved, and matched against the regular expression @code{exver}, with the
+first group becoming the version name. The @code{urlver} field can be set to
+simply '.' which says to use the same document returned for the version code
+again, rather than retrieving a different one.
 @end itemize
 
 @node Update Check Data
index 2a88a516f52b791cbb0abeba49b15a93a2984041..53a29c75b9819157833a1e3d40b3de9feb2b194f 100644 (file)
@@ -43,27 +43,30 @@ def check_http(app):
         if not 'Update Check Data' in app:
             raise Exception('Missing Update Check Data')
 
-        url, verex, codeex = app['Update Check Data'].split('|')
+        urlcode, codeex, urlver, verex = app['Update Check Data'].split('|')
 
-        req = urllib2.Request(url, None)
-        resp = urllib2.urlopen(req, None, 20)
-        page = resp.read()
-
-        if len(verex) > 0:
-            m = re.search(verex, page)
-            if not m:
-                raise Exception("No RE match for version")
-            version = m.group(1)
-        else:
-            version = "??"
+        vercode = "99999999"
+        if len(urlcode) > 0:
+            req = urllib2.Request(urlcode, None)
+            resp = urllib2.urlopen(req, None, 20)
+            page = resp.read()
 
-        if len(codeex) > 0:
             m = re.search(codeex, page)
             if not m:
                 raise Exception("No RE match for version code")
             vercode = m.group(1)
-        else:
-            vercode = "99999999"
+
+        version = "??"
+        if len(urlver) > 0:
+            if urlver != '.':
+                req = urllib2.Request(urlver, None)
+                resp = urllib2.urlopen(req, None, 20)
+                page = resp.read()
+
+            m = re.search(verex, page)
+            if not m:
+                raise Exception("No RE match for version")
+            version = m.group(1)
 
         return (version, vercode)