chiark / gitweb /
Merge branch 'bug-fixes-for-v0.2.1' of https://gitlab.com/eighthave/fdroidserver
authorDaniel Martí <mvdan@mvdan.cc>
Tue, 1 Jul 2014 16:13:00 +0000 (18:13 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 1 Jul 2014 16:13:00 +0000 (18:13 +0200)
1  2 
fdroidserver/common.py
fdroidserver/update.py

diff --combined fdroidserver/common.py
index aa362ea8e22ec0177cc5565b35790d3ef39eaaa1,54c9736ae6299dcb69ba1838f3e52130a7de3658..0636915c3328d3c19f0cffea07422b3fbb5e9d09
@@@ -61,11 -61,11 +61,11 @@@ def get_default_config()
          'repo_url': "https://MyFirstFDroidRepo.org/fdroid/repo",
          'repo_name': "My First FDroid Repo Demo",
          'repo_icon': "fdroid-icon.png",
-         'repo_description':
+         'repo_description': (
              "This is a repository of apps to be used with FDroid. Applications in this "
-             "repository are either official binaries built by the original application "
-             "developers, or are binaries built from source by the admin of f-droid.org "
-             "using the tools on https://gitlab.com/u/fdroid.",
+             "repository are either official binaries built by the original application "
+             "developers, or are binaries built from source by the admin of f-droid.org "
+             + "using the tools on https://gitlab.com/u/fdroid."),
          'archive_older': 0,
      }
  
@@@ -121,6 -121,9 +121,9 @@@ def read_config(opts, config_file='conf
      if not test_sdk_exists(config):
          sys.exit(3)
  
+     if not test_build_tools_exists(config):
+         sys.exit(3)
      for k in ["keystorepass", "keypass"]:
          if k in config:
              write_password_file(k)
@@@ -151,9 -154,6 +154,6 @@@ def test_sdk_exists(c)
      if not os.path.isdir(os.path.join(c['sdk_path'], 'build-tools')):
          logging.critical('Android SDK path "' + c['sdk_path'] + '" does not contain "build-tools/"!')
          return False
-     if not os.path.isdir(os.path.join(c['sdk_path'], 'build-tools', c['build_tools'])):
-         logging.critical('Configured build-tools version "' + c['build_tools'] + '" not found in the SDK!')
-         return False
      return True
  
  
@@@ -414,7 -414,7 +414,7 @@@ class vcs_git(vcs)
      # a safety check.
      def checkrepo(self):
          p = SilentPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local)
 -        result = p.stdout.rstrip()
 +        result = p.output.rstrip()
          if not result.endswith(self.local):
              raise VCSException('Repository mismatch')
  
      def gettags(self):
          self.checkrepo()
          p = SilentPopen(['git', 'tag'], cwd=self.local)
 -        return p.stdout.splitlines()
 +        return p.output.splitlines()
  
      def latesttags(self, alltags, number):
          self.checkrepo()
                          + 'xargs -I@ git log --format=format:"%at @%n" -1 @ | '
                          + 'sort -n | awk \'{print $2}\''],
                          cwd=self.local, shell=True)
 -        return p.stdout.splitlines()[-number:]
 +        return p.output.splitlines()[-number:]
  
  
  class vcs_gitsvn(vcs):
      # a safety check.
      def checkrepo(self):
          p = SilentPopen(['git', 'rev-parse', '--show-toplevel'], cwd=self.local)
 -        result = p.stdout.rstrip()
 +        result = p.output.rstrip()
          if not result.endswith(self.local):
              raise VCSException('Repository mismatch')
  
                      svn_rev = rev
  
                  p = SilentPopen(['git', 'svn', 'find-rev', 'r' + svn_rev, treeish], cwd=self.local)
 -                git_rev = p.stdout.rstrip()
 +                git_rev = p.output.rstrip()
  
                  if p.returncode != 0 or not git_rev:
                      # Try a plain git checkout as a last resort
          p = SilentPopen(['git', 'svn', 'find-rev', 'HEAD'], cwd=self.local)
          if p.returncode != 0:
              return None
 -        return p.stdout.strip()
 +        return p.output.strip()
  
  
  class vcs_svn(vcs):
  
      def getref(self):
          p = SilentPopen(['svn', 'info'], cwd=self.local)
 -        for line in p.stdout.splitlines():
 +        for line in p.output.splitlines():
              if line and line.startswith('Last Changed Rev: '):
                  return line[18:]
          return None
@@@ -688,7 -688,7 +688,7 @@@ class vcs_hg(vcs)
              raise VCSException("Hg checkout of '%s' failed" % rev)
          p = SilentPopen(['hg', 'purge', '--all'], cwd=self.local)
          # Also delete untracked files, we have to enable purge extension for that:
 -        if "'purge' is provided by the following extension" in p.stdout:
 +        if "'purge' is provided by the following extension" in p.output:
              with open(self.local + "/.hg/hgrc", "a") as myfile:
                  myfile.write("\n[extensions]\nhgext.purge=\n")
              p = SilentPopen(['hg', 'purge', '--all'], cwd=self.local)
  
      def gettags(self):
          p = SilentPopen(['hg', 'tags', '-q'], cwd=self.local)
 -        return p.stdout.splitlines()[1:]
 +        return p.output.splitlines()[1:]
  
  
  class vcs_bzr(vcs):
      def gettags(self):
          p = SilentPopen(['bzr', 'tags'], cwd=self.local)
          return [tag.split('   ')[0].strip() for tag in
 -                p.stdout.splitlines()]
 +                p.output.splitlines()]
  
  
  def retrieve_string(app_dir, string, xmlfiles=None):
@@@ -1036,7 -1036,7 +1036,7 @@@ def getsrclib(spec, srclib_dir, srclibp
              p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=libdir)
              if p.returncode != 0:
                  raise BuildException("Error running prepare command for srclib %s"
 -                                     % name, p.stdout)
 +                                     % name, p.output)
  
      if basepath:
          libdir = sdir
@@@ -1088,7 -1088,7 +1088,7 @@@ def prepare_source(vcs, app, build, bui
          p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
          if p.returncode != 0:
              raise BuildException("Error running init command for %s:%s" %
 -                                 (app['id'], build['version']), p.stdout)
 +                                 (app['id'], build['version']), p.output)
  
      # Apply patches if any
      if build['patch']:
          p = FDroidPopen(['bash', '-x', '-c', cmd], cwd=root_dir)
          if p.returncode != 0:
              raise BuildException("Error running prebuild command for %s:%s" %
 -                                 (app['id'], build['version']), p.stdout)
 +                                 (app['id'], build['version']), p.output)
  
      # Generate (or update) the ant build file, build.xml...
      if build['update'] and build['update'] != ['no'] and build['type'] == 'ant':
              # Check to see whether an error was returned without a proper exit
              # code (this is the case for the 'no target set or target invalid'
              # error)
 -            if p.returncode != 0 or p.stdout.startswith("Error: "):
 -                raise BuildException("Failed to update project at %s" % d, p.stdout)
 +            if p.returncode != 0 or p.output.startswith("Error: "):
 +                raise BuildException("Failed to update project at %s" % d, p.output)
              # Clean update dirs via ant
              if d != '.':
                  logging.info("Cleaning subproject %s" % d)
@@@ -1553,7 -1553,7 +1553,7 @@@ def isApkDebuggable(apkfile, config)
      if p.returncode != 0:
          logging.critical("Failed to get apk manifest information")
          sys.exit(1)
 -    for line in p.stdout.splitlines():
 +    for line in p.output.splitlines():
          if 'android:debuggable' in line and not line.endswith('0x0'):
              return True
      return False
@@@ -1585,7 -1585,7 +1585,7 @@@ class AsynchronousFileReader(threading.
  
  class PopenResult:
      returncode = None
 -    stdout = ''
 +    output = ''
  
  
  def SilentPopen(commands, cwd=None, shell=False):
@@@ -1622,7 -1622,7 +1622,7 @@@ def FDroidPopen(commands, cwd=None, she
                  # Output directly to console
                  sys.stdout.write(line)
                  sys.stdout.flush()
 -            result.stdout += line
 +            result.output += line
  
          time.sleep(0.1)
  
diff --combined fdroidserver/update.py
index bff615e43939d11aa3f3dd429aa4fc818d733fbb,18966b46432db4ee39cd1eb0bb1646ebafcffa31..72d268d3b78fc57a7140a36e358360a4c0308c25
@@@ -387,7 -387,7 +387,7 @@@ def scan_apks(apps, apkcache, repodir, 
                  else:
                      logging.error("Failed to get apk information, skipping " + apkfile)
                  continue
 -            for line in p.stdout.splitlines():
 +            for line in p.output.splitlines():
                  if line.startswith("package:"):
                      try:
                          thisinfo['id'] = re.match(name_pat, line).group(1)
                  sys.exit(1)
              p = FDroidPopen(['java', '-cp', os.path.join(os.path.dirname(__file__), 'getsig'),
                               'getsig', os.path.join(os.getcwd(), apkfile)])
 -            if p.returncode != 0 or not p.stdout.startswith('Result:'):
 +            if p.returncode != 0 or not p.output.startswith('Result:'):
                  logging.critical("Failed to get apk signature")
                  sys.exit(1)
 -            thisinfo['sig'] = p.stdout[7:].strip()
 +            thisinfo['sig'] = p.output[7:].strip()
  
              apk = zipfile.ZipFile(apkfile, 'r')
  
@@@ -672,8 -672,8 +672,8 @@@ def make_index(apps, apks, repodir, arc
                  logging.critical(msg)
                  sys.exit(1)
              global repo_pubkey_fingerprint
 -            repo_pubkey_fingerprint = cert_fingerprint(p.stdout)
 -            return "".join("%02x" % ord(b) for b in p.stdout)
 +            repo_pubkey_fingerprint = cert_fingerprint(p.output)
 +            return "".join("%02x" % ord(b) for b in p.output)
  
          repoel.setAttribute("pubkey", extract_pubkey())
  
@@@ -876,11 -876,11 +876,11 @@@ def archive_old_apks(apps, apks, archap
                  if 'srcname' in apk:
                      shutil.move(os.path.join(repodir, apk['srcname']),
                                  os.path.join(archivedir, apk['srcname']))
-                 # Move GPG signature too...
-                 sigfile = apk['srcname'] + '.asc'
-                 sigsrc = os.path.join(repodir, sigfile)
-                 if os.path.exists(sigsrc):
-                     shutil.move(sigsrc, os.path.join(archivedir, sigfile))
+                     # Move GPG signature too...
+                     sigfile = apk['srcname'] + '.asc'
+                     sigsrc = os.path.join(repodir, sigfile)
+                     if os.path.exists(sigsrc):
+                         shutil.move(sigsrc, os.path.join(archivedir, sigfile))
  
                  archapks.append(apk)
                  apks.remove(apk)
@@@ -933,6 -933,13 +933,13 @@@ def main()
          resize_all_icons(repodirs)
          sys.exit(0)
  
+     # check that icons exist now, rather than fail at the end of `fdroid update`
+     for k in ['repo_icon', 'archive_icon']:
+         if k in config:
+             if not os.path.exists(config[k]):
+                 logging.error(k + ' "' + config[k] + '" does not exist! Correct it in config.py.')
+                 sys.exit(1)
      # Get all apps...
      apps = metadata.read_metadata()