diff options
author | Necoro <> | 2008-01-24 23:49:51 +0000 |
---|---|---|
committer | Necoro <> | 2008-01-24 23:49:51 +0000 |
commit | 4d4d5a6fd0348ecc628251dbca5ac9e22acfb555 (patch) | |
tree | 4b9e0de2dc57b8f4794812349c04466c5877c946 | |
parent | bf75aae3c9f6ac2130b65a0499e501ee697688b1 (diff) | |
download | portato-4d4d5a6fd0348ecc628251dbca5ac9e22acfb555.tar.gz portato-4d4d5a6fd0348ecc628251dbca5ac9e22acfb555.tar.bz2 portato-4d4d5a6fd0348ecc628251dbca5ac9e22acfb555.zip |
r716@Devoty: necoro | 2008-01-25 00:35:00 +0100
Improved useflag handling
r717@Devoty: necoro | 2008-01-25 00:47:45 +0100
improved update_world
-rw-r--r-- | portato/backend/flags.py | 17 | ||||
-rw-r--r-- | portato/backend/package.py | 26 | ||||
-rw-r--r-- | portato/backend/portage/package.py | 22 | ||||
-rw-r--r-- | portato/backend/portage/system.py | 18 | ||||
-rw-r--r-- | portato/gui/gtk/windows.py | 12 |
5 files changed, 52 insertions, 43 deletions
diff --git a/portato/backend/flags.py b/portato/backend/flags.py index b9fcae2..61d27aa 100644 --- a/portato/backend/flags.py +++ b/portato/backend/flags.py @@ -213,6 +213,23 @@ def sort_use_flag_list (flaglist): flaglist.sort(key = flag_key) return flaglist +def filter_defaults (flaglist): + """ + Removes "+" and "-" from IUSE defaults. + + @param flaglist: the list of useflags + @type flaglist: string<iterator> + + @returns: the "cleaned" list + @rtype: string<iterator> + """ + + for flag in flaglist: + if flag.startswith(("+","-")): + yield flag[1:] + else: + yield flag + def set_use_flag (pkg, flag): """Sets the useflag for a given package. diff --git a/portato/backend/package.py b/portato/backend/package.py index 16cee0e..da44e8a 100644 --- a/portato/backend/package.py +++ b/portato/backend/package.py @@ -68,20 +68,6 @@ class Package (_Package): return flags.is_locally_masked(self) - def get_installed_use_flags (self): - """Returns a list of the useflags enabled at installation time. If package is not installed, it returns an empty list. - - @returns: list of useflags enabled at installation time or an empty list - @rtype: string[]""" - - if self.is_installed(): - uses = set(self.get_use_flags().split()) # all set at installation time - iuses = set(self.get_iuse_flags(installed=True)) # all you can set for the package - - return list(uses.intersection(iuses)) - else: - return [] - def get_new_use_flags (self): """Returns a list of the new useflags, i.e. these flags which are not written to the portage-system yet. @@ -276,13 +262,13 @@ class Package (_Package): @returns: the reason for masking the package @rtype: string""" - def get_iuse_flags (self, installed = False, keep = False): + def get_iuse_flags (self, installed = False, removeForced = True): """Returns a list of _all_ useflags for this package, i.e. all useflags you can set for this package. @param installed: do not take the ones stated in the ebuild, but the ones it has been installed with @type installed: boolean - @param keep: keep the "+" or "-" signs for forced flags - @type keep: boolean + @param removeForced: remove forced flags (i.e. usemask / useforce) from the iuse flags as they cannot be set from the user + @type removeForced: boolean @returns: list of use-flags @rtype: string[]""" @@ -360,11 +346,11 @@ class Package (_Package): raise NotImplementedError - def get_use_flags(self): + def get_installed_use_flags(self): """Returns _all_ (not only the package-specific) useflags which were set at the installation time of the package. - @returns: string holding all useflags - @rtype: string""" + @returns: list of use flags + @rtype: string[]""" raise NotImplementedError diff --git a/portato/backend/portage/package.py b/portato/backend/portage/package.py index 42badbe..4760acb 100644 --- a/portato/backend/portage/package.py +++ b/portato/backend/portage/package.py @@ -146,21 +146,21 @@ class PortagePackage (Package): else: return reason - def get_iuse_flags (self, installed = False, keep = False): + def get_iuse_flags (self, installed = False, removeForced = True): if installed or not self.is_in_system(): tree = self._settings.vartree else: tree = self._settings.porttree - flags = self.get_package_settings("IUSE", tree = tree).split() + iuse = flags.filter_defaults(self.get_package_settings("IUSE", tree = tree).split()) - if not keep: # remove "+"/"-" - for ctr, f in enumerate(flags): - if f.startswith(("+","-")): - flags[ctr] = f[1:] - - return list(set(flags).difference(self.forced_flags)) + iuse = set(iuse) + if removeForced: + return list(iuse.difference(self.forced_flags)) + else: + return list(iuse) + def get_matched_dep_packages (self, depvar): # change the useflags, because we have internally changed some, but not made them visible for portage actual = self.get_actual_use_flags() @@ -281,10 +281,10 @@ class PortagePackage (Package): return r[0] - def get_use_flags(self): + def get_installed_use_flags(self): if self.is_installed(): - return self.get_package_settings("USE", tree = self._settings.vartree) - else: return "" + return self.get_package_settings("USE", tree = self._settings.vartree).split() + else: return [] def compare_version(self,other): v1 = self._scpv diff --git a/portato/backend/portage/system.py b/portato/backend/portage/system.py index a1ac90c..e2a00cb 100644 --- a/portato/backend/portage/system.py +++ b/portato/backend/portage/system.py @@ -370,9 +370,9 @@ class PortageSystem (SystemInterface): # append system packages packages.extend(unique_array([p.get_cp() for p in self.find_all_system_packages()])) - states = [(["RDEPEND","PDEPEND"],True)]#, (["DEPEND"], False)] + states = [(["RDEPEND"], True)] if self.with_bdeps(): - states[1] = (["DEPEND"], True) + states.append((["DEPEND"], True)) checked = [] updating = [] @@ -413,15 +413,19 @@ class PortageSystem (SystemInterface): new_iuse = set(p.get_iuse_flags(installed = False)) # IUSE in the ebuild old_iuse = set(p.get_iuse_flags(installed = True)) # IUSE in the vardb + + # add forced flags, as they might trigger a rebuild + new_iuse_f = set(p.get_iuse_flags(installed = False, removeForced = False)) + old_iuse_f = set(p.get_iuse_flags(installed = True, removeForced = False)) - if new_iuse.symmetric_difference(old_iuse): # difference between new_iuse and old_iuse + if new_iuse.symmetric_difference(old_iuse): # difference between IUSE (w/o forced) tempDeep = True if not appended: updating.append((p,p)) appended = True - else: - if new_iuse.intersection(p.get_actual_use_flags()).symmetric_difference(p.get_installed_use_flags()): + else: # check for difference between the _set_ useflags (w/ forced) + if new_iuse_f.intersection(p.get_actual_use_flags()).symmetric_difference(old_iuse_f.intersection(p.get_installed_use_flags())): tempDeep = True if not appended: updating.append((p,p)) @@ -429,7 +433,7 @@ class PortageSystem (SystemInterface): if deep or tempDeep: if (appended or prev_appended) and len(states) < 2: - real_states = states + [("DEPEND", False)] + real_states = states + [("PDEPEND", True), ("DEPEND", False)] else: real_states = states for state in real_states: @@ -442,7 +446,7 @@ class PortageSystem (SystemInterface): else: for pkg in bm: if not pkg: continue - check(pkg, state[1], appended) + check(pkg, state[1], appended) # XXX: should be 'or'ed with prev_appended? for p in self.get_new_packages(packages): if not p: continue # if a masked package is installed we have "None" here diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index bdd5bfb..ed31a66 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -1342,16 +1342,18 @@ class MainWindow (Window): if not pkg_flags: # no flags - stop here return None - actual = pkg.get_actual_use_flags() + actual = set(pkg.get_actual_use_flags()) if pkg.is_installed(): - installed = pkg.get_installed_use_flags() + installed = set(pkg.get_iuse_flags()).intersection(pkg.get_installed_use_flags()) else: inst = system.find_installed_packages(pkg.get_slot_cp()) if inst: - installed = inst[0].get_installed_use_flags() + installed = set(inst[0].get_iuse_flags()).intersection(inst[0].get_installed_use_flags()) else: - installed = [] + installed = set() + + diff = actual.symmetric_difference(installed) for use in pkg_flags: exp = pkg.use_expanded(use) @@ -1360,7 +1362,7 @@ class MainWindow (Window): else: useStr = use - if installed and ((use in actual) != (use in installed)): + if installed and use in diff: useStr += " %" if use in actual: enabled.append(useStr) |