Backport virt-sysprep from libguestfs 1.24

Copy the virt-sysprep code from libguestfs 1.24.x, bringing all the
features of it to libguestfs 1.20.x. This is done as single commit
because cherry-picking individual commits is simply not worth it, and
would require to cherry-pick a big number of commits, possibly bringing
in new features implemented elsewhere, etc.

Move existing files (where possible) or import them from 1.24.x,
adapting the current ocaml-based tools to the updated functions in
mllib.
sysprep: add feature of deleting specified paths

Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit e4c9212a8e9fe9c2a75ce5035a4c3bce53261018)
builder/sysprep: Describe --password/--root-password option as "selector".

It now appears in the respective man pages as:

  --root-password selector

or:

  --password selector

This avoids confusion from people who think these command line options
take the password directly.

(cherry picked from commit 9186438937f5451ddfdaa33c9dcb9ffe27b2a098)
builder/sysprep: Allow 'random' as a password selector.

This chooses a random password.

(cherry picked from commit 02b5f00b2bf563d87134ad5f90ec06dbb9535bea)
builder/sysprep: Allow accounts to be locked (RHBZ#1028660).

This allows you to select both locked accounts and disabled
passwords.  The two are subtly different concepts.

A locked account [cf. passwd -l] puts "!!" at the beginning of the
shadow password field.  Locking is reversible, because the "!!"  can
be removed, restoring the original password.  Therefore "locked"
acts as a flag in front of an existing selector.

A disabled account has "*" in the password field.  Therefore it has no
password.

Note that an account may be both locked and disabled, although this is
probably not useful.  The shadow password field will contain "!!*".

(cherry picked from commit 3712249f9659121277a0d2ca0549e02bc38e0cad)
sysprep: Add a test suite for the --password option.

(cherry picked from commit cc1888a4977eb4942254ea5ac15c1d0a47458317)
sysprep: adapt test-virt-sysprep-passwords.sh to libguestfs 1.20

a) do not use $guestfish, but call "../fish/guestfish" directly
b) use "get-attach-method" instead of "get-backend"
sysprep: allow to specify globbing for --delete

Adapt the globbing part from the old --remote-path work previously
proposed for sysprep [1], allowing --delete to perform globbing when
deleting paths.

[1] https://www.redhat.com/archives/libguestfs/2013-October/msg00045.html

(cherry picked from commit ed4bcb119cb908e98ecc1107dcd8b740ee2f484f)
sysprep: mention globbing in help for --delete

Followup of ed4bcb119cb908e98ecc1107dcd8b740ee2f484f.

(cherry picked from commit 1472fbd903befb179112a1de673c376ec5bf9b2f)
firstboot: Send the output to the console as well as to the log file.

For systemd:
Currently stdout+stderr go to the journal (these are effectively
empty unless there are gross errors).  The output of the commands
goes to the log file.

With this change, the output goes to the journal, the console and
the log file.

For SysV-init:
Currently stdout+stderr go to the console (but these are effectively
empty).  The output of the commands goes to the log file.

With this change, the output goes to the console and the log file.

(cherry picked from commit f114e28cc80eabdcf47c97e7e3895065cdfe4886)
(cherry picked from commit e0a88763ad882bcbad2b66adeafee33be2179a2d)
RHEL 6: Emphasize libguestfs-winsupport package (RHBZ#627468).

This RHEL 6.1-only patch changes the error messages when the
inspection code cannot find an operating system inside the guest
image.  For a Windows guest this may happen because the user has not
installed the separate 'libguestfs-winsupport' package.  Therefore we
emphasize that the user may need to install this package.

Notes:

(1) In RHEL 6.1 there are two pieces of inspection code, the old Perl
code (deprecated upstream) and the new C core inspection API.
Therefore this patch has to touch two places with essentially the same
change.

(2) This patch doesn't try to be clever and detect if it was a Windows
guest.  This should reduce the chance of failure.

Output from (Perl) virt-inspector now looks like this:

 $ virt-inspector disk.img
 No operating system could be detected inside this disk image.

 This may be because the file is not a disk image, or is not a virtual machine
 image, or because the OS type is not understood by virt-inspector.

 If you feel this is an error, please file a bug report including as much
 information about the disk image as possible.

 RHEL 6 notice
 -------------
 libguestfs will return this error for Microsoft Windows guests if the
 separate 'libguestfs-winsupport' package is not installed. If the
 guest is running Microsoft Windows, please try again after installing
 'libguestfs-winsupport'.

Output from guestfish (ie. C core inspection API) now looks like this:

 $ guestfish -i disk.img
 guestfish: no operating system was found on this disk

 RHEL 6 notice
 -------------
 libguestfs will return this error for Microsoft Windows guests if the
 separate 'libguestfs-winsupport' package is not installed. If the
 guest is running Microsoft Windows, please try again after installing
 'libguestfs-winsupport'.
RHEL 6: Require external hex editor set with $HEXEDITOR.

RHEL 6 doesn't have the hexedit program or any suitable replacement.
Require that the user sets $HEXEDITOR to make this command work.
(cherry picked from commit 1ee31426e13446bc5fcce242eb496a01d8a78d8c)
RHEL 6: Directly include String::ShellQuote.

Directly include a snippet from String::ShellQuote so that we
don't need to depend on this external library, which is not
included in RHEL 6.1.

This affects virt-make-fs.
RHEL 6: Modify blkid test so it is successful on RHEL 6-era blkid.
RHEL 6: Remove libguestfs live (RHBZ#798980).

This isn't supported in RHEL 6.
RHEL 6: Exclude iptables from the appliance (RHBZ#858648).
RHEL 6: In mount-local docs, change refs to libguestfs 1.18 -> RHEL 6.4.

We backported the libguestfs 1.18 / mount-local functionality
into the libguestfs 1.16 codebase for RHEL 6.4.
RHEL 6: Ignore /etc/release if /etc/redhat-release exists (RHBZ#872454).

If the user has created /etc/release on a RHEL machine, don't
mis-detect the OS as NetBSD.
RHEL 6: Modify ruby Rakefile.in to work with older Ruby.
RHEL 6: Remove check for qemu >= 1.