|
libzypp 17.37.18
|
This is a statefull plugin executed during zypp::ZYpp::commit. At the beginning of a commit all plugins found in /usr/lib/zypp/plugins/commit are launched. The plugins will receive messages as commit proceeds. Unless otherwise specified messages received need to be confirmed by sending an ACC message. Sending back an unexpected or ERROR message execution of the plugin will be canceled.
If you have e.g. zypp-plugin-python installed a basic commit plugin could look like this:
#!/usr/bin/env python
#
# zypp commit plugin
#
import os
import sys
from zypp_plugin import Plugin
class MyPlugin(Plugin):
def PLUGINBEGIN(self, headers, body):
# commit is going to start.
if headers.has_key('userdata'):
print "Commit starts with TID '%s'" % headers['userdata']
self.ack()
def PLUGINEND(self, headers, body):
# commit ended
self.ack()
plugin = MyPlugin()
plugin.main()
PLUGINBEGIN userdata:TIDfoo42 ^@
Sent as 1st message after the plugin was launched. Prepare your plugin and send an ACC message when you are done. Commit will start after all plugins are initialized.
userdata:stringval Optional header sent if the application has provided a user data string. COMMITBEGIN
{
"TransactionStepList": [ <TransactionStep>,... ]
}
^@
Sent before installation actually starts. The body contains a JSON encoded object providing the TransactionStepList, basically the list of install/remove actions the the commit is going to perform. Each TransactionStep is encoded as JSON object:
<TransactionStep> = {
"type": <TypeString> # [optional]
"stage": <StageString> # [optional]
"solvable": <Solvable>
}
<TypeString> = <missing> # ignore; implicit or non-package actions
| "-" # remove
| "+" # install
| "M" # multi version install; install keeping the old version; e.g. kernel
<StageString> = <missing> # todo
| "ok" # done
| "err" # failed
<Solvable> = {
"n": <string> # name
"e": <number> # epoch if not 0 [optional]
"v": <string> # version
"r": <string> # release
"a": <string> # architecture
}
COMMITEND
{
"TransactionStepList": [ <TransactionStep>,... ]
}
^@
Sent at the end of commit. The body contains a JSON encoded object providing the final TransactionStepList. The StepStage indicates whether the action succeeded, failed or was skipped (still 'todo').
PLUGINEND ^@
This message is sent at the end of commit. You should receive this message even if commit was aborted by some unexpected exception.