Compare commits

...

11 Commits

Author SHA1 Message Date
Jochen Sprickerhof e337e29ccf Merge branch 'build_no_vcs' into 'master'
Don't check VCS for completed builds

Closes #920

See merge request fdroid/fdroidserver!1036
2024-02-15 01:11:57 +00:00
Hans-Christoph Steiner 35c373a473 Merge branch 'gradle-release-checksums.py' into 'master'
update to gradle v7.6.4

See merge request fdroid/fdroidserver!1445
2024-02-14 17:41:46 +00:00
fdroid-bot ec88cc627f gradle v8.6 2024-02-14 17:32:15 +00:00
Hans-Christoph Steiner 3c77ac66b1
gitlab-ci: revert to old config.py for servergitmirrors: job 2024-02-14 18:31:25 +01:00
Hans-Christoph Steiner c794c0fe18 Merge branch 'fixup-1438' into 'master'
fixups from "feat: add servergitmirrors as a dict support"

See merge request fdroid/fdroidserver!1446
2024-02-14 17:12:17 +00:00
Hans-Christoph Steiner 4e0c721b04 fixups from "feat: add servergitmirrors as a dict support"
These slipped by in reviewing fdroidserver!1438
https://gitlab.com/fdroid/fdroidserver/-/jobs/6173435409
2024-02-14 18:10:29 +01:00
Hans-Christoph Steiner 094764398a Merge branch 'servergitmirrors-as-dict' into 'master'
feat: add servergitmirrors as a dict support

See merge request fdroid/fdroidserver!1438
2024-02-14 16:50:40 +00:00
proletarius101 947217549a feat: add servergitmirrors as a dict support 2024-02-14 16:50:39 +00:00
Hans-Christoph Steiner 12692b76b7 Merge branch 'safety-ignore-windows-only-CVE-2024-22190' into 'master'
safety: ignore CVE-2024-22190 it only affects Windows

See merge request fdroid/fdroidserver!1444
2024-02-14 16:49:50 +00:00
Hans-Christoph Steiner b36153b06c
safety: ignore CVE-2024-22190 it only affects Windows
https://security-tracker.debian.org/tracker/CVE-2024-22190
2024-02-14 17:46:12 +01:00
Jochen Sprickerhof b12bbe8ed0
Don't check VCS for completed builds
This speeds up the build a lot.
2023-06-12 07:47:28 +02:00
14 changed files with 223 additions and 153 deletions

View File

@ -17,3 +17,6 @@ security:
62044:
reason: "F-Droid doesn't fetch pip dependencies directly from hg/mercurial repositories: https://data.safetycli.com/v/62044/f17/"
expires: '2025-01-31'
63687:
reason: Only affects Windows https://security-tracker.debian.org/tracker/CVE-2024-22190
expires: '2026-01-31'

View File

@ -198,14 +198,18 @@
# deploy_process_logs: true
# The full URL to a git remote repository. You can include
# multiple servers to mirror to by wrapping the whole thing in {} or [], and
# including the servergitmirrors strings in a comma-separated list.
# multiple servers to mirror to by adding strings to a YAML list or map.
# Servers listed here will also be automatically inserted in the mirrors list.
#
# servergitmirrors: https://github.com/user/repo
# servergitmirrors:
# - https://github.com/user/repo
# - https://gitlab.com/user/repo
#
# servergitmirrors:
# - url: https://github.com/user/repo
# - url: https://gitlab.com/user/repo
# indexOnly: true
# Most git hosting services have hard size limits for each git repo.
# `fdroid deploy` will delete the git history when the git mirror repo

View File

@ -53,7 +53,7 @@ ssh_channel = None
# Note that 'force' here also implies test mode.
def build_server(app, build, vcs, build_dir, output_dir, log_dir, force):
def build_server(app, build, output_dir, log_dir, force, refresh):
"""Do a build on the builder vm.
Parameters
@ -61,10 +61,6 @@ def build_server(app, build, vcs, build_dir, output_dir, log_dir, force):
app
app metadata dict
build
vcs
version control system controller object
build_dir
local source-code checkout of app
output_dir
target folder for the build result
force
@ -194,10 +190,6 @@ def build_server(app, build, vcs, build_dir, output_dir, log_dir, force):
srclibpaths.append(
common.getsrclib(lib, 'build/srclib', basepath=True, prepare=False))
# If one was used for the main source, add that too.
basesrclib = vcs.getsrclib()
if basesrclib:
srclibpaths.append(basesrclib)
for name, number, lib in srclibpaths:
logging.info("Sending srclib '%s'" % lib)
ftp.chdir(posixpath.join(homedir, 'build', 'srclib'))
@ -214,9 +206,19 @@ def build_server(app, build, vcs, build_dir, output_dir, log_dir, force):
else:
raise BuildException(_('cannot find required srclibs: "{path}"')
.format(path=srclibsfile))
vcs, build_dir = common.setup_vcs(app)
# When using server mode, still keep a local cache of the repo, by
# grabbing the source now.
vcs.gotorevision(build.commit, refresh)
# Initialise submodules if required
if build.submodules:
vcs.initsubmodules()
# Copy the main app source code
# (no need if it's a srclib)
if (not basesrclib) and os.path.exists(build_dir):
if os.path.exists(build_dir):
ftp.chdir(posixpath.join(homedir, 'build'))
fv = '.fdroidvcs-' + app.id
ftp.put(os.path.join('build', fv), fv)
@ -359,7 +361,7 @@ def get_metadata_from_apk(app, build, apkfile):
return versionCode, versionName
def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, extlib_dir, tmp_dir, force, onserver, refresh):
def build_local(app, build, output_dir, log_dir, srclib_dir, extlib_dir, tmp_dir, force, onserver, refresh):
"""Do a build locally."""
ndk_path = build.ndk_path()
if build.ndk or (build.buildjni and build.buildjni != ['no']):
@ -412,6 +414,7 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
% (app.id, build.versionName, build.sudo))
# Prepare the source code...
vcs, build_dir = common.setup_vcs(app)
root_dir, srclibpaths = common.prepare_source(vcs, app, build,
build_dir, srclib_dir,
extlib_dir, onserver, refresh)
@ -755,8 +758,8 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
os.path.join(output_dir, tarname))
def trybuild(app, build, build_dir, output_dir, log_dir, also_check_dir,
srclib_dir, extlib_dir, tmp_dir, repo_dir, vcs, test,
def trybuild(app, build, output_dir, log_dir, also_check_dir,
srclib_dir, extlib_dir, tmp_dir, repo_dir, test,
server, force, onserver, refresh):
"""Build a particular version of an application, if it needs building.
@ -802,17 +805,9 @@ def trybuild(app, build, build_dir, output_dir, log_dir, also_check_dir,
build.versionName, build.versionCode, app.id))
if server:
# When using server mode, still keep a local cache of the repo, by
# grabbing the source now.
vcs.gotorevision(build.commit, refresh)
# Initialise submodules if required
if build.submodules:
vcs.initsubmodules()
build_server(app, build, vcs, build_dir, output_dir, log_dir, force)
build_server(app, build, output_dir, log_dir, force, refresh)
else:
build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, extlib_dir, tmp_dir, force, onserver, refresh)
build_local(app, build, output_dir, log_dir, srclib_dir, extlib_dir, tmp_dir, force, onserver, refresh)
return True
@ -1020,9 +1015,6 @@ def main():
endtime = time.time() + 72 * 60 * 60
max_build_time_reached = False
for appid, app in apps.items():
first = True
for build in app.get('Builds', []):
if time.time() > endtime:
max_build_time_reached = True
@ -1043,18 +1035,10 @@ def main():
tools_version_log = ''
try:
# For the first build of a particular app, we need to set up
# the source repo. We can reuse it on subsequent builds, if
# there are any.
if first:
vcs, build_dir = common.setup_vcs(app)
first = False
logging.debug("Checking %s:%s" % (appid, build.versionCode))
if trybuild(app, build, build_dir, output_dir, log_dir,
if trybuild(app, build, output_dir, log_dir,
also_check_dir, srclib_dir, extlib_dir,
tmp_dir, repo_dir, vcs, options.test,
tmp_dir, repo_dir, options.test,
options.server, options.force,
options.onserver, options.refresh):
toolslog = os.path.join(log_dir,

View File

@ -67,7 +67,7 @@ from pyasn1.error import PyAsn1Error
import fdroidserver.metadata
import fdroidserver.lint
from fdroidserver import _
from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException,\
from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException, \
BuildException, VerificationException, MetaDataException
from .asynchronousfilereader import AsynchronousFileReader
from .looseversion import LooseVersion
@ -482,8 +482,10 @@ def read_config(opts=None):
if 'servergitmirrors' in config:
if isinstance(config['servergitmirrors'], str):
roots = [config['servergitmirrors']]
roots = [{"url": config['servergitmirrors']}]
elif all(isinstance(item, str) for item in config['servergitmirrors']):
roots = [{'url': i} for i in config['servergitmirrors']]
elif all(isinstance(item, dict) for item in config['servergitmirrors']):
roots = config['servergitmirrors']
else:
raise TypeError(_('only accepts strings, lists, and tuples'))
@ -1109,7 +1111,6 @@ class vcs:
self.local = local
self.clone_failed = False
self.refreshed = False
self.srclib = None
def _gettags(self):
raise NotImplementedError
@ -1218,10 +1219,6 @@ class vcs:
"""Get current commit reference (hash, revision, etc)."""
raise VCSException('getref not supported for this vcs type')
def getsrclib(self):
"""Return the srclib (name, path) used in setting up the current revision, or None."""
return self.srclib
class vcs_git(vcs):
@ -2256,11 +2253,6 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
for name, number, libpath in srclibpaths:
place_srclib(root_dir, int(number) if number else None, libpath)
basesrclib = vcs.getsrclib()
# If one was used for the main source, add that too.
if basesrclib:
srclibpaths.append(basesrclib)
# Update the local.properties file
localprops = [os.path.join(build_dir, 'local.properties')]
if build.subdir:

View File

@ -47,6 +47,19 @@ AUTO_S3CFG = '.fdroid-deploy-s3cfg'
USER_S3CFG = 's3cfg'
REMOTE_HOSTNAME_REGEX = re.compile(r'\W*\w+\W+(\w+).*')
INDEX_FILES = [
"entry.jar",
"entry.json",
"entry.json.asc",
"index-v1.jar",
"index-v1.json",
"index-v1.json.asc",
"index-v2.json",
"index-v2.json.asc",
"index.jar",
"index.xml",
]
def _get_index_excludes(repo_section):
"""Return the list of files to be synced last, since they finalize the deploy.
@ -447,7 +460,8 @@ def update_servergitmirrors(servergitmirrors, repo_section):
repo = git.Repo.init(git_mirror_path, initial_branch=GIT_BRANCH)
enabled_remotes = []
for remote_url in servergitmirrors:
for d in servergitmirrors:
remote_url = d['url']
name = REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
enabled_remotes.append(name)
r = git.remote.Remote(repo, name)
@ -840,10 +854,9 @@ def main():
update_serverwebroots(
config['serverwebroot'], repo_section, standardwebroot
)
if config.get('servergitmirrors', []):
if config.get('servergitmirrors'):
# update_servergitmirrors will take care of multiple mirrors so don't need a foreach
servergitmirrors = config.get('servergitmirrors', [])
update_servergitmirrors(servergitmirrors, repo_section)
update_servergitmirrors(config['servergitmirrors'], repo_section)
if config.get('awsbucket'):
update_awsbucket(repo_section)
if config.get('androidobservatory'):

View File

@ -1478,7 +1478,7 @@ def add_mirrors_to_repodict(repo_section, repodict):
repodict['mirrors'].insert(0, {'isPrimary': True, 'url': repodict['address']})
def get_mirror_service_urls(url):
def get_mirror_service_urls(mirror):
"""Get direct URLs from git service for use by fdroidclient.
Via 'servergitmirrors', fdroidserver can create and push a mirror
@ -1496,6 +1496,7 @@ def get_mirror_service_urls(url):
information about the repo available to end user.
"""
url = mirror['url']
if url.startswith('git@'):
url = re.sub(r'^git@([^:]+):(.+)', r'https://\1/\2', url)

View File

@ -358,7 +358,7 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base,
'archive_url': repo_base + '/archive',
'archive_description': 'Old nightly builds that have been archived.',
'archive_older': options.archive_older,
'servergitmirrors': servergitmirror,
'servergitmirrors': [{"url": servergitmirror}],
'keystore': KEYSTORE_FILE,
'repo_keyalias': KEY_ALIAS,
'keystorepass': PASSWORD,

View File

@ -187,6 +187,7 @@ get_sha() {
'7.6.1') echo '6147605a23b4eff6c334927a86ff3508cb5d6722cd624c97ded4c2e8640f1f87' ;;
'7.6.2') echo 'a01b6587e15fe7ed120a0ee299c25982a1eee045abd6a9dd5e216b2f628ef9ac' ;;
'7.6.3') echo '740c2e472ee4326c33bf75a5c9f5cd1e69ecf3f9b580f6e236c86d1f3d98cfac' ;;
'7.6.4') echo 'bed1da33cca0f557ab13691c77f38bb67388119e4794d113e051039b80af9bb1' ;;
'8.0') echo '4159b938ec734a8388ce03f52aa8f3c7ed0d31f5438622545de4f83a89b79788' ;;
'8.0.1') echo '1b6b558be93f29438d3df94b7dfee02e794b94d9aca4611a92cdb79b6b88e909' ;;
'8.0.2') echo 'ff7bf6a86f09b9b2c40bb8f48b25fc19cf2b2664fd1d220cd7ab833ec758d0d7' ;;
@ -218,7 +219,7 @@ d_gradle_plugin_ver_k=(8.4 8.3 8.2 8.1 8.0 7.4 7.3 7.2.0 7.1 7.0 4.2 4.1 4.0 3.6
d_plugin_min_gradle_v=(8.6 8.4 8.2 8.0 8.0 7.5 7.4 7.3.3 7.2 7.0.2 6.7.1 6.5 6.1.1 5.6.4 5.4.1 5.1.1 4.10.1 4.6 4.4 4.1 3.3 2.14.1 2.14.1 2.12 2.12 2.4 2.4 2.3 2.2.1 2.2.1 2.1 2.1 1.12 1.12 1.12 1.11 1.10 1.9 1.8 1.6 1.6 1.4 1.4)
# All gradle versions we know about
plugin_v=(8.6 8.5 8.4 8.3 8.2.1 8.2 8.1.1 8.1 8.0.2 8.0.1 8.0 7.6.3 7.6.2 7.6.1 7.6 7.5.1 7.5 7.4.2 7.4.1 7.4 7.3.3 7.3.2 7.3.1 7.3 7.2 7.1.1 7.1 7.0.2 7.0.1 7.0 6.9.4 6.9.3 6.9.2 6.9.1 6.9 6.8.3 6.8.2 6.8.1 6.8 6.7.1 6.7 6.6.1 6.6 6.5.1 6.5 6.4.1 6.4 6.3 6.2.2 6.2.1 6.2 6.1.1 6.1 6.0.1 6.0 5.6.4 5.6.3 5.6.2 5.6.1 5.6 5.5.1 5.5 5.4.1 5.4 5.3.1 5.3 5.2.1 5.2 5.1.1 5.1 5.0 4.10.3 4.10.2 4.10.1 4.10 4.9 4.8.1 4.8 4.7 4.6 4.5.1 4.5 4.4.1 4.4 4.3.1 4.3 4.2.1 4.2 4.1 4.0.2 4.0.1 4.0 3.5.1 3.5 3.4.1 3.4 3.3 3.2.1 3.2 3.1 3.0 2.14.1 2.14 2.13 2.12 2.11 2.10 2.9 2.8 2.7 2.6 2.5 2.4 2.3 2.2.1 2.2 2.1 2.0 1.12 1.11 1.10 1.9 1.8 1.7 1.6 1.5 1.4 1.3 1.2 1.1 1.0 0.9.2 0.9.1 0.9 0.8 0.7)
plugin_v=(8.6 8.5 8.4 8.3 8.2.1 8.2 8.1.1 8.1 8.0.2 8.0.1 8.0 7.6.4 7.6.3 7.6.2 7.6.1 7.6 7.5.1 7.5 7.4.2 7.4.1 7.4 7.3.3 7.3.2 7.3.1 7.3 7.2 7.1.1 7.1 7.0.2 7.0.1 7.0 6.9.4 6.9.3 6.9.2 6.9.1 6.9 6.8.3 6.8.2 6.8.1 6.8 6.7.1 6.7 6.6.1 6.6 6.5.1 6.5 6.4.1 6.4 6.3 6.2.2 6.2.1 6.2 6.1.1 6.1 6.0.1 6.0 5.6.4 5.6.3 5.6.2 5.6.1 5.6 5.5.1 5.5 5.4.1 5.4 5.3.1 5.3 5.2.1 5.2 5.1.1 5.1 5.0 4.10.3 4.10.2 4.10.1 4.10 4.9 4.8.1 4.8 4.7 4.6 4.5.1 4.5 4.4.1 4.4 4.3.1 4.3 4.2.1 4.2 4.1 4.0.2 4.0.1 4.0 3.5.1 3.5 3.4.1 3.4 3.3 3.2.1 3.2 3.1 3.0 2.14.1 2.14 2.13 2.12 2.11 2.10 2.9 2.8 2.7 2.6 2.5 2.4 2.3 2.2.1 2.2 2.1 2.0 1.12 1.11 1.10 1.9 1.8 1.7 1.6 1.5 1.4 1.3 1.2 1.1 1.0 0.9.2 0.9.1 0.9 0.8 0.7)
v_all=${plugin_v[@]}

View File

@ -223,6 +223,7 @@ class BuildTest(unittest.TestCase):
@mock.patch('fdroidserver.build.FDroidPopen')
@mock.patch('fdroidserver.common.is_apk_and_debuggable', lambda f: False)
@mock.patch('fdroidserver.common.get_native_code', lambda f: 'x86')
@mock.patch('fdroidserver.common.setup_vcs', lambda f: (mock.Mock(), "."))
def test_build_local_maven(self, fake_FDroidPopen, fake_get_apk_id):
"""Test build_local() with a maven project"""
@ -258,14 +259,11 @@ class BuildTest(unittest.TestCase):
build.versionCode,
build.versionName,
)
vcs = mock.Mock()
build.maven = 'yes@..'
fdroidserver.build.build_local(
app,
build,
vcs,
build_dir=self.testdir,
output_dir=self.testdir,
log_dir=os.getcwd(),
srclib_dir=None,
@ -280,8 +278,6 @@ class BuildTest(unittest.TestCase):
fdroidserver.build.build_local(
app,
build,
vcs,
build_dir=self.testdir,
output_dir=self.testdir,
log_dir=os.getcwd(),
srclib_dir=None,
@ -316,7 +312,6 @@ class BuildTest(unittest.TestCase):
build.ndk = 'r21e' # aka 21.4.7075529
ndk_version = '21.4.7075529'
ndk_dir = Path(config['sdk_path']) / 'ndk' / ndk_version
vcs = mock.Mock()
def make_fake_apk(output, build):
with open(build.output, 'w') as fp:
@ -347,6 +342,8 @@ class BuildTest(unittest.TestCase):
'fdroidserver.build.FDroidPopen', FakeProcess
) as _ignored, mock.patch(
'sdkmanager.install', wraps=fake_sdkmanager_install
) as _ignored, mock.patch(
'fdroidserver.common.setup_vcs', return_value=(mock.Mock(), testdir)
) as _ignored:
_ignored # silence the linters
with self.assertRaises(
@ -356,8 +353,6 @@ class BuildTest(unittest.TestCase):
fdroidserver.build.build_local(
app,
build,
vcs,
build_dir=testdir,
output_dir=testdir,
log_dir=None,
srclib_dir=None,
@ -375,8 +370,6 @@ class BuildTest(unittest.TestCase):
fdroidserver.build.build_local(
app,
build,
vcs,
build_dir=testdir,
output_dir=testdir,
log_dir=os.getcwd(),
srclib_dir=None,
@ -399,6 +392,7 @@ class BuildTest(unittest.TestCase):
'fdroidserver.common.sha256sum',
lambda f: 'ad7ce5467e18d40050dc51b8e7affc3e635c85bd8c59be62de32352328ed467e',
)
@mock.patch('fdroidserver.common.setup_vcs', lambda f: (mock.Mock(), "."))
def test_build_local_ndk_some_installed(self):
"""Test if `fdroid build` detects installed NDKs and auto-installs when missing"""
with tempfile.TemporaryDirectory() as testdir, TmpCwd(
@ -426,7 +420,6 @@ class BuildTest(unittest.TestCase):
build.ndk = 'r21e' # aka 21.4.7075529
ndk_version = '21.4.7075529'
ndk_dir = Path(config['sdk_path']) / 'ndk' / ndk_version
vcs = mock.Mock()
def make_fake_apk(output, build):
with open(build.output, 'w') as fp:
@ -456,8 +449,6 @@ class BuildTest(unittest.TestCase):
fdroidserver.build.build_local(
app,
build,
vcs,
build_dir=testdir,
output_dir=testdir,
log_dir=os.getcwd(),
srclib_dir=None,
@ -491,7 +482,6 @@ class BuildTest(unittest.TestCase):
build.scanignore = ['foo.aar']
build.versionCode = 1
build.versionName = '1.0'
vcs = mock.Mock()
os.mkdir('reports')
os.mkdir('target')
@ -524,29 +514,31 @@ class BuildTest(unittest.TestCase):
fp.write('APK PLACEHOLDER')
return output
with mock.patch('fdroidserver.common.replace_build_vars', wraps=make_fake_apk):
with mock.patch('fdroidserver.common.get_native_code', return_value='x86'):
with mock.patch(
'fdroidserver.common.get_apk_id',
return_value=(app.id, build.versionCode, build.versionName),
):
with mock.patch(
'fdroidserver.common.is_apk_and_debuggable', return_value=False
):
fdroidserver.build.build_local(
app,
build,
vcs,
build_dir=self.testdir,
output_dir=self.testdir,
log_dir=None,
srclib_dir=None,
extlib_dir=None,
tmp_dir=None,
force=False,
onserver=False,
refresh=False,
)
with mock.patch(
'fdroidserver.common.replace_build_vars', wraps=make_fake_apk
) as _ignored, mock.patch(
'fdroidserver.common.get_native_code', return_value='x86'
) as _ignored, mock.patch(
'fdroidserver.common.get_apk_id',
return_value=(app.id, build.versionCode, build.versionName),
) as _ignored, mock.patch(
'fdroidserver.common.is_apk_and_debuggable', return_value=False
) as _ignored, mock.patch(
'fdroidserver.common.setup_vcs', return_value=(mock.Mock(), self.testdir)
) as _ignored:
_ignored # silence the linters
fdroidserver.build.build_local(
app,
build,
output_dir=self.testdir,
log_dir=None,
srclib_dir=None,
extlib_dir=None,
tmp_dir=None,
force=False,
onserver=False,
refresh=False,
)
self.assertTrue(os.path.exists('foo.aar'))
self.assertTrue(os.path.isdir('build'))
@ -881,8 +873,6 @@ class BuildTest(unittest.TestCase):
}
fdroidserver.common.config = {'sdk_path': '/fake/android/sdk/path'}
fdroidserver.build.options = mock.MagicMock()
vcs = mock.Mock()
vcs.getsrclib = mock.Mock(return_value=None)
app = fdroidserver.metadata.App()
app['metadatapath'] = 'metadata/fake.id.yml'
app['id'] = 'fake.id'
@ -897,29 +887,33 @@ class BuildTest(unittest.TestCase):
)
app['Builds'] = [build]
test_flag = ('--on-server', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
self.assertTrue(fdroidserver_vmtools_get_build_vm.called)
with mock.patch(
'fdroidserver.common.setup_vcs', return_value=(mock.Mock(), "")
) as _ignored:
_ignored # silence the linters
test_flag = ('--on-server', True)
fdroidserver.build.build_server(app, build, '', '', False, False)
self.assertTrue(fdroidserver_vmtools_get_build_vm.called)
for force in (True, False):
test_flag = ('--force', force)
fdroidserver.build.build_server(app, build, vcs, '', '', '', force)
for force in (True, False):
test_flag = ('--force', force)
fdroidserver.build.build_server(app, build, '', '', force, False)
fdroidserver.build.options.notarball = True
test_flag = ('--no-tarball', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
fdroidserver.build.options.notarball = False
test_flag = ('--no-tarball', False)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
fdroidserver.build.options.notarball = True
test_flag = ('--no-tarball', True)
fdroidserver.build.build_server(app, build, '', '', False, False)
fdroidserver.build.options.notarball = False
test_flag = ('--no-tarball', False)
fdroidserver.build.build_server(app, build, '', '', False, False)
fdroidserver.build.options.skipscan = False
test_flag = ('--scan-binary', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
fdroidserver.build.options.skipscan = True
test_flag = ('--scan-binary', False)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
test_flag = ('--skip-scan', True)
fdroidserver.build.build_server(app, build, vcs, '', '', '', False)
fdroidserver.build.options.skipscan = False
test_flag = ('--scan-binary', True)
fdroidserver.build.build_server(app, build, '', '', False, False)
fdroidserver.build.options.skipscan = True
test_flag = ('--scan-binary', False)
fdroidserver.build.build_server(app, build, '', '', False, False)
test_flag = ('--skip-scan', True)
fdroidserver.build.build_server(app, build, '', '', False, False)
@mock.patch('fdroidserver.vmtools.get_build_vm')
@mock.patch('fdroidserver.vmtools.get_clean_builder')
@ -930,6 +924,7 @@ class BuildTest(unittest.TestCase):
@mock.patch('fdroidserver.build.build_local')
@mock.patch('fdroidserver.common.get_android_tools_version_log', lambda: 'versions')
@mock.patch('fdroidserver.common.deploy_build_log_with_rsync', lambda a, b, c: None)
@mock.patch('fdroidserver.common.setup_vcs', lambda f: (mock.Mock(), "."))
def test_build_server_no_local_prepare(
self,
build_build_local,
@ -1005,8 +1000,6 @@ class BuildTest(unittest.TestCase):
fdroidserver.build.options = options
fdroidserver.build.config = {'sdk_path': '/fake/android/sdk/path'}
vcs = mock.Mock()
vcs.getsrclib = mock.Mock(return_value=None)
app = fdroidserver.metadata.App()
app['metadatapath'] = 'metadata/fake.id.yml'
app['id'] = 'fake.id'
@ -1033,7 +1026,6 @@ class BuildTest(unittest.TestCase):
fdroidserver.build.trybuild(
app,
build,
build_dir,
'unsigned',
'logs',
None,
@ -1041,7 +1033,6 @@ class BuildTest(unittest.TestCase):
extlib_dir,
'tmp',
'repo',
vcs,
options.test,
options.server,
options.force,

View File

@ -300,6 +300,86 @@ class DeployTest(unittest.TestCase):
name, fdroidserver.deploy.REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url)
)
def test_update_servergitmirrors(self):
# setup parameters for this test run
fdroidserver.deploy.options = mock.Mock()
fdroidserver.deploy.options.identity_file = None
fdroidserver.deploy.options.no_keep_git_mirror_archive = False
fdroidserver.deploy.options.verbose = False
fdroidserver.deploy.options.quiet = True
fdroidserver.deploy.options.index_only = False
config = {}
fdroidserver.common.fill_config_defaults(config)
fdroidserver.deploy.config = config
fdroidserver.deploy.config["servergitmirrors"] = []
repo_section = 'repo'
# setup function for asserting subprocess.call invocations
update_servergitmirrors_call_iteration = 0
remote_push_call_iteration = 0
os.chdir(self.testdir)
repo = Path('repo')
repo.mkdir(parents=True)
fake_apk = repo / 'Sym.apk'
with fake_apk.open('w') as fp:
fp.write('not an APK, but has the right filename')
fake_index = repo / fdroidserver.deploy.INDEX_FILES[0]
with fake_index.open('w') as fp:
fp.write('not an index, but has the right filename')
def update_servergitmirrors_call(cmd):
nonlocal update_servergitmirrors_call_iteration
if update_servergitmirrors_call_iteration == 0:
self.assertListEqual(
cmd,
[
'rsync',
'--recursive',
'--safe-links',
'--times',
'--perms',
'--one-file-system',
'--delete',
'--chmod=Da+rx,Fa-x,a+r,u+w',
'--quiet',
'repo/',
"git-mirror/fdroid/repo/",
],
)
else:
self.fail('unexpected subprocess.call invocation')
update_servergitmirrors_call_iteration += 1
return 0
def remote_push_call(ref, force=False, set_upstream=False, **_args):
nonlocal remote_push_call_iteration
if remote_push_call_iteration == 0:
self.assertEqual([ref, force, set_upstream], ['master', True, True])
else:
self.fail('unexpected git.Remote.push invocation')
remote_push_call_iteration += 1
return []
with mock.patch('subprocess.call', side_effect=update_servergitmirrors_call):
with mock.patch(
'git.Remote.push', side_effect=remote_push_call
) as mock_remote_push:
mock_remote_push.return_value = []
fdroidserver.deploy.update_servergitmirrors(
[{'url': 'https://github.com/user/repo'}], repo_section
)
self.assertEqual(
update_servergitmirrors_call_iteration,
1,
'expected 1 invocations of subprocess.call',
)
self.assertEqual(
remote_push_call_iteration, 1, 'expected 1 invocations of git.Remote.push'
)
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))

View File

@ -575,7 +575,7 @@ class IndexTest(unittest.TestCase):
]:
self.assertEqual(
['https://raw.githubusercontent.com/foo/bar/master/fdroid'],
index.get_mirror_service_urls(url),
index.get_mirror_service_urls({"url": url}),
)
@patch.dict(os.environ, clear=True)
@ -603,13 +603,13 @@ class IndexTest(unittest.TestCase):
]
self.assertEqual(
expected,
index.get_mirror_service_urls(url),
index.get_mirror_service_urls({"url": url}),
)
with patch.dict(os.environ, clear=True):
os.environ['CI_JOB_ID'] = ci_job_id
self.assertEqual(
expected + [artifacts_url],
index.get_mirror_service_urls(url),
index.get_mirror_service_urls({"url": url}),
)
with patch('fdroidserver.common.GITLAB_COM_PAGES_MAX_SIZE', 10):
expected = [
@ -617,13 +617,13 @@ class IndexTest(unittest.TestCase):
]
self.assertEqual(
expected,
index.get_mirror_service_urls(url),
index.get_mirror_service_urls({"url": url}),
)
with patch.dict(os.environ, clear=True):
os.environ['CI_JOB_ID'] = ci_job_id
self.assertEqual(
expected + [artifacts_url],
index.get_mirror_service_urls(url),
index.get_mirror_service_urls({"url": url}),
)
def test_make_website(self):

View File

@ -256,7 +256,7 @@ class NightlyTest(unittest.TestCase):
self.assertEqual(called, [['ssh', '-Tvi'], ['fdroid', 'deploy']])
self.assertFalse(os.path.exists('config.py'))
git_url = 'git@github.com:f-droid/test-nightly'
mirror_url = index.get_mirror_service_urls(git_url)[0]
mirror_url = index.get_mirror_service_urls({"url": git_url})[0]
expected = {
'archive_description': 'Old nightly builds that have been archived.',
'archive_name': 'f-droid/test-nightly archive',
@ -271,7 +271,7 @@ class NightlyTest(unittest.TestCase):
'repo_keyalias': 'androiddebugkey',
'repo_name': 'f-droid/test-nightly',
'repo_url': mirror_url + '/repo',
'servergitmirrors': git_url,
'servergitmirrors': [{"url": git_url}],
'update_stats': True,
}
with open('config.yml') as fp:
@ -344,7 +344,7 @@ class NightlyTest(unittest.TestCase):
'repo_keyalias': 'androiddebugkey',
'repo_name': 'fdroid/test-nightly',
'repo_url': 'https://gitlab.com/fdroid/test-nightly/-/raw/master/fdroid/repo',
'servergitmirrors': 'git@gitlab.com:fdroid/test-nightly',
'servergitmirrors': [{"url": 'git@gitlab.com:fdroid/test-nightly'}],
'update_stats': True,
}
with open('config.yml') as fp:

View File

@ -1154,7 +1154,7 @@ GIT_MIRROR=$REPOROOT/git-mirror
cd $REPOROOT
fdroid_init_with_prebuilt_keystore
printf '\narchive_older: 3\n' >> config.yml
echo "servergitmirrors: $SERVER_GIT_MIRROR" >> config.yml
printf "servergitmirrors: $SERVER_GIT_MIRROR\n" >> config.yml
cp $WORKSPACE/tests/repo/com.politedroid_[345].apk repo/
$fdroid update --create-metadata

View File

@ -246,7 +246,6 @@ class ScannerTest(unittest.TestCase):
build.scanignore = ['baz.so', 'foo.aar']
build.versionCode = 1
build.versionName = '1.0'
vcs = mock.Mock()
for f in ('baz.so', 'foo.aar', 'gradle-wrapper.jar'):
with open(f, 'w') as fp:
@ -269,29 +268,31 @@ class ScannerTest(unittest.TestCase):
fp.write('APK PLACEHOLDER')
return output
with mock.patch('fdroidserver.common.replace_build_vars', wraps=make_fake_apk):
with mock.patch('fdroidserver.common.get_native_code', return_value='x86'):
with mock.patch(
'fdroidserver.common.get_apk_id',
return_value=(app.id, build.versionCode, build.versionName),
):
with mock.patch(
'fdroidserver.common.is_apk_and_debuggable', return_value=False
):
fdroidserver.build.build_local(
app,
build,
vcs,
build_dir=self.testdir,
output_dir=self.testdir,
log_dir=None,
srclib_dir=None,
extlib_dir=None,
tmp_dir=None,
force=False,
onserver=False,
refresh=False,
)
with mock.patch(
'fdroidserver.common.replace_build_vars', wraps=make_fake_apk
) as _ignored, mock.patch(
'fdroidserver.common.get_native_code', return_value='x86'
) as _ignored, mock.patch(
'fdroidserver.common.get_apk_id',
return_value=(app.id, build.versionCode, build.versionName),
) as _ignored, mock.patch(
'fdroidserver.common.is_apk_and_debuggable', return_value=False
) as _ignored, mock.patch(
'fdroidserver.common.setup_vcs', return_value=(mock.Mock(), self.testdir)
) as _ignored:
_ignored # silence the linters
fdroidserver.build.build_local(
app,
build,
output_dir=self.testdir,
log_dir=None,
srclib_dir=None,
extlib_dir=None,
tmp_dir=None,
force=False,
onserver=False,
refresh=False,
)
self.assertTrue(os.path.exists('baz.so'))
self.assertTrue(os.path.exists('foo.aar'))
self.assertFalse(os.path.exists('gradle-wrapper.jar'))