Merge branch 'master' of gitorious.org:f-droid/fdroidserver

This commit is contained in:
Ciaran Gultnieks 2013-05-25 14:10:29 +01:00
commit 0985a6d4f4
4 changed files with 81 additions and 54 deletions

View file

@ -657,11 +657,17 @@ def main():
build_succeeded = [] build_succeeded = []
for app in apps: for app in apps:
build_dir = 'build/' + app['id'] if app['Repo Type'] == 'srclib':
build_dir = os.path.join('build', 'srclib')
else:
build_dir = os.path.join('build', app['id'])
# Set up vcs interface and make sure we have the latest code... # 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 = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
if app['Repo Type'] == 'srclib':
build_dir = os.path.join(build_dir, app['Repo'])
if options.wiki: if options.wiki:
import mwclient import mwclient
site = mwclient.Site(wiki_server, path=wiki_path) site = mwclient.Site(wiki_server, path=wiki_path)

View file

@ -19,7 +19,6 @@
import sys import sys
import os import os
import shutil
import re import re
import urllib2 import urllib2
import time import time
@ -43,24 +42,29 @@ def check_tags(app, sdk_path):
try: try:
build_dir = 'build/' + app['id'] if app['Repo Type'] == 'srclib':
build_dir = os.path.join('build', 'srclib')
repotype = common.getsrclibvcs(app['Repo'])
else:
build_dir = os.path.join('build/', app['id'])
repotype = app['Repo Type']
if app['Repo Type'] not in ('git', 'git-svn'): if repotype not in ('git', 'git-svn'):
return (None, 'Tags update mode only works for git and git-svn repositories currently') return (None, 'Tags update mode only works for git and git-svn repositories currently')
# Set up vcs interface and make sure we have the latest code... # 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 = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
if app['Repo Type'] == 'git':
vcs.gotorevision(None) if app['Repo Type'] == 'srclib':
elif app['Repo Type'] == 'git-svn': build_dir = os.path.join(build_dir, app['Repo'])
vcs.gotorevision(None) vcs.gotorevision(None)
if len(app['builds']) == 0: if len(app['builds']) == 0:
return (None, "Can't use Tags with no builds defined") return (None, "Can't use Tags with no builds defined")
app_dir = build_dir
if 'subdir' in app['builds'][-1]: if 'subdir' in app['builds'][-1]:
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir']) build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
hver = None hver = None
hcode = "0" hcode = "0"
@ -69,8 +73,8 @@ def check_tags(app, sdk_path):
vcs.gotorevision(tag) vcs.gotorevision(tag)
# Only process tags where the manifest exists... # Only process tags where the manifest exists...
if os.path.exists(app_dir + '/AndroidManifest.xml'): if os.path.exists(os.path.join(build_dir, 'AndroidManifest.xml')):
version, vercode, package = common.parse_androidmanifest(app_dir) version, vercode, package = common.parse_androidmanifest(build_dir)
if package and package == app['id'] and version and vercode: if package and package == app['id'] and version and vercode:
if int(vercode) > int(hcode): if int(vercode) > int(hcode):
hcode = str(int(vercode)) hcode = str(int(vercode))
@ -100,24 +104,32 @@ def check_repomanifest(app, sdk_path, branch=None):
try: try:
build_dir = 'build/' + app['id'] if app['Repo Type'] == 'srclib':
build_dir = os.path.join('build', 'srclib')
repotype = common.getsrclibvcs(app['Repo'])
else:
build_dir = os.path.join('build/', app['id'])
repotype = app['Repo Type']
if app['Repo Type'] == 'bzr': if repotype == 'bzr':
return (None, 'RepoManifest update mode has not been ported to bzr repositories yet') return (None, 'RepoManifest update mode has not been ported to bzr repositories yet')
# Set up vcs interface and make sure we have the latest code... # 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 = common.getvcs(app['Repo Type'], app['Repo'], build_dir, sdk_path)
if app['Repo Type'] == 'git': if app['Repo Type'] == 'srclib':
build_dir = os.path.join(build_dir, app['Repo'])
if vcs.repotype() == 'git':
if branch: if branch:
vcs.gotorevision('origin/'+branch) vcs.gotorevision('origin/'+branch)
else: else:
vcs.gotorevision('origin/master') vcs.gotorevision('origin/master')
pass pass
elif app['Repo Type'] == 'git-svn': elif vcs.repotype() == 'git-svn':
vcs.gotorevision('trunk')
elif app['Repo Type'] == 'svn':
vcs.gotorevision(None) vcs.gotorevision(None)
elif app['Repo Type'] == 'hg': elif vcs.repotype() == 'svn':
vcs.gotorevision(None)
elif vcs.repotype() == 'hg':
if branch: if branch:
vcs.gotorevision(branch) vcs.gotorevision(branch)
else: else:
@ -126,11 +138,10 @@ def check_repomanifest(app, sdk_path, branch=None):
if len(app['builds']) == 0: if len(app['builds']) == 0:
return (None, "Can't use RepoManifest with no builds defined") return (None, "Can't use RepoManifest with no builds defined")
app_dir = build_dir
if 'subdir' in app['builds'][-1]: if 'subdir' in app['builds'][-1]:
app_dir = os.path.join(app_dir, app['builds'][-1]['subdir']) build_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
version, vercode, package = common.parse_androidmanifest(app_dir) version, vercode, package = common.parse_androidmanifest(build_dir)
if not package: if not package:
return (None, "Couldn't find package ID") return (None, "Couldn't find package ID")
if package != app['id']: if package != app['id']:

View file

@ -35,9 +35,13 @@ def getvcs(vcstype, remote, local, sdk_path):
if vcstype == 'bzr': if vcstype == 'bzr':
return vcs_bzr(remote, local, sdk_path) return vcs_bzr(remote, local, sdk_path)
if vcstype == 'srclib': if vcstype == 'srclib':
return vcs_srclib(remote, local, sdk_path) return getsrclib(remote, local, sdk_path, raw=True)
raise VCSException("Invalid vcs type " + vcstype) raise VCSException("Invalid vcs type " + vcstype)
def getsrclibvcs(name):
srclib_path = os.path.join('srclibs', name + ".txt")
return parse_srclib(srclib_path)['Repo Type']
class vcs: class vcs:
def __init__(self, remote, local, sdk_path): def __init__(self, remote, local, sdk_path):
@ -253,7 +257,7 @@ class vcs_gitsvn(vcs):
def gettags(self): def gettags(self):
self.checkrepo() self.checkrepo()
return os.listdir(self.local+'/.git/svn/refs/remotes/tags') return os.listdir(os.path.join(self.local, '/.git/svn/refs/remotes/tags'))
class vcs_svn(vcs): class vcs_svn(vcs):
@ -340,29 +344,26 @@ class vcs_bzr(vcs):
cwd=self.local) != 0: cwd=self.local) != 0:
raise VCSException("Bzr revert failed") raise VCSException("Bzr revert failed")
class vcs_srclib(vcs): def __init__(self, remote, local, sdk_path):
def repotype(self): self.sdk_path = sdk_path
return 'srclib'
def gotorevisionx(self, rev): index = remote.find('@')
if index != -1:
srclib_dir = 'build/srclib' self.username = remote[:index]
remote = remote[index+1:]
if os.path.exists(self.local): index = self.username.find(':')
shutil.rmtree(self.local) if index == -1:
raise VCSException("Password required with username")
if self.remote.find(':') != -1: self.password = self.username[index+1:]
srclib, path = self.remote.split(':') self.username = self.username[:index]
else: else:
srclib = self.remote self.username = None
path = None
libdir = getsrclib(srclib + '@' + rev, srclib_dir, self.sdk_path) self.remote = remote
self.srclib = (srclib, libdir) self.local = local
if path: self.refreshed = False
libdir = os.path.join(libdir, path) self.srclib = None
shutil.copytree(libdir, self.local)
return self.local
# Get the type expected for a given metadata field. # Get the type expected for a given metadata field.
@ -849,7 +850,7 @@ def parse_androidmanifest(app_dir):
version = None version = None
vercode = None vercode = None
package = None package = None
for line in file(app_dir + '/AndroidManifest.xml'): for line in file(os.path.join(app_dir, 'AndroidManifest.xml')):
if not package: if not package:
matches = psearch(line) matches = psearch(line)
if matches: if matches:
@ -864,14 +865,15 @@ def parse_androidmanifest(app_dir):
vercode = matches.group(1) vercode = matches.group(1)
if version: if version:
return (version, vercode, package) return (version, vercode, package)
for xmlfile in glob.glob(app_dir + '/res/values/strings*transl*.xml'): for xmlfile in glob.glob(os.path.join(
app_dir, 'res', 'values', 'strings*transl*.xml')):
for line in file(xmlfile): for line in file(xmlfile):
if not version: if not version:
matches = vnsearch_xml(line) matches = vnsearch_xml(line)
if matches: if matches:
version = matches.group(2) version = matches.group(2)
if not version: if not version:
for line in file(app_dir + '/res/values/strings.xml'): for line in file(os.path.join(app_dir, 'res/values/strings.xml')):
if not version: if not version:
matches = vnsearch_xml(line) matches = vnsearch_xml(line)
if matches: if matches:
@ -964,8 +966,12 @@ def parse_srclib(metafile, **kw):
# Returns the path to it. Normally this is the path to be used when referencing # Returns the path to it. Normally this is the path to be used when referencing
# it, which may be a subdirectory of the actual project. If you want the base # it, which may be a subdirectory of the actual project. If you want the base
# directory of the project, pass 'basepath=True'. # directory of the project, pass 'basepath=True'.
def getsrclib(spec, srclib_dir, sdk_path, basepath=False): def getsrclib(spec, srclib_dir, sdk_path, basepath=False, raw=False):
if raw:
name = spec
ref = None
else:
name, ref = spec.split('@') name, ref = spec.split('@')
srclib_path = os.path.join('srclibs', name + ".txt") srclib_path = os.path.join('srclibs', name + ".txt")
@ -979,6 +985,9 @@ def getsrclib(spec, srclib_dir, sdk_path, basepath=False):
vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir, sdk_path) vcs = getvcs(srclib["Repo Type"], srclib["Repo"], sdir, sdk_path)
vcs.gotorevision(ref) vcs.gotorevision(ref)
if raw:
return vcs
libdir = None libdir = None
if srclib["Subdir"] is not None: if srclib["Subdir"] is not None:
@ -1080,7 +1089,7 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, sdk_path,
print 'Force-removing old build.xml' print 'Force-removing old build.xml'
os.remove(buildxml) os.remove(buildxml)
for d in update_dirs: for d in update_dirs:
cwd = root_dir + '/' + d cwd = os.path.join(root_dir, d)
if verbose: if verbose:
print "Update of '%s': exec '%s' in '%s'"%\ print "Update of '%s': exec '%s' in '%s'"%\
(d," ".join(parms),cwd) (d," ".join(parms),cwd)

View file

@ -160,6 +160,9 @@ def main():
for app in metaapps: for app in metaapps:
if len(app['Repo Type']) == 0: if len(app['Repo Type']) == 0:
rtype = 'none' rtype = 'none'
else:
if app['Repo Type'] == 'srclib':
rtype = common.getsrclibvcs(app['Repo'])
else: else:
rtype = app['Repo Type'] rtype = app['Repo Type']
if rtype in repotypes: if rtype in repotypes:
@ -174,7 +177,7 @@ def main():
# Calculate and write stats for update check modes... # Calculate and write stats for update check modes...
ucms = {} ucms = {}
for app in metaapps: for app in metaapps:
checkmode = app['Update Check Mode'] checkmode = app['Update Check Mode'].split('/')[0]
if checkmode in ucms: if checkmode in ucms:
ucms[checkmode] += 1; ucms[checkmode] += 1;
else: else:
@ -197,8 +200,6 @@ def main():
f.write(license + ' ' + str(count) + '\n') f.write(license + ' ' + str(count) + '\n')
f.close() f.close()
# Write list of latest apps added to the repo... # Write list of latest apps added to the repo...
latest = knownapks.getlatest(10) latest = knownapks.getlatest(10)
f = open('stats/latestapps.txt', 'w') f = open('stats/latestapps.txt', 'w')