[Yum-devel] take two: protect-packages plugin
Matthew Miller
mattdm at mattdm.org
Thu Jun 21 17:07:01 UTC 2007
On Thu, Jun 21, 2007 at 12:13:30PM -0400, James Antill wrote:
> This seems really indirect, did I miss the messages for why we don't
> just have a foo.d directory (and confdir be it, defaulting
> to: /etc/sysconfig/yum-protect-packages.d).
Mostly because the .d directory was a suggestion after the single file was
already working. In fact, I imagine that in most cases the directory just
plain wouldn't be used -- you can happily not create it, and then the file
is a nice simple case.
I have no strong feelings about this, though.
> Also I think the sysconfig name should have yum in there somewhere.
There's no reason this same file couldn't be used by apt or some other
package management tool.
> > if protectedlist:
> > for f in protectedlist:
> > for line in open(f).readlines():
> > line = string.strip(line)
> > if (line and line[0] != "#" and line not in opts.override
> > and line not in protectedpkgs):
> > protectedpkgs.append(line)
> Do we want to depend on fileinput, it just sucks to see this much code
> for a "common" operation. getMirrorList() also does the exact same
> thing, but using regexps.
I can see the part about reading in lines except blanks and comments being
common; less so the stripping out of duplicates and even less so
> > open(f).close()
> This is probably not needed though :).
Good point. :)
> > for tsmem in conduit.getTsInfo().getMembers():
> > if tsmem.name in protectedpkgs and tsmem.ts_state == 'e':
> > raise PluginYumExit("This transaction would cause %s to be removed. "
> > "This package is vital for the basic operation of your system. "
> > "If you really want to remove it, edit the list of protected "
> > "packages in the file %s or in the directory %s."
> > %(tsmem.name, confdir + "/protected-packages",
> > confdir + "/protected-packages.d"))
>
> It would be nice to change protectedpkgs to a dict with (file, line) as
> the values, then we could give a more helpful message here (as a bonus
> it should also be marginally faster).
Not a bad idea. There'd have to be special handling for duplicates, though.
Additionally, I'm not sure we want to overwhelm with too much information in
the error message.
Thansk very much for the feedback.
--
Matthew Miller mattdm at mattdm.org <http://mattdm.org/>
Boston University Linux ------> <http://linux.bu.edu/>
More information about the Yum-devel
mailing list