From 5ae2703477e554cb3236ab7ce862b8c2814d7db6 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 9 Jul 2018 22:41:08 +0200 Subject: [PATCH 1/4] init: no error if examples/ dir cannot be found; overhaul repo_icon There are so many possible installation paths for Python modules, it has been very hard to even find and test them all. This adds a fallback option if the examples dir cannot be found. A repo can work without an icon or the example config.py. This removes the fake assumption that the icon can be a full path in the config.py. While the path was being properly passed through to the index file, the file was never copied properly into place nor rsynced to the web server. --- MANIFEST.in | 1 - examples/config.yml | 11 +++++++++-- examples/fdroid-icon.png | Bin 3367 -> 0 bytes fdroidserver/common.py | 4 ++-- fdroidserver/index.py | 8 ++++---- fdroidserver/init.py | 13 +++++++++++-- fdroidserver/nightly.py | 12 +----------- fdroidserver/update.py | 5 ++--- tests/config.py | 2 -- tests/repo/index-v1.json | 2 +- tests/repo/index.xml | 2 +- tests/run-tests | 2 -- 12 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 examples/fdroid-icon.png diff --git a/MANIFEST.in b/MANIFEST.in index 48e4830a..4a14e8ad 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -13,7 +13,6 @@ include examples/fdroid_exportkeystore.py include examples/fdroid_export_keystore_to_nitrokey.py include examples/fdroid_extract_repo_pubkey.py include examples/fdroid_fetchsrclibs.py -include examples/fdroid-icon.png include examples/fdroid_nitrokeyimport.py include examples/makebuildserver.config.py include examples/opensc-fdroid.cfg diff --git a/examples/config.yml b/examples/config.yml index db93de9d..7b009fde 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -54,7 +54,6 @@ repo_url: https://MyFirstFDroidRepo.org/fdroid/repo repo_name: My First F-Droid Repo Demo -repo_icon: fdroid-icon.png repo_description: >- This is a repository of apps to be used with F-Droid. Applications in this repository are either official binaries built by the original application @@ -68,10 +67,18 @@ repo_description: >- archive_older: 3 archive_url: https://f-droid.org/archive archive_name: My First F-Droid Archive Demo -archive_icon: fdroid-icon.png archive_description: >- The repository of older versions of packages from the main demo repository. +# The repo's icon defaults to a file called 'icon.png' in the 'icons' +# folder for each section, e.g. repo/icons/icon.png and +# archive/icons/icon.png. To use a different filename for the icons, +# set the filename here. You must still copy it into place in +# repo/icons/ and/or archive/icons/. +# +# repo_icon: myicon.png +# archive_icon: myicon.png + # This allows a specific kind of insecure APK to be included in the # 'repo' section. Since April 2017, APK signatures that use MD5 are # no longer considered valid, jarsigner and apksigner will return an diff --git a/examples/fdroid-icon.png b/examples/fdroid-icon.png deleted file mode 100644 index 0c0d41738f054eaa77bba0ef0785e87227aa2692..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3367 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 diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 22a4f3ff..4218ef48 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -147,7 +147,7 @@ default_config = { 'keyaliases': {}, 'repo_url': "https://MyFirstFDroidRepo.org/fdroid/repo", 'repo_name': "My First FDroid Repo Demo", - 'repo_icon': "fdroid-icon.png", + 'repo_icon': "icon.png", '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 @@ -228,7 +228,7 @@ def fill_config_defaults(thisconfig): return None return path - for k in ['sdk_path', 'ant', 'mvn3', 'gradle', 'keystore', 'repo_icon']: + for k in ['sdk_path', 'ant', 'mvn3', 'gradle', 'keystore']: v = thisconfig[k] exp = expand_path(v) if exp is not None: diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 95b46ed5..6eae6ffe 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -75,13 +75,13 @@ def make(apps, apks, repodir, archive): if archive: repodict['name'] = common.config['archive_name'] - repodict['icon'] = os.path.basename(common.config['archive_icon']) + repodict['icon'] = common.config.get('archive_icon', common.default_config['repo_icon']) repodict['address'] = common.config['archive_url'] repodict['description'] = common.config['archive_description'] urlbasepath = os.path.basename(urllib.parse.urlparse(common.config['archive_url']).path) else: repodict['name'] = common.config['repo_name'] - repodict['icon'] = os.path.basename(common.config['repo_icon']) + repodict['icon'] = common.config.get('repo_icon', common.default_config['repo_icon']) repodict['address'] = common.config['repo_url'] repodict['description'] = common.config['repo_description'] urlbasepath = os.path.basename(urllib.parse.urlparse(common.config['repo_url']).path) @@ -331,7 +331,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fing doc.appendChild(root) repoel = doc.createElement("repo") - repoel.setAttribute("icon", os.path.basename(repodict['icon'])) + repoel.setAttribute("icon", repodict['icon']) if 'maxage' in repodict: repoel.setAttribute("maxage", str(repodict['maxage'])) repoel.setAttribute("name", repodict['name']) @@ -604,7 +604,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fing if os.path.exists(repo_icon): shutil.copyfile(common.config['repo_icon'], iconfilename) else: - logging.warning(_('repo_icon %s does not exist, generating placeholder.') + logging.warning(_('repo_icon "repo/icons/%s" does not exist, generating placeholder.') % repo_icon) os.makedirs(os.path.dirname(iconfilename), exist_ok=True) try: diff --git a/fdroidserver/init.py b/fdroidserver/init.py index 53eac796..7f9fc817 100644 --- a/fdroidserver/init.py +++ b/fdroidserver/init.py @@ -120,8 +120,17 @@ def main(): # 'metadata' and 'tmp' are created in fdroid if not os.path.exists('repo'): os.mkdir('repo') - shutil.copy(os.path.join(examplesdir, 'fdroid-icon.png'), fdroiddir) - shutil.copyfile(os.path.join(examplesdir, 'config.yml'), 'config.yml') + example_config_yml = os.path.join(examplesdir, 'config.yml') + if os.path.exists(example_config_yml): + shutil.copyfile(example_config_yml, 'config.yml') + else: + from pkg_resources import get_distribution + versionstr = get_distribution('fdroidserver').version + if not versionstr: + versionstr = 'master' + with open('config.yml', 'w') as fp: + fp.write('# see https://gitlab.com/fdroid/fdroidserver/blob/' + + versionstr + '/examples/config.yml\n') os.chmod('config.yml', 0o0600) # If android_home is None, test_config['sdk_path'] will be used and # "$ANDROID_HOME" may be used if the env var is set up correctly. diff --git a/fdroidserver/nightly.py b/fdroidserver/nightly.py index 63e7d131..50239e20 100644 --- a/fdroidserver/nightly.py +++ b/fdroidserver/nightly.py @@ -192,7 +192,7 @@ def main(): readme = ''' # {repo_git_base} -[![{repo_url}](icon.png)]({repo_url}) +[![{repo_url}]({repo_url}/icons/icon.png)]({repo_url}) Last updated: {date}'''.format(repo_git_base=repo_git_base, repo_url=repo_url, @@ -202,16 +202,8 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base, mirror_git_repo.git.add(all=True) mirror_git_repo.index.commit("update README") - icon_path = os.path.join(git_mirror_path, 'icon.png') - try: - import qrcode - qrcode.make(repo_url).save(icon_path) - except Exception: - exampleicon = os.path.join(common.get_examples_dir(), 'fdroid-icon.png') - shutil.copy(exampleicon, icon_path) mirror_git_repo.git.add(all=True) mirror_git_repo.index.commit("update repo/website icon") - shutil.copy(icon_path, repo_basedir) os.chdir(repo_basedir) if os.path.isdir(git_mirror_repodir): @@ -234,11 +226,9 @@ Last updated: {date}'''.format(repo_git_base=repo_git_base, config += "identity_file = '%s'\n" % ssh_private_key_file config += "repo_name = '%s'\n" % repo_git_base config += "repo_url = '%s'\n" % repo_url - config += "repo_icon = 'icon.png'\n" config += "repo_description = 'Nightly builds from %s'\n" % git_user_email config += "archive_name = '%s'\n" % (repo_git_base + ' archive') config += "archive_url = '%s'\n" % (repo_base + '/archive') - config += "archive_icon = 'icon.png'\n" config += "archive_description = 'Old nightly builds that have been archived.'\n" config += "archive_older = %i\n" % options.archive_older config += "servergitmirrors = '%s'\n" % servergitmirror diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 8679b134..983bdb79 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -2244,9 +2244,8 @@ def main(): for k in ['repo_icon', 'archive_icon']: if k in config: if not os.path.exists(config[k]): - logging.critical(_('{name} "{path}" does not exist! Correct it in config.py.') - .format(name=k, path=config[k])) - sys.exit(1) + logging.warning(_('{name} "{section}/icons/{path}" does not exist! Check "config.yml".') + .format(name=k, section=k.split('_')[0], path=config[k])) # if the user asks to create a keystore, do it now, reusing whatever it can if options.create_key: diff --git a/tests/config.py b/tests/config.py index ead06f91..fde7e973 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,7 +1,6 @@ repo_url = "https://MyFirstFDroidRepo.org/fdroid/repo" repo_name = "My First F-Droid Repo Demo" -repo_icon = "fdroid-icon.png" repo_description = """ This is a repository of apps to be used with F-Droid. Applications in this repository are either official binaries built by the original application @@ -12,7 +11,6 @@ using the tools on https://gitlab.com/u/fdroid. archive_older = 3 archive_url = "https://f-droid.org/archive" archive_name = "My First F-Droid Archive Demo" -archive_icon = "fdroid-icon.png" archive_description = """ The repository of older versions of applications from the main demo repository. """ diff --git a/tests/repo/index-v1.json b/tests/repo/index-v1.json index 5ad2ffe6..923384eb 100644 --- a/tests/repo/index-v1.json +++ b/tests/repo/index-v1.json @@ -3,7 +3,7 @@ "timestamp": 1502845383782, "version": 20000, "name": "My First F-Droid Repo Demo", - "icon": "fdroid-icon.png", + "icon": "icon.png", "address": "https://MyFirstFDroidRepo.org/fdroid/repo", "description": "This is a repository of apps to be used with F-Droid. 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.", "mirrors": [ diff --git a/tests/repo/index.xml b/tests/repo/index.xml index 6f9ed101..557be383 100644 --- a/tests/repo/index.xml +++ b/tests/repo/index.xml @@ -1,6 +1,6 @@ - + This is a repository of apps to be used with F-Droid. 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. http://foobarfoobarfoobar.onion/fdroid/repo https://foo.bar/fdroid/repo diff --git a/tests/run-tests b/tests/run-tests index 935ceb8e..3e475814 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -228,7 +228,6 @@ echo_header 'copy git import and run "fdroid scanner" on it' REPOROOT=`create_test_dir` cd $REPOROOT -cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/ mkdir metadata echo "AutoName: Just A Test" > metadata/org.fdroid.ci.test.app.yml echo "WebSite: " >> metadata/org.fdroid.ci.test.app.yml @@ -942,7 +941,6 @@ echo_header "setup a new repo manually and generate a keystore" REPOROOT=`create_test_dir` KEYSTORE=$REPOROOT/keystore.p12 cd $REPOROOT -cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/ ! test -e $KEYSTORE set +e $fdroid update From f6b5f74ec61f1f81f9a59067be9527be59e328ec Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 22 Jan 2021 22:12:17 +0100 Subject: [PATCH 2/4] gitlab-ci: drop support for Ubuntu/xenial, test on bionic now xenial will become obsolete in April --- .gitlab-ci.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dbfc219f..d4f93712 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -84,7 +84,7 @@ debian_testing: - ./run-tests # Test using latest LTS set up with the PPA, including Recommends. -# bionic's apksigner, which comes from Recommends:, requires binfmt +# focal's apksigner, which comes from Recommends:, requires binfmt # support in the kernel. ubuntu_lts_ppa: image: ubuntu:latest @@ -106,13 +106,11 @@ ubuntu_lts_ppa: - cd tests - ./run-tests -# Test using Xenial LTS with all depends from pypi. The venv is used -# to isolate the dist tarball generation environment from the clean -# install environment. Xenial's pip is too old to install all the -# dependencies, so this has to uppgrade pip and setuptools in order to -# run the install. -ubuntu_xenial_pip: - image: ubuntu:xenial +# Test using Ubuntu/bionic LTS (supported til 2022) with all depends +# from pypi. The venv is used to isolate the dist tarball generation +# environment from the clean install environment. +ubuntu_bionic_pip: + image: ubuntu:bionic <<: *apt-template script: - apt-get install git default-jdk-headless python3-pip python3-venv rsync zipalign libarchive13 @@ -127,9 +125,8 @@ ubuntu_xenial_pip: - deactivate - tar tzf dist/fdroidserver-*.tar.gz | grep locale/de/LC_MESSAGES/fdroidserver.mo # back to bare machine to act as user's install machine - - $pip install --upgrade pip setuptools + - $pip install --upgrade pip setuptools wheel # make this go away: "error: invalid command 'bdist_wheel'" - $pip install dist/fdroidserver-*.tar.gz - - test -e /usr/share/locale/de/LC_MESSAGES/fdroidserver.mo - tar xzf dist/fdroidserver-*.tar.gz - cd fdroidserver-* - ./tests/run-tests From aebf70a76349f1d4a919ce9f24c43a4d0644d60d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 23 Jan 2021 13:36:41 +0100 Subject: [PATCH 3/4] tests: run pip tests using fdroid that pip installed --- .gitlab-ci.yml | 2 +- tests/update.TestCase | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4f93712..26c900ad 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -129,7 +129,7 @@ ubuntu_bionic_pip: - $pip install dist/fdroidserver-*.tar.gz - tar xzf dist/fdroidserver-*.tar.gz - cd fdroidserver-* - - ./tests/run-tests + - fdroid=`which fdroid` ./tests/run-tests # test install process on a bleeding edge distro with pip arch_pip_install: diff --git a/tests/update.TestCase b/tests/update.TestCase index ffc8fa5f..19b7436e 100755 --- a/tests/update.TestCase +++ b/tests/update.TestCase @@ -830,8 +830,17 @@ class UpdateTest(unittest.TestCase): # yaml.add_representer(fdroidserver.metadata.Build, _build_yaml_representer) # yaml.dump(apk, f, default_flow_style=False) + # CFullLoader doesn't always work + # https://github.com/yaml/pyyaml/issues/266#issuecomment-559116876 + TestLoader = FullLoader + try: + testyaml = '- !!python/object/new:fdroidserver.update.UsesPermission\n - test\n - null' + from_yaml = yaml.load(testyaml, Loader=TestLoader) + except yaml.constructor.ConstructorError: + from yaml import UnsafeLoader as TestLoader + with open(savepath, 'r') as f: - from_yaml = yaml.load(f, Loader=FullLoader) + from_yaml = yaml.load(f, Loader=TestLoader) self.maxDiff = None self.assertEqual(apk, from_yaml) From f527b177153a1c89e465d39eafb1adfd0ea8fce3 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 23 Jan 2021 19:36:15 +0100 Subject: [PATCH 4/4] sync repo examples with defaults and comment out example repo settings !359 --- CHANGELOG.md | 1 + examples/config.yml | 28 ++++++++++++++++------------ fdroidserver/common.py | 10 +++------- fdroidserver/index.py | 5 +++-- tests/repo/index-v1.json | 2 +- tests/repo/index.xml | 2 +- tests/run-tests | 12 ++++++++---- 7 files changed, 33 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b76fe549..7d6497e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ milestone](https://gitlab.com/fdroid/fdroidserver/-/milestones/10) ([!692](https://gitlab.com/fdroid/fdroidserver/-/merge_requests/692)) * Major refactoring on core parts of code to be more Pythonic ([!756](https://gitlab.com/fdroid/fdroidserver/-/merge_requests/756)) +* `fdroid init` now works when installed with pip ### Removed * Removed all support for _.txt_ and _.json_ metadata diff --git a/examples/config.yml b/examples/config.yml index 7b009fde..ac1e44a0 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -52,23 +52,27 @@ # The same policy is applied to the archive repo, if there is one. # repo_maxage: 0 -repo_url: https://MyFirstFDroidRepo.org/fdroid/repo -repo_name: My First F-Droid Repo Demo -repo_description: >- - This is a repository of apps to be used with F-Droid. 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. +# repo_url: https://MyFirstFDroidRepo.org/fdroid/repo +# repo_name: My First F-Droid Repo Demo +# repo_description: >- +# This is a repository of apps to be used with F-Droid. 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/fdroid. # As above, but for the archive repo. +# +# archive_url: https://f-droid.org/archive +# archive_name: My First F-Droid Archive Demo +# archive_description: >- +# The repository of older versions of packages from the main demo repository. + # archive_older sets the number of versions kept in the main repo, with all # older ones going to the archive. Set it to 0, and there will be no archive # repository, and no need to define the other archive_ values. -archive_older: 3 -archive_url: https://f-droid.org/archive -archive_name: My First F-Droid Archive Demo -archive_description: >- - The repository of older versions of packages from the main demo repository. +# +# archive_older: 3 # The repo's icon defaults to a file called 'icon.png' in the 'icons' # folder for each section, e.g. repo/icons/icon.png and diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 4218ef48..3fe24c23 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -146,14 +146,10 @@ default_config = { }, 'keyaliases': {}, 'repo_url': "https://MyFirstFDroidRepo.org/fdroid/repo", - 'repo_name': "My First FDroid Repo Demo", + 'repo_name': "My First F-Droid Repo Demo", 'repo_icon': "icon.png", - '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 f-droid.org using the - tools on https://gitlab.com/fdroid. - '''), + 'repo_description': _("""This is a repository of apps to be used with F-Droid. 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/fdroid."""), + 'archive_name': 'My First F-Droid Archive Demo', 'archive_description': _('These are the apps that have been archived from the main repo.'), 'archive_older': 0, 'lint_licenses': fdroidserver.lint.APPROVED_LICENSES, diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 6eae6ffe..d6d396a5 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -76,9 +76,10 @@ def make(apps, apks, repodir, archive): if archive: repodict['name'] = common.config['archive_name'] repodict['icon'] = common.config.get('archive_icon', common.default_config['repo_icon']) - repodict['address'] = common.config['archive_url'] repodict['description'] = common.config['archive_description'] - urlbasepath = os.path.basename(urllib.parse.urlparse(common.config['archive_url']).path) + archive_url = common.config.get('archive_url', common.config['repo_url'][:-4] + 'archive') + repodict['address'] = archive_url + urlbasepath = os.path.basename(urllib.parse.urlparse(archive_url).path) else: repodict['name'] = common.config['repo_name'] repodict['icon'] = common.config.get('repo_icon', common.default_config['repo_icon']) diff --git a/tests/repo/index-v1.json b/tests/repo/index-v1.json index 923384eb..6ca6d559 100644 --- a/tests/repo/index-v1.json +++ b/tests/repo/index-v1.json @@ -5,7 +5,7 @@ "name": "My First F-Droid Repo Demo", "icon": "icon.png", "address": "https://MyFirstFDroidRepo.org/fdroid/repo", - "description": "This is a repository of apps to be used with F-Droid. 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.", + "description": "This is a repository of apps to be used with F-Droid. 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/fdroid.", "mirrors": [ "http://foobarfoobarfoobar.onion/fdroid/repo", "https://foo.bar/fdroid/repo" diff --git a/tests/repo/index.xml b/tests/repo/index.xml index 557be383..69b09bcf 100644 --- a/tests/repo/index.xml +++ b/tests/repo/index.xml @@ -1,7 +1,7 @@ - This is a repository of apps to be used with F-Droid. 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. + This is a repository of apps to be used with F-Droid. 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/fdroid. http://foobarfoobarfoobar.onion/fdroid/repo https://foo.bar/fdroid/repo diff --git a/tests/run-tests b/tests/run-tests index 3e475814..693c89e6 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -309,7 +309,7 @@ cp $WORKSPACE/tests/urzip.apk \ $WORKSPACE/tests/repo/com.politedroid_[0-9].apk \ $WORKSPACE/tests/repo/obb.main.twoversions_110161[357].apk \ repo/ -$sed -i.tmp 's,archive_older: [0-9],archive_older: 3,' config.yml +printf '\narchive_older: 3\n' >> config.yml $fdroid update --pretty --nosign if which apksigner; then @@ -332,7 +332,7 @@ if ! which apksigner; then cp $WORKSPACE/tests/metadata/com.politedroid.yml metadata/ test -d repo || mkdir repo cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/ - $sed -i.tmp 's,archive_older: [0-9],archive_older: 3,' config.yml + printf '\narchive_older: 3\n' >> config.yml $fdroid update --pretty --nosign test `grep '' archive/index.xml | wc -l` -eq 0 @@ -418,7 +418,7 @@ cp $WORKSPACE/tests/metadata/com.politedroid.yml metadata/ $sed -i.tmp '/ArchivePolicy:/d' metadata/com.politedroid.yml test -d repo || mkdir repo cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/ -$sed -i.tmp 's,archive_older: [0-9],archive_older: 3,' config.yml +printf '\narchive_older: 3\n' >> config.yml $fdroid update --pretty --nosign test `grep '' archive/index.xml | wc -l` -eq 1 @@ -494,7 +494,7 @@ REPOROOT=`create_test_dir` cd $REPOROOT fdroid_init_with_prebuilt_keystore echo 'allow_disabled_algorithms: true' >> config.yml -$sed -i.tmp 's,archive_older: [0-9],archive_older: 3,' config.yml +printf '\narchive_older: 3\n' >> config.yml test -d metadata || mkdir metadata cp $WORKSPACE/tests/metadata/com.politedroid.yml metadata/ echo 'Summary: good test version of urzip' > metadata/info.guardianproject.urzip.yml @@ -615,6 +615,7 @@ echo_header "test for added date being set correctly for repo and archive" REPOROOT=`create_test_dir` cd $REPOROOT fdroid_init_with_prebuilt_keystore +printf '\narchive_older: 3\n' >> config.yml mkdir -p {repo,archive,metadata,stats} cp $WORKSPACE/tests/repo/com.politedroid_5.apk archive cp $WORKSPACE/tests/repo/com.politedroid_6.apk repo @@ -1125,6 +1126,7 @@ REPOROOT=`create_test_dir` 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 cp $WORKSPACE/tests/repo/com.politedroid_[345].apk repo/ @@ -1193,6 +1195,7 @@ if have_git_2_3; then cd $OFFLINE_ROOT fdroid_init_with_prebuilt_keystore + printf '\narchive_older: 3\n' >> config.yml cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $OFFLINE_ROOT/ echo "mirrors: ['http://foo.bar/fdroid', 'http://asdflkdsfjafdsdfhkjh.onion/fdroid']" >> config.yml @@ -1282,6 +1285,7 @@ if which wget; then # clean up kill -9 $http_server_pid rm -f 127.0.0.1\:${port}/repo/*.apk 127.0.0.1\:${port}/repo/*/*/*/*.png + sleep 1 # wait for webserver thread to quit else echo "WARNING: wget not installed, skipping" fi