Commit Graph

106 Commits

Author SHA1 Message Date
Richard W.M. Jones
3b8322e18c customize: Document missing command line parameters in the synopsis.
I noticed that the --attach option was not covered in the synopsis.
This commit documents all of the missing command line parameters in
the synopsis.
2016-01-11 13:42:49 +00:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Richard W.M. Jones
be1b9315ac customize, dib, resize, sysprep: Use 'may' pattern in various places. 2015-11-11 16:12:36 +00:00
Pino Toscano
4cc98d8f6e OCaml tools: use open_guestfs everywhere
Instead of creating Guestfs handles and manually apply common options
(e.g. debug and trace), use the open_guestfs in Common_utils.
This also applies the common options to handles which didn't set them
before, so we can inspect also their messages if needed.
2015-11-10 11:38:40 +01:00
Pino Toscano
a7f3f48dd1 customize: allow editing symlinked files
Resolve also symlinks when checking whether a path passed to --edit is a
file: the file editing code supports symlinks anyway (properly changes
the target file, instead of overwrite the symlink with a real file), so
it is safe to allow this operation in customize/builder.
2015-11-09 18:33:52 +01:00
Pino Toscano
6e41fc5a7f customize: check for file existence with --edit (RHBZ#1275806)
Check that a path provided to --edit exists already; while the is_file
call later will fail for non-existing files, with an explicit check a
better error message can be provided.
2015-11-09 18:26:05 +01:00
Richard W.M. Jones
47b095b928 website: Put website into a separate directory.
Move the random set of HTML files we build from html/ into
the website/ directory.

Also in the website/ directory, put the index.html file from
http://libguestfs.org, which was previously not under version control.
It is generated from index.html.in so we can automatically add the
current version and release date.

Also in the website/ directory, put various CSS file, images, etc.
which are required by the website and were also previously not under
version control.

Change the 'make website' rule to 'make maintainer-upload-website'.
As the name suggests, it is only useful for the maintainer, and will
fail with an error for anyone else.
2015-10-31 17:09:29 +00:00
Richard W.M. Jones
dc1d0880b0 tests: Move the tests/data and tests/guests directories to test-data.
Create a new top-level directory called test-data, which will carry
all the test data which is large and/or shared between multiple tests.

There are actually several new subdirectories created:

test-data/binaries: The pre-built binary and library files for random
architectures that we use to test various architecture detection
features (was part of tests/data).

test-data/blank-disks: The blank disks which are used for disk format
detection (was part of tests/data).

test-data/files: Other miscellaneous test files from tests/data that
are not included in the above.

test-data/phony-guests: The phony guests (was tests/guests).

test-data: The top-level directory builds the 'test.iso' image file
that is used for testing the C API and in miscellaneous other tests.
2015-10-30 16:07:32 +00:00
Richard W.M. Jones
63952d9666 ocaml: Rename Config module as Guestfs_config.
Unfortunately Coccinelle places a Config module in the ocaml libdir,
and this confuses ocamlfind (only when Coccinelle is installed).
Since this is a private module that only libguestfs tools use
internally, just rename it from Config -> Guestfs_config.
2015-10-30 09:45:02 +00:00
Richard W.M. Jones
0944acf90c mllib: Replace various ad hoc string_* functions with String.*
This is just a straight refactoring.  Various ad hoc string_*
functions that appeared in Common_utils have been renamed and placed
in the String.* namespace.  The old vs "new" functions are:

string_prefix  -> String.is_prefix
string_suffix  -> String.is_suffix
string_find    -> String.find
replace_str    -> String.replace
string_nsplit  -> String.nsplit
string_split   -> String.split
string_lines_split -> String.lines_split
string_random8 -> String.random8
2015-10-06 13:40:34 +01:00
Cédric Bosdonnat
bc8e1ff9ae customize: remove zypper's gpg keys auto-import
This option was considered unsecure, found a fix on the generated
opensuse images instead.
2015-10-02 17:21:47 +01:00
Richard W.M. Jones
2c519cf055 Add missing generated files to generator_built and EXTRA_DIST.
Use the generator_built variable to list any files which are built by
the generator.  This ensures they get automatically rebuilt.

Three files were missing from EXTRA_DIST, so they were not included in
the tarball, meaning you would have needed OCaml to build from the
tarball.  You would have seen this when building:

  cd .. && /builddir/build/BUILD/libguestfs-1.31.9/generator/generator
  written gobject/docs/guestfs-title.sgml
  written customize/customize-synopsis.pod
  written customize/customize-options.pod
  generated 476921 lines of code
2015-10-01 14:13:30 +01:00
Cédric Bosdonnat
3b4f83e0b2 customize: sles password defaults. 2015-10-01 13:01:59 +01:00
Cédric Bosdonnat
66efad4172 customize: get zypper to eat licenses and gpg keys
Without these flags --install will most likely fail as the GPG key
may no be imported in the guest image.
2015-09-29 17:48:19 +01:00
Pino Toscano
1b4c1d74d3 customize: password: use SHA-512 on openSUSE >= 11.0
openSUSE 11.0 has glibc 2.8, which supports the SHA-512 method.
Fallback to an explicit MD5 for older versions.
2015-09-08 19:07:23 +02:00
Richard W.M. Jones
5ed4388ecd customize: Create .ssh as 0700 and .ssh/authorized_keys as 0600 (RHBZ#1260778).
Both ssh-copy-id and ssh create .ssh as 0700.  ssh-copy-id creates
.ssh/authorized_keys as 0600.

Thanks: Ryan Sawhill for finding the bug.
2015-09-08 09:09:40 +01:00
Pino Toscano
2ec0332e5e mllib: move -q/--quiet as common option
Most of the OCaml-based tools had it already, except from virt-dib and
virt-get-kernel.
2015-09-02 00:25:55 +02:00
Pino Toscano
4cc3cc3fbd mllib: set --debug-gc as common option
Move --debug-gc as common option for all the OCaml-based tools, even a
couple of them which didn't have it previously.

As implementation note, make set_debug_gc private to
set_standard_options, as it needed to be moved otherwise, and it is no
more required as public function.
2015-08-31 18:34:37 +02:00
Pino Toscano
2af6e48ba3 mllib: add and use set_standard_options
Introduce a new common helper to add the common options for libguestfs
tools (short/long options, version, verbose, trace), and sort them.
All the OCaml-based tools had these options already, so there are no
functional changes in the interface they provide.

The only difference is that now the options are always sorted, while
some tools didn't had them like that previously: because of this, a
couple of ditto markers (as descriptions) don't match what's above them
anymore, and thus their full description is put instead.
2015-08-31 18:25:48 +02:00
Pino Toscano
7bdb3e0df9 customize: fix running commands on the same architecture
Wrap the command around an heredoc only if setarch needs to be used;
otherwise the heredoc will not be run at all.

Fix commit d875346ad4.
2015-08-31 17:55:14 +02:00
Richard W.M. Jones
d875346ad4 customize: Use setarch when running commands on i686 guest (RHBZ#1256405).
When running (eg) dnf on a 32 bit i686 guest when the host is 64 bit
x86_64, dnf believes it is running on a 64 bit machine and so tries to
install x86_64 packages.  We can 'trick' dnf into believing it's a 32
bit machine using the setarch program.

$ virt-builder fedora-22 --arch i686 --install 'gperf'
...
[  27.4] Installing packages: gperf
...
Running transaction test
Error: Transaction check error:
  package libgcc-5.1.1-4.fc22.x86_64 is intended for a different architecture
...

The use of a heredoc to solve quoting issues comes from:
http://stackoverflow.com/a/3435460

Thanks: Jan Sedlák for finding the solution.
2015-08-28 19:09:17 +01:00
Roman Kagan
a628fb65fa handle --debug-gc universally via at_exit hook
Several tools handle --debug-gc command-line option, by explicitly
forcing GC on every exit path.  This is tedious and prone to forgetting
some of the exit paths.

Instead, add a generic handler for --debug-gc, which installs an at_exit
hook to do the GC consistency check, and which can be called right in
the command-line parser.  Also adjust all users of --debug-gc to use
that handler.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
2015-08-28 17:53:41 +01:00
Richard W.M. Jones
f3a7cf994b customize: firstboot: Place firstboot.service file in systemd unit directory (RHBZ#1250955).
It turns out that -- some of the time -- systemd ignores unit files
which are not placed in one of the official unit directories.  This
caused the service to be timed out and killed when the systemd daemon
was reloaded, as could happen for long-running package installs at
first boot.

Thanks: Marius Vollmer for diagnosing the problem and finding the
solution.
2015-08-12 10:42:57 +01:00
Richard W.M. Jones
16e6378a5b customize: Make dnf upgrade to the latest versions of packages.
I discovered that 'dnf upgrade' doesn't actually upgrade to the latest
versions of packages unless you also supply the '--best' flag.

This also changes update -> upgrade, since apparently 'dnf update'
is deprecated.
2015-08-05 13:01:12 +01:00
Richard W.M. Jones
91c06391c1 automake: Admit defeat and use 'subdir-objects'.
Because this 'feature' is broken (since 2013):

  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928

we have to replace all instances of $(top_srcdir) in *_SOURCES lines
with a relative path.  According to what I read, this shouldn't break
split builds, but I didn't test it.

The only things automake moans about now are:

* Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^ \t=:+{}]+)}/ at /usr/bin/automake line 3936.

  - This is another bug in automake

* autoreconf: configure.ac: AM_GNU_GETTEXT is used, but not AM_GNU_GETTEXT_VERSION

  - This is a feature, not a bug.
2015-08-05 13:01:12 +01:00
Richard W.M. Jones
dbbf4b8afe customize: Combine separate -a and -d option synopses (RHBZ#1246882) 2015-07-28 14:13:03 +01:00
Pino Toscano
6c9ea0471e customize: password: improve unknown default crypto message
When warning that there is no known default password encryption for the
current guest, print also its minor version (help debugging unsupported
guests).

Also, fix wrapping (and indentation) of the message.
2015-07-24 16:40:11 +02:00
Pino Toscano
563b388b8e customize: random_seed: add CirrOS location
CirrOS has its random-seed file in /etc.
2015-07-24 15:25:28 +02:00
Pino Toscano
44f71d0782 customize: add basic subscription-manager operations
Add simple operations for RHEL guests using subscription-manager, so it
is possible to e.g. install software on them.
2015-07-17 17:03:04 +02:00
Pino Toscano
b357553cd6 mllib: add and use read_first_line_from_file
Move the read_password_from_file helper in Password to mllib with a more
generic name, and use it in place of the former.

Also, use it in v2v instead of reading the whole file contaning a
password: given that the documentation says that the whole content is
used, there will not be newlines in the password file, so the behaviour
will be preserved. The oly difference is that newline is no more an
acceptable character for passwords, but that is a really unlikely
(if not impossible at all) situation.
2015-07-17 17:03:04 +02:00
Pino Toscano
a614f3451d mllib: add and use last_part_of
Collect this small snippet to get the part of a string after the last
occurrency of a character; replace with it the current snippets doing
the same.

Should be just code motion.
2015-07-01 17:17:58 +02:00
Richard W.M. Jones
533901409e pod: Use F<> for filenames instead of C<>.
Done using a sequence of regular expressions like this:

  perl -pi.bak -e 's{C</}{F</}g' `git ls-files \*.pod` generator/actions.ml
  perl -pi.bak -e 's{C<C:\\}{F<C:\\}g' `git ls-files \*.pod` generator/actions.ml
  [etc]

and then tediously checking every change by hand.
2015-06-15 15:42:46 +01:00
Richard W.M. Jones
c919f6f75c api: Don't truncate /dev/stdout or /dev/stderr when used as FileOut.
In APIs such as guestfs_download, when the FileOut parameter exactly
matches "/dev/stdout" or "/dev/stderr", don't reopen the possibly
redirected output file with O_TRUNC (truncate).  Instead dup the file
descriptor.

This magic behaviour doesn't happen for /dev/fd/* (or any other output
file) allowing callers the choice of using /dev/stderr or /dev/fd/2
depending on whether or not they want truncation.

This works around an annoying virt-builder bug.  If you do:

  $ virt-builder fedora-21 --install no_such_package -v -x >& /tmp/log

then when the `--install' command fails, virt-builder will download
the log file using `guestfs_download (g, log, "/dev/stderr")'.  Since
this truncates the redirected /dev/stderr, the final log file is
truncated and corrupted.

With this patch the log file is no longer corrupted.
2015-05-26 20:21:15 +01:00
Richard W.M. Jones
59228c39b1 ocaml tools: Use global variable to store quiet (--quiet) flag.
Don't pass this flag to dozens of functions.

This change is analogous to the change made in
commit 79fc6074a7 for the -v & -x flags.
2015-05-15 19:08:36 +01:00
Richard W.M. Jones
a43e8405ef customize: Allow --selinux-relabel flag to work on cross-architecture builds (RHBZ#1212807). 2015-05-15 15:18:20 +01:00
Richard W.M. Jones
8864c47b94 customize: Give a clear error message if host_cpu not compatible with guest arch.
In cases where we are asked to run commands in the guest (eg.  options
such as --run-command or --install), give a clear error in the cases
where the guest arch is not compatible with the host arch.

Similar code existed in virt-builder, but I have removed that.  Users
will still get an error message, it will just happen a bit later on.

There is a slight change in semantics here, in that architectures are
no longer normalized when matching, but that's probably fine since
`virt-builder -l' prints the exact arch string that people should use.
2015-05-15 15:18:20 +01:00
Richard W.M. Jones
79fc6074a7 ocaml tools: Use global variables to store trace (-x) and verbose (-v) flags.
Don't pass these flags to dozens of functions.
2015-05-15 15:18:19 +01:00
Richard W.M. Jones
e35605ad8d ocaml tools: Define Common_utils.prog and don't pass it to every function.
This large commit is just code refactoring.  Instead of having
every OCaml tool define 'prog' the same way, always as:

  let prog = Filename.basename Sys.executable_name

move that into a single place, Common_utils.prog.  Then we can use
that global value everywhere else, instead of having to pass it as a
parameter into a dozen different functions.
2015-05-15 15:18:19 +01:00
Pino Toscano
13dd632301 build: factor out the OCaml link.sh scripts
Create a single ocaml-link.sh script, which supports a -cclib parameter
so it can be used instead of the per-project link.sh scripts.
As result, the libraries for each OCaml application can be moved back to
each Makefile.am.
2015-05-13 15:30:39 +02:00
Pino Toscano
22686d2cfd customize: add a "touch" operation (RHBZ#1212808) 2015-04-28 15:22:45 +02:00
Richard W.M. Jones
b70aec11c6 random_seed: Don't try to create random seed if no parent directory.
Partial fix for https://bugzilla.redhat.com/show_bug.cgi?id=1215803
2015-04-27 20:28:26 +01:00
Richard W.M. Jones
2841400721 firstboot: Don't create very long filenames for --firstboot-command (RHBZ#1212152). 2015-04-27 16:19:33 +01:00
Richard W.M. Jones
aa8d66e755 firstboot: Factor out regular expression constant.
Don't need to evaluate this every time we call the function.
2015-04-27 16:19:33 +01:00
Pino Toscano
4268865a78 build: require Config before Common_utils
Build the Config mllib module before Common_utils, as the latter will
soon make use of the former.
2015-04-20 15:38:31 +02:00
Richard W.M. Jones
478a552ab4 Common function to implement --version flag in all OCaml tools (RHBZ#1213247).
Add a common function print_version_and_exit ~prog () and use this
function to display the version in all OCaml tools, to ensure
consistent output.
2015-04-20 08:48:08 +01:00
Maros Zatko
e6dadd6aca customize: fix --upload to FAT partition (RHBZ#1196101)
Some filesystems, such as FAT doesn't support file
ownership, so show warning instead of error on EPERM.
2015-03-27 10:05:12 +00:00
Maros Zatko
ea6d4e5535 customize: add --move (RHBZ#1203817).
This adds --move SOURCE:DEST, equivalent of calling g#mv src dst.

RFE: RHBZ#1203817
2015-03-24 13:27:44 +00:00
Maros Zatko
943fec0399 customize: add --copy (RHBZ#1203817).
This adds --copy SOURCE:DEST, equivalent of calling g#cp_a src dst.

RFE: RHBZ#1203817
2015-03-24 13:27:40 +00:00
Maros Zatko
7e8ed7cb21 customize: add --truncate-recursive option
Allows user to recursively truncate files in PATH. e.g.:
virt-builder --truncate-recursive /var/log

Relates to RHBZ#119673
2015-03-23 12:34:05 +00:00
Maros Zatko
a084758e83 customize: add --truncate option (RHBZ#119673) 2015-03-05 12:29:21 +00:00