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.
This commit is contained in:
Hans-Christoph Steiner 2018-07-09 22:41:08 +02:00
parent b655d20d6b
commit 5ae2703477
12 changed files with 31 additions and 31 deletions

View file

@ -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