~kdeneon/ubuntu-release-upgrader-neon/trunk

« back to all changes in this revision

Viewing changes to DistUpgrade/DistUpgradeQuirks.py

  • Committer: Jonathan Riddell
  • Date: 2018-09-05 09:58:54 UTC
  • Revision ID: jriddell@ubuntu.com-20180905095854-abywkkizk31twadp
patch up to 1:18.04.22

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        # PreCacheOpen would be better but controller.abort fails terribly
131
131
        """ run after the apt cache is opened the first time """
132
132
        logging.debug("running Quirks.bionicPostInitialUpdate")
133
 
        if self.controller.cache['ubuntu-desktop'].is_installed:
 
133
        if self.controller.cache['ubuntu-desktop'].is_installed and \
 
134
                self.controller.cache['snapd'].is_installed:
134
135
            self._checkStoreConnectivity()
135
136
        # neon packages with versions < in bionic
136
137
        copyfile('98-xenial-overrides', '/etc/apt/preferences.d/98-xenial-overrides')
138
139
 
139
140
    def bionicPostUpgrade(self):
140
141
        logging.debug("running Quirks.bionicPostUpgrade")
141
 
        if self.controller.cache['ubuntu-desktop'].is_installed:
 
142
        if self.controller.cache['ubuntu-desktop'].is_installed and \
 
143
                self.controller.cache['snapd'].is_installed:
142
144
            self._replaceDebsWithSnaps()
143
145
        # neon packages with versions < in bionic tidy
144
146
        os.remove('/etc/apt/preferences.d/98-xenial-overrides')
494
496
    def _checkStoreConnectivity(self):
495
497
        """ check for connectivity to the snap store to install snaps"""
496
498
        res = False
 
499
        snap_env = os.environ.copy()
 
500
        snap_env["LANG"] = "C.UTF-8"
497
501
        connected = Popen(["snap", "debug", "connectivity"], stdout=PIPE,
498
 
                          stderr=PIPE, universal_newlines=True).communicate()
 
502
                          stderr=PIPE, env=snap_env,
 
503
                          universal_newlines=True).communicate()
499
504
        if re.search("^ \* PASS", connected[0], re.MULTILINE):
500
505
            return
501
506
        # can't connect
528
533
    def _replaceDebsWithSnaps(self):
529
534
        """ install a snap and mark its corresponding package for removal """
530
535
        # gtk-common-themes isn't a package name but is this risky?
531
 
        snaps = ['gtk-common-themes', 'gnome-calculator', 'gnome-characters',
532
 
                 'gnome-logs', 'gnome-system-monitor']
 
536
        snaps = ['gnome-3-26-1604', 'gtk-common-themes', 'gnome-calculator',
 
537
                 'gnome-characters', 'gnome-logs', 'gnome-system-monitor']
 
538
        self._view.updateStatus(_("Checking for installed snaps"))
533
539
        installed_snaps = subprocess.Popen(["snap", "list"],
534
540
                                           universal_newlines=True,
535
541
                                           stdout=PIPE).communicate()
 
542
        self._view.processEvents()
536
543
        for snap in snaps:
537
544
            installed = False
538
545
            # check to see if the snap is already installed
541
548
                installed = True
542
549
            if not installed:
543
550
                try:
 
551
                    self._view.updateStatus(_("Installing snap %s" % snap))
 
552
                    self._view.processEvents()
544
553
                    proc = subprocess.run(["snap", "install", "--channel",
545
554
                                           "stable/ubuntu-18.04", snap],
546
555
                                          stdout=subprocess.PIPE,
547
556
                                          check=True)
 
557
                    self._view.processEvents()
548
558
                except subprocess.CalledProcessError:
549
559
                    logging.debug("Install of snap %s failed" % snap)
550
560
                    continue