From: Daniel Martí Date: Thu, 17 Oct 2013 21:27:55 +0000 (+0200) Subject: New Update Check Mode: RepoTrunk X-Git-Tag: 0.1~335 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b75d8b72710a494c19d24daa24c1fa46f98c3880;p=fdroidserver.git New Update Check Mode: RepoTrunk --- diff --git a/docs/fdroid.texi b/docs/fdroid.texi index 08931c3c..202728d2 100644 --- a/docs/fdroid.texi +++ b/docs/fdroid.texi @@ -1091,6 +1091,13 @@ in place of the default one. The default values are "master" for git, On the other hand, branch support hasn't been implemented yet in bzr and svn, but RepoManifest may still be used without it. @item +@code{RepoTrunk} - For svn and git-svn repositories, especially those who +don't have a bundled AndroidManifest.xml file, the Tags and RepoManifest +checks will not work, since there is no version information to obtain. But, +for those apps who automate their build process with the commit ref that HEAD +points to, RepoTrunk will set the Current Version and Current Version Code to +that number. +@item @code{Tags} - The AndroidManifest.xml file in all tagged revisions in the source repository is checked, looking for the highest version code. The appropriateness of this method depends on the development process used by the diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index b43a772a..1ffec342 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -203,6 +203,35 @@ def check_repomanifest(app, sdk_path, branch=None): msg = "Could not scan app %s due to unknown error: %s" % (app['id'], traceback.format_exc()) return (None, msg) +def check_repotrunk(app, sdk_path, branch=None): + + try: + if app['Repo Type'] == 'srclib': + build_dir = os.path.join('build', 'srclib', app['Repo']) + repotype = common.getsrclibvcs(app['Repo']) + else: + build_dir = os.path.join('build/', app['id']) + repotype = app['Repo Type'] + + if repotype not in ('svn', 'git-svn'): + return (None, 'RepoTrunk update mode only makes sense in svn and git-svn repositories') + + # Set up vcs interface and make sure we have the latest code... + vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path) + + vcs.gotorevision(None) + + ref = vcs.getref() + return (ref, ref) + except BuildException as be: + msg = "Could not scan app %s due to BuildException: %s" % (app['id'], be) + return (None, msg) + except VCSException as vcse: + msg = "VCS error while scanning app %s: %s" % (app['id'], vcse) + return (None, msg) + except Exception: + msg = "Could not scan app %s due to unknown error: %s" % (app['id'], traceback.format_exc()) + return (None, msg) # Check for a new version by looking at the Google Play Store. # Returns (None, "a message") if this didn't work, or (version, None) for @@ -307,6 +336,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 == 'RepoTrunk': + (version, vercode) = check_repotrunk(app, sdk_path) elif mode == 'HTTP': (version, vercode) = check_http(app) elif mode == 'Static': diff --git a/fdroidserver/common.py b/fdroidserver/common.py index b4a164f3..b4bac820 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -126,6 +126,10 @@ class vcs: def gettags(self): raise VCSException('gettags not supported for this vcs type') + # Get current commit reference (hash, revision, etc) + def getref(self): + raise VCSException('getref not supported for this vcs type') + # Returns the srclib (name, path) used in setting up the current # revision, or None. def getsrclib(self): @@ -287,6 +291,12 @@ class vcs_gitsvn(vcs): self.checkrepo() return os.listdir(os.path.join(self.local, '.git/svn/refs/remotes/tags')) + def getref(self): + self.checkrepo() + p = subprocess.Popen(['git', 'svn', 'find-rev', 'HEAD'], + stdout=subprocess.PIPE, cwd=self.local) + return p.communicate()[0] + class vcs_svn(vcs): def repotype(self): @@ -321,6 +331,12 @@ class vcs_svn(vcs): self.userargs(), cwd=self.local) != 0: raise VCSException("Svn update failed") + def getref(self): + p = subprocess.Popen(['svn', 'info'], + stdout=subprocess.PIPE, cwd=self.local) + for line in p.communicate()[0].splitlines(): + if line is not None and line.startswith('Last Changed Rev: '): + return line[18:] class vcs_hg(vcs):