233 Commits

Author SHA1 Message Date
Richard W.M. Jones
4807dacb57 daemon: Add zstd support to guestfs_file_architecture
This is required so we can determine the file architecture of
zstd-compressed Linux kernel modules as used by OpenSUSE and maybe
other distros in future.

Note that zstd becomes a required package, but it is widely available
in current Linux distros.

The package names come from https://pkgs.org/download/zstd and my own
research.

(cherry picked from commit 0e784824e8)
2022-08-10 08:43:58 +01:00
Richard W.M. Jones
9318f39bd7 build: Pick first field in ID_LIKE
CentOS Stream has:

ID_LIKE="rhel fedora"

which confused the existing script.  If there are multiple "likes"
arbitrarily pick the first one in the list.

Fixes: commit 63b722b6c0
(cherry picked from commit 7afbf5ee44)
2022-05-26 14:56:51 +01:00
Richard W.M. Jones
86cbff0a4b build: When parsing distro from /etc/os-release, try $ID_LIKE first
The current code for working out the distro uses the ID entry from
/etc/os-release, and then we map those strings into a smaller set of
values (basically, what package manager to use).  However it was
suggested that we should try ID_LIKE first so that distros which act
like other distros would work.  On an Arch Linux 32 system:

ID=arch32
ID_LIKE=arch

See-also: https://github.com/libguestfs/libguestfs/issues/81
Thanks: S D Rausty
(cherry picked from commit 63b722b6c0)
2022-05-26 11:20:29 +01:00
Neil Hanlon
796e0b763b build: Add ROCKY to REDHAT distros list
(cherry picked from commit a3487ef4c5)
2022-05-26 11:19:41 +01:00
Richard W.M. Jones
395ca6fea5 m4: Add support for Artix
Fixes: https://github.com/libguestfs/libguestfs/issues/81
(cherry picked from commit f9babf8c04)
2022-05-12 14:47:12 +01:00
Richard W.M. Jones
2ad3f1ca5d build: No longer check for ocamldep -one-line and -all options
These were added to ocamldep in Jan 2012, over 10 years ago.  They
were not present in RHEL 6, but we don't care about that now.

(cherry picked from virt-v2v commit f6108bbd661d3e922d07b47f00daa901ab846e59)

(cherry picked from commit 0a2d43988f)
2022-05-12 14:46:56 +01:00
Richard W.M. Jones
1941593585 Disable OCaml warning 6 completely
Warning 6 "labels-omitted" is not useful.  It's fine to omit labels on
positional arguments.

Example:

  File "perl_edit.ml", line 30, characters 2-13:
  30 |   c_edit_file (verbose ()) g (Guestfs.c_pointer g) file expr
         ^^^^^^^^^^^
  Warning 6 [labels-omitted]: label verbose was omitted in the application of this function.

The function is specified as:

  external c_edit_file : verbose:bool -> Guestfs.t -> int64 -> string -> string -> unit

The complaint is that the verbose: label has been omitted from the
first argument when the function is called, but IMO this is a
stylistic thing, not a bug.

(cherry picked from
guestfs-tools commit 577f7aee4b1c720f4c4826115b49a0c3870b149e)
2021-12-10 10:30:17 +00:00
Richard W.M. Jones
0d05a229f3 customize: Suppress OCaml warning
In OCaml 4.13:

File "perl_edit.ml", line 30, characters 2-13:
30 |   c_edit_file (verbose ()) g (Guestfs.c_pointer g) file expr
       ^^^^^^^^^^^
Error (warning 6 [labels-omitted]): label verbose was omitted in the application of this function.

(cherry picked from
guestfs-tools commit a4930f5fad82e5358d565b8cf3610970e9646259)
2021-12-10 10:30:11 +00:00
Richard W.M. Jones
60e9232f4e Move minimum OCaml version to 4.04.
Synchronize with common module which also requires 4.04.

Small adjustment to use of List.sort_uniq because the signature
changed slightly.
2021-11-09 10:21:30 +00:00
Richard W.M. Jones
b536c61a6d m4: Remove test for OCaml Bytes module 2021-11-09 10:07:00 +00:00
Laszlo Ersek
f34bd6b12f build, docs: spell out minimum version (4.0.0) for the (optional) Yara lib
Commit e597fc5317 ("daemon/yara: fix undefined behavior due to Yara 4.0
API changes", 2021-10-12) prevents the daemon from using such a Yara
version that precedes 4.0.0.

If only yara < 4 is found, treat the library as absent, rather than
attempting and failing to compile the yara module of the daemon. Note the
version requirement in the documentation too.

Suggested-by: Eric Blake <eblake@redhat.com>
Suggested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211013133611.21599-4-lersek@redhat.com>
Acked-by: Eric Blake <eblake@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-14 19:45:07 +02:00
Laszlo Ersek
4daec34a01 build: eliminate the AC_CHECK_LIB / AC_CHECK_HEADER tests for Yara
Eliminate the AC_CHECK_LIB / AC_CHECK_HEADER tests for Yara, for the
following reasons:

- Upstream Yara has provided a pkg-config file since 2015, so the
  (now-fixed) pkg-config check should always find it, without the
  AC_CHECK_LIB / AC_CHECK_HEADER fallback branch.

- In a subsequent patch, we'll want to test for the incompatible Yara API
  changes described at
  <https://github.com/VirusTotal/yara/wiki/Backward-incompatible-changes-in-YARA-4.0-API>.

  That's easy to do with pkg-config, but impossible with AC_CHECK_*,
  without a custom test. Namely, both AC_CHECK_DECLS and AC_CHECK_TYPES
  appear unable to check the parameter list of a function pointer typedef
  (namely YR_CALLBACK_FUNC and YR_COMPILER_CALLBACK_FUNC). And writing a
  dedicated test for this is overkill.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211013133611.21599-3-lersek@redhat.com>
Acked-by: Eric Blake <eblake@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-14 19:45:03 +02:00
Laszlo Ersek
54187b7f98 build: fix the pkg-config identifier of the (optional) Yara library
The upstream Yara project has always provided its "libyara/yara.pc.in"
file with "Name: yara" -- ever since its introduction in commit
334bd1a671ca ("Add support for pkg-config", 2015-01-08).

In spite of this, when the (optional) Yara dependency was added to
libguestfs in commit 2e24129da3 ("appliance: add yara dependency",
2017-05-02), PKG_CHECK_MODULES was invoked with [libyara] as
list-of-modules.

(That was clearly a bug. I'm unsure what Debian calls their Yara
pkg-config module, but calling it anything else than "yara" would be a
distribution bug: upstream projects provide pkg-config files specifically
so that dependent projects can find their dependencies *regardless of
distribution*.)

As a consequence, on Fedora today, the PKG_CHECK_MODULES macro always
fails, and only the AC_CHECK_LIB / AC_CHECK_HEADER branch finds Yara.

In a subsequent patch, we'll want to add a version requirement to the
PKG_CHECK_MODULES macro invocation, so at first, fix the pkg-config
identifier of Yara.

Fixes: 2e24129da3
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211013133611.21599-2-lersek@redhat.com>
Acked-by: Eric Blake <eblake@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-14 19:44:31 +02:00
Laszlo Ersek
7915938b8e build: fix typo in "--enable-werror" help string
While <https://libguestfs.org/guestfs-building.1.html> correctly documents
the "--enable-werror" option, the "./configure" help text itself doesn't.
Replace "--enable-error" with "--enable-werror" now.

Fixes: 0f54df53d2
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211011223627.20856-2-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
2021-10-12 16:47:37 +02:00
Richard W.M. Jones
63c9cd933a m4/guestfs-ocaml.m4: Fix deprecated warning format
In OCaml 4.13:

Alert ocaml_deprecated_cli: Setting a warning with a sequence of lowercase or uppercase letters,
like 'CDEFLMPSUVYZX', is deprecated.
Use the equivalent signed form: +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3.

(cherry picked from
guestfs-tools commit fa4f59e1d99c08d7e0bae2a7cb54f254a6506d67)
2021-10-05 21:08:07 +01:00
Richard W.M. Jones
4e02c13941 m4/guestfs-appliance.m4: Add support for Alma and Cloud Linux
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2001636
Thanks: sasha121196@mail.ru
2021-09-06 17:02:19 +01:00
Alexandre Iooss
210959cc34 build: Define HAVE_RPM, HAVE_DPKG and HAVE_PACMAN
When using option `--with-distro`, `HAVE_RPM`, `HAVE_DPKG` and
`HAVE_PACMAN` are not defined and make the configure phase fail.
This makes sure that these conditionals are always defined.
2021-08-27 20:25:14 +01:00
Martin Kletzander
e68a844eb4 build: Don't use non-POSIX tests
The `test` builtin/binary usually accepts `==` for string comparison, it is
mostly accepted for typos and people being used to double equals, but is not
documented and not always accepted either.  Since autoconf uses the default
shell, it might just fail in some cases with:

    ./configure: 29986: test: xrustc: unexpected operator
    ./configure: 29990: test: xcargo: unexpected operator

Just change it to single equals as it is done everywhere else.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2021-06-01 10:34:58 +01:00
Richard W.M. Jones
95de3f6c50 golang: Fix bindings for golang 1.16.
See https://blog.golang.org/go116-module-changes
2021-04-08 12:55:19 +01:00
Richard W.M. Jones
0f54df53d2 build: Remove gnulib.
As part of our efforts to clean up and simplify libguestfs, removing
gnulib deletes a large dependency that we mostly no longer use and
causes problems for new users trying to build the library from source.

A few modules from gnulib are still used (under a compatible license)
and these are copied into gnulib/lib/
2021-04-08 11:36:40 +01:00
Richard W.M. Jones
2216ab2e32 tests: Prefer xorriso over genisoimage to generate test.iso
This Debian page explains the upstream situation:
https://wiki.debian.org/genisoimage

On Fedora, xorriso provides a compatibility program called "mkisofs".
However this is not present in Debian.  Hence the choice to look for
the program called "xorrisofs".
2021-03-30 13:57:30 +01:00
Richard W.M. Jones
8317279c35 m4/guestfs-find-db-tool.m4: Remove unused file.
Fixes: commit 42e5e7cfdb
2021-03-29 18:38:39 +01:00
Richard W.M. Jones
42e5e7cfdb test-data/phony-guests: Fix phony RPM database, fix virt-inspector test.
libguestfs 1.45.3 now reads the RPM database using librpm, which means
our old phony database created by db_dump can no longer work.  Instead
provide a real (but very minimal) sqlite database.

This commit also fixes the virt-inspector test since the RPM database
contents are now different.
2021-03-29 17:26:43 +01:00
Richard W.M. Jones
c9ee831aff inspection: Fix inspection of recent RPM guests using non-BDB.
Recent RPM-based guests have switched from using Berkeley DB (BDB) to
sqlite.  In order to inspect these guests (and earlier ones) we need
to stop using the hokey parsing of the BDB and use librpm APIs
instead.

This commit adds a new internal API so we can call librpm from the
daemon, and changes the library part to use the new API for RPM-based
guests.

This change removes the requirement for BDB tools like db_dump.

See also:
http://lists.rpm.org/pipermail/rpm-ecosystem/2021-March/000751.html
http://lists.rpm.org/pipermail/rpm-ecosystem/2021-March/000754.html
https://blog.fpmurphy.com/2011/08/programmatically-retrieve-rpm-package-details.html

This breaks the virt-inspector test (now in the separate guestfs-tools
repository).  However this is not a bug in libguestfs, but a bug in
the phoney Fedora guest that we use for testing - we created a
BDB-style RPM database which was supposed to be just enough to make
the old code work.  The new code using real librpm needs
/usr/lib/rpm/rpmrc (not present in the phoney image) and also cannot
parse the phoney database, so we will need to separately rework that
test.

Thanks: Panu Matilainen
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1766487
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1409024
2021-03-26 16:26:00 +00:00
Richard W.M. Jones
3b1ed4c9bc build: Use correct ounit2 OCaml module.
Also update common module to get the same fix.
2021-03-25 08:26:42 +00:00
Richard W.M. Jones
24e112c1b7 perl: Remove dependency on Win::Hivex::*
This is used in virt-win-reg, but that tool have moved out to
guestfs-tools so the dependency is no longer needed by libguestfs
itself.

Fixes: commit 733d2182b6
2021-03-18 12:19:55 +00:00
Richard W.M. Jones
061be6bb84 tests: Remove dependency on Sys::Virt.
This was only used for a single rule (check-valgrind-local-guests)
which ran "make check-valgrind" on local guests.  This was never
really used by me and was fairly inadvisable anyway, so we can easily
remove it and thus remove the dependency on perl Sys::Virt.
2021-03-18 12:16:28 +00:00
Richard W.M. Jones
82493579f3 Port libguestfs to use pcre2 instead of pcre.
https://bugzilla.redhat.com/show_bug.cgi?id=1938982
2021-03-16 11:24:37 +00:00
Richard W.M. Jones
f19fd566f6 appliance: Add dhclient for Arch-like Manjaro distro.
Thanks: hatifnatt on IRC
2021-02-17 09:44:19 +00:00
Richard W.M. Jones
fb7b683a29 appliance: Avoid having ${exec_prefix} in guestfs appliance path.
Normally packagers should try to use ./configure --with-guestfs-path=...
However if they do not, then a regression in 1.44 caused the path to
constain the literal string "${exec_prefix}".  This was because of
autoconf stupidity.

Try to resolve this by expanding ${exec_prefix} to something sensible.

The expansion will often be wrong (but at least it will now be a valid
path), hence the recommendation to always set --libdir and/or
--with-guestfs-path when configuring.

Fixes: commit 94ff24b880
Fixes: https://bugzilla.redhat.com/1915646
2021-01-15 14:20:00 +00:00
Richard W.M. Jones
812f837c97 build: Avoid warnings about unknown pragmas.
In commit 4bbbf03b8b we started to
ignore bogus GCC 11 warnings.  Unfortunately earlier versions of GCC
don't know about those pragmas so give warnings [hence errors in
developer builds] like:

tsk.c:75:32: error: unknown option after '#pragma GCC diagnostic' kind [-Werror=pragmas]

Turn off these warnings.

Updates: commit 4bbbf03b8b
2021-01-12 10:27:35 +00:00
Richard W.M. Jones
675b336f63 gnulib: Update to latest. 2021-01-05 15:53:51 +00:00
Richard W.M. Jones
3d2c38d5ab m4: Define INCLUDE_DIRECTORY for libguestfs only. 2020-12-01 14:31:12 +00:00
Thierry Vignaud
d63c8041d5 fix detecing db_* tool on Mageia 2020-11-24 09:28:05 +00:00
Richard W.M. Jones
e49be55630 m4/.gitignore: Update.
Fixes: commit cfcd3385cc
2020-10-22 14:50:33 +01:00
Hilko Bengen
133a491677 Use guestfsd binary to auto-generate library dependencies for appliance
The ELF NEEDED are used to determine guestfsd's library dependencies
with help from the dynamic linker and the package manager.

This was prompted by Debian bug #972241 which was caused by a
libtirpc package renaming in Debian/unstable because the SONAME had
been changed.
2020-10-19 12:14:34 +01:00
Pino Toscano
bd896d68c0 po-docs: split pot and po handling
With the Weblate adoption, we let it update the po files from the
catalog template. The po4a behaviour of extracting the template,
merging the existing translations, and creating the translated PODs at
once is problematic. Hence, split the extraction and the translated POD
generation in two.

Use po4a-gettextize to extract the catalog template only, not doing it
anymore automatically at each build. There is no more need for a
po4a.conf file.

Use po4a-translate to create translated PODs from the po files, keeping
the fixup of the generated files (to avoid spurious =encoding, etc).
Add a silent rule to hide the po4a-translate command lines by default.

These changes also allow us to get rid of the POD existance checks with
associated error message pointing to the update-po rule. Now each
translated POD file is generated because of make dependency, and it
depends only on its po file.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2020-08-13 11:27:44 +02:00
Richard W.M. Jones
599f2f7bd9 m4: Increase warning limit for frame-larger-than.
Generated code in virt-builder causes the error below.  Since we
cannot control what is generated by bison, increase the limit.

  CCLD     virt-index-validate
index-parse.c: In function 'yyparse':
index-parse.c:1857:1: error: the frame size of 5152 bytes is larger than 5000 bytes [-Werror=frame-larger-than=]
 1857 | }
      | ^
lto1: all warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status
2020-08-01 07:09:52 +01:00
Richard W.M. Jones
403d17a876 python: Drop support for Python 2.
Python 2 reached end of life on 2020-01-01:
https://python3statement.org/
https://pythonclock.org/

The minimum version required is now Python 3.4 (since that is the
version in Debian oldoldstable), but 3.6 is the minimum version that
I actually test.
2020-07-06 12:40:33 +01:00
Richard W.M. Jones
94ff24b880 appliance: Set default guestfs appliance path to $libdir/guestfs.
For unclear reasons this broke recently, although the breakage is only
reproducible in Fedora Koji.  It appears to be caused by the
calculation of the internal autoconf variable $acl_libdirstem
changing.  In the reproducer system:

checking for the common suffixes of directories in the library search path... lib,lib,lib64

On my local system:

checking for the common suffixes of directories in the library search path... lib64,lib64

My local system would be the correct one.  The actual code that
calculates this does some crazy stuff with ‘gcc -print-search-dirs’
which would hint that this output has changed in some way that subtly
breaks the generated configure script.  However even with match GCC
versions on my local system I could still not reproduce the issue.

None of this matters, as the easiest fix here is simply to stop using
internal autoconf variables at all.  I also added some AC_MSG_*
statements so we can more easily see what's going on in the configure
output.

Fixes commit 0f79400c7f.
2020-05-06 12:39:41 +01:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
77f8018f6a Update gnulib to latest. 2020-03-06 19:03:03 +00:00
Richard W.M. Jones
18c3f40c60 appliance: Pass root=UUID=<uuid> instead of appliance device name (RHBZ#1804207).
Appliance device names are not reliable since the kernel no longer
enumerates virtio-scsi devices serially.  Instead get the UUID of the
appliance and pass this as the parameter.

Note this requires supermin >= 5.1.18 (from around July 2017).
2020-03-06 19:03:03 +00:00
Richard W.M. Jones
4e90febbaa RHEL 7: python: Check for _Py_IsFinalizing.
This symbol is not present in Python 2.7 or 3.6.  It's not really
necessary to call this, it just avoids a crash in certain corner cases
when the interpreter is shutting down.  So make the call conditional
on the function existing.

Fixes commit e6f9e0b0f6.
2020-03-06 18:59:52 +00:00
Richard W.M. Jones
9f3148c791 ocaml: Use caml_alloc_initialized_string instead of memcpy.
See this commit in libguestfs-common:
398dc56a6c
2020-02-06 10:32:08 +00:00
Richard W.M. Jones
378b49152d m4: ocaml: Move definition of HIVEX_OPEN_UNSAFE_FLAG closer to test.
Minor code cleanup, no change in semantics.
2020-02-06 10:28:34 +00:00
Richard W.M. Jones
538f728d5f Update gnulib. 2020-01-22 13:03:03 +00:00
Pino Toscano
5d8cca738e build: define HAVE_PYCODESTYLE in all the cases
Fixes commit cad3ea9e74 in case Python is
disabled, or not available.
2020-01-16 11:02:25 +01:00
Richard W.M. Jones
711fab172c ocaml: Fix test for -runtime-variant _pic.
This fails with Fedora 32, and possibly earlier versions:

  checking if OCaml ‘-runtime-variant _pic’ works... no

The reason is:

  $ ocamlc -runtime-variant _pic test.ml -o test
  File "test.ml", line 1:
  Error: Cannot find file camlheader_pic

which may even be a packaging error in the Fedora package.  However it
makes no sense to test the bytecode compiler since we don't use it on
any architecture we care about and bytecode doesn't even contain a
linked runtime.  Changing the test to use ocamlopt instead of ocamlc
fixes the problem.
2020-01-15 12:52:29 +00:00
Pino Toscano
cad3ea9e74 python: add a pycodestyle test
Look for pycodestyle, and use it to check all the Python sources (tests
and auxiliary scripts included) of the Python bindings.
2020-01-14 16:21:22 +01:00