[Yum-devel] take two: protect-packages plugin
James Antill
jantill at redhat.com
Thu Jun 21 16:13:30 UTC 2007
On Thu, 2007-06-21 at 10:46 -0400, Matthew Miller wrote:
>
> if os.access(confdir + "/protected-packages", os.R_OK) :
> protectedlist.append(confdir + "/protected-packages")
>
> if os.access(confdir + "/protected-packages.d", os.R_OK):
> protectedlist.extend(glob.glob(confdir +
> "/protected-packages.d/*.list"))
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).
Also I think the sysconfig name should have yum in there somewhere.
> 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.
> open(f).close()
This is probably not needed though :).
> 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).
--
James Antill <jantill at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.baseurl.org/pipermail/yum-devel/attachments/20070621/523387a4/attachment.pgp
More information about the Yum-devel
mailing list