Merge pull request #1 from YunoHost/master

update
This commit is contained in:
anmol26s 2017-06-27 00:51:43 +05:30 committed by GitHub
commit da03bddf03
2 changed files with 78 additions and 23 deletions

View file

@ -1,12 +1,12 @@
# YunoHost apps directory # YunoHost apps directory
<img src="https://yunohost.org/logo.png" width=80> <img src="https://yunohost.org/logo.png" width=80>
![roundcube](https://yunohost.org/images/roundcube.png) ![roundcube](https://yunohost.org/images/roundcube.png)
![ttrss](https://yunohost.org/images/ttrss.png) ![ttrss](https://yunohost.org/images/ttrss.png)
![wordpress](https://yunohost.org/images/wordpress.png) ![wordpress](https://yunohost.org/images/wordpress.png)
![transmission](https://yunohost.org/images/transmission.png) ![transmission](https://yunohost.org/images/transmission.png)
![jappix](https://yunohost.org/images/jappix.png) ![jappix](https://yunohost.org/images/jappix.png)
<img src="https://yunohost.org/images/freshrss_logo.png" width=60> <img src="https://yunohost.org/images/freshrss_logo.png" width=60>
<img src="https://yunohost.org/images/Icons_mumble.svg" width=60> <img src="https://yunohost.org/images/Icons_mumble.svg" width=60>
<img src="https://yunohost.org/images/Lutim_small.png" width=50> <img src="https://yunohost.org/images/Lutim_small.png" width=50>
@ -41,26 +41,19 @@ sudo yunohost app fetchlist -n community -u https://yunohost.org/community.json
* Fork and edit the [community list](https://github.com/YunoHost/apps/tree/master/community.json) * Fork and edit the [community list](https://github.com/YunoHost/apps/tree/master/community.json)
* Add your app's ID and git information at the right alphabetical place * Add your app's ID and git information at the right alphabetical place
* Indicate the app's functioning state: `notworking`, `inprogress`, or `ready` * Indicate the app's functioning state: `notworking`, `inprogress`, or `working`
* Send a [Pull Request](https://github.com/YunoHost/apps/pulls/) * Send a [Pull Request](https://github.com/YunoHost/apps/pulls/)
An example app addition: App example addition:
```json ```json
"wallabag": { "wallabag": {
"branch": "master", "branch": "master",
"revision": "c2fc62438ac5c9503e3f4ebfdc425ec03a0ec0c0", "revision": "c2fc62438ac5c9503e3f4ebfdc425ec03a0ec0c0",
"url": "https://github.com/abeudin/wallabag_ynh.git", "url": "https://github.com/abeudin/wallabag_ynh.git",
"state": "ready" "state": "working"
} }
``` ```
#### How to add an app to the official list
Same steps than above, but on the `official.json` list with the status `validated`.
The integration will be discussed on the Pull Request.
**Important**: You will have to find a maintainer willing to take care of the package while published if you want your app to be validated.
#### Helper script #### Helper script
You can use the <code>add_or_update.py</code> python script to add or update You can use the <code>add_or_update.py</code> python script to add or update
@ -69,7 +62,7 @@ your app from one of the 2 json files.
Usage: Usage:
```bash ```bash
python ./add_or_update.py [community.json OR official.json] [github url [github url [github url ...]]] ./add_or_update.py [community.json OR official.json] [github url OR app name [github url OR app name [github url OR app name ...]]]
``` ```
#### More information on [yunohost.org/packaging_apps](https://yunohost.org/packaging_apps) #### More information on [yunohost.org/packaging_apps](https://yunohost.org/packaging_apps)

View file

@ -11,7 +11,7 @@ import requests
from dateutil.parser import parse from dateutil.parser import parse
## Regular expression patterns # Regular expression patterns
"""GitHub repository URL.""" """GitHub repository URL."""
re_github_repo = re.compile( re_github_repo = re.compile(
@ -24,7 +24,7 @@ re_commit_author = re.compile(
) )
## Helpers # Helpers
def fail(msg, retcode=1): def fail(msg, retcode=1):
"""Show failure message and exit.""" """Show failure message and exit."""
@ -32,7 +32,37 @@ def fail(msg, retcode=1):
sys.exit(retcode) sys.exit(retcode)
## Main def include_translations_in_manifest(app_name, manifest):
for i in os.listdir("locales"):
if not i.endswith("json"):
continue
if i == "en.json":
continue
current_lang = i.split(".")[0]
translations = json.load(open(os.path.join("locales", i), "r"))
key = "%s_manifest_description" % app_name
if key in translations and translations[key]:
manifest["description"][current_lang] = translations[key]
for category, questions in manifest["arguments"].items():
for question in questions:
key = "%s_manifest_arguments_%s_%s" % (app_name, category, question["name"])
if key in translations and translations[key]:
print "[ask]", current_lang, key
question["ask"][current_lang] = translations[key]
key = "%s_manifest_arguments_%s_help_%s" % (app_name, category, question["name"])
if key in translations and translations[key]:
print "[help]", current_lang, key
question["help"][current_lang] = translations[key]
return manifest
# Main
# Create argument parser # Create argument parser
parser = argparse.ArgumentParser(description='Process YunoHost application list.') parser = argparse.ArgumentParser(description='Process YunoHost application list.')
@ -60,6 +90,13 @@ print(":: Building %s list..." % list_name)
if not args.output: if not args.output:
args.output = '%s-build.json' % list_name args.output = '%s-build.json' % list_name
already_built_file = {}
if os.path.exists(args.output):
try:
already_built_file = json.load(open(args.output))
except Exception as e:
print("Error while trying to load already built file: %s" % e)
# GitHub credentials # GitHub credentials
if args.github: if args.github:
token = (args.github.split(':')[0], args.github.split(':')[1]) token = (args.github.split(':')[0], args.github.split(':')[1])
@ -74,11 +111,34 @@ for app, info in apps_list.items():
# Store usefull values # Store usefull values
app_url = info['url'] app_url = info['url']
app_rev = info['revision'] app_rev = info['revision']
app_state = info["state"]
app_level = info.get("level")
previous_state = already_built_file.get(app, {}).get("state", {})
manifest = {} manifest = {}
timestamp = None timestamp = None
## Hosted on GitHub previous_rev = already_built_file.get(app, {}).get("git", {}).get("revision", None)
previous_url = already_built_file.get(app, {}).get("git", {}).get("url")
previous_level = already_built_file.get(app, {}).get("level")
if previous_rev == app_rev and previous_url == app_url:
print("%s[%s] is already up to date in target output, ignore" % (app, app_rev))
result_dict[app] = already_built_file[app]
if previous_state != app_state:
result_dict[app]["state"] = app_state
print("... but has changed of state, updating it from '%s' to '%s'" % (previous_state, app_state))
if previous_level != app_level or app_level is None:
result_dict[app]["level"] = app_level
print("... but has changed of level, updating it from '%s' to '%s'" % (previous_level, app_level))
print "update translations but don't download anything"
result_dict[app]['manifest'] = include_translations_in_manifest(app, result_dict[app]['manifest'])
continue
# Hosted on GitHub
github_repo = re_github_repo.match(app_url) github_repo = re_github_repo.match(app_url)
if github_repo: if github_repo:
owner = github_repo.group('owner') owner = github_repo.group('owner')
@ -116,7 +176,8 @@ for app, info in apps_list.items():
else: else:
commit_date = parse(info2['commit']['author']['date']) commit_date = parse(info2['commit']['author']['date'])
timestamp = int(time.mktime(commit_date.timetuple())) timestamp = int(time.mktime(commit_date.timetuple()))
## Git repository with HTTP/HTTPS (Gogs, GitLab, ...)
# Git repository with HTTP/HTTPS (Gogs, GitLab, ...)
elif app_url.startswith('http') and app_url.endswith('.git'): elif app_url.startswith('http') and app_url.endswith('.git'):
raw_url = '%s/raw/%s/manifest.json' % (app_url[:-4], app_rev) raw_url = '%s/raw/%s/manifest.json' % (app_url[:-4], app_rev)
try: try:
@ -179,15 +240,16 @@ for app, info in apps_list.items():
'url': app_url 'url': app_url
}, },
'lastUpdate': timestamp, 'lastUpdate': timestamp,
'manifest': manifest, 'manifest': include_translations_in_manifest(manifest['id'], manifest),
'state': info['state'] 'state': info['state'],
'level': info.get('level', '?')
} }
except KeyError as e: except KeyError as e:
print("-> Error: invalid app info or manifest, %s" % e) print("-> Error: invalid app info or manifest, %s" % e)
continue continue
# Write resulting file # Write resulting file
with open(args.output , 'w') as f: with open(args.output, 'w') as f:
f.write(json.dumps(result_dict, sort_keys=True)) f.write(json.dumps(result_dict, sort_keys=True))
print("\nDone! Written in %s" % args.output) print("\nDone! Written in %s" % args.output)