diff -Nur --no-dereference 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 --- smeserver-yum-2.6.0.old/root/usr/lib/yum-plugins/smeserver.py 2021-03-17 17:37:05.619000000 -0400 +++ smeserver-yum-2.6.0/root/usr/lib/yum-plugins/smeserver.py 2021-03-17 18:32:44.417000000 -0400 @@ -7,6 +7,8 @@ from yum.constants import * from yum.plugins import PluginYumExit from yum.plugins import TYPE_CORE +from yum.packages import parsePackages +from yum.packages import RpmBase requires_api_version = '2.1' plugin_type = (TYPE_CORE,) @@ -67,6 +69,8 @@ ourfile = False erasing = False DEBUG = False +smeEventPretrans = False +removenorebootok = dict() def log(s): if DEBUG : @@ -143,12 +147,16 @@ # otherwise for updated packages headers will not be available ts = conduit.getTsInfo() removes = ts.getMembersWithState(output_states=TS_REMOVE_STATES) + rpmdb = conduit.getRpmDB() global smechange global eventlist global actionlist global templateslist global serviceslist global erasing + global smeEventPretrans + global removenorebootok + # reinstall are not listed there so already skipped # downgrade are going there @@ -177,7 +185,15 @@ log(" template " + mytmptemplate) # nothing for actions ??? - + tmppathsrv = tmppath + os.sep + files = [f for f in os.listdir(tmppathsrv)] + for f in files: + if os.path.islink(tmppathsrv + f): + mytmpaction = os.path.realpath(os.readlink(tmppath + f).replace("..",events_path)) + log(" link " + f + ": " + mytmpaction) + actionlist[f]=mytmpaction + + # end debug print if os.path.isdir(tmppath + "services2adjust" + os.sep): tmppathsrv = tmppath + "services2adjust" + os.sep files = [f for f in os.listdir(tmppathsrv)] @@ -195,6 +211,12 @@ if mytmpserv == "restart": log("overriding all signals, forcing restart " + f ) serviceslist[f]="restart" + removenorebootok[n]=1; + thispo = rpmdb.searchNevra(name=n, arch=a, epoch=e, ver=v, rel=r)[0] + # thispo.dirlist thispo.ghostlist thispo.filelist + if "/etc/e-smith/web/panels/manager/cgi-bin" in thispo.dirlist: + log(" ==> pannel detected : adding navigation-conf") + actionlist['S80navigation-conf']="../actions/navigation-conf" else: if (n.startswith('smeserver') or n.startswith('e-smith')) and not n.startswith('smeserver-locale'): @@ -204,16 +226,19 @@ #only for debug log('## smechange: '+str(smechange)) - log('## eventlist: '+ str(eventlist.keys())) + log('## eventlist: '+ str(eventlist)) log('## templateslist: '+str(templateslist.keys())) log('## serviceslist: '+str(serviceslist.items())) + log('## actions ALL: ' + str(actionlist.keys())) log('## smechangelist: ' + str(smechangelist.keys())) - # would it be a good idea to do some action/event there to stop service being removed ? - # create an empty temp event - print "Creating temporary event 'temp' and populating it..." - createevent() if len(serviceslist)>0: + # would it be a good idea to do some action/event there to stop service being removed ? + # for the moment we do not, logic : if template still there at posttrans, we expand it after removal + # probably the actions in some situations could be done before... + # create an empty temp event + print "Creating temporary event 'temp' and populating it..." + createevent() print " Adding services to adjust" for kservices in serviceslist: log(" " + kservices + ": " + serviceslist[kservices]) @@ -222,23 +247,30 @@ # execute the event ; should we really wait ?? print "Executing signal-event temp before uninstalling ..........." os.spawnl(os.P_WAIT,signal_event,signal_event, 'temp') + smeEventPretrans = True; def posttrans_hook(conduit): report_yum_status('posttrans') log("*******Postrans********") ts = conduit.getTsInfo() - + rpmdb = conduit.getRpmDB() + global smechange global eventlist global actionlist global templateslist global serviceslist global erasing + global smeEventPretrans + global removenorebootok for tsmem in ts.getMembers(): (n, a, e, v, r) = tsmem.po.pkgtup - + # n: name ; a : arch; e: epoch ; v: version, r: release + #if tsmem.output_state in TS_INSTALL_STATES: + # thispo = rpmdb.searchNevra(name=n, arch=a, epoch=e, ver=v, rel=r)[0] + # we're upgrading/installing/removing a rebootpkgs package.. a reboot is required for pkg in rebootpkgs: if n.startswith(pkg): @@ -314,9 +346,15 @@ #only for debug log("overriding all signals, forcing restart " + f) serviceslist[f]="restart" + if tsmem.output_state in TS_INSTALL_STATES: + thispo = rpmdb.searchNevra(name=n, arch=a, epoch=e, ver=v, rel=r)[0] + # thispo.dirlist thispo.ghostlist thispo.filelist + if "/etc/e-smith/web/panels/manager/cgi-bin" in thispo.dirlist: + log(" ==> pannel detected : adding navigation-conf") + actionlist['S80navigation-conf']="../actions/navigation-conf" else: - if (n.startswith('smeserver') or n.startswith('e-smith')) and not n.startswith('smeserver-locale'): + if (n.startswith('smeserver') or n.startswith('e-smith')) and not n.startswith('smeserver-locale') and not (n in removenorebootok): smechange = True smechangelist[n]=str(tsmem.po.state) + " " + str(tsmem.current_state) + " " + str(tsmem.output_state) log("smechange set to True because of " + n + " with " + str(tsmem.po.state) + " " + str(tsmem.current_state) + " " + str(tsmem.output_state) ) @@ -340,6 +378,19 @@ if not actionlist.has_key('S89systemd-reload'): actionlist['S89systemd-reload'] = '/etc/e-smith/events/actions/systemd-reload' + # here we would like to remove duplicates + # those are potential : S??navigation-conf S??systemd-reload S??systemd-default + for act in ('navigation-conf','systemd-reload','systemd-default'): + global iter + iter = 0 + for key in actionlist.keys(): + if key.endswith(act): + iter += 1 + if iter>1: + del actionlist[key] + log("removing duplicate action " + key + " iter " + str(iter)) + + # now, if smechange is false (no reboot needed), we can execute actions, expand templates and adjust services # create an empty temp event