def check_assertions(self): # Be on stretch (9.x) and yunohost 3.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() == 9 \ and not self.yunohost_major_version() == 3: raise YunohostError("migration_0015_not_stretch") # Have > 1 Go free space on /var/ ? if free_space_in_directory("/var/") / (1024**3) < 1.0: raise YunohostError("migration_0015_not_enough_free_space") # Check system is up to date # (but we don't if 'stretch' is already in the sources.list ... # which means maybe a previous upgrade crashed and we're re-running it) if " buster " not in read_file("/etc/apt/sources.list"): tools_update(system=True) upgradable_system_packages = list(_list_upgradable_apt_packages()) if upgradable_system_packages: raise YunohostError( "migration_0015_system_not_fully_up_to_date")
def run(self): self.check_assertions() logger.info(m18n.n("migration_0015_start")) # # Make sure certificates do not use weak signature hash algorithms (md5, sha1) # otherwise nginx will later refuse to start which result in # catastrophic situation # self.validate_and_upgrade_cert_if_necessary() # # Patch sources.list # logger.info(m18n.n("migration_0015_patching_sources_list")) self.patch_apt_sources_list() tools_update(system=True) # 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_0015_specific_upgrade")) # Update unscd independently, was 0.53-1+yunohost on stretch (custom build of ours) but now it's 0.53-1+b1 on vanilla buster, # which for apt appears as a lower version (hence the --allow-downgrades and the hardcoded version number) unscd_version = check_output( 'dpkg -s unscd | grep "^Version: " | cut -d " " -f 2') if "yunohost" in unscd_version: new_version = check_output( "LC_ALL=C apt policy unscd 2>/dev/null | grep -v '\\*\\*\\*' | grep http -B1 | head -n 1 | awk '{print $1}'" ).strip() if new_version: self.apt_install('unscd=%s --allow-downgrades' % new_version) else: logger.warning( "Could not identify which version of unscd to install") # Upgrade libpam-modules independently, small issue related to willing to overwrite a file previously provided by Yunohost libpammodules_version = check_output( 'dpkg -s libpam-modules | grep "^Version: " | cut -d " " -f 2') if not libpammodules_version.startswith("1.3"): self.apt_install( 'libpam-modules -o Dpkg::Options::="--force-overwrite"') # # Main upgrade # logger.info(m18n.n("migration_0015_main_upgrade")) apps_packages = self.get_apps_equivs_packages() self.hold(apps_packages) tools_upgrade(system=True, allow_yunohost_upgrade=False) if self.debian_major_version() == 9: raise YunohostError( "migration_0015_still_on_stretch_after_main_upgrade") # Clean the mess logger.info(m18n.n("migration_0015_cleaning_up")) os.system("apt autoremove --assume-yes") os.system("apt clean --assume-yes") # # Yunohost upgrade # logger.info(m18n.n("migration_0015_yunohost_upgrade")) self.unhold(apps_packages) tools_upgrade(system=True)