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 0c0d4173..00000000 Binary files a/examples/fdroid-icon.png and /dev/null differ 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