~ubuntu-branches/ubuntu/natty/aptdaemon/natty

« back to all changes in this revision

Viewing changes to aptdaemon/worker.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-10-20 09:40:01 UTC
  • mfrom: (1.1.36 upstream)
  • Revision ID: james.westby@ubuntu.com-20101020094001-5ktl4cfuxnmvwb33
Tags: 0.33-0ubuntu1
* new upstream release
* debian/patches/06_rosetta_po_update.patch:
  - removed, upstream has up-to-date translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
        ac.release()
260
260
        self._commit_changes()
261
261
 
262
 
    def _check_unauthenticated(self):
263
 
        """Check if any of the cache changes get installed from an
264
 
        unauthenticated repository"""
265
 
        if self.trans.allow_unauthenticated:
266
 
            return
 
262
    def _get_unauthenticated(self):
 
263
        """Return a list of unauthenticated package names """
267
264
        unauthenticated = []
268
265
        for pkg in self._cache:
269
266
            if (pkg.marked_install or
275
272
                    trusted |= origin.trusted
276
273
                if not trusted:
277
274
                    unauthenticated.append(pkg.name)
 
275
        return unauthenticated
 
276
 
 
277
    def _check_unauthenticated(self):
 
278
        """Check if any of the cache changes get installed from an
 
279
        unauthenticated repository"""
 
280
        if self.trans.allow_unauthenticated:
 
281
            return
 
282
        unauthenticated = self._get_unauthenticated()
278
283
        if unauthenticated:
279
284
            raise TransactionFailed(ERROR_PACKAGE_UNAUTHENTICATED,
280
285
                                    " ".join(sorted(unauthenticated)))
594
599
                                    str(error.message))
595
600
        except apt.cache.FetchCancelledException:
596
601
            raise TransactionCancelled()
 
602
        except apt.cache.LockFailedException:
 
603
            raise TransactionFailed(ERROR_NO_LOCK)
597
604
 
598
605
    def upgrade_system(self, safe_mode=True):
599
606
        """Upgrade the system.
798
805
 
799
806
        status = ""
800
807
        depends = [[], [], [], [], [], [], []]
 
808
        unauthenticated = []
801
809
        skip_pkgs = []
802
810
        size = 0
803
811
        installs = reinstalls = removals = purges = upgrades = downgrades = \
809
817
        if trans.role not in [ROLE_INSTALL_PACKAGES, ROLE_UPGRADE_PACKAGES,
810
818
                              ROLE_UPGRADE_SYSTEM, ROLE_REMOVE_PACKAGES,
811
819
                              ROLE_COMMIT_PACKAGES, ROLE_INSTALL_FILE]:
812
 
            return depends, status, 0, 0
 
820
            return depends, status, 0, 0, []
813
821
 
814
822
        # Fast forward the cache
815
823
        if not status_path:
848
856
            status += "\n"
849
857
            skip_pkgs.append(deb.pkgname)
850
858
            try:
851
 
                size = int(deb["Installed-Size"]) * 1024
852
 
            except (KeyError, AttributeError):
 
859
                # Some manually created packages use thousands seperators
 
860
                # or invalid values - see LP #656633
 
861
                size = int(deb["Installed-Size"].replace(",","")) * 1024
 
862
            except (KeyError, AttributeError, ValueError):
853
863
                pass
854
864
            try:
855
865
                pkg = self._cache[deb.pkgname]
896
906
                depends[PKGS_REMOVE].append(pkg.name)
897
907
            #FIXME: add support for purges
898
908
            changes_names.append(pkg.name)
 
909
        # get the unauthenticated packages
 
910
        unauthenticated = self._get_unauthenticated()
899
911
        # Check for skipped upgrades
900
912
        for pkg in upgradables:
901
913
            if not pkg in changes or not pkg.marked_upgrade:
934
946
            status += "\n"
935
947
 
936
948
        return depends, status, self._cache.required_download, \
937
 
               size + self._cache.required_space
 
949
               size + self._cache.required_space, unauthenticated
938
950
 
939
951
 
940
952
class DummyWorker(AptWorker):
1026
1038
 
1027
1039
    def simulate(self, trans, status_path=None):
1028
1040
        depends = [[], [], [], [], [], [], []]
1029
 
        return depends, "", 0, 0
 
1041
        return depends, "", 0, 0, []
1030
1042
 
1031
1043
 
1032
1044
# vim:ts=4:sw=4:et