import glob
import subprocess
import re
+import resource
import tarfile
import traceback
import time
# Helper to copy the contents of a directory to the server...
def send_dir(path):
- startroot = os.path.dirname(path)
- main = os.path.basename(path)
- ftp.mkdir(main)
- for root, dirs, files in os.walk(path):
- rr = os.path.relpath(root, startroot)
- ftp.chdir(rr)
- for d in dirs:
- ftp.mkdir(d)
- for f in files:
- lfile = os.path.join(startroot, rr, f)
- if not os.path.islink(lfile):
- ftp.put(lfile, f)
- ftp.chmod(f, os.stat(lfile).st_mode)
- for i in range(len(rr.split('/'))):
- ftp.chdir('..')
- ftp.chdir('..')
+ logging.debug("rsyncing " + path + " to " + ftp.getcwd())
+ try:
+ subprocess.check_output(['rsync', '-rplqe',
+ 'ssh -o StrictHostKeyChecking=no' +
+ ' -o UserKnownHostsFile=/dev/null' +
+ ' -o LogLevel=FATAL' +
+ ' -o IdentitiesOnly=yes' +
+ ' -o PasswordAuthentication=no' +
+ ' -p ' + str(sshinfo['port']) +
+ ' -i ' + sshinfo['idfile'],
+ path,
+ sshinfo['user'] +
+ "@" + sshinfo['hostname'] +
+ ":" + ftp.getcwd()],
+ stderr=subprocess.STDOUT)
+ except subprocess.CalledProcessError as e:
+ raise FDroidException(str(e), e.output.decode())
logging.info("Preparing server for build...")
serverpath = os.path.abspath(os.path.dirname(__file__))
if f in files:
os.remove(os.path.join(root, f))
- if 'build.gradle' in files:
+ if any(f in files for f in ['build.gradle', 'settings.gradle']):
# Even when running clean, gradle stores task/artifact caches in
# .gradle/ as binary files. To avoid overcomplicating the scanner,
# manually delete them, just like `gradle clean` should have removed
# Read all app and srclib metadata
pkgs = common.read_pkg_args(options.appid, True)
- allapps = metadata.read_metadata(not options.onserver, pkgs)
+ allapps = metadata.read_metadata(not options.onserver, pkgs, sort_by_time=True)
apps = common.read_app_args(options.appid, allapps, True)
for appid, app in list(apps.items()):
if not apps:
raise FDroidException("No apps to process.")
+ # make sure enough open files are allowed to process everything
+ soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
+ if len(apps) > soft:
+ try:
+ soft = len(apps) * 2
+ if soft > hard:
+ soft = hard
+ resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard))
+ logging.debug(_('Set open file limit to {integer}')
+ .format(integer=soft))
+ except (OSError, ValueError) as e:
+ logging.warning(_('Setting open file limit failed: ') + str(e))
+
if options.latest:
for app in apps.values():
for build in reversed(app.builds):
vcs, build_dir = common.setup_vcs(app)
first = False
+ logging.info("Using %s" % vcs.clientversion())
logging.debug("Checking " + build.versionName)
if trybuild(app, build, build_dir, output_dir, log_dir,
also_check_dir, srclib_dir, extlib_dir,
logging.info(ngettext("{} build failed",
"{} builds failed", len(failed_apps)).format(len(failed_apps)))
- sys.exit(0)
+ # hack to ensure this exits, even is some threads are still running
+ sys.stdout.flush()
+ sys.stderr.flush()
+ os._exit(0)
if __name__ == "__main__":