193 Commits

Author SHA1 Message Date
Pino Toscano
e89ab6dde4 tests: sysprep: slightly improve output
Add minor spacing changes, and report the image being sysprep'ed, so it
is easier to spot which image caused some warning message.
2014-09-09 15:10:33 +02:00
Pino Toscano
a0cf4b3407 sysprep: remove comment and notes about /etc/shadow lens
We are either using the upstream lens, or our copy of it, to handle
/etc/shadow, so now removing entries from it works.
2014-09-05 15:57:56 +02:00
Richard W.M. Jones
bb362f6878 OCaml virt-* tools: Handle pretty printing of exceptions through a common library function. 2014-09-03 12:37:39 +01:00
Pino Toscano
e52742e6d3 sysprep: user-account: remove the correct home
Query using augeas for the home directory of an user, instead of
hardcoding /home/<username>.
2014-09-03 11:13:54 +02:00
Pino Toscano
128d474095 sysprep: user-account: select which users to remove or keep
Enhance the user-account sysprep operation, so it is possible to select
which user accounts should be removed only (instead of all), or which to
eventually keep.
2014-09-02 16:35:43 +02:00
Richard W.M. Jones
a3881445ef Use ocamldep -all option.
In v2v, 'stringMap.ml' has no corresponding *.mli file.  ocamldep does
not generate a *.cmi dependency for such modules, and this can result
in parallel builds failing rarely because:

 (1) stringMap.ml is built (which has the side-effect of generating
     stringMap.cmi)

 (2) at the same time, types.mli is compiled.  types.mli depends on
     stringMap.cmi, but it is half way through being created by (1).

There is no dependency to serialize (1) and (2).

The resulting error is:

  File "types.mli", line 1:
  Error: Corrupted compiled interface
  stringMap.cmi

Using 'ocamldep -all' generates extra deps for the *.cmi files, and
otherwise appears to be safe, so use it.

There are currently a few upstream OCaml bugs with dependencies and
parallel builds:

http://caml.inria.fr/mantis/view.php?id=3190
http://caml.inria.fr/mantis/view.php?id=4991
http://caml.inria.fr/mantis/view.php?id=5000

It's not clear which of these apply here.
2014-09-01 22:24:14 +01:00
Pino Toscano
c6b7e6cdda customize: use the common perl file editing code
Wrap edit_file_perl to OCaml, and use it instead of the OCaml version
of it.
2014-08-29 11:30:17 +02:00
Richard W.M. Jones
f4698575cc customize: Add the ability to use --firstboot for Windows guests.
This allows you to add potentially multiple --firstboot
scripts to a Windows guest.
2014-07-23 17:02:49 +01:00
Richard W.M. Jones
fe9d3f7a90 ocaml: Ignore Warning 3: deprecated feature: String.* functions.
In OCaml 4.02, the 'string' type can be made immutable.  All String.*
functions that are concerned with creating or mutating strings now
give a warning like this:

  Warning 3: deprecated feature: String.unsafe_set

Disable this warning since we don't want to turn on immutable strings
yet.
2014-07-15 17:51:52 +01:00
Richard W.M. Jones
9d8ede1ae4 sysprep: Standard exception handling, taken from virt-builder & virt-v2v. 2014-07-15 17:38:32 +01:00
Richard W.M. Jones
f955fec760 docs: Remove useless "SHELL QUOTING" section from manual pages. 2014-07-15 17:38:31 +01:00
Pino Toscano
71ac957d4a Use Mkdtemp.temp_dir instead of Mkdtemp.mkdtemp 2014-07-07 19:33:44 +02:00
Richard W.M. Jones
b6b9b90dd7 Use -v and -x flags consistently across OCaml virt-* tools.
virt-customize:
virt-sparsify:
virt-sysprep:
virt-v2v:
  - These tools consistently used -v to mean verbose/debugging
    and -x to mean enable libguestfs tracing.

virt-builder:
virt-resize:
  - These two tools did not recognize -x at all, and used -v
    to enable libguestfs tracing and general debugging.
  - This commit changes these two tools to consume -v/-x
    consistently with the other tools.

Unfortunately this has a cascade of effects through the code.
2014-06-24 16:54:32 +01:00
Richard W.M. Jones
6f73266363 mllib: Add a common 'warning' utility function.
This commit changes many places in OCaml utilities that print
warnings to use the warning function instead.
2014-06-23 21:58:10 +01:00
Pino Toscano
3633109ff3 Fix handling of passwords in URLs
So far, passwords in URLs (eg http://user:password@host..) have been
handled as part of the username, and thus passing
  add-drive path username:username:password ...
instead of
  add-drive path username:username secret:password ...

Fix the parsing of URLs to handle passwords as separate elements,
properly passing it as "secret" parameter for add-drive, and properly
readd it when building URLs in the direct backend.

Furthmore, to keep curl- and ssh-based qemu drivers working with
authenticated resources, make sure they can accept secrets.

Reported in comment #1 of RHBZ#1092583.
2014-05-07 15:06:51 +02:00
Pino Toscano
8ae2a8a936 sysprep: remove also hidden files/dirs in temporary dirs
List manually and remove the content left (hidden files/directories) in
temporary directories after the glob listing & removal.
2014-04-14 14:18:41 +02:00
Pino Toscano
65b8edda0a sysprep: remove ConsoleKit logs 2014-04-09 15:54:54 +02:00
Pino Toscano
54d1f6e611 sysprep: remove the exim logs 2014-04-09 15:54:54 +02:00
Pino Toscano
f7d2738902 sysprep: remove apt and aptitude logs 2014-04-09 15:54:54 +02:00
Pino Toscano
d413c94fa6 sysprep: remove debug, syslog and faillog logs 2014-04-09 15:54:53 +02:00
Pino Toscano
ccf84d7b80 sysprep: remove debian-installer files 2014-04-09 15:54:53 +02:00
Pino Toscano
b08955e76a sysprep: remove the lightdm logs 2014-04-09 15:54:53 +02:00
Pino Toscano
fc9a4221ba sysprep: remove more anaconda configs/logs 2014-04-09 15:54:53 +02:00
Pino Toscano
0c35c3addd sysprep: remove systemd journals 2014-04-09 15:54:53 +02:00
Richard W.M. Jones
ffffe71c16 build: Remove code coverage and code profiling options.
This reverts commit 5a2e320ec9.
2014-04-09 14:51:59 +01:00
Richard W.M. Jones
2b208d84db Add virt-customize standalone tool.
This includes some simple tests and a manual page.
2014-03-25 12:41:04 +00:00
Richard W.M. Jones
aa3bc8b65d sysprep: Remove the --autorelabel (and related) options.
The customize module includes an --selinux-label option which can run
'fixfiles restore' (on most SELinux guests) or set /.autorelabel (on
some older ones).

Commit 49014f81f3 renamed the old
--selinux-label option to --autorelabel, but note this was not
included in a stable version of libguestfs.

Note this change leaves a bunch of now redundant code for detecting if
we created a new file in the guest.
2014-03-25 12:41:04 +00:00
Richard W.M. Jones
ae6f726ecc sysprep: Use customize module for customizing the guest after sysprepping.
Note this removes the following modules (all replaced by 'customize'):

 - delete       [--delete, --scrub]
 - firstboot    [--firstboot]
 - hostname     [--hostname]
 - password     [--password, --password-crypto, --root-password]
 - random-seed
 - timezone     [--timezone]
2014-03-25 12:41:04 +00:00
Richard W.M. Jones
4b0b3589e8 customize: Move virt-customize-related code to a separate directory.
Split virt-builder into build and customize steps, so that we can spin
off a separate tool called 'virt-customize'.  This commit does not in
fact create such a tool, but it moves all the common code into a
library, in the customize/ subdirectory of the source.

Although this is mostly refactoring, it does change the order in which
virt-builder command line arguments are processed, so they are now
processed in the order they appear, not the inflexible fixed order
used before.
2014-03-25 12:41:04 +00:00
Richard W.M. Jones
8e386fc1be sysprep: Pass debug and quiet flags to all modules.
Also use the Common_utils.make_message_function function to print
messages (same as virt-builder).
2014-03-25 12:41:04 +00:00
Richard W.M. Jones
1edfdcbd58 sysprep: Allow order of operations to be specified by modules. 2014-03-25 12:41:04 +00:00
Richard W.M. Jones
f450fb4106 sysprep: Perform operations in alphabetical order.
Previously we ran them in essentially a random order, although it
might have looked alphabetical in some cases because the modules are
loaded in order.
2014-03-25 12:41:04 +00:00
Richard W.M. Jones
c4dc70f8c4 podwrapper: Remove =encoding from input files and add it back in podwrapper.
This changes podwrapper so that the input (POD) files should not
contain an =encoding directive.  However they must be UTF-8.
Podwrapper then adds the '=encoding utf8' directive back during final
generation.

This in particular avoids problems with nested =encoding directives in
fragments.  These break POD, and are undesirable anyway.
2014-03-20 13:47:19 +00:00
Richard W.M. Jones
b48e885004 sysprep: Add disks with discard = "besteffort".
Since virt-sysprep tends to delete a lot of files, adding discard
support to it makes some sense.

Note that this probably won't have any effect for most filesystems
since:

(a) ext4 mounts also need to use -o discard,

(b) ext4, and maybe others, require you to call fstrim explicitly,
they don't discard automatically (except for userspace tools like
mkfs.ext4 but that doesn't apply in this case).
2014-03-13 10:38:40 +00:00
Hilko Bengen
b30e2cf122 Fix out-of-tree build: Do not accidentally build mllib components in srcdir 2014-03-04 00:06:09 +01:00
Hilko Bengen
f75142c577 Fix building on architectures where ocamlopt is not available 2014-02-28 14:01:25 +00:00
Pino Toscano
0f3898b2f5 sysprep: use Mkdtemp to create the temporary directory
Use the safer mkdtemp instead of manually creating a path.
2014-02-24 15:40:29 +01:00
Richard W.M. Jones
bf8d75590c test: Use = instead of == for testing string equality in bash script.
Found by make syntax-check.
2014-02-14 12:33:37 +00:00
Pino Toscano
4ca4eef0cc sysprep: remove RH subscription manager files
Add a new operation for it, which should do what
`subscription-manager clean` does.

Part of RHBZ#1063374.
2014-02-13 10:57:31 +01:00
Pino Toscano
f78877c77e sysprep: remove RH subscription manager log files
Part of RHBZ#1063374.
2014-02-13 10:50:15 +01:00
Richard W.M. Jones
49014f81f3 sysprep: Deprecate --selinux-relabel in favour of --autorelabel.
virt-builder added a --selinux-relabel option with a slightly
different meaning.

This commit keeps the old --selinux-relabel / --no-selinux-relabel
options in virt-sysprep, but deprecates them and replaces them with
--autorelabel and --no-autorelabel.
2014-01-30 09:03:46 +00:00
Richard W.M. Jones
fc6d3e6a9a sysprep: Add a reference to virt-builder from the manual page.
The whole "COPYING AND CLONING" section really needs to be overhauled
too, but first we need to make virt-builder work properly for
customizing templates.
2014-01-30 09:03:46 +00:00
Richard W.M. Jones
5db1a28461 sysprep: Add --scrub option.
This works like the option in virt-builder with the same name.
2014-01-30 09:03:46 +00:00
Richard W.M. Jones
59fce974e2 pod: Remove stray +x (executable) mode on various POD files.
find -name '*.pod' -perm /0111 -exec chmod -x {} \;
2014-01-28 22:17:12 +00:00
Richard W.M. Jones
233d5410e5 sysprep: Add script4.sh (test script) to EXTRA_DIST.
This fixes commit ce9d4d335b.
2014-01-28 21:56:18 +00:00
Richard W.M. Jones
f02fddc26b tests: Update miscellaneous tests to use disk-create API.
Instead of calling out to qemu-img / truncate.
2014-01-28 21:02:11 +00:00
Pino Toscano
ce9d4d335b builder, sysprep: initialise the random generator
virt-builder and virt-sysprep may make use of
Common_utils.string_random8 (which uses Random.int) for constructing
temporary paths; not initialising the random generator means that every
invocation will reuse the same name used previously (!).
Thus just call Random.self_init, just like virt-sparsify already does.

Expand the test-virt-sysprep-script.sh test to ensure that virt-sysprep
is not affected again by this issue.
2014-01-28 15:04:38 +01:00
Richard W.M. Jones
3e3e7cf029 sysprep: Replace flags list with side_effects object.
Previously callbacks would return a list of flags, such as []
or [`Created_files].

In this commit we introduce two new objects, filesystem_side_effects
and device_side_effects (the latter is not used yet).

The callbacks that create files now need to call

  side_effects#created_file ()

instead of returning flags.

There is no functional change in this patch.
2014-01-21 17:33:35 +00:00
Richard W.M. Jones
11b4fc88fb sysprep: Update comments. 2014-01-21 17:33:35 +00:00
Pino Toscano
418c064bc1 sysprep: add --operations
Add a new --operation parameter which, similarly to --enable, can be
used to enable operations, but also to remove them, and to add/remove
the default operations and all the available ones.
2014-01-13 14:57:00 +01:00