From: Michael Tremer Date: Wed, 11 Apr 2012 17:28:16 +0000 (+0200) Subject: Add scriptlets that are executed prior to the transaction. X-Git-Tag: 0.9.22~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f943de15ecea7b39defdd9a0d45cfd4939f12600;p=pakfire.git Add scriptlets that are executed prior to the transaction. --- diff --git a/python/pakfire/actions.py b/python/pakfire/actions.py index d1e1fba2f..1434841f4 100644 --- a/python/pakfire/actions.py +++ b/python/pakfire/actions.py @@ -249,6 +249,22 @@ class ActionScriptPostUp(ActionScript): script_action = "postup" +class ActionScriptPreTrans(ActionScript): + pass + + +class ActionScriptPreTransIn(ActionScriptPreTrans): + script_action = "pretransin" + + +class ActionScriptPreTransUn(ActionScriptPreTrans): + script_action = "pretransun" + + +class ActionScriptPreTransUp(ActionScriptPreTrans): + script_action = "pretransup" + + class ActionScriptPostTrans(ActionScript): pass diff --git a/python/pakfire/constants.py b/python/pakfire/constants.py index 9d4f34a2a..0899dd028 100644 --- a/python/pakfire/constants.py +++ b/python/pakfire/constants.py @@ -190,6 +190,9 @@ SCRIPTLET_INTERPRETER = "/bin/sh" SCRIPTLET_TIMEOUT = 60 * 15 SCRIPTS = ( + "pretransin", + "pretransun", + "pretransup", "prein", "postin", "preun", diff --git a/python/pakfire/packages/lexer.py b/python/pakfire/packages/lexer.py index 432806d7a..2e662c9a0 100644 --- a/python/pakfire/packages/lexer.py +++ b/python/pakfire/packages/lexer.py @@ -29,7 +29,7 @@ class LexerUndefinedVariableError(LexerError): LEXER_VALID_PACKAGE_NAME = re.compile(r"[A-Za-z][A-Za-z0-9\_\-\+]") # XXX need to build check -LEXER_VALID_SCRIPTLET_NAME = re.compile(r"((pre|post|posttrans)(in|un|up))") +LEXER_VALID_SCRIPTLET_NAME = re.compile(r"((pre|post|pretrans|posttrans)(in|un|up))") LEXER_COMMENT_CHAR = "#" LEXER_COMMENT = re.compile(r"^\s*#") diff --git a/python/pakfire/transaction.py b/python/pakfire/transaction.py index 9610f61ed..0b417d26d 100644 --- a/python/pakfire/transaction.py +++ b/python/pakfire/transaction.py @@ -157,12 +157,44 @@ class TransactionCheck(object): class Transaction(object): action_classes = { - ActionInstall.type : [ActionScriptPreIn, ActionInstall, ActionScriptPostIn, ActionScriptPostTransIn], - ActionReinstall.type : [ActionScriptPreIn, ActionReinstall, ActionScriptPostIn, ActionScriptPostTransIn], - ActionRemove.type : [ActionScriptPreUn, ActionRemove, ActionScriptPostUn, ActionScriptPostTransUn], - ActionUpdate.type : [ActionScriptPreUp, ActionUpdate, ActionScriptPostUp, ActionScriptPostTransUp], - ActionCleanup.type : [ActionCleanup,], - ActionDowngrade.type : [ActionScriptPreUp, ActionDowngrade, ActionScriptPostUp, ActionScriptPostTransUp], + ActionInstall.type : [ + ActionScriptPreTransIn, + ActionScriptPreIn, + ActionInstall, + ActionScriptPostIn, + ActionScriptPostTransIn, + ], + ActionReinstall.type : [ + ActionScriptPreTransIn, + ActionScriptPreIn, + ActionReinstall, + ActionScriptPostIn, + ActionScriptPostTransIn, + ], + ActionRemove.type : [ + ActionScriptPreTransUn, + ActionScriptPreUn, + ActionRemove, + ActionScriptPostUn, + ActionScriptPostTransUn, + ], + ActionUpdate.type : [ + ActionScriptPreTransUp, + ActionScriptPreUp, + ActionUpdate, + ActionScriptPostUp, + ActionScriptPostTransUp, + ], + ActionCleanup.type : [ + ActionCleanup, + ], + ActionDowngrade.type : [ + ActionScriptPreTransUp, + ActionScriptPreUp, + ActionDowngrade, + ActionScriptPostUp, + ActionScriptPostTransUp, + ], } def __init__(self, pakfire): @@ -233,15 +265,18 @@ class Transaction(object): Sort all actions. """ actions = [] + actions_pre = [] actions_post = [] for action in self.actions: - if isinstance(action, ActionScriptPostTrans): + if isinstance(action, ActionScriptPreTrans): + actions_pre.append(action) + elif isinstance(action, ActionScriptPostTrans): actions_post.append(action) else: actions.append(action) - self.actions = actions + actions_post + self.actions = actions_pre + actions + actions_post self.__need_sort = False @property