From 5d9a62192f02cd27ac3dc0ed93fbd8edcfaced63 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 26 Feb 2019 01:32:52 +0100 Subject: [PATCH 1/5] Migrate to apps.json --- .../0009_migrate_to_apps_json.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/yunohost/data_migrations/0009_migrate_to_apps_json.py diff --git a/src/yunohost/data_migrations/0009_migrate_to_apps_json.py b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py new file mode 100644 index 000000000..364497b46 --- /dev/null +++ b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py @@ -0,0 +1,27 @@ +from moulinette.utils.log import getActionLogger +from yunohost.app import app_fetchlist, app_removelist +from yunohost.tools import Migration + +logger = getActionLogger('yunohost.migration') + +class MyMigration(Migration): + + "Migrate from official.json to apps.json" + + def migrate(self): + + # Remove official.json list + app_removelist(name="yunohost") + + # Replace by apps.json list + app_fetchlist(name="yunohost", + url="https://app.yunohost.org/apps.json") + + def backward(self): + + # Remove apps.json list + app_removelist(name="yunohost") + + # Replace by official.json list + app_fetchlist(name="yunohost", + url="https://app.yunohost.org/official.json") From e2e9a7a0339ae269a239156972595d6ff590cebe Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 22 Mar 2019 17:47:32 +0100 Subject: [PATCH 2/5] Remove all deprecated lists, not just 'yunohost' --- .../0009_migrate_to_apps_json.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/yunohost/data_migrations/0009_migrate_to_apps_json.py b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py index 364497b46..b5ae1130b 100644 --- a/src/yunohost/data_migrations/0009_migrate_to_apps_json.py +++ b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py @@ -1,5 +1,5 @@ from moulinette.utils.log import getActionLogger -from yunohost.app import app_fetchlist, app_removelist +from yunohost.app import app_fetchlist, app_removelist, _read_appslist_list from yunohost.tools import Migration logger = getActionLogger('yunohost.migration') @@ -10,12 +10,21 @@ class MyMigration(Migration): def migrate(self): - # Remove official.json list - app_removelist(name="yunohost") + # 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") + url="https://app.yunohost.org/apps.json") def backward(self): From 93c978ba422b26971180a4277a0b69e82848ee78 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 22 Mar 2019 17:58:46 +0100 Subject: [PATCH 3/5] Backup / restore original appslist to handle backward case properly --- .../0009_migrate_to_apps_json.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/yunohost/data_migrations/0009_migrate_to_apps_json.py b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py index b5ae1130b..8c81746d9 100644 --- a/src/yunohost/data_migrations/0009_migrate_to_apps_json.py +++ b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py @@ -1,15 +1,25 @@ +import os + from moulinette.utils.log import getActionLogger -from yunohost.app import app_fetchlist, app_removelist, _read_appslist_list +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_0009.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", @@ -28,9 +38,5 @@ class MyMigration(Migration): def backward(self): - # Remove apps.json list - app_removelist(name="yunohost") - - # Replace by official.json list - app_fetchlist(name="yunohost", - url="https://app.yunohost.org/official.json") + if os.path.exists(APPSLISTS_BACKUP): + os.system("cp %s %s") % (APPSLISTS_BACKUP, APPSLISTS_JSON) From d6b6fff7064c06ec505de5c5aaf572b776223ce9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 22 Mar 2019 18:00:46 +0100 Subject: [PATCH 4/5] Add description for migration 0009 --- locales/en.json | 1 + 1 file changed, 1 insertion(+) diff --git a/locales/en.json b/locales/en.json index 1157e0a54..2a2db5340 100644 --- a/locales/en.json +++ b/locales/en.json @@ -294,6 +294,7 @@ "migration_description_0006_sync_admin_and_root_passwords": "Synchronize admin and root passwords", "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_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…", From d0df02837347def4b8e9b66c92a2a74937083ff3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 22 Mar 2019 18:06:39 +0100 Subject: [PATCH 5/5] Woopsi typo --- src/yunohost/data_migrations/0009_migrate_to_apps_json.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/yunohost/data_migrations/0009_migrate_to_apps_json.py b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py index 8c81746d9..4f4baa5bd 100644 --- a/src/yunohost/data_migrations/0009_migrate_to_apps_json.py +++ b/src/yunohost/data_migrations/0009_migrate_to_apps_json.py @@ -18,7 +18,7 @@ class MyMigration(Migration): def migrate(self): # Backup current app list json - os.system("cp %s %s") % (APPSLISTS_JSON, APPSLISTS_BACKUP) + os.system("cp %s %s" % (APPSLISTS_JSON, APPSLISTS_BACKUP)) # Remove all the deprecated lists lists_to_remove = [ @@ -39,4 +39,4 @@ class MyMigration(Migration): def backward(self): if os.path.exists(APPSLISTS_BACKUP): - os.system("cp %s %s") % (APPSLISTS_BACKUP, APPSLISTS_JSON) + os.system("cp %s %s" % (APPSLISTS_BACKUP, APPSLISTS_JSON))