rpm-software-management / dnf5

Next-generation RPM package management system
Other
238 stars 79 forks source link

Present rpm logs to the user in case of problems #1710

Closed m-blaha closed 8 hours ago

m-blaha commented 1 week ago

Although we write rpm logs to dnf5.log, we should directly print the errors to the terminal (as dnf4 do).

For example (see https://bugzilla.redhat.com/show_bug.cgi?id=2312906):

Prepare the environment:

# mkdir -p /tmp/IR/mnt
# dd if=/dev/zero of=/tmp/IR-loop bs=1024 count=1000
# losetup /dev/loop0 /tmp/IR-loop
# mkfs -t ext4 -v /dev/loop0
# mount -t ext4 -o ro /dev/loop0 /tmp/IR/mnt/

With dnf4 the root cause (readonly filesystem) is clearly visible:

# dnf4 install filesystem --installroot=/tmp/IR --repo=fedora
Fedora 39 - x86_64                                       5.1 MB/s |  34 MB     00:06    
Last metadata expiration check: 0:00:02 ago on Thu 19 Sep 2024 08:37:10 AM CEST.
Dependencies resolved.
=========================================================================================
 Package               Architecture      Version                 Repository         Size
=========================================================================================
Installing:
 filesystem            x86_64            3.18-6.fc39             fedora            1.1 M

Transaction Summary
=========================================================================================
Install  1 Package

Total download size: 1.1 M
Installed size: 106  
Is this ok [y/N]: y
Downloading Packages:
filesystem-3.18-6.fc39.x86_64.rpm                        3.5 MB/s | 1.1 MB     00:00    
-----------------------------------------------------------------------------------------
Total                                                    1.3 MB/s | 1.1 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Running scriptlet: filesystem-3.18-6.fc39.x86_64                                   1/1 
  Preparing        :                                                                 1/1 
  Installing       : filesystem-3.18-6.fc39.x86_64                                   1/1 
error: lsetfilecon: (27 /mnt, system_u:object_r:mnt_t:s0) Read-only file system
error: Plugin selinux: hook fsm_file_prepare failed

Error unpacking rpm package filesystem-3.18-6.fc39.x86_64

Failed:
  filesystem-3.18-6.fc39.x86_64                                                          

Error: Transaction failed

With dnf5 the user does not have a clue:

# dnf5 install filesystem --installroot=/tmp/IR --use-host-config --repo=fedora
Updating and loading repositories:
Repositories loaded.
Package                     Arch     Version                     Repository          Size
Installing:
 filesystem                 x86_64   3.18-6.fc39                 fedora         106.0   B

Transaction Summary:
 Installing:        1 packages

Total size of inbound packages is 1 MiB. Need to download 0 B.
After this operation, 106 B extra will be used (install 106 B, remove 0 B).
Is this ok [y/N]: y
[1/1] filesystem-0:3.18-6.fc39.x86_64            100% |   0.0   B/s |   0.0   B |  00m00s
>>> Already downloaded
-----------------------------------------------------------------------------------------
[1/1] Total                                      100% |   0.0   B/s |   0.0   B |  00m00s
Running transaction
[1/3] Verify package files                       100% |  66.0   B/s |   1.0   B |  00m00s
[2/3] Prepare transaction                        100% |  55.0   B/s |   1.0   B |  00m00s
[3/3] Installing filesystem-0:3.18-6.fc39.x86_64 100% |   2.7 MiB/s | 212.4 KiB |  00m00s
>>> Unpack error: filesystem-0:3.18-6.fc39.x86_64

Transaction failed: Rpm transaction failed.