1 |
slords |
1.1 |
--- smeserver-yum-2.0.0/root/usr/lib/yum-plugins/protect-packages.py.yumremove 2008-11-24 08:56:16.000000000 -0700 |
2 |
|
|
+++ smeserver-yum-2.0.0/root/usr/lib/yum-plugins/protect-packages.py 2007-07-09 15:32:12.000000000 -0600 |
3 |
|
|
@@ -0,0 +1,92 @@ |
4 |
|
|
+# This program is free software; you can redistribute it and/or modify |
5 |
|
|
+# it under the terms of the GNU General Public License as published by |
6 |
|
|
+# the Free Software Foundation; either version 2 of the License, or |
7 |
|
|
+# (at your option) any later version. |
8 |
|
|
+# |
9 |
|
|
+# This program is distributed in the hope that it will be useful, |
10 |
|
|
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
|
|
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
|
|
+# GNU Library General Public License for more details. |
13 |
|
|
+# |
14 |
|
|
+# You should have received a copy of the GNU General Public License |
15 |
|
|
+# along with this program; if not, write to the Free Software |
16 |
|
|
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 |
|
|
+ |
18 |
|
|
+ |
19 |
|
|
+# Copyright 2007 Boston University |
20 |
|
|
+# written by Svetlana Anissimova <svetanis@gmail.com> and |
21 |
|
|
+# Matthew Miller <mattdm@mattdm.org> |
22 |
|
|
+ |
23 |
|
|
+""" |
24 |
|
|
+This plugin prevents Yum from removing itself and other protected packages. |
25 |
|
|
+ |
26 |
|
|
+By default, yum is the only package protected, but by extension this |
27 |
|
|
+automatically protects everything on which yum depends (rpm, python, glibc, |
28 |
|
|
+and so on).Therefore, the plugin functions well even without |
29 |
|
|
+compiling careful lists of all important packages. |
30 |
|
|
+ |
31 |
|
|
+Additional packages to protect may be listed one per line in the file |
32 |
|
|
+/etc/sysconfig/protected-packages and in *.list files placed in |
33 |
|
|
+/etc/sysconfig/protected-packages.d/. |
34 |
|
|
+ |
35 |
|
|
+If you wish to temporarily exclude certain packages from protection, you can |
36 |
|
|
+use the --override-protection command-line option. |
37 |
|
|
+""" |
38 |
|
|
+ |
39 |
|
|
+try: |
40 |
|
|
+ from yum.plugins import TYPE_CORE, TYPE_INTERACTIVE, PluginYumExit |
41 |
|
|
+except ImportError: |
42 |
|
|
+ from yum.plugins import TYPE_CORE, TYPE_INTERFACE, PluginYumExit |
43 |
|
|
+import sys |
44 |
|
|
+import os |
45 |
|
|
+import string |
46 |
|
|
+import glob |
47 |
|
|
+ |
48 |
|
|
+requires_api_version = '2.1' |
49 |
|
|
+try: |
50 |
|
|
+ plugin_type = (TYPE_CORE, TYPE_INTERACTIVE) |
51 |
|
|
+except NameError: |
52 |
|
|
+ plugin_type = (TYPE_CORE, TYPE_INTERFACE) |
53 |
|
|
+ |
54 |
|
|
+def config_hook(conduit): |
55 |
|
|
+ parser = conduit.getOptParser() |
56 |
|
|
+ parser.add_option("", "--override-protection", dest='override', |
57 |
|
|
+ action="append", default=[], metavar='[package]', |
58 |
|
|
+ help="remove package from the list of protected packages") |
59 |
|
|
+ |
60 |
|
|
+def postresolve_hook(conduit): |
61 |
|
|
+ protectedpkgs = ['yum'] |
62 |
|
|
+ protectedlist = [] |
63 |
|
|
+ opts, args = conduit.getCmdLine() |
64 |
|
|
+ |
65 |
|
|
+ confdir = conduit.confString('main','confdir','/etc/sysconfig') |
66 |
|
|
+ |
67 |
|
|
+ if os.access(confdir + "/protected-packages", os.R_OK) : |
68 |
|
|
+ protectedlist.append(confdir + "/protected-packages") |
69 |
|
|
+ |
70 |
|
|
+ if os.access(confdir + "/protected-packages.d", os.R_OK): |
71 |
|
|
+ protectedlist.extend(glob.glob(confdir + "/protected-packages.d/*.list")) |
72 |
|
|
+ |
73 |
|
|
+ if protectedlist: |
74 |
|
|
+ for f in protectedlist: |
75 |
|
|
+ for line in open(f).readlines(): |
76 |
|
|
+ line = string.strip(line) |
77 |
|
|
+ if (line and line[0] != "#" and line not in opts.override |
78 |
|
|
+ and line not in protectedpkgs): |
79 |
|
|
+ protectedpkgs.append(line) |
80 |
|
|
+ |
81 |
|
|
+ for tsmem in conduit.getTsInfo().getMembers(): |
82 |
|
|
+ if tsmem.name in protectedpkgs and tsmem.ts_state == 'e': |
83 |
|
|
+ raise PluginYumExit("This transaction would cause %s to be removed." |
84 |
|
|
+ " This package is vital for the basic operation of your system." |
85 |
|
|
+ " If you really want to remove it, edit the list of protected" |
86 |
|
|
+ " packages in the file %s or in the directory %s or use the" |
87 |
|
|
+ " --override-protection command-line option." |
88 |
|
|
+ %(tsmem.name, confdir + "/protected-packages", |
89 |
|
|
+ confdir + "/protected-packages.d")) |
90 |
|
|
+ |
91 |
|
|
+ |
92 |
|
|
+ |
93 |
|
|
+ |
94 |
|
|
+ |
95 |
|
|
+ |
96 |
|
|
--- smeserver-yum-2.0.0/root/etc/yum/pluginconf.d/protect-packages.conf.yumremove 2008-11-24 08:55:46.000000000 -0700 |
97 |
|
|
+++ smeserver-yum-2.0.0/root/etc/yum/pluginconf.d/protect-packages.conf 2007-07-06 14:00:44.000000000 -0600 |
98 |
|
|
@@ -0,0 +1,3 @@ |
99 |
|
|
+[main] |
100 |
|
|
+enabled = 1 |
101 |
|
|
+confdir = /etc/sysconfig |