168 Commits

Author SHA1 Message Date
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
Richard W.M. Jones
dd1bfea513 sysprep, builder: Add --timezone option to set timezone of guest.
You can use it like this:

  virt-sysprep --timezone Europe/London ...
  virt-builder --timezone Europe/London ...
2014-01-10 21:20:36 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Pino Toscano
30936f499e sysprep: remove some Pegasus files, like certs (RHBZ#1041552). 2013-12-13 11:04:30 +01:00
Pino Toscano
1472fbd903 sysprep: mention globbing in help for --delete
Followup of ed4bcb119c.
2013-12-09 19:37:51 +01:00
Pino Toscano
ed4bcb119c 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
2013-12-09 15:26:43 +00:00
Pino Toscano
c89ffbc152 sysprep: remove more anaconda and tuned logs (RHBZ#1039540). 2013-12-09 15:26:43 +00:00
Richard W.M. Jones
53e45c8280 sysprep: Fix broken test when backend is UML.
This fixes commit cc1888a497.
2013-11-23 09:37:17 +00:00
Richard W.M. Jones
cc1888a497 sysprep: Add a test suite for the --password option. 2013-11-22 15:10:44 +00:00
Richard W.M. Jones
3712249f96 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 "!!*".
2013-11-22 15:10:44 +00:00
Richard W.M. Jones
02b5f00b2b builder/sysprep: Allow 'random' as a password selector.
This chooses a random password.
2013-11-22 14:16:09 +00:00
Richard W.M. Jones
91450b5f9a mllib: password: Replace password string with password_selector type.
This is just code motion, there is no functional change.
2013-11-21 17:34:59 +00:00
Richard W.M. Jones
9186438937 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.
2013-11-21 17:13:37 +00:00
Richard W.M. Jones
f013b15fa1 mllib: Add a utility function for safely reading from /dev/urandom.
OCaml's buffered 'in_channel' has a 64k buffer, so using it to read a
few bytes from /dev/urandom removes a lot of the system's entropy (for
example /proc/sys/kernel/random/entropy_avail goes from ~3000 to 128).

This patch was originally by Edwin Török for builder.ml.  I
generalized it because there are two other places where we did
over-sized reads from /dev/urandom.
2013-11-14 10:52:16 +00:00
Wanlong Gao
e4c9212a8e 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>
2013-10-29 19:24:08 +00:00
Richard W.M. Jones
5b89dd4aa1 mllib: Create config.ml from configure and use it for --version options.
Also don't internationalize the output of the --version option, as
that isn't useful.
2013-10-22 13:48:41 +01:00
Richard W.M. Jones
b816f29ada firstboot: Ensure firstboot scripts run in command line order.
Previously they ran in effectively random order.
2013-10-15 20:41:22 +01:00
Richard W.M. Jones
a3e5bc7bfa sysprep: firstboot: Don't set `Created_files flag unless files are created. 2013-10-15 20:41:22 +01:00
Richard W.M. Jones
22fc66f6b2 sysprep: Fix documentation for --mount-options. 2013-10-07 14:27:32 +01:00
Richard W.M. Jones
dfa52c63b1 sysprep: Don't remove /var/cache/apt/archives/partial directory.
Removing this directory breaks Ubuntu guests.

This change adds a utility function which removes only files from a
directory.  This is a safer way to clean cache directories etc.
2013-10-07 14:19:38 +01:00
Richard W.M. Jones
08b7c90228 sysprep: Refactor hostname code into a common library. 2013-10-03 22:02:47 +01:00
Richard W.M. Jones
6203c50479 sysprep: Refactor setting random seed code into a common library.
This is just code motion.
2013-10-03 21:42:05 +01:00
Richard W.M. Jones
147b4ee87e sysprep: Refactor firstboot code into a common library. 2013-10-03 21:42:05 +01:00
Richard W.M. Jones
e8a092ae87 sysprep: Refactor password handling code into a common library.
Also the crypt binding is moved to mllib because this is a dependency
of the password library.

This is just code motion.
2013-10-03 21:42:04 +01:00
Richard W.M. Jones
98d56bb102 mllib: error function has ~prog parameter, instead of assuming virt-resize.
$ virt-sparsify a a
  virt-resize: error: you cannot use the same disk image for input and
  output
  If reporting bugs, run virt-resize with the '-d' option and include the
  complete output.

Note (a) it assumes the program is called "virt-resize" which it
isn't, and (b) it assumes the program has a debug option -d which it
doesn't.

This commit changes the error message and adds a -v option to
virt-resize.
2013-10-03 21:42:04 +01:00
Richard W.M. Jones
09a4f42861 uri: Fix two compiler warnings.
We have to include the right header so that guestfs___free_string_list
is declared.  Unfortunately that means ensuring -I src is passed to
the compiler in every tool subdirectory.

Also fix (bogus) compiler warning about incorrect type of the
parameter to caml_copy_string_array.
2013-09-24 13:41:35 +01:00