mirror of
https://github.com/YunoHost/yunodevtools.git
synced 2024-09-03 20:16:19 +02:00
commit
da03bddf03
2 changed files with 78 additions and 23 deletions
17
README.md
17
README.md
|
@ -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>
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
<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)
|
||||||
|
|
|
@ -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,18 +111,41 @@ 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')
|
||||||
repo = github_repo.group('repo')
|
repo = github_repo.group('repo')
|
||||||
|
|
||||||
raw_url = 'https://raw.githubusercontent.com/%s/%s/%s/manifest.json' % (
|
raw_url = 'https://raw.githubusercontent.com/%s/%s/%s/manifest.json' % (
|
||||||
owner, repo, app_rev
|
owner, repo, app_rev
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
# Retrieve and load manifest
|
# Retrieve and load manifest
|
||||||
|
@ -100,7 +160,7 @@ for app, info in apps_list.items():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
api_url = 'https://api.github.com/repos/%s/%s/commits/%s' % (
|
api_url = 'https://api.github.com/repos/%s/%s/commits/%s' % (
|
||||||
owner, repo, app_rev
|
owner, repo, app_rev
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
# Retrieve last commit information
|
# Retrieve last commit information
|
||||||
|
@ -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:
|
||||||
|
@ -132,7 +193,7 @@ for app, info in apps_list.items():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
obj_url = '%s/objects/%s/%s' % (
|
obj_url = '%s/objects/%s/%s' % (
|
||||||
app_url, app_rev[0:2], app_rev[2:]
|
app_url, app_rev[0:2], app_rev[2:]
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
# Retrieve last commit information
|
# Retrieve last commit information
|
||||||
|
@ -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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue