From 473bff6e5dfeecd744d5fb88d686867669a1e722 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 31 May 2021 18:46:28 +0200 Subject: [PATCH 01/12] Draft for bullseye migration --- .../0021_migrate_to_bullseye.py | 252 ++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 src/yunohost/data_migrations/0021_migrate_to_bullseye.py diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py new file mode 100644 index 000000000..289e9d765 --- /dev/null +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -0,0 +1,252 @@ +import glob +import os + +from moulinette import m18n +from yunohost.utils.error import YunohostError +from moulinette.utils.log import getActionLogger +from moulinette.utils.process import check_output, call_async_output +from moulinette.utils.filesystem import read_file + +from yunohost.tools import Migration, tools_update, tools_upgrade +from yunohost.app import unstable_apps +from yunohost.regenconf import manually_modified_files +from yunohost.utils.filesystem import free_space_in_directory +from yunohost.utils.packages import ( + get_ynh_package_version, + _list_upgradable_apt_packages, +) + +logger = getActionLogger("yunohost.migration") + +N_CURRENT_DEBIAN = 10 +N_CURRENT_YUNOHOST = 4 + +N_NEXT_DEBAN = 11 +N_NEXT_YUNOHOST == 11 + +class MyMigration(Migration): + + "Upgrade the system to Debian Bullseye and Yunohost 11.x" + + mode = "manual" + + def run(self): + + self.check_assertions() + + logger.info(m18n.n("migration_0021_start")) + + # + # Patch sources.list + # + logger.info(m18n.n("migration_0021_patching_sources_list")) + self.patch_apt_sources_list() + tools_update(target="system") + + # Tell libc6 it's okay to restart system stuff during the upgrade + os.system( + "echo 'libc6 libraries/restart-without-asking boolean true' | debconf-set-selections" + ) + + # Don't send an email to root about the postgresql migration. It should be handled automatically after. + os.system( + "echo 'postgresql-common postgresql-common/obsolete-major seen true' | debconf-set-selections" + ) + + # + # Specific packages upgrades + # + logger.info(m18n.n("migration_0021_specific_upgrade")) + + # + # Main upgrade + # + logger.info(m18n.n("migration_0021_main_upgrade")) + + self.patch_yunohost_conflicts() + + apps_packages = self.get_apps_equivs_packages() + self.hold(apps_packages) + tools_upgrade(target="system", allow_yunohost_upgrade=False) + + if self.debian_major_version() == N_CURRENT_DEBIAN: + raise YunohostError("migration_0021_still_on_buster_after_main_upgrade") + + # Clean the mess + logger.info(m18n.n("migration_0021_cleaning_up")) + os.system("apt autoremove --assume-yes") + os.system("apt clean --assume-yes") + + # + # Yunohost upgrade + # + logger.info(m18n.n("migration_0021_yunohost_upgrade")) + self.unhold(apps_packages) + tools_upgrade(target="system") + + def debian_major_version(self): + # The python module "platform" and lsb_release are not reliable because + # on some setup, they may still return Release=9 even after upgrading to + # buster ... (Apparently this is related to OVH overriding some stuff + # with /etc/lsb-release for instance -_-) + # Instead, we rely on /etc/os-release which should be the raw info from + # the distribution... + return int( + check_output( + "grep VERSION_ID /etc/os-release | head -n 1 | tr '\"' ' ' | cut -d ' ' -f2" + ) + ) + + def yunohost_major_version(self): + return int(get_ynh_package_version("yunohost")["version"].split(".")[0]) + + def check_assertions(self): + + # Be on buster (10.x) and yunohost 4.x + # NB : we do both check to cover situations where the upgrade crashed + # in the middle and debian version could be > 9.x but yunohost package + # would still be in 3.x... + if ( + not self.debian_major_version() == N_CURRENT_DEBIAN + and not self.yunohost_major_version() == N_CURRENT_YUNOHOST + ): + raise YunohostError("migration_0021_not_buster") + + # Have > 1 Go free space on /var/ ? + if free_space_in_directory("/var/") / (1024 ** 3) < 1.0: + raise YunohostError("migration_0021_not_enough_free_space") + + # Check system is up to date + # (but we don't if 'bullseye' is already in the sources.list ... + # which means maybe a previous upgrade crashed and we're re-running it) + if " bullseye " not in read_file("/etc/apt/sources.list"): + tools_update(target="system") + upgradable_system_packages = list(_list_upgradable_apt_packages()) + if upgradable_system_packages: + raise YunohostError("migration_0021_system_not_fully_up_to_date") + + @property + def disclaimer(self): + + # Avoid having a super long disclaimer + uncessary check if we ain't + # on buster / yunohost 4.x anymore + # NB : we do both check to cover situations where the upgrade crashed + # in the middle and debian version could be >= 10.x but yunohost package + # would still be in 4.x... + if ( + not self.debian_major_version() == N_CURRENT_DEBIAN + and not self.yunohost_major_version() == N_CURRENT_YUNOHOST + ): + return None + + # Get list of problematic apps ? I.e. not official or community+working + problematic_apps = unstable_apps() + problematic_apps = "".join(["\n - " + app for app in problematic_apps]) + + # Manually modified files ? (c.f. yunohost service regen-conf) + modified_files = manually_modified_files() + modified_files = "".join(["\n - " + f for f in modified_files]) + + message = m18n.n("migration_0021_general_warning") + + # FIXME: re-enable this message with updated topic link once we release the migration as stable + #message = ( + # "N.B.: This migration has been tested by the community over the last few months but has only been declared stable recently. If your server hosts critical services and if you are not too confident with debugging possible issues, we recommend you to wait a little bit more while we gather more feedback and polish things up. If on the other hand you are relatively confident with debugging small issues that may arise, you are encouraged to run this migration ;)! You can read about remaining known issues and feedback from the community here: https://forum.yunohost.org/t/12195\n\n" + # + message + #) + + if problematic_apps: + message += "\n\n" + m18n.n( + "migration_0021_problematic_apps_warning", + problematic_apps=problematic_apps, + ) + + if modified_files: + message += "\n\n" + m18n.n( + "migration_0021_modified_files", manually_modified_files=modified_files + ) + + return message + + def patch_apt_sources_list(self): + + sources_list = glob.glob("/etc/apt/sources.list.d/*.list") + sources_list.append("/etc/apt/sources.list") + + # This : + # - replace single 'buster' occurence by 'bulleye' + # - comments lines containing "backports" + # - replace 'buster/updates' by 'bullseye/updates' (or same with -) + for f in sources_list: + command = ( + f"sed -i {f} " + "-e 's@ buster @ bullseye @g' " + "-e '/backports/ s@^#*@#@' " + "-e 's@ buster/updates @ bullseye/updates @g' " + "-e 's@ buster-@ bullseye-@g' " + ) + os.system(command) + + def get_apps_equivs_packages(self): + + command = ( + "dpkg --get-selections" + " | grep -v deinstall" + " | awk '{print $1}'" + " | { grep 'ynh-deps$' || true; }" + ) + + output = check_output(command) + + return output.split("\n") if output else [] + + def hold(self, packages): + for package in packages: + os.system("apt-mark hold {}".format(package)) + + def unhold(self, packages): + for package in packages: + os.system("apt-mark unhold {}".format(package)) + + def apt_install(self, cmd): + def is_relevant(line): + return "Reading database ..." not in line.rstrip() + + callbacks = ( + lambda l: logger.info("+ " + l.rstrip() + "\r") + if is_relevant(l) + else logger.debug(l.rstrip() + "\r"), + lambda l: logger.warning(l.rstrip()), + ) + + cmd = ( + "LC_ALL=C DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none apt install --quiet -o=Dpkg::Use-Pty=0 --fix-broken --assume-yes " + + cmd + ) + + logger.debug("Running: %s" % cmd) + + call_async_output(cmd, callbacks, shell=True) + + + def patch_yunohost_conflicts(self): + # + # This is a super dirty hack to remove the conflicts from yunohost's debian/control file + # Those conflicts are there to prevent mistakenly upgrading critical packages + # such as dovecot, postfix, nginx, openssl, etc... usually related to mistakenly + # using backports etc. + # + # The hack consists in savagely removing the conflicts directly in /var/lib/dpkg/status + # + + # We only patch the conflict if we're on yunohost 4.x + if self.yunohost_major_version() != N_CURRENT_YUNOHOST: + return + + conflicts = check_output("dpkg-query -s yunohost | grep '^Conflicts:'").strip() + if conflicts: + # We want to keep conflicting with apache/bind9 tho + new_conflicts = "Conflicts: apache2, bind9" + + command = f"sed -i /var/lib/dpkg/status 's@{conflicts}@{new_conflicts}@g'" + os.system(command) From da57653a01770e130a53c6e732ee6dac61035790 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 31 May 2021 19:12:08 +0200 Subject: [PATCH 02/12] Misc fixes after tests on the battlefield --- .../data_migrations/0021_migrate_to_bullseye.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index 289e9d765..a5bb1e523 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -22,7 +22,7 @@ N_CURRENT_DEBIAN = 10 N_CURRENT_YUNOHOST = 4 N_NEXT_DEBAN = 11 -N_NEXT_YUNOHOST == 11 +N_NEXT_YUNOHOST = 11 class MyMigration(Migration): @@ -54,17 +54,17 @@ class MyMigration(Migration): ) # - # Specific packages upgrades + # Patch yunohost conflicts # - logger.info(m18n.n("migration_0021_specific_upgrade")) + logger.info(m18n.n("migration_0021_patch_yunohost_conflicts")) + + self.patch_yunohost_conflicts() # # Main upgrade # logger.info(m18n.n("migration_0021_main_upgrade")) - self.patch_yunohost_conflicts() - apps_packages = self.get_apps_equivs_packages() self.hold(apps_packages) tools_upgrade(target="system", allow_yunohost_upgrade=False) @@ -248,5 +248,6 @@ class MyMigration(Migration): # We want to keep conflicting with apache/bind9 tho new_conflicts = "Conflicts: apache2, bind9" - command = f"sed -i /var/lib/dpkg/status 's@{conflicts}@{new_conflicts}@g'" + command = f"sed -i /var/lib/dpkg/status -e 's@{conflicts}@{new_conflicts}@g'" + logger.debug(f"Running: {command}") os.system(command) From fd3a10489deec0c99f2566408c134f1bca78c4d6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 7 Jun 2021 16:17:58 +0200 Subject: [PATCH 03/12] Add i18n strings for bullseye migration --- locales/en.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/locales/en.json b/locales/en.json index 84a01dfaa..a479672d7 100644 --- a/locales/en.json +++ b/locales/en.json @@ -426,6 +426,7 @@ "migration_description_0018_xtable_to_nftable": "Migrate old network traffic rules to the new nftable system", "migration_description_0019_extend_permissions_features": "Extend/rework the app permission management system", "migration_description_0020_ssh_sftp_permissions": "Add SSH and SFTP permissions support", + "migration_description_0021_migrate_to_bullseye": "Upgrade the system to Debian Bullseye and YunoHost 11.x", "migration_ldap_backup_before_migration": "Creating a backup of LDAP database and apps settings prior to the actual migration.", "migration_ldap_can_not_backup_before_migration": "The backup of the system could not be completed before the migration failed. Error: {error:s}", "migration_ldap_migration_failed_trying_to_rollback": "Could not migrate... trying to roll back the system.", @@ -452,6 +453,21 @@ "migration_0018_failed_to_reset_legacy_rules": "Failed to reset legacy iptables rules: {error}", "migration_0019_add_new_attributes_in_ldap": "Add new attributes for permissions in LDAP database", "migration_0019_slapd_config_will_be_overwritten": "It looks like you manually edited the slapd configuration. For this critical migration, YunoHost needs to force the update of the slapd configuration. The original files will be backuped in {conf_backup_folder}.", + "migration_0021_start" : "Starting migration to Bullseye", + "migration_0021_patching_sources_list": "Patching the sources.lists...", + "migration_0021_main_upgrade": "Starting main upgrade...", + "migration_0021_still_on_buster_after_main_upgrade": "Something went wrong during the main upgrade, the system appears to still be on Debian Buster", + "migration_0021_yunohost_upgrade" : "Starting YunoHost core upgrade...", + "migration_0021_not_buster" : "The current Debian distribution is not Buster!", + "migration_0021_not_enough_free_space" : "Free space is pretty low in /var/! You should have at least 1GB free to run this migration.", + "migration_0021_system_not_fully_up_to_date": "Your system is not fully up-to-date. Please perform a regular upgrade before running the migration to Bullseye.", + "migration_0021_general_warning": "Please note that this migration is a delicate operation. The YunoHost team did its best to review and test it, but the migration might still break parts of the system or its apps.\n\nTherefore, it is recommended to:\n - Perform a backup of any critical data or app. More info on https://yunohost.org/backup;\n - Be patient after launching the migration: Depending on your Internet connection and hardware, it might take up to a few hours for everything to upgrade.", + "migration_0021_problematic_apps_warning": "Please note that the following possibly problematic installed apps were detected. It looks like those were not installed from the YunoHost app catalog, or are not flagged as 'working'. Consequently, it cannot be guaranteed that they will still work after the upgrade: {problematic_apps}", + "migration_0021_modified_files": "Please note that the following files were found to be manually modified and might be overwritten following the upgrade: {manually_modified_files}", + "migration_0021_specific_upgrade": "Starting upgrade of system packages that needs to be upgrade independently...", + "migration_0021_cleaning_up": "Cleaning up cache and packages not useful anymore...", + "migration_0021_weak_certs": "The following certificates were found to still use weak signature algorithms and have to be upgraded to be compatible with the next version of nginx: {certs}", + "migration_0021_patch_yunohost_conflicts": "Applying patch to workaround conflict issue...", "migrations_already_ran": "Those migrations are already done: {ids}", "migrations_cant_reach_migration_file": "Could not access migrations files at the path '%s'", "migrations_dependencies_not_satisfied": "Run these migrations: '{dependencies_id}', before migration {id}.", From 43d924252fa0dc4d6ffdcfcbcb32a3a4f3ee18eb Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 7 Jun 2021 17:41:57 +0200 Subject: [PATCH 04/12] Fix patch of security repo in sources.list --- src/yunohost/data_migrations/0021_migrate_to_bullseye.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index a5bb1e523..6678fa040 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -177,12 +177,14 @@ class MyMigration(Migration): # - replace single 'buster' occurence by 'bulleye' # - comments lines containing "backports" # - replace 'buster/updates' by 'bullseye/updates' (or same with -) + # Special note about the security suite: + # https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html#security-archive for f in sources_list: command = ( f"sed -i {f} " "-e 's@ buster @ bullseye @g' " "-e '/backports/ s@^#*@#@' " - "-e 's@ buster/updates @ bullseye/updates @g' " + "-e 's@ buster/updates @ bullseye-security @g' " "-e 's@ buster-@ bullseye-@g' " ) os.system(command) From 43ef4f4a29e53f139439b4ab46004384abcfcf76 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 7 Jun 2021 17:44:24 +0200 Subject: [PATCH 05/12] Unecessary i18n strings --- locales/en.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index a479672d7..a739b93c4 100644 --- a/locales/en.json +++ b/locales/en.json @@ -464,9 +464,7 @@ "migration_0021_general_warning": "Please note that this migration is a delicate operation. The YunoHost team did its best to review and test it, but the migration might still break parts of the system or its apps.\n\nTherefore, it is recommended to:\n - Perform a backup of any critical data or app. More info on https://yunohost.org/backup;\n - Be patient after launching the migration: Depending on your Internet connection and hardware, it might take up to a few hours for everything to upgrade.", "migration_0021_problematic_apps_warning": "Please note that the following possibly problematic installed apps were detected. It looks like those were not installed from the YunoHost app catalog, or are not flagged as 'working'. Consequently, it cannot be guaranteed that they will still work after the upgrade: {problematic_apps}", "migration_0021_modified_files": "Please note that the following files were found to be manually modified and might be overwritten following the upgrade: {manually_modified_files}", - "migration_0021_specific_upgrade": "Starting upgrade of system packages that needs to be upgrade independently...", "migration_0021_cleaning_up": "Cleaning up cache and packages not useful anymore...", - "migration_0021_weak_certs": "The following certificates were found to still use weak signature algorithms and have to be upgraded to be compatible with the next version of nginx: {certs}", "migration_0021_patch_yunohost_conflicts": "Applying patch to workaround conflict issue...", "migrations_already_ran": "Those migrations are already done: {ids}", "migrations_cant_reach_migration_file": "Could not access migrations files at the path '%s'", From 996a399f94f3e15f507dbf1334ebff37c4fa2e22 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 13 Aug 2021 17:58:46 +0200 Subject: [PATCH 06/12] bullseye migration: add new apg .deb signing key --- src/yunohost/data_migrations/0021_migrate_to_bullseye.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index 6678fa040..4b40fcbe0 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -36,6 +36,13 @@ class MyMigration(Migration): logger.info(m18n.n("migration_0021_start")) + # + # Add new apt .deb signing key + # + + new_apt_key = "https://forge.yunohost.org/yunohost_bullseye.asc" + check_output(f"wget -O- {new_apt_key} -q | apt-key add -qq -") + # # Patch sources.list # From 4dc53d5a8e49447d5368b699676c41eee9ac0e9e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 20 Oct 2021 21:07:53 +0200 Subject: [PATCH 07/12] migrate_to_bullseye: get rid of custom my.cnf --- .../data_migrations/0021_migrate_to_bullseye.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index 4b40fcbe0..db10777bf 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -5,11 +5,11 @@ from moulinette import m18n from yunohost.utils.error import YunohostError from moulinette.utils.log import getActionLogger from moulinette.utils.process import check_output, call_async_output -from moulinette.utils.filesystem import read_file +from moulinette.utils.filesystem import read_file, rm from yunohost.tools import Migration, tools_update, tools_upgrade from yunohost.app import unstable_apps -from yunohost.regenconf import manually_modified_files +from yunohost.regenconf import manually_modified_files, _force_clear_hashes from yunohost.utils.filesystem import free_space_in_directory from yunohost.utils.packages import ( get_ynh_package_version, @@ -67,6 +67,16 @@ class MyMigration(Migration): self.patch_yunohost_conflicts() + # + # Specific tweaking to get rid of custom my.cnf and use debian's default one + # (my.cnf is actually a symlink to mariadb.cnf) + # + + _force_clear_hashes(["/etc/mysql/my.cnf"]) + rm("/etc/mysql/mariadb.cnf", force=True) + rm("/etc/mysql/my.cnf", force=True) + self.apt_install("mariadb-common --reinstall -o Dpkg::Options::='--force-confmiss'") + # # Main upgrade # From dc4341f98cc75baeff03b32777e17045338ec144 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 22 Nov 2021 08:21:54 +0100 Subject: [PATCH 08/12] migrate_to_bullseye: /usr/share/yunohost/yunohost-config/ssl/yunoCA -> /usr/share/yunohost/ssl --- src/yunohost/data_migrations/0021_migrate_to_bullseye.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index db10777bf..aee3bc2d6 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -77,6 +77,13 @@ class MyMigration(Migration): rm("/etc/mysql/my.cnf", force=True) self.apt_install("mariadb-common --reinstall -o Dpkg::Options::='--force-confmiss'") + # + # /usr/share/yunohost/yunohost-config/ssl/yunoCA -> /usr/share/yunohost/ssl + # + if os.path.exists("/usr/share/yunohost/yunohost-config/ssl/yunoCA"): + os.system("mv /usr/share/yunohost/yunohost-config/ssl/yunoCA /usr/share/yunohost/ssl") + rm("/usr/share/yunohost/yunohost-config", recursive=True, force=True) + # # Main upgrade # From b617c799d05fa95e8fb3af85442b59053412f03f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 8 Dec 2021 22:11:02 +0100 Subject: [PATCH 09/12] migrate_to_bullseye: move /home/yunohost.conf to /var/cache/yunohost/regenconf --- src/yunohost/data_migrations/0021_migrate_to_bullseye.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index aee3bc2d6..b39ef09e8 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -84,6 +84,13 @@ class MyMigration(Migration): os.system("mv /usr/share/yunohost/yunohost-config/ssl/yunoCA /usr/share/yunohost/ssl") rm("/usr/share/yunohost/yunohost-config", recursive=True, force=True) + # + # /home/yunohost.conf -> /var/cache/yunohost/regenconf + # + if os.path.exists("/home/yunohost.conf"): + os.system("mv /home/yunohost.conf /var/cache/yunohost/regenconf") + rm("/home/yunohost.conf", recursive=True, force=True) + # # Main upgrade # From 107bd854eb338617741847e07a085981140249b7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 9 Dec 2021 16:47:57 +0100 Subject: [PATCH 10/12] migrate_to_bullseye: fix PHP dependencies issues --- .../data_migrations/0021_migrate_to_bullseye.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index b39ef09e8..6ce963625 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -108,6 +108,22 @@ class MyMigration(Migration): os.system("apt autoremove --assume-yes") os.system("apt clean --assume-yes") + # Force add sury if it's not there yet + # This is to solve some weird issue with php-common breaking php7.3-common, + # hence breaking many php7.3-deps + # hence triggering some dependency conflict (or foobar-ynh-deps uninstall) + # Adding it there shouldnt be a big deal - Yunohost 11.x does add it + # through its regen conf anyway. + if not os.path.exists("/etc/apt/sources.list.d/extra_php_version.list"): + open("/etc/apt/sources.list.d/extra_php_version.list", "w").write("deb https://packages.sury.org/php/ bullseye main") + os.system('wget --timeout 900 --quiet "https://packages.sury.org/php/apt.gpg" --output-document=- | gpg --dearmor >"/etc/apt/trusted.gpg.d/extra_php_version.gpg"') + + os.system("apt update") + + # Force explicit install of php7.4-fpm to make sure it's ll be there + # during 0022_php73_to_php74_pools migration + self.apt_install("php7.4-fpm -o Dpkg::Options::='--force-confmiss'") + # # Yunohost upgrade # From c4732b776e7420c5b19658d61dc36c787f5cf6c5 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 9 Dec 2021 17:13:06 +0100 Subject: [PATCH 11/12] migrate_to_bullseye: Remove legacy postgresql service record added by helpers, will now be dynamically handled by the core in bullseye --- src/yunohost/data_migrations/0021_migrate_to_bullseye.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index 6ce963625..de53ba8be 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -15,6 +15,7 @@ from yunohost.utils.packages import ( get_ynh_package_version, _list_upgradable_apt_packages, ) +from yunohost.services import _get_services, _save_services logger = getActionLogger("yunohost.migration") @@ -124,6 +125,13 @@ class MyMigration(Migration): # during 0022_php73_to_php74_pools migration self.apt_install("php7.4-fpm -o Dpkg::Options::='--force-confmiss'") + # Remove legacy postgresql service record added by helpers, + # will now be dynamically handled by the core in bullseye + services = _get_services() + if "postgresql" in services: + del services["postgresql"] + _save_services(services) + # # Yunohost upgrade # From 8abd843fdde7fcec9cc2ae79fbe2f9417ec30725 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 9 Dec 2021 17:31:07 +0100 Subject: [PATCH 12/12] Aaaand typo T_T --- src/yunohost/data_migrations/0021_migrate_to_bullseye.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py index de53ba8be..36e816db1 100644 --- a/src/yunohost/data_migrations/0021_migrate_to_bullseye.py +++ b/src/yunohost/data_migrations/0021_migrate_to_bullseye.py @@ -15,7 +15,7 @@ from yunohost.utils.packages import ( get_ynh_package_version, _list_upgradable_apt_packages, ) -from yunohost.services import _get_services, _save_services +from yunohost.service import _get_services, _save_services logger = getActionLogger("yunohost.migration")