Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{pre,post}-transaction-actions: fix package files filtering regression #540

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ DNF-PLUGINS-CORE CONTRIBUTORS
Wieland Hoffmann <themineo@gmail.com>
Otto Urpelainen <oturpe@iki.fi>
Matija Skrgulja <mskrgulja@gmail.com>
Xiao Liang <github.com/TheHillBright>
Xiao Liang <github.com/TheHillBright>
Kamil Szczęk <kamil@szczek.dev>
15 changes: 13 additions & 2 deletions plugins/post-transaction-actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import libdnf.conf
import dnf
import dnf.transaction
import dnf.util
import glob
import os
import subprocess
Expand All @@ -45,13 +46,22 @@ 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)
if conf.has_section("main"):
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."""
Expand Down Expand Up @@ -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 = []
Expand All @@ -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":
Expand Down
15 changes: 13 additions & 2 deletions plugins/pre-transaction-actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import libdnf.conf
import dnf
import dnf.transaction
import dnf.util
import glob
import os
import subprocess
Expand All @@ -30,13 +31,22 @@ 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)
if conf.has_section("main"):
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."""
Expand Down Expand Up @@ -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 = []
Expand All @@ -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":
Expand Down
Loading