1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
/**
\page plugin-commit Commit plugin
\author Michael Andres <ma@suse.de>
<HR><!-- ====================================================================== -->
\section intro Introduction
This is a statefull plugin executed during \ref zypp::ZYpp::commit. At the beginning of a commit all plugins found in \c /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 \c ACC message. Sending back an unexpected or \c ERROR message execution of the plugin will be canceled.
If you have e.g. \c zypp-plugin-python installed a basic commit plugin could look like this:
\verbatim
#!/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()
\endverbatim
\see \ref plugin-writing
<HR><!-- ====================================================================== -->
\section pluginbegin PLUGINBEGIN
\verbatim
PLUGINBEGIN
userdata:TIDfoo42
^@
\endverbatim
Sent as 1st message after the plugin was launched. Prepare your plugin and send an \c ACC message when you are done. Commit will start after all plugins are initialized.
\li \c userdata:stringval Optional header sent if the application has provided a user data string. \see \ref zypp-userdata
<HR><!-- ====================================================================== -->
\section commitbegin COMMITBEGIN (added in v1)
\verbatim
COMMITBEGIN
{
"TransactionStepList": [ <TransactionStep>,... ]
}
^@
\endverbatim
Sent before installation actually starts. The body contains a JSON encoded object providing the \c TransactionStepList, basically the list of install/remove actions the the commit is going to perform. Each \c TransactionStep is encoded as JSON object:
\verbatim
<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
}
\endverbatim
\see \ref zypp::sat::Transaction::Step
<HR><!-- ====================================================================== -->
\section commitend COMMITEND (added in v1)
\verbatim
COMMITEND
{
"TransactionStepList": [ <TransactionStep>,... ]
}
^@
\endverbatim
Sent at the end of commit. The body contains a JSON encoded object providing the final \c TransactionStepList. The \c StepStage indicates whether the action succeeded, failed or was skipped (still 'todo').
\see \ref commitbegin
<HR><!-- ====================================================================== -->
\section pluginend PLUGINEND
\verbatim
PLUGINEND
^@
\endverbatim
This message is sent at the end of commit. You should receive this message even if commit was aborted by some unexpected exception.
*/
|