示例#1
0
def assign_packages(broken, logger, settings):
    ''' Finds and returns packages that owns files placed in broken.
		Broken is list of files
	'''
    assigned = set()
    if not broken:
        return assigned

    pkgset = set(get_installed_cpvs())

    # Map all files in CONTENTS database to package names
    fname_pkg_dict = {}
    for pkg in pkgset:
        contents = Package(pkg).parsed_contents()
        for fname in contents.keys():
            if contents[fname][0] == "obj":
                fname_pkg_dict[fname] = str(pkg)

    for fname in broken:
        realname = os.path.realpath(fname)
        if realname in fname_pkg_dict.keys():
            pkgname = fname_pkg_dict[realname]
        elif fname in fname_pkg_dict.keys():
            pkgname = fname_pkg_dict[fname]
        else:
            pkgname = None
        if pkgname and pkgname not in assigned:
            assigned.add(pkgname)
        if not pkgname:
            pkgname = "(none)"
        logger.info('\t' + fname + ' -> ' + bold(pkgname))

    return assigned
示例#2
0
    def analyse_flags(self, target):
        """This will scan the installed packages db and analyze the
		USE flags used for installation and produce a report on how
		they were used.

		@type target: string
		@param target: the target to be analyzed, one of ["use", "pkguse"]
		"""
        system_use = portage.settings["USE"].split()
        self.printer = AnalysisPrinter("use", self.options["verbose"],
                                       system_use)
        if self.options["verbose"]:
            cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
            #cpvs = get_installed_cpvs()
            #print "Total number of installed ebuilds =", len(cpvs)
            flag_users = gather_flags_info(cpvs,
                                           system_use,
                                           self.options["unset"],
                                           target=target.upper(),
                                           use_portage=self.options['portage'])
        else:
            cpvs = get_installed_cpvs()
            flag_users = gather_flags_info(cpvs,
                                           system_flags=system_use,
                                           include_unset=self.options["unset"],
                                           target=target.upper(),
                                           use_portage=self.options['portage'])
        #print flag_users
        flag_keys = sorted(flag_users)
        if self.options["verbose"]:
            print(
                " Flag                                 System  #pkgs   cat/pkg-ver"
            )
            blankline = nl
        elif not self.options['quiet']:
            print(" Flag                                 System  #pkgs")
            blankline = lambda: None
        for flag in flag_keys:
            flag_pos = flag_users[flag]["+"]
            if len(flag_pos):
                self.printer(flag, "+", flag_pos)
                #blankline()
            flag_neg = flag_users[flag]["-"]
            if len(flag_neg):
                self.printer(flag, "-", flag_neg)
                #blankline()
            if "unset" in flag_users[flag] and flag_users[flag]["unset"]:
                flag_unset = flag_users[flag]["unset"]
                self.printer(flag, "unset", flag_unset)
            #blankline()
        if not self.options['quiet']:
            print("===================================================")
            print("Total number of flags in report =",
                  pp.output.red(str(len(flag_keys))))
            if self.options["verbose"]:
                print("Total number of installed ebuilds =",
                      pp.output.red(str(len([x for x in cpvs]))))
            print()
示例#3
0
	def analyse_flags(self, target):
		"""This will scan the installed packages db and analyze the
		USE flags used for installation and produce a report on how
		they were used.

		@type target: string
		@param target: the target to be analyzed, one of ["use", "pkguse"]
		"""
		system_use = portage.settings["USE"].split()

		self.printer = AnalysisPrinter(
				"use",
				self.options["verbose"],
				system_use,
				width=self.options["width"],
				prepend=self.options["prepend"])
		if self.options["verbose"]:
			cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
			#cpvs = get_installed_cpvs()
			#print "Total number of installed ebuilds =", len(cpvs)
			flag_users = gather_flags_info(cpvs, system_use,
				self.options["unset"], target=target.upper(),
				use_portage=self.options['portage'])
		else:
			cpvs = get_installed_cpvs()
			flag_users = gather_flags_info(cpvs, system_flags=system_use,
				include_unset=self.options["unset"], target=target.upper(),
				use_portage=self.options['portage'])
		#print flag_users
		flag_keys = sorted(flag_users)
		if self.options["verbose"]:
			print(" Flag                                 System  #pkgs   cat/pkg-ver")
			blankline = nl
		elif not self.options['quiet']:
			print(" Flag                                 System  #pkgs")
			blankline = lambda: None
		for flag in flag_keys:
			flag_pos = flag_users[flag]["+"]
			if len(flag_pos):
				self.printer(flag, "+", flag_pos)
				#blankline()
			flag_neg = flag_users[flag]["-"]
			if len(flag_neg):
				self.printer(flag, "-", flag_neg)
				#blankline()
			if "unset" in flag_users[flag] and flag_users[flag]["unset"]:
				flag_unset = flag_users[flag]["unset"]
				self.printer(flag, "unset", flag_unset)
			#blankline()
		if not self.options['quiet']:
			print("===================================================")
			print("Total number of flags in report =",
				pp.output.red(str(len(flag_keys))))
			if self.options["verbose"]:
				print("Total number of installed ebuilds =",
					pp.output.red(str(len([x for x in cpvs]))))
			print()
示例#4
0
 def _remove_uninstalled_packages(self):
     from gentoolkit.helpers import get_installed_cpvs
     
     for cpv in self._cpvs.keys():
         from gentoolkit.cpv import split_cpv
         scpv = rcpv = cpv.split('=')[-1].split('<')[-1].split('>')[-1]
         try:
             (category, pkg_name, version, revision) = split_cpv(rcpv)
             scpv = category + "/" + pkg_name
         except: continue
         if self._debug: output.debug(__file__, "scpv: %s", scpv)
         pred = lambda x: x.startswith(scpv)
         if self._debug: 
             output.debug(__file__, "list(get_installed_cpvs(pred)): %s", list(get_installed_cpvs(pred)))
             output.debug(__file__, "rcpv: %s", rcpv)
             output.debug(__file__, "''.join(list(get_installed_cpvs(pred))): %s", ''.join(list(get_installed_cpvs(pred))))
         import re
         if not re.search(rcpv, ''.join(list(get_installed_cpvs(pred)))):
             if self._verbose: output.verbose("Could not find %s installed on the system!", rcpv)
             self._cpvs.pop(cpv)
示例#5
0
    def analyse_packages(self):
        """This will scan the installed packages db and analyze the
        USE flags used for installation and produce a report.

        @type target: string
        @param target: the target to be analyzed, one of ["use", "pkguse"]
        """
        system_use = portage.settings["USE"].split()
        if self.options["verbose"]:
            cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
            key_width = 45
        else:
            cpvs = get_installed_cpvs()
            key_width = 1

        self.printer = AnalysisPrinter(
            "packages",
            self.options["verbose"],
            key_width=key_width,
            width=self.options["width"],
            prepend=self.options["prepend"],
        )

        cpvs = sorted(cpvs)
        flags = FlagAnalyzer(system=system_use,
                             filter_defaults=False,
                             target="USE")

        if self.options["verbose"]:
            print("   cat/pkg-ver                             USE Flags")
            #   "app-emulation/emul-linux-x86-sdl-20100915 ...."
            # blankline = nl
        elif not self.options["quiet"]:
            print("   cat/pkg-ver                             USE Flags")
            # blankline = lambda: None
        for cpv in cpvs:
            (flag_plus, flag_neg, unset) = flags.analyse_cpv(cpv)
            if self.options["unset"]:
                self.printer(
                    cpv, "",
                    (sorted(flag_plus), sorted(flag_neg), sorted(unset)))
            else:
                self.printer(cpv, "",
                             (sorted(flag_plus), sorted(flag_neg), []))
        if not self.options["quiet"]:
            print("===================================================")
            print(
                "Total number of installed ebuilds =",
                pp.output.red(str(len([x for x in cpvs]))),
            )
            print()
示例#6
0
	def analyse_packages(self):
		"""This will scan the installed packages db and analyze the
		USE flags used for installation and produce a report.

		@type target: string
		@param target: the target to be analyzed, one of ["use", "pkguse"]
		"""
		system_use = portage.settings["USE"].split()
		if self.options["verbose"]:
			cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all()
			key_width = 45
		else:
			cpvs = get_installed_cpvs()
			key_width = 1

		self.printer = AnalysisPrinter(
				"packages",
				self.options["verbose"],
				key_width=key_width,
				width=self.options["width"],
				prepend=self.options["prepend"])

		cpvs = sorted(cpvs)
		flags = FlagAnalyzer(
					system=system_use,
					filter_defaults=False,
					target="USE"
					)

		if self.options["verbose"]:
			print("   cat/pkg-ver                             USE Flags")
				#   "app-emulation/emul-linux-x86-sdl-20100915 ...."
			blankline = nl
		elif not self.options['quiet']:
			print("   cat/pkg-ver                             USE Flags")
			blankline = lambda: None
		for cpv in cpvs:
			(flag_plus, flag_neg, unset) = flags.analyse_cpv(cpv)
			if self.options["unset"]:
				self.printer(cpv, "", (sorted(flag_plus), sorted(flag_neg),
					sorted(unset)))
			else:
				self.printer(cpv, "", (sorted(flag_plus), sorted(flag_neg), []))
		if not self.options['quiet']:
			print("===================================================")
			print("Total number of installed ebuilds =",
				pp.output.red(str(len([x for x in cpvs]))))
			print()
示例#7
0
文件: package.py 项目: Arnox/pclean
 def _remove_uninstalled_packages(self):
     from gentoolkit.helpers import get_installed_cpvs
     
     for cpv in self._cpvs.keys():
         from gentoolkit.cpv import split_cpv
         scpv = cpv.split('=')[-1].split('<')[-1].split('>')[-1]
         try:
             (category, pkg_name, version, revision) = split_cpv(scpv)
             scpv = category + "/" + pkg_name
         except: continue
         if self._debug: output.debug(__file__, "scpv: %s", scpv)
         pred = lambda x: x.startswith(scpv)
         if self._debug: 
             output.debug(__file__, "len(set(get_installed_cpvs(pred))): %s", len(set(get_installed_cpvs(pred))))
         if len(set(get_installed_cpvs(pred))) <= 0:
             self._cpvs.pop(cpv)