diff --git a/AUTHORS b/AUTHORS index 06afc7b9..4888268f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -39,4 +39,5 @@ DNF-PLUGINS-CORE CONTRIBUTORS Wieland Hoffmann Otto Urpelainen Matija Skrgulja - Xiao Liang \ No newline at end of file + Xiao Liang + Kamil Szczęk diff --git a/plugins/post-transaction-actions.py b/plugins/post-transaction-actions.py index a293fe2f..7796103f 100644 --- a/plugins/post-transaction-actions.py +++ b/plugins/post-transaction-actions.py @@ -31,6 +31,7 @@ import libdnf.conf import dnf import dnf.transaction +import dnf.util import glob import os import subprocess @@ -45,6 +46,7 @@ def __init__(self, base, cli): self.actiondir = "/etc/dnf/plugins/post-transaction-actions.d/" self.base = base self.logger = logger + self.action_tuples = None def config(self): conf = self.read_config(self.base.conf) @@ -52,6 +54,14 @@ def config(self): if conf.has_option("main", "actiondir"): self.actiondir = conf.get("main", "actiondir") + if "filelists" not in self.base.conf.optional_metadata_types: + if self.action_tuples is None: + self.action_tuples = self._parse_actions() + for (a_key, _, _) in self.action_tuples: + if dnf.util._is_file_pattern_present(a_key): + self.base.conf.optional_metadata_types += ["filelists"] + break + def _parse_actions(self): """Parses *.action files from self.actiondir path. Parsed actions are stored in a list of tuples.""" @@ -105,7 +115,8 @@ def _replace_vars(self, ts_item, command): return result def transaction(self): - action_tuples = self._parse_actions() + if self.action_tuples is None: + self.action_tuples = self._parse_actions() in_ts_items = [] out_ts_items = [] @@ -121,7 +132,7 @@ def transaction(self): all_ts_items.append(ts_item) commands_to_run = [] - for (a_key, a_state, a_command) in action_tuples: + for (a_key, a_state, a_command) in self.action_tuples: if a_state == "in": ts_items = in_ts_items elif a_state == "out": diff --git a/plugins/pre-transaction-actions.py b/plugins/pre-transaction-actions.py index 3f59ec3f..b84511d4 100644 --- a/plugins/pre-transaction-actions.py +++ b/plugins/pre-transaction-actions.py @@ -16,6 +16,7 @@ import libdnf.conf import dnf import dnf.transaction +import dnf.util import glob import os import subprocess @@ -30,6 +31,7 @@ def __init__(self, base, cli): self.actiondir = "/etc/dnf/plugins/pre-transaction-actions.d/" self.base = base self.logger = logger + self.action_tuples = None def config(self): conf = self.read_config(self.base.conf) @@ -37,6 +39,14 @@ def config(self): if conf.has_option("main", "actiondir"): self.actiondir = conf.get("main", "actiondir") + if "filelists" not in self.base.conf.optional_metadata_types: + if self.action_tuples is None: + self.action_tuples = self._parse_actions() + for (a_key, _, _) in self.action_tuples: + if dnf.util._is_file_pattern_present(a_key): + self.base.conf.optional_metadata_types += ["filelists"] + break + def _parse_actions(self): """Parses *.action files from self.actiondir path. Parsed actions are stored in a list of tuples.""" @@ -90,7 +100,8 @@ def _replace_vars(self, ts_item, command): return result def pre_transaction(self): - action_tuples = self._parse_actions() + if self.action_tuples is None: + self.action_tuples = self._parse_actions() in_ts_items = [] out_ts_items = [] @@ -106,7 +117,7 @@ def pre_transaction(self): all_ts_items.append(ts_item) commands_to_run = [] - for (a_key, a_state, a_command) in action_tuples: + for (a_key, a_state, a_command) in self.action_tuples: if a_state == "in": ts_items = in_ts_items elif a_state == "out":