mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-03 17:50:11 +02:00
Add HTTP update check mode
This commit is contained in:
parent
89a4e17c3b
commit
e9aff5f31d
@ -1082,8 +1082,23 @@ Despite these caveats, it is the often the favourite update check mode.
|
||||
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}.
|
||||
@end itemize
|
||||
|
||||
@node Update Check Data
|
||||
@section Update Check Data
|
||||
|
||||
@cindex Update Check Data
|
||||
|
||||
Used in conjunction with @code{Update Check Mode} for certain modes.
|
||||
|
||||
@node Auto Update Mode
|
||||
@section Auto Update Mode
|
||||
|
||||
|
@ -33,6 +33,43 @@ from common import BuildException
|
||||
from common import VCSException
|
||||
|
||||
|
||||
# Check for a new version by looking at a document retrieved via HTTP.
|
||||
# The app's Update Check Data field is used to provide the information
|
||||
# required.
|
||||
def check_http(app):
|
||||
|
||||
try:
|
||||
|
||||
if not 'Update Check Data' in app:
|
||||
raise Exception('Missing Update Check Data')
|
||||
|
||||
url, verex, codeex = 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 = "??"
|
||||
|
||||
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"
|
||||
|
||||
return (version, vercode)
|
||||
|
||||
except Exception:
|
||||
msg = "Could not complete http check for app %s due to unknown error: %s" % (app['id'], traceback.format_exc())
|
||||
return (None, msg)
|
||||
|
||||
# Check for a new version by looking at the tags in the source repo.
|
||||
# Whether this can be used reliably or not depends on
|
||||
@ -272,6 +309,8 @@ def main():
|
||||
(version, vercode) = check_repomanifest(app, sdk_path)
|
||||
elif mode.startswith('RepoManifest/'):
|
||||
(version, vercode) = check_repomanifest(app, sdk_path, mode[13:])
|
||||
elif mode == 'HTTP':
|
||||
(version, vercode) = check_http(app)
|
||||
elif mode == 'Static':
|
||||
version = None
|
||||
vercode = 'Checking disabled'
|
||||
|
@ -661,6 +661,8 @@ def write_metadata(dest, app):
|
||||
mf.write('\n')
|
||||
writefield('Auto Update Mode')
|
||||
writefield('Update Check Mode')
|
||||
if 'Update Check Data' in app:
|
||||
writefield('Update Check Data')
|
||||
if len(app['Current Version']) > 0:
|
||||
writefield('Current Version')
|
||||
writefield('Current Version Code')
|
||||
|
Loading…
Reference in New Issue
Block a user