mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-07-14 13:00:08 +02:00
Merge branch 'log-deploy-fix' into 'master'
fix disappearing build logs when deploying See merge request fdroid/fdroidserver!685
This commit is contained in:
commit
4ef3f96e27
@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
([!669](https://gitlab.com/fdroid/fdroidserver/merge_requests/669))
|
||||
|
||||
### Fixed
|
||||
* fix build-logs dissapearing when deploying
|
||||
([!685](https://gitlab.com/fdroid/fdroidserver/merge_requests/685))
|
||||
* do not crash when system encoding can not be retrieved
|
||||
([!671](https://gitlab.com/fdroid/fdroidserver/merge_requests/671))
|
||||
* checkupdates: UpdateCheckIngore gets properly observed now
|
||||
|
@ -3253,42 +3253,44 @@ def deploy_build_log_with_rsync(appid, vercode, log_content):
|
||||
logging.warning(_('skip deploying full build logs: log content is empty'))
|
||||
return
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
# gzip compress log file
|
||||
log_gz_path = os.path.join(
|
||||
tmpdir, '{pkg}_{ver}.log.gz'.format(pkg=appid,
|
||||
ver=vercode))
|
||||
with gzip.open(log_gz_path, 'wb') as f:
|
||||
if isinstance(log_content, str):
|
||||
f.write(bytes(log_content, 'utf-8'))
|
||||
else:
|
||||
f.write(log_content)
|
||||
if not os.path.exists('repo'):
|
||||
os.mkdir('repo')
|
||||
|
||||
# TODO: sign compressed log file, if a signing key is configured
|
||||
# gzip compress log file
|
||||
log_gz_path = os.path.join('repo',
|
||||
'{pkg}_{ver}.log.gz'.format(pkg=appid,
|
||||
ver=vercode))
|
||||
with gzip.open(log_gz_path, 'wb') as f:
|
||||
if isinstance(log_content, str):
|
||||
f.write(bytes(log_content, 'utf-8'))
|
||||
else:
|
||||
f.write(log_content)
|
||||
|
||||
for webroot in config.get('serverwebroot', []):
|
||||
dest_path = os.path.join(webroot, "repo")
|
||||
if not dest_path.endswith('/'):
|
||||
dest_path += '/' # make sure rsync knows this is a directory
|
||||
cmd = ['rsync',
|
||||
'--archive',
|
||||
'--delete-after',
|
||||
'--safe-links']
|
||||
if options.verbose:
|
||||
cmd += ['--verbose']
|
||||
if options.quiet:
|
||||
cmd += ['--quiet']
|
||||
if 'identity_file' in config:
|
||||
cmd += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + config['identity_file']]
|
||||
cmd += [log_gz_path, dest_path]
|
||||
# TODO: sign compressed log file, if a signing key is configured
|
||||
|
||||
# TODO: also deploy signature file if present
|
||||
for webroot in config.get('serverwebroot', []):
|
||||
dest_path = os.path.join(webroot, "repo")
|
||||
if not dest_path.endswith('/'):
|
||||
dest_path += '/' # make sure rsync knows this is a directory
|
||||
cmd = ['rsync',
|
||||
'--archive',
|
||||
'--delete-after',
|
||||
'--safe-links']
|
||||
if options.verbose:
|
||||
cmd += ['--verbose']
|
||||
if options.quiet:
|
||||
cmd += ['--quiet']
|
||||
if 'identity_file' in config:
|
||||
cmd += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + config['identity_file']]
|
||||
cmd += [log_gz_path, dest_path]
|
||||
|
||||
retcode = subprocess.call(cmd)
|
||||
if retcode:
|
||||
logging.warning(_("failed deploying build logs to '{path}'").format(path=webroot))
|
||||
else:
|
||||
logging.info(_("deployed build logs to '{path}'").format(path=webroot))
|
||||
# TODO: also deploy signature file if present
|
||||
|
||||
retcode = subprocess.call(cmd)
|
||||
if retcode:
|
||||
logging.warning(_("failed deploying build logs to '{path}'").format(path=webroot))
|
||||
else:
|
||||
logging.info(_("deployed build logs to '{path}'").format(path=webroot))
|
||||
|
||||
|
||||
def get_per_app_repos():
|
||||
@ -3321,6 +3323,7 @@ def is_repo_file(filename):
|
||||
return os.path.isfile(filename) \
|
||||
and not filename.endswith(b'.asc') \
|
||||
and not filename.endswith(b'.sig') \
|
||||
and not filename.endswith(b'.log.gz') \
|
||||
and os.path.basename(filename) not in [
|
||||
b'index.jar',
|
||||
b'index_unsigned.jar',
|
||||
|
@ -361,6 +361,7 @@ def delete_disabled_builds(apps, apkcache, repodirs):
|
||||
os.path.join(repodir, apkfilename),
|
||||
os.path.join(repodir, apkfilename + '.asc'),
|
||||
os.path.join(repodir, apkfilename[:-4] + "_src.tar.gz"),
|
||||
os.path.join(repodir, apkfilename[:-4] + ".log.gz"),
|
||||
]
|
||||
for density in all_screen_densities:
|
||||
repo_dir = get_icon_dir(repodir, density)
|
||||
@ -1879,6 +1880,7 @@ def move_apk_between_sections(from_dir, to_dir, apk):
|
||||
logging.info("Moving %s from %s to %s" % (apk['apkName'], from_dir, to_dir))
|
||||
_move_file(from_dir, to_dir, apk['apkName'], False)
|
||||
_move_file(from_dir, to_dir, apk['apkName'] + '.asc', True)
|
||||
_move_file(from_dir, to_dir, apk['apkName'][:-4] + '.log.gz', True)
|
||||
for density in all_screen_densities:
|
||||
from_icon_dir = get_icon_dir(from_dir, density)
|
||||
to_icon_dir = get_icon_dir(to_dir, density)
|
||||
|
@ -1008,8 +1008,14 @@ class CommonTest(unittest.TestCase):
|
||||
|
||||
with mock.patch('subprocess.call',
|
||||
side_effect=assert_subprocess_call):
|
||||
fdroidserver.common.deploy_build_log_with_rsync(
|
||||
'com.example.app', '4711', mocklogcontent)
|
||||
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
||||
fdroidserver.common.deploy_build_log_with_rsync(
|
||||
'com.example.app', '4711', mocklogcontent)
|
||||
|
||||
expected_log_path = os.path.join(tmpdir, 'repo', 'com.example.app_4711.log.gz')
|
||||
self.assertTrue(os.path.isfile(expected_log_path))
|
||||
with gzip.open(expected_log_path, 'r') as f:
|
||||
self.assertEqual(f.read(), mocklogcontent)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
Reference in New Issue
Block a user