From 428b33cf7184416c5a0d07d23b279bb0b919e458 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Tue, 12 Sep 2023 13:49:55 +0200 Subject: [PATCH] Add a cmdline option to enabled blivet's auto_dev_updates flag Resolves: rhbz#2238292 --- blivet-gui | 5 ++++- blivetgui/blivet_utils.py | 11 ++++++++++- blivetgui/blivetgui.py | 8 ++++++-- man/blivet-gui.1 | 3 +++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/blivet-gui b/blivet-gui index 7ac513ae..db5e3d88 100755 --- a/blivet-gui +++ b/blivet-gui @@ -75,6 +75,9 @@ def parse_options(): help=_("show version information")) parser.add_argument("--keep-above", action="store_true", dest="keep_above", default=False, help=_("keep blivet-gui window above other windows")) + parser.add_argument("--auto-dev-updates", action="store_true", dest="auto_dev_updates", default=False, + help="gather all information about devices even if it requires potentially dangerous operation \ + like mounting or filesystem check") parser.add_argument("disks", metavar="disk", type=str, nargs="*", help="run blivet-gui only on specified disk(s) (optional)") @@ -108,7 +111,7 @@ def main(): sockfile = output.split()[0] client = BlivetGUIClient(server_socket=sockfile) - BlivetGUI(client, exclusive_disks=options.disks, keep_above=options.keep_above) + BlivetGUI(client, exclusive_disks=options.disks, keep_above=options.keep_above, auto_dev_updates=options.auto_dev_updates) if __name__ == '__main__': diff --git a/blivetgui/blivet_utils.py b/blivetgui/blivet_utils.py index 3c083842..e2f0a089 100644 --- a/blivetgui/blivet_utils.py +++ b/blivetgui/blivet_utils.py @@ -138,7 +138,7 @@ class BlivetUtils(object): installer_mode = False - def __init__(self, ignored_disks=None, exclusive_disks=None): + def __init__(self, ignored_disks=None, exclusive_disks=None, flags=None): self.ignored_disks = ignored_disks self.exclusive_disks = exclusive_disks @@ -164,9 +164,18 @@ def __init__(self, ignored_disks=None, exclusive_disks=None): # ignore zram devices blivet.udev.ignored_device_names.append(r"^zram") + # set blivet flags + if flags: + self._set_blivet_flags(flags) + self.blivet_reset() self._update_min_sizes_info() + def _set_blivet_flags(self, flags): + for flag, value in flags.items(): + self.log.info("setting blivet flag '%s' to '%s'", flag, value) + setattr(blivet.flags.flags, flag, value) + @property def resizable_filesystems(self): if self._resizable_filesystems is None: diff --git a/blivetgui/blivetgui.py b/blivetgui/blivetgui.py index 9322398b..0a6749e7 100644 --- a/blivetgui/blivetgui.py +++ b/blivetgui/blivetgui.py @@ -67,7 +67,7 @@ class BlivetGUI(object): installer_mode = False - def __init__(self, client, exclusive_disks=None, keep_above=False): + def __init__(self, client, exclusive_disks=None, keep_above=False, auto_dev_updates=False): self.client = client @@ -93,6 +93,10 @@ def __init__(self, client, exclusive_disks=None, keep_above=False): # supported filesystems self._supported_filesystems = [] + self.flags = dict() + if auto_dev_updates: + self.flags["auto_dev_updates"] = True + # CSS styles css_provider = Gtk.CssProvider() css_provider.load_from_path(locate_css_file("rectangle.css")) @@ -789,7 +793,7 @@ def _blivet_init_already_running(self): def blivet_init(self): loading_window = LoadingWindow(self.main_window) - ret = self._run_thread(loading_window, self.client.remote_control, ("init", self.ignored_disks, self.exclusive_disks)) + ret = self._run_thread(loading_window, self.client.remote_control, ("init", self.ignored_disks, self.exclusive_disks, self.flags)) if not ret.success: # pylint: disable=maybe-no-member # blivet-gui is already running --> quit diff --git a/man/blivet-gui.1 b/man/blivet-gui.1 index d24886c0..be65bd43 100644 --- a/man/blivet-gui.1 +++ b/man/blivet-gui.1 @@ -19,6 +19,9 @@ show version information and exit .TP .BR \-\-keep\-above keep the blivet-gui window above other windows +.TP +.BR \-\-auto\-dev\-updates +gather all information about devices even if it requires potentially dangerous operation like mounting or filesystem check .SH EXAMPLES You can run blivet-gui from a command line and specify one or more disks.