Skip to content

Commit

Permalink
Merge branch '3.9-devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechtrefny committed Nov 10, 2023
2 parents be6244e + 4205a28 commit 6f7a76c
Show file tree
Hide file tree
Showing 45 changed files with 1,816 additions and 1,297 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/anaconda_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
podman run -i --rm -v ./blivet:/blivet:z -v ./anaconda:/anaconda:z quay.io/rhinstaller/anaconda-ci:$TARGET_BRANCH sh -c " \
set -xe; \
dnf remove -y python3-blivet; \
dnf install -y python3-blockdev libblockdev-plugins-all python3-bytesize libbytesize python3-pyparted parted libselinux-python3; \
dnf install -y python3-blockdev libblockdev-plugins-all python3-bytesize libbytesize python3-pyparted python3-libmount parted libselinux-python3; \
cd /blivet; \
python3 ./setup.py install; \
cd /anaconda; \
Expand Down
31 changes: 1 addition & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,36 +165,7 @@ rpmlog:
@echo

bumpver: po-pull
@opts="-n $(PKGNAME) -v $(VERSION) -r $(RPMRELEASE)" ; \
if [ ! -z "$(IGNORE)" ]; then \
opts="$${opts} -i $(IGNORE)" ; \
fi ; \
if [ ! -z "$(MAP)" ]; then \
opts="$${opts} -m $(MAP)" ; \
fi ; \
if [ ! -z "$(SKIP_ACKS)" ]; then \
opts="$${opts} -s" ; \
fi ; \
if [ ! -z "$(BZDEBUG)" ]; then \
opts="$${opts} -d" ; \
fi ; \
( scripts/makebumpver $${opts} ) || exit 1 ; \

scratch-bumpver:
@opts="-n $(PKGNAME) -v $(RPMVERSION) -r $(RPMRELEASE) --newrelease $(RC_RELEASE)" ; \
if [ ! -z "$(IGNORE)" ]; then \
opts="$${opts} -i $(IGNORE)" ; \
fi ; \
if [ ! -z "$(MAP)" ]; then \
opts="$${opts} -m $(MAP)" ; \
fi ; \
if [ ! -z "$(SKIP_ACKS)" ]; then \
opts="$${opts} -s" ; \
fi ; \
if [ ! -z "$(BZDEBUG)" ]; then \
opts="$${opts} -d" ; \
fi ; \
( scripts/makebumpver $${opts} ) || exit 1 ; \
( scripts/makebumpver -n $(PKGNAME) -v $(VERSION) -r $(RPMRELEASE) ) || exit 1 ;

scratch:
@rm -f ChangeLog
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ To install these dependencies use following commands:
# dnf install python3-blockdev libblockdev-plugins-all python3-bytesize libbytesize python3-pyparted parted libselinux-python3
* On Debian and Ubuntu based distributions:

# apt-get install python3-blockdev python3-bytesize python3-parted python3-selinux gir1.2-blockdev-3.0 libblockdev-lvm3 libblockdev-btrfs3 libblockdev-swap3 libblockdev-loop3 libblockdev-crypto3 libblockdev-mpath3 libblockdev-dm3 libblockdev-mdraid3 libblockdev-nvdimm3
# apt-get install python3-blockdev python3-bytesize python3-parted python3-selinux gir1.2-blockdev-3.0 libblockdev-lvm3 libblockdev-btrfs3 libblockdev-swap3 libblockdev-loop3 libblockdev-crypto3 libblockdev-mpath3 libblockdev-dm3 libblockdev-mdraid3 libblockdev-nvdimm3 libblockdev-fs3

### Development

Expand Down
4 changes: 2 additions & 2 deletions blivet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def log_bd_message(level, msg):
from gi.repository import GLib
from gi.repository import BlockDev as blockdev
if arch.is_s390():
_REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm", "nvme"))
_REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm", "nvme", "fs"))
else:
_REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm", "nvme"))
_REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm", "nvme", "fs"))

_requested_plugins = blockdev.plugin_specs_from_names(_REQUESTED_PLUGIN_NAMES)
try:
Expand Down
21 changes: 20 additions & 1 deletion blivet/actionlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,24 +268,39 @@ def _post_process(self, devices=None):
partition.parted_partition = pdisk.getPartitionByPath(partition.path)

@with_flag("processing")
def process(self, callbacks=None, devices=None, dry_run=None):
def process(self, callbacks=None, devices=None, fstab=None, dry_run=None):
"""
Execute all registered actions.
:param callbacks: callbacks to be invoked when actions are executed
:param devices: a list of all devices current in the devicetree
:param fstab: FSTabManagerObject tied to blivet, if None fstab file will not be modified
:type callbacks: :class:`~.callbacks.DoItCallbacks`
"""
devices = devices or []
self._pre_process(devices=devices)

skip_fstab = fstab is None or fstab.dest_file is None

for action in self._actions[:]:
log.info("executing action: %s", action)
if dry_run:
continue

# get (b)efore (a)ction.(e)xecute fstab entry
# (device may not exist afterwards)
if not skip_fstab:
try:
entry = fstab.entry_from_device(action.device)
except ValueError:
# this device should not be in fstab
bae_entry = None
else:
bae_entry = fstab.find_entry(entry=entry)

with blivet_lock:

try:
action.execute(callbacks)
except DiskLabelCommitError:
Expand Down Expand Up @@ -315,4 +330,8 @@ def process(self, callbacks=None, devices=None, dry_run=None):
self._completed_actions.append(self._actions.pop(0))
_callbacks.action_executed(action=action)

if not skip_fstab:
fstab.update(action, bae_entry)
fstab.write()

self._post_process(devices=devices)
13 changes: 12 additions & 1 deletion blivet/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from .errors import StorageError, DependencyError
from .size import Size
from .devicetree import DeviceTree
from .fstab import FSTabManager
from .formats import get_default_filesystem_type
from .flags import flags
from .formats import get_format
Expand All @@ -55,6 +56,9 @@
log = logging.getLogger("blivet")


FSTAB_PATH = "/etc/fstab"


@six.add_metaclass(SynchronizedMeta)
class Blivet(object):

Expand All @@ -71,6 +75,10 @@ def __init__(self):
self.size_sets = []
self.set_default_fstype(get_default_filesystem_type())

# fstab write location purposedly set to None. It has to be overriden
# manually when using blivet.
self.fstab = FSTabManager(src_file=FSTAB_PATH, dest_file=None)

self._short_product_name = 'blivet'

self._next_id = 0
Expand Down Expand Up @@ -111,7 +119,8 @@ def do_it(self, callbacks=None):
"""

self.devicetree.actions.process(callbacks=callbacks, devices=self.devices)
self.devicetree.actions.process(callbacks=callbacks, devices=self.devices, fstab=self.fstab)
self.fstab.read()

@property
def next_id(self):
Expand Down Expand Up @@ -141,6 +150,8 @@ def reset(self, cleanup_only=False):
self.edd_dict = get_edd_dict(self.partitioned)
self.devicetree.edd_dict = self.edd_dict

self.fstab.read()

if flags.include_nodev:
self.devicetree.handle_nodev_filesystems()

Expand Down
19 changes: 16 additions & 3 deletions blivet/fcoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#

import os

import gi
gi.require_version("BlockDev", "3.0")

from gi.repository import BlockDev

from . import errors
from . import udev
from . import util
Expand All @@ -33,11 +39,18 @@
def has_fcoe():
global _fcoe_module_loaded
if not _fcoe_module_loaded:
util.run_program(["modprobe", "libfc"])
_fcoe_module_loaded = True
try:
BlockDev.utils.load_kernel_module("libfc", None)
except BlockDev.UtilsError as e:
log.error("failed to load libfc: %s", str(e))
else:
_fcoe_module_loaded = True
if "bnx2x" in util.lsmod():
log.info("fcoe: loading bnx2fc")
util.run_program(["modprobe", "bnx2fc"])
try:
BlockDev.utils.load_kernel_module("bnx2fc", None)
except BlockDev.UtilsError as e:
log.error("failed to load bnx2fc: %s", str(e))

return os.access("/sys/module/libfc", os.X_OK)

Expand Down
4 changes: 0 additions & 4 deletions blivet/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def __init__(self):
self.noiswmd = False

self.gfs2 = True
self.jfs = True
self.reiserfs = True

# for this flag to take effect,
# blockdev.mpath.set_friendly_names(flags.multipath_friendly_names) must
Expand Down Expand Up @@ -112,8 +110,6 @@ def update_from_boot_cmdline(self):
self.multipath = "nompath" not in self.boot_cmdline
self.noiswmd = "noiswmd" in self.boot_cmdline
self.gfs2 = "gfs2" in self.boot_cmdline
self.jfs = "jfs" in self.boot_cmdline
self.reiserfs = "reiserfs" in self.boot_cmdline


flags = Flags()
20 changes: 8 additions & 12 deletions blivet/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
import importlib
from six import add_metaclass

import gi
gi.require_version("BlockDev", "3.0")

from gi.repository import BlockDev as blockdev

from .. import udev
from ..util import get_sysfs_path_by_name
from ..util import run_program
Expand Down Expand Up @@ -560,19 +565,10 @@ def _pre_destroy(self, **kwargs):
raise DeviceFormatError("device path does not exist or is not writable")

def _destroy(self, **kwargs):
rc = 0
err = ""
try:
rc = run_program(["wipefs", "-f", "-a", self.device])
except OSError as e:
err = str(e)
else:
if rc:
err = str(rc)

if err:
msg = "error wiping old signatures from %s: %s" % (self.device, err)
raise FormatDestroyError(msg)
blockdev.fs.clean(self.device, force=True)
except blockdev.FSError as e:
raise FormatDestroyError("error wiping old signatures from %s: %s" % (self.device, str(e)))

def _post_destroy(self, **kwargs):
udev.settle()
Expand Down
Loading

0 comments on commit 6f7a76c

Please sign in to comment.