Commit graph

16 commits

Author SHA1 Message Date
Paweł Poławski
db08c472f3 general: Fix linter issues across the codebase 2024-08-26 11:59:46 -07:00
Michael Vogt
e0bbb3397d test: update test_mount.py for lsblk --json differences
Older version of `lsblk --json` will not have the plural `mountpoints`
but only a singular `mountpoint`. But newer version lost the
singular `mountpoint` in the json. Adjust the test accordingly.
2024-01-16 13:51:30 +01:00
Michael Vogt
d96f94fede test: fix new mount tests under rhel8
The new `create_image_with_partitions()` helper fails under rhel8
currently. The reason is that `mkfs.ext4 -E offset=` will warn
in older versions about a partition table and require user input.

This got fixed `e2fsprogs` 1.46.3 in Jul 2021 but RHEL8 still
has 1.45.

[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989612
2024-01-16 13:51:30 +01:00
Michael Vogt
8c95bd9dd7 test: fix autopep8 issues 2024-01-02 19:31:31 +01:00
Michael Vogt
530afa566f test: fix isort issues 2024-01-02 19:31:31 +01:00
Michael Vogt
57b5c7994e test: fix all pylint issues 2024-01-02 19:31:31 +01:00
Michael Vogt
8b475bb3f2 test: extend test_mount.py to mount 2 partitions 2023-12-22 10:18:29 -05:00
Michael Vogt
9cf68394d9 test: add mount service test with partitions 2023-12-22 10:18:29 -05:00
Dusty Mabe
ce8408a9c6 mounts: support mounting partitions
This allows us to map in a whole disk as a loopback device with parition
scanning rather than slicing up the disk and creating several loopback
devices. Something like this:

```
      - type: org.osbuild.copy
        inputs:
          tree:
            type: org.osbuild.tree
            origin: org.osbuild.pipeline
            references:
              - name:tree
        options:
          paths:
            - from: input://tree/
              to: mount://root/
        devices:
          efi:
            type: org.osbuild.loopback
            options:
              filename: disk.img
              start:
                mpp-format-int: '{image.layout[''EFI-SYSTEM''].start}'
              size:
                mpp-format-int: '{image.layout[''EFI-SYSTEM''].size}'
          boot:
            type: org.osbuild.loopback
            options:
              filename: disk.img
              start:
                mpp-format-int: '{image.layout[''boot''].start}'
              size:
                mpp-format-int: '{image.layout[''boot''].size}'
          root:
            type: org.osbuild.loopback
            options:
              filename: disk.img
              start:
                mpp-format-int: '{image.layout[''root''].start}'
              size:
                mpp-format-int: '{image.layout[''root''].size}'
        mounts:
          - name: root
            type: org.osbuild.xfs
            source: root
            target: /
          - name: boot
            type: org.osbuild.ext4
            source: boot
            target: /boot
          - name: efi
            type: org.osbuild.fat
            source: efi
            target: /boot/efi
```

now becomes a little more simple:

```
      - type: org.osbuild.copy
        inputs:
          tree:
            type: org.osbuild.tree
            origin: org.osbuild.pipeline
            references:
              - name:tree
        options:
          paths:
            - from: input://tree/
              to: mount://root/
        devices:
          disk:
            type: org.osbuild.loopback
            options:
              filename: disk.img
              partscan: true
        mounts:
          - name: root
            type: org.osbuild.xfs
            source: disk
            partition:
              mpp-format-int: '{image.layout[''root''].partnum}'
            target: /
          - name: boot
            type: org.osbuild.ext4
            source: disk
            partition:
              mpp-format-int: '{image.layout[''boot''].partnum}'
            target: /boot
          - name: efi
            type: org.osbuild.fat
            source: disk
            partition:
              mpp-format-int: '{image.layout[''EFI-SYSTEM''].partnum}'
            target: /boot/efi
```

Fixes https://github.com/osbuild/osbuild/issues/1495
2023-12-22 10:18:29 -05:00
Michael Vogt
1374faa488 tests: remove custom tmpdir() fixtures and use tmp_path
This commit removes some unnecessary custom tmpdir() fixtures
and uses the pytest buildin tmp_path instead.

Some custom tmpdir fixtures are left in place as they configure
the tmp location to be under `/var/tmp` which is not trivial to
do with pytests `tmp_path`. Not sure or not if the is a deep
reason there for using /var/tmp. I assume it's to ensure that
the tests run on a real FS not on a potential tmpfs but I don't
have the full background so didn't want to change anything.
2023-11-23 13:09:25 +01:00
Brian C. Lane
44c28c8c16 autopep8: Update with changes to make autopep8 -a -a -a happy 2023-08-10 13:04:14 +02:00
Tomáš Hozza
eb427e2513 Don't use capture_output=True with subprocess.run()
The `capture_output` argument does not exist on Python 3.6 used by
default on RHEL-8.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-26 11:43:13 +02:00
Tomáš Hozza
56987fdda4 Test: make run/test_mount.py not depend on installed osbuild
Previously, the unit test depended on osbuild modules being installed on
the system. As a result, this made the test not work in CI where we do
not install osbuild when running unit tests. In addition, the stage
executed by the unit test would use different version of osbuild
internals than the version that is being tests, which could result in
issues or not testing the intended code.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Tomáš Hozza
975965510b Test: handle non-existence of /run/osbuild in test/run/test_mount.py
The directory does not exist when the unit test is run in CI. Handle
this case by ensuring that parent directories are created as needed.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-04-12 11:57:18 +02:00
Thomas Lavocat
8f08433804 mounts: accept more mount options
Before we could only ask OSBuild to mount a device as readonly. But
devices can have more mount options than this. Supporting more options
is necessary for the new version of image-info that is using OSBuild's
internals in order to mount the image it wants to work on. Otherwise,
for instance, some umasks aren't applied properly and we can get
differences in rpm-verify results, thus corrupting the DB.

Mount is now accepting:
* readonly
* uid
* gid
* umask
* shortname
2023-02-01 12:29:58 +01:00
Thomas Lavocat
5112f72cbf mounts: use the options object for mountopts
This modification will allow a user to ask to mount the system as read
only for instance. Which would be super useful for image-info who is
progressively using more of OSbuild internals to mount partitions.
2022-11-30 14:21:10 +01:00