Bug 1519623

Summary: Supermin could install ntfs in OpenSUSE42.3
Product: [Community] Virtualization Tools Reporter: Bamvor Zhang <bamv2005>
Component: superminAssignee: Richard W.M. Jones <rjones>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: bamv2005, ptoscano, rjones
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
libguest-test-tool-log none

Description Bamvor Zhang 2017-12-01 03:47:40 UTC
Created attachment 1361401 [details]
libguest-test-tool-log

Description of problem:
When I build libguest locally in my OpenSUSE. I found that ./test-data/phony-guests/make-windows-img.sh failed. It prompt mount ntfs fail. But I could run the guestfish script manually successful:
guestfish <<EOF
sparse windows.img-t 512M
run

# Format the disk.
part-init /dev/sda mbr
part-add /dev/sda p 64     524287
part-add /dev/sda p 524288    -64

# Disk ID.
pwrite-device /dev/sda "1234" 0x01b8 | cat >/dev/null

# Phony boot loader filesystem.
mkfs ntfs /dev/sda1

# Phony root filesystem.
mkfs ntfs /dev/sda2

# Enough to fool inspection API.
mount /dev/sda2 /
mkdir-p /Windows/System32/Config
mkdir-p /Windows/System32/Drivers

upload $SRCDIR/windows-software /Windows/System32/Config/SOFTWARE
upload $SRCDIR/windows-system /Windows/System32/Config/SYSTEM

upload $SRCDIR/../binaries/bin-win32.exe /Windows/System32/cmd.exe

mkdir "/Program Files"
touch /autoexec.bat

EOF

Then I investigate the supermin command. I found that supermin will not install ntfs relative packages even if it already found the correct dependency. Please reference the "actual result" for the full log of supermin.

Version-Release number of selected component (if applicable):
supermin(both 5.1.18 and master)
Name        : supermin
Version     : 5.1.18
Release     : 19.d_l_ocaml.2

commit 45a03544962f01ff8a4444c22b1552e27c246c31 (HEAD -> master, origin/master, origin/HEAD)
Author: Richard W.M. Jones <rjones>
Date:   Tue Oct 24 13:43:26 2017 +0100

    docs: Adjust kernel command line in example.

    Thanks: Hangbin Liu.

qemu: 2.10.1

kernel: 4.4.76-1-default

Distribution: openSUSE Leap 42.3


How reproducible:

Steps to Reproduce:
1. supermin --prepare -v -o supermin.d ntfs-3g
2.
3.

Actual results
supermin will not install the ntfs-3g, see the following log
supermin: version: 5.1.19
supermin: rpm: detected RPM version 4.11
supermin: rpm: detected zypper version 1.13.28
supermin: package handler: opensuse/rpm
supermin: prepare: ntfs-3g
supermin: packages specified on the command line:
  - ntfs-3g-2013.1.13-6.3.x86_64
supermin: writing supermin.d.3e34g1ua/packages
supermin: after resolving dependencies there are 24 packages:
  - bash-4.3-82.6.x86_64
  - coreutils-8.25-3.3.x86_64
  - filesystem-13.1-9.5.x86_64
  - glibc-2.22-8.4.x86_64
  - info-4.13a-42.18.x86_64
  - libacl1-2.2.52-10.15.x86_64
  - libattr1-2.4.47-8.15.x86_64
  - libbz2-1-1.0.6-34.15.x86_64
  - libcap2-2.22-18.16.x86_64
  - libfuse2-2.9.3-11.3.x86_64
  - libgcc_s1-7.1.1+r248970-1.4.x86_64
  - libgmp10-5.1.3-7.15.x86_64
  - liblzma5-5.2.2-3.15.x86_64
  - libncurses5-5.9-59.1.x86_64
  - libntfs-3g84-2013.1.13-6.3.x86_64
  - libpcre1-8.39-9.15.x86_64
  - libreadline6-6.3-82.6.x86_64
  - libselinux1-2.5-4.17.x86_64
  - libstdc++6-7.1.1+r248970-1.4.x86_64
  - libz1-1.2.8-13.15.x86_64
  - libzio1-1.00-14.15.x86_64
  - ntfs-3g-2013.1.13-6.3.x86_64
  - terminfo-base-5.9-57.1.x86_64
  - update-alternatives-1.18.4-4.15.x86_64
Verbosity: 2
Entering non-interactive mode.
Entering 'no-gpg-checks' mode.
Warning: Turning on '--gpg-auto-import-keys'. New repository signing keys will be automatically imported!
Non-option program arguments: 'bash.x86_64' 'glibc.x86_64' 'terminfo-base.x86_64' 'info.x86_64' 'libattr1.x86_64' 
Initializing Target


Expected results:
supermin wil install the ntfs-3g, see the following log


Additional info:
See attachment for libguest-test-tool-log

Comment 1 Pino Toscano 2017-12-01 10:32:34 UTC
supermin creates the appliances by copying the files of the packages specified.
In openSUSE, both ntfs-3g and ntfsprogs (only ntfs-3g is not enough) use the "alternatives" system of RPM to setup the links for the programs.

For example, installing them in a openSUSE Factory VM:

  (3/3) Installing: ntfs-3g-2016.2.22-3.3.x86_64 ...[snip].....[done]
  Additional rpm output:
  update-alternatives: using /sbin/mount.ntfs-3g to provide /sbin/mount.ntfs (mount.ntfs) in auto mode

which is exactly what I described.  mkfs.ntfs is a real application, while mount.ntfs is a symlink managed by alternatives:

  $ ls -lh `which mount.ntfs`
  lrwxrwxrwx 1 root root 28 Dec  1 11:25 /sbin/mount.ntfs -> /etc/alternatives/mount.ntfs
  $ ls -lh /etc/alternatives/mount.ntfs
  lrwxrwxrwx 1 root root 19 Dec  1 11:25 /etc/alternatives/mount.ntfs -> /sbin/mount.ntfs-3g

So installing both the packages allows libguestfs to create ntfs filesystems, but not mount them.

See also bug 1223522 on why we do not run any pre/post scripts of package managers.  Unless this kind of operation get some sort of declarative configuration format (so supermin can execute them on its own), there is nothing much that can be done, I'm afraid.  The other option would be that ntfs-3g stops using the alternative, but from what I know it is done on purpose.