Exemple #1
0
    def update_ents(self, updates, onProgress=None, onUpdate=None):
        """
        Update metadata of all packages for package moves.
        @param updates: A list of move commands, or dict of {repo_name: list}
        @type updates: list or dict
        @param onProgress: A progress callback function
        @type onProgress: a callable that takes 2 integer arguments: maxval and curval
        @param onUpdate: A progress callback function called only
                for packages that are modified by updates.
        @type onUpdate: a callable that takes 2 integer arguments:
                maxval and curval
        """
        cpv_all = self.cpv_all()
        cpv_all.sort()
        maxval = len(cpv_all)
        aux_get = self.aux_get
        aux_update = self.aux_update
        update_keys = Package._dep_keys
        meta_keys = update_keys + self._pkg_str_aux_keys
        repo_dict = None
        if isinstance(updates, dict):
            repo_dict = updates
        if onUpdate:
            onUpdate(maxval, 0)
        if onProgress:
            onProgress(maxval, 0)
        for i, cpv in enumerate(cpv_all):
            try:
                metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
            except KeyError:
                continue
            try:
                pkg = _pkg_str(cpv, metadata=metadata, settings=self.settings)
            except InvalidData:
                continue
            metadata = dict((k, metadata[k]) for k in update_keys)
            if repo_dict is None:
                updates_list = updates
            else:
                try:
                    updates_list = repo_dict[pkg.repo]
                except KeyError:
                    try:
                        updates_list = repo_dict["DEFAULT"]
                    except KeyError:
                        continue

            if not updates_list:
                continue

            metadata_updates = portage.update_dbentries(updates_list,
                                                        metadata,
                                                        parent=pkg)
            if metadata_updates:
                aux_update(cpv, metadata_updates)
                if onUpdate:
                    onUpdate(maxval, i + 1)
            if onProgress:
                onProgress(maxval, i + 1)
Exemple #2
0
	def update_ents(self, updates, onProgress=None, onUpdate=None):
		"""
		Update metadata of all packages for package moves.
		@param updates: A list of move commands, or dict of {repo_name: list}
		@type updates: list or dict
		@param onProgress: A progress callback function
		@type onProgress: a callable that takes 2 integer arguments: maxval and curval
		@param onUpdate: A progress callback function called only
			for packages that are modified by updates.
		@type onUpdate: a callable that takes 2 integer arguments:
			maxval and curval
		"""
		cpv_all = self.cpv_all()
		cpv_all.sort()
		maxval = len(cpv_all)
		aux_get = self.aux_get
		aux_update = self.aux_update
		update_keys = Package._dep_keys + ("PROVIDE",)
		meta_keys = update_keys + self._pkg_str_aux_keys
		repo_dict = None
		if isinstance(updates, dict):
			repo_dict = updates
		if onUpdate:
			onUpdate(maxval, 0)
		if onProgress:
			onProgress(maxval, 0)
		for i, cpv in enumerate(cpv_all):
			try:
				metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
			except KeyError:
				continue
			try:
				pkg = _pkg_str(cpv, metadata=metadata, settings=self.settings)
			except InvalidData:
				continue
			metadata = dict((k, metadata[k]) for k in update_keys)
			if repo_dict is None:
				updates_list = updates
			else:
				try:
					updates_list = repo_dict[pkg.repo]
				except KeyError:
					try:
						updates_list = repo_dict['DEFAULT']
					except KeyError:
						continue

			if not updates_list:
				continue

			metadata_updates = \
				portage.update_dbentries(updates_list, metadata, parent=pkg)
			if metadata_updates:
				aux_update(cpv, metadata_updates)
				if onUpdate:
					onUpdate(maxval, i+1)
			if onProgress:
				onProgress(maxval, i+1)
Exemple #3
0
    def update_ents(self, updates, onProgress=None, onUpdate=None):
        """
		Update metadata of all packages for package moves.
		@param updates: A list of move commands, or dict of {repo_name: list}
		@type updates: list or dict
		@param onProgress: A progress callback function
		@type onProgress: a callable that takes 2 integer arguments: maxval and curval
		@param onUpdate: A progress callback function called only
			for packages that are modified by updates.
		@type onUpdate: a callable that takes 2 integer arguments:
			maxval and curval
		"""
        cpv_all = self.cpv_all()
        cpv_all.sort()
        maxval = len(cpv_all)
        aux_get = self.aux_get
        aux_update = self.aux_update
        meta_keys = [
            "DEPEND", "EAPI", "RDEPEND", "PDEPEND", "PROVIDE", 'repository'
        ]
        repo_dict = None
        if isinstance(updates, dict):
            repo_dict = updates
        if onUpdate:
            onUpdate(maxval, 0)
        if onProgress:
            onProgress(maxval, 0)
        for i, cpv in enumerate(cpv_all):
            metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
            eapi = metadata.pop('EAPI')
            repo = metadata.pop('repository')
            if repo_dict is None:
                updates_list = updates
            else:
                try:
                    updates_list = repo_dict[repo]
                except KeyError:
                    try:
                        updates_list = repo_dict['DEFAULT']
                    except KeyError:
                        continue

            if not updates_list:
                continue

            metadata_updates = \
             portage.update_dbentries(updates_list, metadata, eapi=eapi)
            if metadata_updates:
                aux_update(cpv, metadata_updates)
                if onUpdate:
                    onUpdate(maxval, i + 1)
            if onProgress:
                onProgress(maxval, i + 1)
Exemple #4
0
	def update_ents(self, updates, onProgress=None, onUpdate=None):
		"""
		Update metadata of all packages for package moves.
		@param updates: A list of move commands, or dict of {repo_name: list}
		@type updates: list or dict
		@param onProgress: A progress callback function
		@type onProgress: a callable that takes 2 integer arguments: maxval and curval
		@param onUpdate: A progress callback function called only
			for packages that are modified by updates.
		@type onUpdate: a callable that takes 2 integer arguments:
			maxval and curval
		"""
		cpv_all = self.cpv_all()
		cpv_all.sort()
		maxval = len(cpv_all)
		aux_get = self.aux_get
		aux_update = self.aux_update
		meta_keys = ["DEPEND", "EAPI", "RDEPEND", "PDEPEND", "PROVIDE", 'repository']
		repo_dict = None
		if isinstance(updates, dict):
			repo_dict = updates
		if onUpdate:
			onUpdate(maxval, 0)
		if onProgress:
			onProgress(maxval, 0)
		for i, cpv in enumerate(cpv_all):
			metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
			eapi = metadata.pop('EAPI')
			repo = metadata.pop('repository')
			if repo_dict is None:
				updates_list = updates
			else:
				try:
					updates_list = repo_dict[repo]
				except KeyError:
					try:
						updates_list = repo_dict['DEFAULT']
					except KeyError:
						continue

			if not updates_list:
				continue

			metadata_updates = \
				portage.update_dbentries(updates_list, metadata, eapi=eapi)
			if metadata_updates:
				aux_update(cpv, metadata_updates)
				if onUpdate:
					onUpdate(maxval, i+1)
			if onProgress:
				onProgress(maxval, i+1)
Exemple #5
0
    def check(self, **kwargs):
        onProgress = kwargs.get('onProgress', None)
        allupdates, errors = self._grab_global_updates()
        # Matching packages and moving them is relatively fast, so the
        # progress bar is updated in indeterminate mode.
        match = self._tree.dbapi.match
        aux_get = self._tree.dbapi.aux_get
        pkg_str = self._tree.dbapi._pkg_str
        settings = self._tree.dbapi.settings
        if onProgress:
            onProgress(0, 0)
        for repo, updates in allupdates.items():
            if repo == 'DEFAULT':
                continue
            if not updates:
                continue

            def repo_match(repository):
                return repository == repo or \
                 (repo == self._master_repo and \
                 repository not in allupdates)

            for i, update_cmd in enumerate(updates):
                if update_cmd[0] == "move":
                    origcp, newcp = update_cmd[1:]
                    for cpv in match(origcp):
                        try:
                            cpv = pkg_str(cpv, origcp.repo)
                        except (KeyError, InvalidData):
                            continue
                        if repo_match(cpv.repo):
                            errors.append("'%s' moved to '%s'" % (cpv, newcp))
                elif update_cmd[0] == "slotmove":
                    pkg, origslot, newslot = update_cmd[1:]
                    atom = pkg.with_slot(origslot)
                    for cpv in match(atom):
                        try:
                            cpv = pkg_str(cpv, atom.repo)
                        except (KeyError, InvalidData):
                            continue
                        if repo_match(cpv.repo):
                            errors.append("'%s' slot moved from '%s' to '%s'" % \
                             (cpv, origslot, newslot))
                if onProgress:
                    onProgress(0, 0)

        # Searching for updates in all the metadata is relatively slow, so this
        # is where the progress bar comes out of indeterminate mode.
        cpv_all = self._tree.dbapi.cpv_all()
        cpv_all.sort()
        maxval = len(cpv_all)
        meta_keys = self._update_keys + self._portdb._pkg_str_aux_keys
        if onProgress:
            onProgress(maxval, 0)
        for i, cpv in enumerate(cpv_all):
            try:
                metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
            except KeyError:
                continue
            try:
                pkg = _pkg_str(cpv, metadata=metadata, settings=settings)
            except InvalidData:
                continue
            metadata = dict((k, metadata[k]) for k in self._update_keys)
            try:
                updates = allupdates[pkg.repo]
            except KeyError:
                try:
                    updates = allupdates['DEFAULT']
                except KeyError:
                    continue
            if not updates:
                continue
            metadata_updates = \
             portage.update_dbentries(updates, metadata, parent=pkg)
            if metadata_updates:
                errors.append("'%s' has outdated metadata" % cpv)
            if onProgress:
                onProgress(maxval, i + 1)

        if errors:
            return (False, errors)
        return (True, None)
Exemple #6
0
	def check(self, **kwargs):
		onProgress = kwargs.get('onProgress', None)
		allupdates, errors = self._grab_global_updates()
		# Matching packages and moving them is relatively fast, so the
		# progress bar is updated in indeterminate mode.
		match = self._tree.dbapi.match
		aux_get = self._tree.dbapi.aux_get
		pkg_str = self._tree.dbapi._pkg_str
		settings = self._tree.dbapi.settings
		if onProgress:
			onProgress(0, 0)
		for repo, updates in allupdates.items():
			if repo == 'DEFAULT':
				continue
			if not updates:
				continue

			def repo_match(repository):
				return repository == repo or \
					(repo == self._master_repo and \
					repository not in allupdates)

			for i, update_cmd in enumerate(updates):
				if update_cmd[0] == "move":
					origcp, newcp = update_cmd[1:]
					for cpv in match(origcp):
						try:
							cpv = pkg_str(cpv, origcp.repo)
						except (KeyError, InvalidData):
							continue
						if repo_match(cpv.repo):
							errors.append("'%s' moved to '%s'" % (cpv, newcp))
				elif update_cmd[0] == "slotmove":
					pkg, origslot, newslot = update_cmd[1:]
					atom = pkg.with_slot(origslot)
					for cpv in match(atom):
						try:
							cpv = pkg_str(cpv, atom.repo)
						except (KeyError, InvalidData):
							continue
						if repo_match(cpv.repo):
							errors.append("'%s' slot moved from '%s' to '%s'" % \
								(cpv, origslot, newslot))
				if onProgress:
					onProgress(0, 0)

		# Searching for updates in all the metadata is relatively slow, so this
		# is where the progress bar comes out of indeterminate mode.
		cpv_all = self._tree.dbapi.cpv_all()
		cpv_all.sort()
		maxval = len(cpv_all)
		meta_keys = self._update_keys + self._portdb._pkg_str_aux_keys
		if onProgress:
			onProgress(maxval, 0)
		for i, cpv in enumerate(cpv_all):
			try:
				metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
			except KeyError:
				continue
			try:
				pkg = _pkg_str(cpv, metadata=metadata, settings=settings)
			except InvalidData:
				continue
			metadata = dict((k, metadata[k]) for k in self._update_keys)
			try:
				updates = allupdates[pkg.repo]
			except KeyError:
				try:
					updates = allupdates['DEFAULT']
				except KeyError:
					continue
			if not updates:
				continue
			metadata_updates = \
				portage.update_dbentries(updates, metadata, parent=pkg)
			if metadata_updates:
				errors.append("'%s' has outdated metadata" % cpv)
			if onProgress:
				onProgress(maxval, i+1)
		return errors
Exemple #7
0
	def check(self, **kwargs):
		onProgress = kwargs.get('onProgress', None)
		allupdates, errors = self._grab_global_updates()
		# Matching packages and moving them is relatively fast, so the
		# progress bar is updated in indeterminate mode.
		match = self._tree.dbapi.match
		aux_get = self._tree.dbapi.aux_get
		if onProgress:
			onProgress(0, 0)
		for repo, updates in allupdates.items():
			if repo == 'DEFAULT':
				continue
			if not updates:
				continue

			def repo_match(repository):
				return repository == repo or \
					(repo == self._master_repo and \
					repository not in allupdates)

			for i, update_cmd in enumerate(updates):
				if update_cmd[0] == "move":
					origcp, newcp = update_cmd[1:]
					for cpv in match(origcp):
						if repo_match(aux_get(cpv, ["repository"])[0]):
							errors.append("'%s' moved to '%s'" % (cpv, newcp))
				elif update_cmd[0] == "slotmove":
					pkg, origslot, newslot = update_cmd[1:]
					for cpv in match(pkg):
						slot, prepo = aux_get(cpv, ["SLOT", "repository"])
						if slot == origslot and repo_match(prepo):
							errors.append("'%s' slot moved from '%s' to '%s'" % \
								(cpv, origslot, newslot))
				if onProgress:
					onProgress(0, 0)

		# Searching for updates in all the metadata is relatively slow, so this
		# is where the progress bar comes out of indeterminate mode.
		cpv_all = self._tree.dbapi.cpv_all()
		cpv_all.sort()
		maxval = len(cpv_all)
		meta_keys = self._update_keys + ['repository', 'EAPI']
		if onProgress:
			onProgress(maxval, 0)
		for i, cpv in enumerate(cpv_all):
			metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
			eapi = metadata.pop('EAPI')
			repository = metadata.pop('repository')
			try:
				updates = allupdates[repository]
			except KeyError:
				try:
					updates = allupdates['DEFAULT']
				except KeyError:
					continue
			if not updates:
				continue
			metadata_updates = \
				portage.update_dbentries(updates, metadata, eapi=eapi)
			if metadata_updates:
				errors.append("'%s' has outdated metadata" % cpv)
			if onProgress:
				onProgress(maxval, i+1)
		return errors
Exemple #8
0
    def check(self, **kwargs):
        onProgress = kwargs.get('onProgress', None)
        allupdates, errors = self._grab_global_updates()
        # Matching packages and moving them is relatively fast, so the
        # progress bar is updated in indeterminate mode.
        match = self._tree.dbapi.match
        aux_get = self._tree.dbapi.aux_get
        if onProgress:
            onProgress(0, 0)
        for repo, updates in allupdates.items():
            if repo == 'DEFAULT':
                continue
            if not updates:
                continue

            def repo_match(repository):
                return repository == repo or \
                 (repo == self._master_repo and \
                 repository not in allupdates)

            for i, update_cmd in enumerate(updates):
                if update_cmd[0] == "move":
                    origcp, newcp = update_cmd[1:]
                    for cpv in match(origcp):
                        if repo_match(aux_get(cpv, ["repository"])[0]):
                            errors.append("'%s' moved to '%s'" % (cpv, newcp))
                elif update_cmd[0] == "slotmove":
                    pkg, origslot, newslot = update_cmd[1:]
                    for cpv in match(pkg):
                        slot, prepo = aux_get(cpv, ["SLOT", "repository"])
                        if slot == origslot and repo_match(prepo):
                            errors.append("'%s' slot moved from '%s' to '%s'" % \
                             (cpv, origslot, newslot))
                if onProgress:
                    onProgress(0, 0)

        # Searching for updates in all the metadata is relatively slow, so this
        # is where the progress bar comes out of indeterminate mode.
        cpv_all = self._tree.dbapi.cpv_all()
        cpv_all.sort()
        maxval = len(cpv_all)
        meta_keys = self._update_keys + ['repository', 'EAPI']
        if onProgress:
            onProgress(maxval, 0)
        for i, cpv in enumerate(cpv_all):
            metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys)))
            eapi = metadata.pop('EAPI')
            repository = metadata.pop('repository')
            try:
                updates = allupdates[repository]
            except KeyError:
                try:
                    updates = allupdates['DEFAULT']
                except KeyError:
                    continue
            if not updates:
                continue
            metadata_updates = \
             portage.update_dbentries(updates, metadata, eapi=eapi)
            if metadata_updates:
                errors.append("'%s' has outdated metadata" % cpv)
            if onProgress:
                onProgress(maxval, i + 1)
        return errors