From 8daf273843b05998521083d0a8a55e792580f895 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 21 Oct 2020 10:16:17 +0200 Subject: [PATCH 1/2] server: purge `fdroid server init` command, it is totally unneeded The existing rsync command used to deploy via SSH will create all the dirs that `fdroid server init` does. --- fdroidserver/server.py | 71 ++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/fdroidserver/server.py b/fdroidserver/server.py index d406da1d..9ae21d5f 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/server.py @@ -21,8 +21,6 @@ import glob import hashlib import json import os -import paramiko -import pwd import re import subprocess import time @@ -715,8 +713,8 @@ def main(): config = common.read_config(options) - if options.command != 'init' and options.command != 'update': - logging.critical(_("The only commands currently supported are 'init' and 'update'")) + if options.command != 'update': + logging.critical(_("The only command currently supported is 'update'")) sys.exit(1) if config.get('nonstandardwebroot') is True: @@ -792,52 +790,29 @@ def main(): if config['per_app_repos']: repo_sections += common.get_per_app_repos() - if options.command == 'init': - ssh = paramiko.SSHClient() - ssh.load_system_host_keys() - for serverwebroot in config.get('serverwebroot', []): - sshstr, remotepath = serverwebroot.rstrip('/').split(':') - if sshstr.find('@') >= 0: - username, hostname = sshstr.split('@') + for repo_section in repo_sections: + if local_copy_dir is not None: + if config['sync_from_local_copy_dir']: + sync_from_localcopy(repo_section, local_copy_dir) else: - username = pwd.getpwuid(os.getuid())[0] # get effective uid - hostname = sshstr - ssh.connect(hostname, username=username) - sftp = ssh.open_sftp() - if os.path.basename(remotepath) \ - not in sftp.listdir(os.path.dirname(remotepath)): - sftp.mkdir(remotepath, mode=0o755) - for repo_section in repo_sections: - repo_path = os.path.join(remotepath, repo_section) - if os.path.basename(repo_path) \ - not in sftp.listdir(remotepath): - sftp.mkdir(repo_path, mode=0o755) - sftp.close() - ssh.close() - elif options.command == 'update': - for repo_section in repo_sections: - if local_copy_dir is not None: - if config['sync_from_local_copy_dir']: - sync_from_localcopy(repo_section, local_copy_dir) - else: - update_localcopy(repo_section, local_copy_dir) - for serverwebroot in config.get('serverwebroot', []): - update_serverwebroot(serverwebroot, repo_section) - 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) - if config.get('awsbucket'): - update_awsbucket(repo_section) - if config.get('androidobservatory'): - upload_to_android_observatory(repo_section) - if config.get('virustotal_apikey'): - upload_to_virustotal(repo_section, config.get('virustotal_apikey')) + update_localcopy(repo_section, local_copy_dir) + for serverwebroot in config.get('serverwebroot', []): + update_serverwebroot(serverwebroot, repo_section) + 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) + if config.get('awsbucket'): + update_awsbucket(repo_section) + if config.get('androidobservatory'): + upload_to_android_observatory(repo_section) + if config.get('virustotal_apikey'): + upload_to_virustotal(repo_section, config.get('virustotal_apikey')) - binary_transparency_remote = config.get('binary_transparency_remote') - if binary_transparency_remote: - push_binary_transparency(BINARY_TRANSPARENCY_DIR, - binary_transparency_remote) + binary_transparency_remote = config.get('binary_transparency_remote') + if binary_transparency_remote: + push_binary_transparency(BINARY_TRANSPARENCY_DIR, + binary_transparency_remote) if config.get('wiki_server') and config.get('wiki_path'): update_wiki() From 17f6a778ba510c86a22abd5e2219cffd029890a3 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 21 Oct 2020 09:52:58 +0200 Subject: [PATCH 2/2] deploy: move server.py to deploy.py and remove aliases closes #832 --- MANIFEST.in | 2 +- examples/config.py | 4 +- fdroidserver/__init__.py | 2 +- fdroidserver/__main__.py | 9 +-- fdroidserver/btlog.py | 4 +- fdroidserver/{server.py => deploy.py} | 13 +--- fdroidserver/nightly.py | 2 +- locale/POTFILES.in | 2 +- locale/fdroidserver.pot | 70 +++++++++++----------- tests/{server.TestCase => deploy.TestCase} | 50 ++++++++-------- tests/main.TestCase | 3 +- tests/run-tests | 20 +++---- 12 files changed, 85 insertions(+), 96 deletions(-) rename fdroidserver/{server.py => deploy.py} (98%) rename tests/{server.TestCase => deploy.TestCase} (83%) diff --git a/MANIFEST.in b/MANIFEST.in index ce591656..b3dcf59b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -537,6 +537,7 @@ include tests/check-fdroid-apk include tests/common.TestCase include tests/complete-ci-tests include tests/config.py +include tests/deploy.TestCase include tests/description-parsing.py include tests/dummy-keystore.jks include tests/dump_internal_metadata_format.py @@ -667,7 +668,6 @@ include tests/repo/urzip-*.apk include tests/repo/v1.v2.sig_1020.apk include tests/run-tests include tests/scanner.TestCase -include tests/server.TestCase include tests/signatures.TestCase include tests/signindex/guardianproject.jar include tests/signindex/guardianproject-v1.jar diff --git a/examples/config.py b/examples/config.py index f074fb15..c9c1cbc1 100644 --- a/examples/config.py +++ b/examples/config.py @@ -222,9 +222,9 @@ The repository of older versions of applications from the main demo repository. # If you are running the repo signing process on a completely offline machine, # which provides the best security, then you can specify a folder to sync the -# repo to when running `fdroid server update`. This is most likely going to +# repo to when running `fdroid deploy`. This is most likely going to # be a USB thumb drive, SD Card, or some other kind of removable media. Make -# sure it is mounted before running `fdroid server update`. Using the +# sure it is mounted before running `fdroid deploy`. Using the # standard folder called 'fdroid' as the specified folder is recommended, like # with serverwebroot. # diff --git a/fdroidserver/__init__.py b/fdroidserver/__init__.py index 3a395ea2..1e1cd42f 100644 --- a/fdroidserver/__init__.py +++ b/fdroidserver/__init__.py @@ -48,7 +48,7 @@ process_apk # NOQA: B101 process_apks # NOQA: B101 scan_apk # NOQA: B101 scan_repo_files # NOQA: B101 -from fdroidserver.server import (update_awsbucket, +from fdroidserver.deploy import (update_awsbucket, update_servergitmirrors, update_serverwebroot) # NOQA: E402 update_awsbucket # NOQA: B101 diff --git a/fdroidserver/__main__.py b/fdroidserver/__main__.py index 4d0c4785..d90a4316 100755 --- a/fdroidserver/__main__.py +++ b/fdroidserver/__main__.py @@ -48,7 +48,6 @@ COMMANDS = OrderedDict([ ("lint", _("Warn about possible metadata errors")), ("scanner", _("Scan the source code of a package")), ("stats", _("Update the stats of the repo")), - ("server", _("Old, deprecated name for fdroid deploy")), ("signindex", _("Sign indexes created using update --nosign")), ("btlog", _("Update the binary transparency log for a URL")), ("signatures", _("Extract signatures from APKs")), @@ -137,6 +136,9 @@ def main(): if command in ('-h', '--help'): print_help(available_plugins=available_plugins) sys.exit(0) + elif command == 'server': + print(_("""ERROR: The "server" subcommand has been removed, use "deploy"!""")) + sys.exit(1) elif command == '--version': output = _('no version info found!') cmddir = os.path.realpath(os.path.dirname(os.path.dirname(__file__))) @@ -187,11 +189,6 @@ def main(): "can not be specified at the same time.")) sys.exit(1) - # temporary workaround until server.py becomes deploy.py - if command == 'deploy': - command = 'server' - sys.argv.insert(2, 'update') - # Trick optparse into displaying the right usage when --help is used. sys.argv[0] += ' ' + command diff --git a/fdroidserver/btlog.py b/fdroidserver/btlog.py index 08993aec..f1e83c90 100755 --- a/fdroidserver/btlog.py +++ b/fdroidserver/btlog.py @@ -42,7 +42,7 @@ from argparse import ArgumentParser from . import _ from . import common -from . import server +from . import deploy from .exception import FDroidException @@ -219,7 +219,7 @@ def main(): os.chdir(tempdirbase) make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog') if options.git_remote: - server.push_binary_transparency(options.git_repo, options.git_remote) + deploy.push_binary_transparency(options.git_repo, options.git_remote) shutil.rmtree(tempdirbase, ignore_errors=True) diff --git a/fdroidserver/server.py b/fdroidserver/deploy.py similarity index 98% rename from fdroidserver/server.py rename to fdroidserver/deploy.py index 9ae21d5f..724487d5 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/deploy.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# server.py - part of the FDroid server tools +# deploy.py - part of the FDroid server tools # Copyright (C) 2010-15, Ciaran Gultnieks, ciaran@ciarang.com # # This program is free software: you can redistribute it and/or modify @@ -41,7 +41,7 @@ start_timestamp = time.gmtime() BINARY_TRANSPARENCY_DIR = 'binary_transparency' -AUTO_S3CFG = '.fdroid-server-update-s3cfg' +AUTO_S3CFG = '.fdroid-deploy-s3cfg' USER_S3CFG = 's3cfg' REMOTE_HOSTNAME_REGEX = re.compile(r'\W*\w+\W+(\w+).*') @@ -344,7 +344,7 @@ def update_servergitmirrors(servergitmirrors, repo_section): from clint.textui import progress if config.get('local_copy_dir') \ and not config.get('sync_from_local_copy_dir'): - logging.debug('Offline machine, skipping git mirror generation until `fdroid server update`') + logging.debug(_('Offline machine, skipping git mirror generation until `fdroid deploy`')) return # right now we support only 'repo' git-mirroring @@ -697,10 +697,8 @@ def update_wiki(): def main(): global config, options - # Parse command line... parser = ArgumentParser() common.setup_global_opts(parser) - parser.add_argument("command", help=_("command to execute, either 'init' or 'update'")) parser.add_argument("-i", "--identity-file", default=None, help=_("Specify an identity file to provide to SSH for rsyncing")) parser.add_argument("--local-copy-dir", default=None, @@ -710,13 +708,8 @@ def main(): parser.add_argument("--no-keep-git-mirror-archive", action="store_true", default=False, help=_("If a git mirror gets to big, allow the archive to be deleted")) options = parser.parse_args() - config = common.read_config(options) - if options.command != 'update': - logging.critical(_("The only command currently supported is 'update'")) - sys.exit(1) - if config.get('nonstandardwebroot') is True: standardwebroot = False else: diff --git a/fdroidserver/nightly.py b/fdroidserver/nightly.py index 671c217a..63e7d131 100644 --- a/fdroidserver/nightly.py +++ b/fdroidserver/nightly.py @@ -301,7 +301,7 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base, if not options.no_deploy: try: - cmd = ['fdroid', 'server', 'update', '--verbose', '--no-keep-git-mirror-archive'] + cmd = ['fdroid', 'deploy', '--verbose', '--no-keep-git-mirror-archive'] subprocess.check_call(cmd, cwd=repo_basedir) except subprocess.CalledProcessError: logging.error(_('cannot publish update, did you set the deploy key?') diff --git a/locale/POTFILES.in b/locale/POTFILES.in index 7d31bec0..07ad4fcc 100644 --- a/locale/POTFILES.in +++ b/locale/POTFILES.in @@ -3,6 +3,7 @@ fdroidserver/btlog.py fdroidserver/build.py fdroidserver/checkupdates.py fdroidserver/common.py +fdroidserver/deploy.py fdroidserver/import.py fdroidserver/init.py fdroidserver/install.py @@ -11,7 +12,6 @@ fdroidserver/metadata.py fdroidserver/publish.py fdroidserver/rewritemeta.py fdroidserver/scanner.py -fdroidserver/server.py fdroidserver/stats.py fdroidserver/update.py fdroidserver/verify.py diff --git a/locale/fdroidserver.pot b/locale/fdroidserver.pot index cb5017a6..31ab5fc6 100644 --- a/locale/fdroidserver.pot +++ b/locale/fdroidserver.pot @@ -66,7 +66,7 @@ msgstr "" msgid "\"{path}\" contains recent {name} ({version})" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "\"{path}\" exists but s3cmd is not installed!" msgstr "" @@ -505,12 +505,12 @@ msgstr "" msgid "Create skeleton metadata files that are missing" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Created new container \"{name}\"" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Creating \"{path}\" for configuring s3cmd." msgstr "" @@ -519,7 +519,7 @@ msgstr "" msgid "Creating log directory" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Creating new S3 bucket: {url}" msgstr "" @@ -554,12 +554,12 @@ msgstr "" msgid "Delete APKs and/or OBBs without metadata from the repo" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "Deleting archive, repo is too big ({size} max {limit})" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "Deleting git-mirror history, repo is too big ({size} max {limit})" msgstr "" @@ -621,7 +621,7 @@ msgstr "" msgid "Don't refresh the repository, useful when testing a build with no internet connection" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/nightly.py +#: ../fdroidserver/deploy.py ../fdroidserver/nightly.py #: ../fdroidserver/upload.py msgid "Don't use rsync checksums" msgstr "" @@ -684,7 +684,7 @@ msgid "" "> " msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/checkupdates.py +#: ../fdroidserver/deploy.py ../fdroidserver/checkupdates.py #: ../fdroidserver/upload.py #, python-format msgid "Error while attempting to publish log: %s" @@ -722,7 +722,7 @@ msgstr "" msgid "Failed to align application" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Failed to create S3 bucket: {url}" msgstr "" @@ -848,7 +848,7 @@ msgstr "" msgid "Found non-file at %s" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "Found {apkfilename} at {url}" msgstr "" @@ -896,11 +896,11 @@ msgstr "" msgid "HTTPS must be used with Subversion URLs!" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "If a git mirror gets to big, allow the archive to be deleted" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "If this upload fails, try manually uploading to {url}" msgstr "" @@ -1131,7 +1131,7 @@ msgstr "" msgid "Malformed repository mirrors." msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "Malformed serverwebroot line:" msgstr "" @@ -1193,7 +1193,7 @@ msgstr "" msgid "No need to specify that the app is for Android" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "No option set! Edit your config.py to set at least one of these:" msgstr "" @@ -1407,12 +1407,12 @@ msgstr "" msgid "Push the log to this git remote repository" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Pushing binary transparency log to {url}" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Pushing to {url}" msgstr "" @@ -1506,7 +1506,7 @@ msgstr "" msgid "Run rewritemeta to fix formatting" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py msgid "Running first pass with MD5 checking disabled" msgstr "" @@ -1613,11 +1613,11 @@ msgstr "" msgid "Skipping {appid}: no builds specified" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py msgid "Specify a local folder to sync the repo to" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py msgid "Specify an identity file to provide to SSH for rsyncing" msgstr "" @@ -1680,7 +1680,7 @@ msgstr "" msgid "The file to be included in the repo (path or glob)" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "The only commands currently supported are 'init' and 'update'" msgstr "" @@ -1692,7 +1692,7 @@ msgstr "" msgid "The repository's index could not be verified." msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "The root dir for local_copy_dir \"{path}\" does not exist!" msgstr "" @@ -1710,7 +1710,7 @@ msgstr "" msgid "This repo already has local metadata: %s" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py msgid "To use awsbucket, awssecretkey and awsaccesskeyid must also be set in config.py!" msgstr "" @@ -1901,12 +1901,12 @@ msgstr "" msgid "UpdateCheckName is set to the known application ID, it can be removed" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "Uploading {apkfilename} to androidobservatory.org" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "Uploading {apkfilename} to virustotal" msgstr "" @@ -1941,7 +1941,7 @@ msgstr "" msgid "Use date from apk instead of current time for newly added apks" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Using \"{path}\" for configuring s3cmd." msgstr "" @@ -1968,7 +1968,7 @@ msgstr "" msgid "Using existing keystore \"{path}\"" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "Using s3cmd to sync with: {url}" msgstr "" @@ -1989,7 +1989,7 @@ msgstr "" msgid "Verifying index signature:" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "VirusTotal API key cannot upload files larger than 32MB, use {url} to upload {path}." msgstr "" @@ -2122,7 +2122,7 @@ msgstr "" msgid "cloning {url}" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "command to execute, either 'init' or 'update'" msgstr "" @@ -2287,16 +2287,16 @@ msgstr "" msgid "invalid option string %(option)r: must start with a character %(prefix_chars)r" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "local_copy_dir does not end with \"fdroid\", perhaps you meant: \"{path}\"" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "local_copy_dir must be an absolute path!" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "local_copy_dir must be directory, not a file!" msgstr "" @@ -2432,7 +2432,7 @@ msgstr "" msgid "ruamel.yaml not installed, can not write metadata." msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "s3cmd sync indexes {path} to {url} and delete" msgstr "" @@ -2520,12 +2520,12 @@ msgstr "" msgid "usage: fdroid [-h|--help|--version] []" msgstr "" -#: ../fdroidserver/server.py ../fdroidserver/upload.py +#: ../fdroidserver/deploy.py ../fdroidserver/upload.py #, python-brace-format msgid "using Apache libcloud to sync with {url}" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py msgid "virustotal.com is rate limiting, waiting to retry..." msgstr "" @@ -2642,7 +2642,7 @@ msgstr "" msgid "{path} is zero size!" msgstr "" -#: ../fdroidserver/server.py +#: ../fdroidserver/deploy.py #, python-brace-format msgid "{path} more than 200MB, manually upload: {url}" msgstr "" diff --git a/tests/server.TestCase b/tests/deploy.TestCase similarity index 83% rename from tests/server.TestCase rename to tests/deploy.TestCase index 4236d6e5..2ce5e500 100755 --- a/tests/server.TestCase +++ b/tests/deploy.TestCase @@ -15,29 +15,29 @@ if localmodule not in sys.path: sys.path.insert(0, localmodule) import fdroidserver.common -import fdroidserver.server +import fdroidserver.deploy from testcommon import TmpCwd -class ServerTest(unittest.TestCase): - '''fdroidserver/server.py''' +class DeployTest(unittest.TestCase): + '''fdroidserver/deploy.py''' def setUp(self): logging.basicConfig(level=logging.DEBUG) self.basedir = os.path.join(localmodule, 'tests') - fdroidserver.server.options = mock.Mock() - fdroidserver.server.config = {} + fdroidserver.deploy.options = mock.Mock() + fdroidserver.deploy.config = {} def test_update_serverwebroot_make_cur_version_link(self): # setup parameters for this test run - fdroidserver.server.options.no_chcksum = True - fdroidserver.server.options.identity_file = None - fdroidserver.server.options.verbose = False - fdroidserver.server.options.quiet = True - fdroidserver.server.options.identity_file = None - fdroidserver.server.config['make_current_version_link'] = True + fdroidserver.deploy.options.no_chcksum = True + fdroidserver.deploy.options.identity_file = None + fdroidserver.deploy.options.verbose = False + fdroidserver.deploy.options.quiet = True + fdroidserver.deploy.options.identity_file = None + fdroidserver.deploy.config['make_current_version_link'] = True serverwebroot = "example.com:/var/www/fdroid" repo_section = 'repo' @@ -86,19 +86,19 @@ class ServerTest(unittest.TestCase): os.symlink('repo/com.example.sym.apk.asc', 'Sym.apk.asc') os.symlink('repo/com.example.sym.apk.sig', 'Sym.apk.sig') with mock.patch('subprocess.call', side_effect=update_server_webroot_call): - fdroidserver.server.update_serverwebroot(serverwebroot, + fdroidserver.deploy.update_serverwebroot(serverwebroot, repo_section) self.assertEqual(call_iteration, 3, 'expected 3 invocations of subprocess.call') def test_update_serverwebroot_with_id_file(self): # setup parameters for this test run - fdroidserver.server.options.no_chcksum = False - fdroidserver.server.options.verbose = True - fdroidserver.server.options.quiet = False - fdroidserver.server.options.identity_file = None - fdroidserver.server.config['identity_file'] = './id_rsa' - fdroidserver.server.config['make_current_version_link'] = False + fdroidserver.deploy.options.no_chcksum = False + fdroidserver.deploy.options.verbose = True + fdroidserver.deploy.options.quiet = False + fdroidserver.deploy.options.identity_file = None + fdroidserver.deploy.config['identity_file'] = './id_rsa' + fdroidserver.deploy.config['make_current_version_link'] = False serverwebroot = "example.com:/var/www/fdroid" repo_section = 'archive' @@ -115,7 +115,7 @@ class ServerTest(unittest.TestCase): '--verbose', '-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' - + fdroidserver.server.config['identity_file'], + + fdroidserver.deploy.config['identity_file'], '--exclude', 'archive/index.xml', '--exclude', 'archive/index.jar', '--exclude', 'archive/index-v1.jar', @@ -129,7 +129,7 @@ class ServerTest(unittest.TestCase): '--verbose', '-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' - + fdroidserver.server.config['identity_file'], + + fdroidserver.deploy.config['identity_file'], 'archive', serverwebroot]) else: @@ -138,15 +138,15 @@ class ServerTest(unittest.TestCase): return 0 with mock.patch('subprocess.call', side_effect=update_server_webroot_call): - fdroidserver.server.update_serverwebroot(serverwebroot, + fdroidserver.deploy.update_serverwebroot(serverwebroot, repo_section) self.assertEqual(call_iteration, 2, 'expected 2 invocations of subprocess.call') @unittest.skipIf(not os.getenv('VIRUSTOTAL_API_KEY'), 'VIRUSTOTAL_API_KEY is not set') def test_upload_to_virustotal(self): - fdroidserver.server.options.verbose = True + fdroidserver.deploy.options.verbose = True virustotal_apikey = os.getenv('VIRUSTOTAL_API_KEY') - fdroidserver.server.upload_to_virustotal('repo', virustotal_apikey) + fdroidserver.deploy.upload_to_virustotal('repo', virustotal_apikey) def test_remote_hostname_regex(self): for remote_url, name in ( @@ -158,7 +158,7 @@ class ServerTest(unittest.TestCase): ): self.assertEqual( name, - fdroidserver.server.REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url) + fdroidserver.deploy.REMOTE_HOSTNAME_REGEX.sub(r'\1', remote_url) ) @@ -171,5 +171,5 @@ if __name__ == "__main__": (fdroidserver.common.options, args) = parser.parse_args(['--verbose']) newSuite = unittest.TestSuite() - newSuite.addTest(unittest.makeSuite(ServerTest)) + newSuite.addTest(unittest.makeSuite(DeployTest)) unittest.main(failfast=False) diff --git a/tests/main.TestCase b/tests/main.TestCase index e05efd95..11e4410b 100755 --- a/tests/main.TestCase +++ b/tests/main.TestCase @@ -42,7 +42,6 @@ class MainTest(unittest.TestCase): 'lint', 'scanner', 'stats', - 'server', 'signindex', 'btlog', 'signatures', @@ -63,7 +62,7 @@ class MainTest(unittest.TestCase): def test_call_deploy(self): co = mock.Mock() with mock.patch('sys.argv', ['', 'deploy', '-h']): - with mock.patch('fdroidserver.server.main', co): + with mock.patch('fdroidserver.deploy.main', co): with mock.patch('sys.exit') as exit_mock: fdroidserver.__main__.main() # note: this is sloppy, if `deploy` changes diff --git a/tests/run-tests b/tests/run-tests index 66b00ed7..ea878c83 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -691,7 +691,7 @@ $fdroid lint $fdroid readmeta $fdroid rewritemeta fake $fdroid deploy -$fdroid server update +$fdroid deploy $fdroid scanner # run these to get their output, but the are not setup, so don't fail @@ -725,26 +725,26 @@ cd $REPOROOT $fdroid init $fdroid update --create-metadata --verbose $fdroid readmeta -$fdroid server update --local-copy-dir=/tmp/fdroid +$fdroid deploy --local-copy-dir=/tmp/fdroid $fdroid deploy --local-copy-dir=/tmp/fdroid --verbose # now test the errors work set +e -$fdroid server update --local-copy-dir=thisisnotanabsolutepath +$fdroid deploy --local-copy-dir=thisisnotanabsolutepath if [ $? -eq 0 ]; then echo "This should have failed because thisisnotanabsolutepath is not an absolute path!" exit 1 else echo "testing absolute path checker passed" fi -$fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf +$fdroid deploy --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf if [ $? -eq 0 ]; then echo "This should have failed because the path does not end with 'fdroid'!" exit 1 else echo "testing dirname exists checker passed" fi -$fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid +$fdroid deploy --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid if [ $? -eq 0 ]; then echo "This should have failed because the dirname path does not exist!" exit 1 @@ -766,12 +766,12 @@ $fdroid readmeta grep -F '> config.py $fdroid update --verbose if have_git_2_3; then - $fdroid server update --verbose + $fdroid deploy --verbose test -e repo/index.xml test -e repo/index.jar test -e repo/index-v1.jar @@ -1204,7 +1204,7 @@ if have_git_2_3; then cd binary_transparency [ `git rev-list --count HEAD` == "1" ] cd .. - $fdroid server update --verbose + $fdroid deploy --verbose grep -F '> config.py @@ -1213,7 +1213,7 @@ if have_git_2_3; then echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py - $fdroid server update --verbose + $fdroid deploy --verbose cd $BINARY_TRANSPARENCY_REMOTE [ `git rev-list --count HEAD` == "1" ] cd $SERVER_GIT_MIRROR