From f96aa4450537dec77c4c1479bbdb1f36ad24d3c0 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 12 Jun 2018 00:05:47 +0200 Subject: [PATCH] Rely on the codename instead of release number because lsb_release is fokin stupid --- .../data_migrations/0003_migrate_to_stretch.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/yunohost/data_migrations/0003_migrate_to_stretch.py b/src/yunohost/data_migrations/0003_migrate_to_stretch.py index 6900b678a..add511a81 100644 --- a/src/yunohost/data_migrations/0003_migrate_to_stretch.py +++ b/src/yunohost/data_migrations/0003_migrate_to_stretch.py @@ -55,7 +55,7 @@ class MyMigration(Migration): _run_service_command("stop", "mysql") self.apt_dist_upgrade(conf_flags=["old", "miss", "def"]) _run_service_command("start", "mysql") - if self.debian_major_version() == 8: + if self.debian_major_version() == "jessie": raise MoulinetteError(m18n.n("migration_0003_still_on_jessie_after_main_upgrade", log=self.logfile)) # Specific upgrade for fail2ban... @@ -89,7 +89,10 @@ class MyMigration(Migration): # because "platform" relies on uname, which on some weird setups does # not behave correctly (still says running Jessie when lsb_release says # Stretch...) - return int(check_output("lsb_release -r").split("\t")[1][0]) + # Also lsb_release is fucking stupid and sometimes return "Release: 8" + # and "Codename: stretch". So apparently the codename is more reliable + # than the release number :| + return check_output("lsb_release -c").split("\t")[1].strip() def yunohost_major_version(self): return int(get_installed_version("yunohost").split('.')[0]) @@ -100,7 +103,7 @@ class MyMigration(Migration): # 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 2.x... - if not self.debian_major_version() == 8 \ + if not self.debian_major_version() == "jessie" \ and not self.yunohost_major_version() == 2: raise MoulinetteError(m18n.n("migration_0003_not_jessie")) @@ -125,7 +128,7 @@ class MyMigration(Migration): # 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 2.x... - if not self.debian_major_version() == 8 \ + if not self.debian_major_version() == "jessie" \ and not self.yunohost_major_version() == 2: return None