1 |
jpp |
1.1 |
diff -Nur smeserver-yum-2.6.0.old/root/usr/lib/yum-plugins/smeserver.py smeserver-yum-2.6.0/root/usr/lib/yum-plugins/smeserver.py |
2 |
|
|
--- smeserver-yum-2.6.0.old/root/usr/lib/yum-plugins/smeserver.py 2020-12-06 23:11:14.321000000 -0500 |
3 |
|
|
+++ smeserver-yum-2.6.0/root/usr/lib/yum-plugins/smeserver.py 2020-12-06 23:12:58.737000000 -0500 |
4 |
|
|
@@ -63,6 +63,11 @@ |
5 |
|
|
smechange = False |
6 |
|
|
ourfile = False |
7 |
|
|
erasing = False |
8 |
|
|
+DEBUG = False |
9 |
|
|
+ |
10 |
|
|
+def log(s): |
11 |
|
|
+ if DEBUG: |
12 |
|
|
+ print s |
13 |
|
|
|
14 |
|
|
def report_yum_status(status): |
15 |
|
|
fileHandle = open(status_file, 'w') |
16 |
|
|
@@ -94,7 +99,21 @@ |
17 |
|
|
report_yum_status('postresolve') |
18 |
|
|
|
19 |
|
|
def pretrans_hook(conduit): |
20 |
|
|
+#transaction set states |
21 |
|
|
+#TS_UPDATE = 10 |
22 |
|
|
+#TS_INSTALL = 20 |
23 |
|
|
+#TS_TRUEINSTALL = 30 |
24 |
|
|
+#TS_ERASE = 40 |
25 |
|
|
+#TS_OBSOLETED = 50 |
26 |
|
|
+#TS_OBSOLETING = 60 |
27 |
|
|
+#TS_AVAILABLE = 70 |
28 |
|
|
+#TS_UPDATED = 90 |
29 |
|
|
+#TS_FAILED = 100 |
30 |
|
|
+#TS_INSTALL_STATES = [TS_INSTALL, TS_TRUEINSTALL, TS_UPDATE, TS_OBSOLETING] |
31 |
|
|
+#TS_REMOVE_STATES = [TS_ERASE, TS_OBSOLETED, TS_UPDATED] |
32 |
|
|
+ |
33 |
|
|
report_yum_status('pretrans') |
34 |
|
|
+ log("*******Pretrans********") |
35 |
|
|
# Prefetch filelist for packages to be removed, |
36 |
|
|
# otherwise for updated packages headers will not be available |
37 |
|
|
ts = conduit.getTsInfo() |
38 |
|
|
@@ -112,10 +131,10 @@ |
39 |
|
|
erasing = True |
40 |
|
|
(n, a, e, v, r) = tsmem.po.pkgtup |
41 |
|
|
#only for debug |
42 |
|
|
- #print 'Package: ' + tsmem.name + ' remove' |
43 |
|
|
+ log('**Package: ' + tsmem.name + ' remove') |
44 |
|
|
smeevent = tsmem.name + '-update' |
45 |
|
|
#only for debug |
46 |
|
|
- #print smeevent |
47 |
|
|
+ #log(smeevent) |
48 |
|
|
if os.path.isdir(events_path + os.sep + smeevent): |
49 |
|
|
tmppath = events_path + os.sep + smeevent + os.sep |
50 |
|
|
eventlist[tsmem.name] = smeevent |
51 |
|
|
@@ -128,22 +147,24 @@ |
52 |
|
|
if not templateslist.has_key(mytmptemplate): |
53 |
|
|
templateslist[mytmptemplate]=mytmptemplate |
54 |
|
|
#tmptmplpath = subdir + os.sep + file |
55 |
|
|
- #print (file) |
56 |
|
|
+ log(" template " + file) |
57 |
|
|
|
58 |
|
|
+ # nothing for actions ??? |
59 |
|
|
+ |
60 |
|
|
if os.path.isdir(tmppath + "services2adjust" + os.sep): |
61 |
|
|
tmppathsrv = tmppath + "services2adjust" + os.sep |
62 |
|
|
files = [f for f in os.listdir(tmppathsrv)] |
63 |
|
|
for f in files: |
64 |
|
|
if os.path.islink(tmppathsrv + f): |
65 |
|
|
- #print "link " + f + ": " + (os.readlink(tmppathsrv + f)) |
66 |
|
|
+ log(" service link " + f + ": " + (os.readlink(tmppathsrv + f))) |
67 |
|
|
mytmpserv = os.readlink(tmppathsrv + f) |
68 |
|
|
if not serviceslist.has_key(f): |
69 |
|
|
- serviceslist[f]=mytmpserv |
70 |
|
|
+ if tsmem.output_state == TS_ERASE: |
71 |
|
|
+ print('===> removal, we stop the service ' + f) |
72 |
|
|
+ serviceslist[f]="stop" |
73 |
|
|
+ else: |
74 |
|
|
+ serviceslist[f]=mytmpserv |
75 |
|
|
else: |
76 |
|
|
- #only for debug |
77 |
|
|
- #print "old value: " + serviceslist[f] |
78 |
|
|
- #print "new value: " + mytmpserv |
79 |
|
|
- |
80 |
|
|
if mytmpserv == "restart": |
81 |
jpp |
1.3 |
print "overriding all signals, forcing restart" |
82 |
jpp |
1.1 |
serviceslist[f]="restart" |
83 |
|
|
@@ -153,13 +174,14 @@ |
84 |
|
|
smechange = True |
85 |
|
|
|
86 |
|
|
#only for debug |
87 |
|
|
- #print 'smechange: '+str(smechange) |
88 |
|
|
- #print 'eventlist: '+ str(eventlist) |
89 |
|
|
- #print 'templateslist: '+str(templateslist) |
90 |
|
|
- #print 'serviceslist: '+str(serviceslist) |
91 |
|
|
+ log('## smechange: '+str(smechange)) |
92 |
|
|
+ log('## eventlist: '+ str(eventlist.keys())) |
93 |
|
|
+ log('## templateslist: '+str(templateslist.keys())) |
94 |
|
|
+ log('## serviceslist: '+str(serviceslist.keys())) |
95 |
|
|
|
96 |
|
|
def posttrans_hook(conduit): |
97 |
|
|
report_yum_status('posttrans') |
98 |
|
|
+ log("*******Postrans********") |
99 |
|
|
ts = conduit.getTsInfo() |
100 |
|
|
|
101 |
|
|
global smechange |
102 |
|
|
@@ -174,13 +196,12 @@ |
103 |
|
|
|
104 |
|
|
for tsmem in ts.getMembers(): |
105 |
|
|
(n, a, e, v, r) = tsmem.po.pkgtup |
106 |
|
|
- |
107 |
|
|
#print 'smechange: '+str(smechange) |
108 |
|
|
|
109 |
|
|
# we're upgrading/installing/removing a rebootpkgs package.. a reboot is required |
110 |
|
|
for pkg in rebootpkgs: |
111 |
|
|
if n.startswith(pkg): |
112 |
|
|
- #print 'Package: ' + tsmem.name + ' triggers reboot' |
113 |
|
|
+ log('**Package: ' + tsmem.name + ' triggers reboot') |
114 |
|
|
#smechange = True |
115 |
|
|
# we do some exclusions -devel -doc ... |
116 |
|
|
if pkg in rebootpkgsexclude: |
117 |
|
|
@@ -216,7 +237,11 @@ |
118 |
|
|
|
119 |
|
|
|
120 |
|
|
#if smechange is true we can ignore the following part |
121 |
|
|
- if not smechange and not erasing: |
122 |
|
|
+ # wondering if we reallly do want to ignore that : let's say we want to delay kernel reboot, |
123 |
|
|
+ # could we at least configure httpd cleanly until next week ? |
124 |
|
|
+ # also when updating a package the erasing flag was on and prevented to do this .... |
125 |
|
|
+ # if not smechange and not erasing: |
126 |
|
|
+ if True: |
127 |
|
|
|
128 |
|
|
#smeevent = 'yum-reconfigure-' + tsmem.name |
129 |
|
|
smeevent = tsmem.name + '-update' |
130 |
|
|
@@ -229,17 +254,20 @@ |
131 |
|
|
if os.path.islink(tmppath + f): |
132 |
|
|
|
133 |
|
|
mytmpaction = os.path.realpath(os.readlink(tmppath + f).replace("..",events_path)) |
134 |
|
|
- #print "link " + f + ": " + mytmpaction |
135 |
|
|
+ #log(" link " + f + ": " + mytmpaction) |
136 |
|
|
|
137 |
|
|
if f < "S05generic_template_expand": |
138 |
|
|
if not actionlistpre.has_key(mytmpaction): |
139 |
|
|
actionlistpre[mytmpaction] = mytmpaction |
140 |
|
|
+ log(" action Pre : " + f + " -> " + mytmpaction) |
141 |
|
|
elif f > "S90adjust-services": |
142 |
|
|
if not actionlistpost.has_key(mytmpaction): |
143 |
|
|
actionlistpost[mytmpaction] = mytmpaction |
144 |
|
|
+ log(" action Post : " + f + " -> " + mytmpaction) |
145 |
|
|
else: |
146 |
|
|
if not actionlist.has_key(mytmpaction): |
147 |
|
|
actionlist[mytmpaction] = mytmpaction |
148 |
|
|
+ log(" action : " + f + " -> " + mytmpaction) |
149 |
|
|
|
150 |
|
|
if os.path.isdir(tmppath + "templates2expand" + os.sep): |
151 |
|
|
tmppathtmpl = tmppath + "templates2expand" + os.sep |
152 |
|
|
@@ -249,22 +277,18 @@ |
153 |
|
|
if not templateslist.has_key(mytmptemplate): |
154 |
|
|
templateslist[mytmptemplate]=mytmptemplate |
155 |
|
|
#tmptmplpath = subdir + os.sep + file |
156 |
|
|
- #print (file) |
157 |
|
|
+ log(" template " + mytmptemplate) |
158 |
|
|
|
159 |
|
|
if os.path.isdir(tmppath + "services2adjust" + os.sep): |
160 |
|
|
tmppathsrv = tmppath + "services2adjust" + os.sep |
161 |
|
|
files = [f for f in os.listdir(tmppathsrv)] |
162 |
|
|
for f in files: |
163 |
|
|
if os.path.islink(tmppathsrv + f): |
164 |
|
|
- #print "link " + f + ": " + (os.readlink(tmppathsrv + f)) |
165 |
|
|
+ log(" service link " + f + ": " + (os.readlink(tmppathsrv + f))) |
166 |
|
|
mytmpserv = os.readlink(tmppathsrv + f) |
167 |
|
|
if not serviceslist.has_key(f): |
168 |
|
|
serviceslist[f]=mytmpserv |
169 |
|
|
else: |
170 |
|
|
- #only for debug |
171 |
|
|
- #print "old value: " + serviceslist[f] |
172 |
|
|
- #print "new value: " + mytmpserv |
173 |
|
|
- |
174 |
|
|
if mytmpserv == "restart": |
175 |
|
|
#only for debug |
176 |
|
|
print "overriding all signals, forcing restart" |
177 |
|
|
@@ -276,11 +300,15 @@ |
178 |
|
|
|
179 |
|
|
|
180 |
|
|
#only for debug |
181 |
|
|
- #print 'smechange: '+str(smechange) |
182 |
|
|
+ log('## smechange: '+str(smechange)) |
183 |
|
|
#print 'post-trans' |
184 |
|
|
- #print 'eventlist: '+ str(eventlist) |
185 |
|
|
- #print 'templateslist: '+str(templateslist) |
186 |
|
|
- #print 'serviceslist: '+str(serviceslist) |
187 |
|
|
+ log('## eventlist: '+ str(eventlist)) |
188 |
|
|
+ log('## actions early: ' + str(actionlistpre.keys())) |
189 |
|
|
+ log('## templateslist: '+str(templateslist.keys())) |
190 |
|
|
+ log('## actions: ' + str(actionlist.keys())) |
191 |
|
|
+ log('## serviceslist: '+str(serviceslist.keys())) |
192 |
|
|
+ log('## actions late: ' + str(actionlistpost.keys())) |
193 |
|
|
+ |
194 |
|
|
|
195 |
|
|
# check if smechange is true or if eventlist has items.. in both cases we must initialize databases |
196 |
|
|
if smechange == True or len(eventlist)>0: |
197 |
|
|
@@ -293,14 +321,14 @@ |
198 |
|
|
if len(actionlistpre)>0: |
199 |
|
|
print "Executing early actions" |
200 |
|
|
for kactions in actionlistpre: |
201 |
|
|
- #print kactions |
202 |
|
|
+ log(" " + kactions) |
203 |
|
|
if os.path.isfile(kactions): |
204 |
|
|
os.spawnl(os.P_WAIT, kactions, kactions) |
205 |
|
|
|
206 |
|
|
if len(templateslist)>0: |
207 |
|
|
print "Expanding templates" |
208 |
|
|
for ktemplates in templateslist: |
209 |
|
|
- #print ktemplates |
210 |
|
|
+ log(" " + ktemplates) |
211 |
|
|
mytemplatedir = '/etc/e-smith/templates/' + ktemplates |
212 |
|
|
mytemplatemeta = '/etc/e-smith/templates.metadata/' + ktemplates |
213 |
|
|
if os.path.exists(mytemplatedir) or os.path.exists(mytemplatemeta): |
214 |
|
|
@@ -309,7 +337,7 @@ |
215 |
|
|
if len(actionlist)>0: |
216 |
|
|
print "Executing actions" |
217 |
|
|
for kactions in actionlist: |
218 |
|
|
- #print kactions |
219 |
|
|
+ log(" " + kactions) |
220 |
|
|
if os.path.isfile(kactions): |
221 |
|
|
os.spawnl(os.P_WAIT, kactions, kactions,"post-upgrade") |
222 |
|
|
|
223 |
|
|
@@ -322,7 +350,7 @@ |
224 |
|
|
if len(actionlistpost)>0: |
225 |
|
|
print "Executing late actions" |
226 |
|
|
for kactions in actionlistpost: |
227 |
|
|
- #print kactions |
228 |
|
|
+ log(" " + kactions) |
229 |
|
|
if os.path.isfile(kactions): |
230 |
|
|
os.spawnl(os.P_WAIT, kactions, kactions) |
231 |
|
|
|
232 |
|
|
@@ -335,6 +363,7 @@ |
233 |
|
|
def close_hook(conduit): |
234 |
|
|
if ourfile and os.path.isfile('/var/run/yum.status'): |
235 |
|
|
os.unlink('/var/run/yum.status') |
236 |
|
|
+ log("***Close***") |
237 |
|
|
|
238 |
|
|
if smechange: |
239 |
|
|
print "\n==============================================================" |