diff --git a/locales/en.json b/locales/en.json index 9c4183adb..d6a17e7f6 100644 --- a/locales/en.json +++ b/locales/en.json @@ -300,6 +300,7 @@ "migration_description_0007_ssh_conf_managed_by_yunohost_step1": "Let the SSH configuration be managed by YunoHost (step 1, automatic)", "migration_description_0008_ssh_conf_managed_by_yunohost_step2": "Let the SSH configuration be managed by YunoHost (step 2, manual)", "migration_description_0009_decouple_regenconf_from_services": "Decouple the regen-conf mechanism from services", + "migration_description_0010_migrate_to_apps_json": "Remove deprecated appslists and use the new unified 'apps.json' list instead", "migration_0003_backward_impossible": "The stretch migration cannot be reverted.", "migration_0003_start": "Starting migration to Stretch. The logs will be available in {logfile}.", "migration_0003_patching_sources_list": "Patching the sources.lists…", diff --git a/src/yunohost/data_migrations/0010_migrate_to_apps_json.py b/src/yunohost/data_migrations/0010_migrate_to_apps_json.py new file mode 100644 index 000000000..442d52492 --- /dev/null +++ b/src/yunohost/data_migrations/0010_migrate_to_apps_json.py @@ -0,0 +1,42 @@ +import os + +from moulinette.utils.log import getActionLogger +from yunohost.app import app_fetchlist, app_removelist, _read_appslist_list, APPSLISTS_JSON +from yunohost.tools import Migration + +logger = getActionLogger('yunohost.migration') + +BASE_CONF_PATH = '/home/yunohost.conf' +BACKUP_CONF_DIR = os.path.join(BASE_CONF_PATH, 'backup') +APPSLISTS_BACKUP = os.path.join(BACKUP_CONF_DIR, "appslist_before_migration_to_unified_list.json") + + +class MyMigration(Migration): + + "Migrate from official.json to apps.json" + + def migrate(self): + + # Backup current app list json + os.system("cp %s %s" % (APPSLISTS_JSON, APPSLISTS_BACKUP)) + + # Remove all the deprecated lists + lists_to_remove = [ + "https://app.yunohost.org/official.json", + "https://app.yunohost.org/community.json", + "https://labriqueinter.net/apps/labriqueinternet.json" + ] + + appslists = _read_appslist_list() + for appslist, infos in appslists.items(): + if infos["url"] in lists_to_remove: + app_removelist(name=appslist) + + # Replace by apps.json list + app_fetchlist(name="yunohost", + url="https://app.yunohost.org/apps.json") + + def backward(self): + + if os.path.exists(APPSLISTS_BACKUP): + os.system("cp %s %s" % (APPSLISTS_BACKUP, APPSLISTS_JSON))