~ubuntu-branches/ubuntu/karmic/update-manager/karmic-updates

« back to all changes in this revision

Viewing changes to DistUpgrade/DistUpgradeQuirks.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-10-08 17:45:25 UTC
  • Revision ID: james.westby@ubuntu.com-20091008174525-rgk3uzd5h9fvw0x5
Tags: 1:0.126
* DistUpgrade/DistUpgrade.cfg:
  - add gnome-app-install to the ForcedObsoletes
* DistUpgrade/DistUpgrade.cfg.hardy:
  - add ability to upgrade from hardy to karmic (as asked for
    by Jonathan Riddell)
* DistUpgrade/DistUpgradeQuirks.py:
  - add quirk handler to mark the dependencies of
    language-support-translations-* as manual on upgrade

    The language-support-translations- packages are removed in 
    karmic and would otherwise be marked as auto-removable.
    (LP: #439296)
  - convert PASS value from 1 to 0 for ntfs entries in
    /etc/fstab (LP: #441242) and add tests for it
  - put 386 to generic transition code here and decouple from
    the kernel selection
  - inhibit gnome-screensaver once the upgrade started 
    to avoid X crash (LP: #439594)
* DistUpgrade/DistUpgradeCache.py:
  - workaround issues with kdesu when it drop the permission bits
    in a tmpdir (thanks to Jonathan Riddell)
  - fix base-installer kernel selection (LP: #441629)
  - fix log dir does not exist, create it (LP: #441959)
* UpdateManager/backend/InstallBackendAptdaemon.py:
  - give up lock before running aptdaemon (LP: #445920)
* po/ 
  - updated from launchpad (required as during a release upgrade
    we can't use langpacks)

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
        self._rewriteFstab()
132
132
        self._checkAdminGroup()
133
133
 
 
134
    def karmicPostUpgrade(self):
 
135
        """ this function works around quirks in the jaunty->karmic upgrade """
 
136
        logging.debug("running Controller.karmicPostUpgrade handler")
 
137
        self._ntfsFstabFixup()
 
138
 
134
139
    # quirks when run when the initial apt-get update was run -------
135
140
    def karmicPostInitialUpdate(self):
136
141
        " quirks that are run before the upgrade to karmic "
192
197
        self.feistyPostDistUpgradeCache()
193
198
        self.edgyPostDistUpgradeCache()
194
199
 
 
200
    def from_hardyPostDistUpgradeCache(self):
 
201
        self._kernel386TransitionCheck()
 
202
 
195
203
    def karmicPostDistUpgradeCache(self):
196
204
        """ 
197
205
        this function works around quirks in the 
200
208
        # check if "wl" module is loaded and if so, install
201
209
        # bcmwl-kernel-source (this is needed for lts->lts as well)
202
210
        self._checkAndInstallBroadcom()
 
211
        self._dealWithLanguageSupportTransition()
 
212
        self._kernel386TransitionCheck()
203
213
 
204
214
    def jauntyPostDistUpgradeCache(self):
205
215
        """ 
470
480
        self._removeBadMaintainerScripts()
471
481
        self._killUpdateNotifier()
472
482
        self._killKBluetooth()
 
483
        self._killScreensaver()
473
484
    def jauntyStartUpgrade(self):
474
485
        self._createPycentralPkgRemove()
475
486
        # hal/NM triggers problem, if the old (intrepid) hal gets
509
520
            return False
510
521
        return True
511
522
 
 
523
    def _dealWithLanguageSupportTransition(self):
 
524
        """
 
525
        In karmic the language-support-translations-* metapackages
 
526
        are gone and the direct dependencies will get marked for
 
527
        auto removal - mark them as manual instead
 
528
        """
 
529
        logging.debug("language-support-translations-* transition")
 
530
        for pkg in self.controller.cache:
 
531
            depcache = self.controller.cache._depcache
 
532
            if (pkg.name.startswith("language-support-translations") and
 
533
                pkg.isInstalled):
 
534
                for dp_or in pkg.installedDependencies:
 
535
                    for dpname in dp_or.or_dependencies:
 
536
                        dp = self.controller.cache[dpname.name]
 
537
                        if dp.isInstalled and depcache.IsAutoInstalled(dp._pkg):
 
538
                            logging.debug("marking '%s' manual installed" % dp.name)
 
539
                            autoInstDeps = False
 
540
                            fromUser = True
 
541
                            depcache.MarkInstall(dp._pkg, autoInstDeps, fromUser)
 
542
 
512
543
    def _checkAndInstallBroadcom(self):
513
544
        """
514
545
        check for the 'wl' kernel module and install bcmwl-kernel-source
530
561
        if os.path.exists("/usr/bin/killall"):
531
562
            logging.debug("killing kblueplugd kbluetooth4")
532
563
            subprocess.call(["killall", "-q", "kblueplugd", "kbluetooth4"])
 
564
    def _killScreensaver(self):
 
565
        """killall gnome-screensaver """
 
566
        if os.path.exists("/usr/bin/killall"):
 
567
            logging.debug("killing gnome-screensaver")
 
568
            subprocess.call(["killall", "-q", "gnome-screensaver"])
533
569
    def _removeBadMaintainerScripts(self):
534
570
        " remove bad/broken maintainer scripts (last resort) "
535
571
        # apache: workaround #95325 (edgy->feisty)
639
675
            os.rename("/etc/fstab.intrepid","/etc/fstab")
640
676
        return True
641
677
        
 
678
    def _ntfsFstabFixup(self, fstab="/etc/fstab"):
 
679
        """change PASS 1 to 0 for ntfs entries (#441242)"""
 
680
        logging.debug("_ntfsFstabFixup")
 
681
        replaced = False
 
682
        lines = []
 
683
        for line in open(fstab):
 
684
            line = line.strip()
 
685
            if line == '' or line.startswith("#"):
 
686
                lines.append(line)
 
687
                continue
 
688
            try:
 
689
                (device, mount_point, fstype, options, fdump, fpass) = line.split()
 
690
            except Exception, e:
 
691
                logging.error("can't parse line '%s'" % line)
 
692
                lines.append(line)
 
693
                continue
 
694
            if ("ntfs" in fstype and fpass == "1"):
 
695
                logging.debug("changing PASS for ntfs to 0 for '%s' " % line)
 
696
                if line[-1] == "1":
 
697
                    line = line[:-1] + "0"
 
698
                else:
 
699
                    logging.error("unexpected value in line")
 
700
                logging.debug("replaced line is '%s' " % line)
 
701
                replaced=True
 
702
            lines.append(line)
 
703
        # we have converted a line
 
704
        if replaced:
 
705
            suffix = ".jaunty"
 
706
            logging.debug("writing new /etc/fstab")
 
707
            f=open(fstab + suffix, "w")
 
708
            f.write("\n".join(lines))
 
709
            # add final newline (see LP: #279093)
 
710
            f.write("\n")
 
711
            f.close()
 
712
            os.rename(fstab+suffix, fstab)
 
713
        return True
 
714
        
642
715
 
643
716
    def _rewriteFstab(self):
644
717
        " convert /dev/{hd?,scd0} to /dev/cdrom for the feisty upgrade "
783
856
                if line:
784
857
                    lspci.add(line.split()[2])
785
858
        for filename in os.listdir(modaliasesdir):
 
859
            #logging.debug("modalias file '%s'" % filename)
786
860
            for line in open(os.path.join(modaliasesdir,filename)):
787
861
                line = line.strip()
788
862
                if line == "" or line.startswith("#"):
800
874
        return False
801
875
                    
802
876
 
 
877
    def _kernel386TransitionCheck(self):
 
878
        """ test if the current kernel is 386 and if the system is 
 
879
            capable of using a generic one instead (#353534)
 
880
        """
 
881
        logging.debug("_kernel386TransitionCheck")
 
882
        # we test first if one of 386 is installed
 
883
        # if so, check if the system could also work with -generic
 
884
        # (we get that from base-installer) and try to installed
 
885
        #  that)
 
886
        for pkgname in ["linux-386", "linux-image-386"]:
 
887
            if (self.controller.cache.has_key(pkgname) and
 
888
                self.controller.cache[pkgname].isInstalled):
 
889
                working_kernels = self.controller.cache.getKernelsFromBaseInstaller()
 
890
                upgrade_to = ["linux-generic", "linux-image-generic"]
 
891
                for pkgname in upgrade_to:
 
892
                    if pkgname in working_kernels:
 
893
                        logging.debug("386 kernel installed, but generic kernel  will work on this machine")
 
894
                        if self.controller.cache.markInstall(pkgname, "386 -> generic transition"):
 
895
                            return
 
896
        
 
897
 
803
898