Update to current master

This commit is contained in:
Pino Toscano 2014-10-07 15:27:35 +02:00
parent a82b32b7a4
commit cfc87a581d
14 changed files with 1590 additions and 1 deletions

View File

@ -0,0 +1,26 @@
From b84a7d38902199382a7264cc17be509384940020 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 9 Sep 2014 14:43:02 +0200
Subject: [PATCH] ext2: fix small memory leak on error
When failing to read the output of `readlink -f`, free the memory buffer
used for it.
---
src/ext2fs-c.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/ext2fs-c.c b/src/ext2fs-c.c
index 9e0770a..f3ca7dc 100644
--- a/src/ext2fs-c.c
+++ b/src/ext2fs-c.c
@@ -631,6 +631,7 @@ ext2_copy_file (struct ext2_data *data, const char *src, const char *dest)
}
if (fgets (new_dirname, PATH_MAX, fp) == NULL) {
pclose (fp);
+ free (new_dirname);
goto cont;
}
pclose (fp);
--
1.9.3

View File

@ -0,0 +1,36 @@
From c11daf4e7b254bcb56af4871e0a1b8d27b828486 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 13 Sep 2014 14:41:29 +0100
Subject: [PATCH] build: Add some more debug messages.
Allows us to use 'annotate-output supermin -v ...' in order to find
out how long the RPM dependency checking takes.
---
src/build.ml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/build.ml b/src/build.ml
index 8ff574b..7011731 100644
--- a/src/build.ml
+++ b/src/build.ml
@@ -86,11 +86,17 @@ let rec build debug
(* Read the supermin appliance, ie. the input files and/or
* directories that make up the appliance.
*)
+ if debug >= 1 then
+ printf "supermin: reading the supermin appliance\n%!";
let appliance = read_appliance debug basedir empty_appliance inputs in
(* Resolve dependencies in the list of packages. *)
let ph = get_package_handler () in
+ if debug >= 1 then
+ printf "supermin: mapping package names to installed packages\n%!";
let packages = filter_map ph.ph_package_of_string appliance.packages in
+ if debug >= 1 then
+ printf "supermin: resolving full list of package dependencies\n%!";
let packages =
let packages = package_set_of_list packages in
get_all_requires packages in
--
1.9.3

View File

@ -0,0 +1,61 @@
From 7c3984e45b91f8a78530efe6ddfc7a83556892ec Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 15 Sep 2014 13:51:06 +0100
Subject: [PATCH] rpm: Don't both verifying signatures and digests when reading
RPM metadata.
supermin doesn't care, and there's a performance penalty for
doing it.
Thanks: Panu Matilainen
---
src/rpm.ml | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/rpm.ml b/src/rpm.ml
index 434f15b..1195948 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -136,7 +136,7 @@ let rpm_package_of_string str =
* ourselves. *)
let parse_rpm str =
let cmd =
- sprintf "%s -q --qf '%%{name} %%{epoch} %%{version} %%{release} %%{arch}\\n' %s"
+ sprintf "%s --nosignature --nodigest -q --qf '%%{name} %%{epoch} %%{version} %%{release} %%{arch}\\n' %s"
Config.rpm
(quote str) in
let lines = run_command_get_lines cmd in
@@ -177,7 +177,8 @@ let rpm_package_of_string str =
(* Check if an RPM is installed. *)
and check_rpm_installed name =
- let cmd = sprintf "%s -q %s >/dev/null" Config.rpm (quote name) in
+ let cmd = sprintf "%s --nosignature --nodigest -q %s >/dev/null"
+ Config.rpm (quote name) in
0 = Sys.command cmd
in
@@ -227,9 +228,9 @@ let rpm_get_package_database_mtime () =
let rpm_get_all_requires pkgs =
let get pkgs =
let cmd = sprintf "\
- %s -qR %s |
+ %s --nosignature --nodigest -qR %s |
awk '{print $1}' |
- xargs rpm -q --qf '%%{name}\\n' --whatprovides |
+ xargs rpm --nosignature --nodigest -q --qf '%%{name}\\n' --whatprovides |
grep -v 'no package provides' |
sort -u"
Config.rpm
@@ -251,7 +252,7 @@ let rpm_get_all_requires pkgs =
let rpm_get_all_files pkgs =
let cmd = sprintf "\
- %s -q --qf '[%%{FILENAMES}\\t%%{FILEFLAGS:fflags}\\n]' %s |
+ %s --nosignature --nodigest -q --qf '[%%{FILENAMES}\\t%%{FILEFLAGS:fflags}\\n]' %s |
grep '^/' |
sort -u"
Config.rpm
--
1.9.3

View File

@ -0,0 +1,37 @@
From 68bc5e82e4892f981b1d5409ec217518749c4b61 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Wed, 17 Sep 2014 12:59:54 +0200
Subject: [PATCH] Use open_process_full in compressed file reading
Since only few bytes of the compressed file are read, closing the stdout
of the process will cause it to complain about that.
Switch to open_process_full instead of open_process_in, so we can close
also stderr and avoid that harmless error message.
---
src/build.ml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/build.ml b/src/build.ml
index 7011731..500ce33 100644
--- a/src/build.ml
+++ b/src/build.ml
@@ -322,13 +322,13 @@ and get_file_content file buf len =
and get_compressed_file_content zcat file =
let cmd = sprintf "%s %s" zcat (quote file) in
- let chan = open_process_in cmd in
+ let chan_out, chan_in, chan_err = open_process_full cmd [||] in
let buf = String.create 512 in
- let len = input chan buf 0 (String.length buf) in
+ let len = input chan_out buf 0 (String.length buf) in
(* We're expecting the subprocess to fail because we close the pipe
* early, so:
*)
- ignore (close_process_in chan);
+ ignore (Unix.close_process_full (chan_out, chan_in, chan_err));
get_file_content file buf len
--
1.9.3

View File

@ -0,0 +1,120 @@
From 57cb5a62439cc0e4b59d4d19ee1d7e0ffdb4ba26 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Wed, 17 Sep 2014 13:07:24 +0200
Subject: [PATCH] package handlers: add possibility for final teardown
Add a ph_fini callback to package handlers, so they can do teardown
operations, if needed, at the very end of the supermin run.
Currently all of the current package handlers do nothing.
---
src/dpkg.ml | 1 +
src/package_handler.ml | 5 +++++
src/package_handler.mli | 7 +++++++
src/pacman.ml | 1 +
src/rpm.ml | 1 +
src/supermin.ml | 4 +++-
6 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/dpkg.ml b/src/dpkg.ml
index 1bb3f7f..ddfb03a 100644
--- a/src/dpkg.ml
+++ b/src/dpkg.ml
@@ -191,6 +191,7 @@ let () =
let ph = {
ph_detect = dpkg_detect;
ph_init = dpkg_init;
+ ph_fini = (fun () -> ());
ph_package_of_string = dpkg_package_of_string;
ph_package_to_string = dpkg_package_to_string;
ph_package_name = dpkg_package_name;
diff --git a/src/package_handler.ml b/src/package_handler.ml
index b1dffc0..64b8f66 100644
--- a/src/package_handler.ml
+++ b/src/package_handler.ml
@@ -59,6 +59,7 @@ let file_source file =
type package_handler = {
ph_detect : unit -> bool;
ph_init : settings -> unit;
+ ph_fini : unit -> unit;
ph_package_of_string : string -> package option;
ph_package_to_string : package -> string;
ph_package_name : package -> string;
@@ -140,6 +141,10 @@ let rec get_package_handler_name () =
| Some (system, packager, _) -> sprintf "%s/%s" system packager
| None -> assert false
+let package_handler_shutdown () =
+ let ph = get_package_handler () in
+ ph.ph_fini ()
+
let get_all_requires pkgs =
let ph = get_package_handler () in
match ph.ph_get_requires with
diff --git a/src/package_handler.mli b/src/package_handler.mli
index 7e17981..43b0c08 100644
--- a/src/package_handler.mli
+++ b/src/package_handler.mli
@@ -99,6 +99,11 @@ type package_handler = {
initializes. The [settings] parameter is a struct of general
settings and configuration. *)
+ ph_fini : unit -> unit;
+ (** This is called at the end of the supermin processing. It can
+ be used to do teardown operations for the package handler,
+ when no more package-related operations are going to be done. *)
+
ph_package_of_string : string -> package option;
(** Convert a string (from user input) into a package object. If
the package is not installed or the string is otherwise
@@ -172,6 +177,8 @@ val list_package_handlers : unit -> unit
val check_system : settings -> unit
+val package_handler_shutdown : unit -> unit
+
val get_package_handler : unit -> package_handler
val get_package_handler_name : unit -> string
diff --git a/src/pacman.ml b/src/pacman.ml
index 8b11ba8..45fb393 100644
--- a/src/pacman.ml
+++ b/src/pacman.ml
@@ -227,6 +227,7 @@ let () =
let ph = {
ph_detect = pacman_detect;
ph_init = pacman_init;
+ ph_fini = (fun () -> ());
ph_package_of_string = pacman_package_of_string;
ph_package_to_string = pacman_package_to_string;
ph_package_name = pacman_package_name;
diff --git a/src/rpm.ml b/src/rpm.ml
index 1195948..1bd81f4 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -394,6 +394,7 @@ let () =
let fedora = {
ph_detect = fedora_detect;
ph_init = rpm_init;
+ ph_fini = (fun () -> ());
ph_package_of_string = rpm_package_of_string;
ph_package_to_string = rpm_package_to_string;
ph_package_name = rpm_package_name;
diff --git a/src/supermin.ml b/src/supermin.ml
index 0153977..2ee61a9 100644
--- a/src/supermin.ml
+++ b/src/supermin.ml
@@ -261,7 +261,9 @@ let main () =
*)
sprintf "( chmod -R +w %s ; rm -rf %s ) 2>/dev/null &"
(quote old_outputdir) (quote old_outputdir) in
- ignore (Sys.command cmd)
+ ignore (Sys.command cmd);
+
+ package_handler_shutdown ()
let () =
try main ()
--
1.9.3

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,27 @@
From 906fedeed83fe8f1a4e4fd7ec2656e548b83b9c5 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Wed, 17 Sep 2014 17:34:59 +0200
Subject: [PATCH] rpm: fix typo in non-librpm code
Properly spell the name of a stub function, so it builds fine also with
no rpm library.
---
src/librpm-c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/librpm-c.c b/src/librpm-c.c
index 7131de9..e5079b1 100644
--- a/src/librpm-c.c
+++ b/src/librpm-c.c
@@ -463,7 +463,7 @@ supermin_rpm_installed (value rpmv, value pkgv)
}
value
-supermin_rpm_pkg_required (value rpmv, value pkgv)
+supermin_rpm_pkg_requires (value rpmv, value pkgv)
{
abort ();
}
--
1.9.3

View File

@ -0,0 +1,91 @@
From 3a967a746008001fb9b7ade5451d19a1f1956601 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Thu, 18 Sep 2014 16:37:48 +0200
Subject: [PATCH] rpm: reuse the rpmtd when possible
Use a single rpmtd object per operation, making sure it is properly
cleaned when needed. This slightly reduces the number of malloc/free's.
---
src/librpm-c.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/librpm-c.c b/src/librpm-c.c
index e5079b1..1ae3bad 100644
--- a/src/librpm-c.c
+++ b/src/librpm-c.c
@@ -185,6 +185,7 @@ supermin_rpm_installed (value rpmv, value pkgv)
rpmdbMatchIterator iter;
int count, i;
Header h;
+ rpmtd td;
data = Librpm_val (rpmv);
if (data.ts == NULL)
@@ -200,16 +201,15 @@ supermin_rpm_installed (value rpmv, value pkgv)
rv = caml_alloc (count, 0);
i = 0;
+ td = rpmtdNew ();
while ((h = rpmdbNextIterator (iter)) != NULL) {
HeaderIterator hi;
- rpmtd td;
uint32_t *val;
bool stored_vals[5] = { false };
v = caml_alloc (5, 0);
hi = headerInitIterator (h);
- td = rpmtdNew ();
while (headerNext (hi, td) == 1) {
switch (rpmtdTag (td)) {
case RPMTAG_NAME:
@@ -251,11 +251,11 @@ supermin_rpm_installed (value rpmv, value pkgv)
Store_field (v, 4, caml_copy_string ("unknown"));
Store_field (rv, i, v);
- rpmtdFree (td);
headerFreeIterator (hi);
++i;
}
+ rpmtdFree (td);
rpmdbFreeIterator (iter);
CAMLreturn (rv);
@@ -334,6 +334,7 @@ supermin_rpm_pkg_whatprovides (value rpmv, value pkgv)
rpmdbMatchIterator iter;
int count, i;
Header h;
+ rpmtd td;
data = Librpm_val (rpmv);
if (data.ts == NULL)
@@ -349,12 +350,11 @@ supermin_rpm_pkg_whatprovides (value rpmv, value pkgv)
rv = caml_alloc (count, 0);
i = 0;
+ td = rpmtdNew ();
while ((h = rpmdbNextIterator (iter)) != NULL) {
- rpmtd td;
int ret;
- td = rpmtdNew ();
ret = headerGet (h, RPMTAG_NAME, td, HEADERGET_MINMEM);
if (ret != 1)
caml_failwith ("rpm_pkg_whatprovides: headerGet failed");
@@ -362,10 +362,10 @@ supermin_rpm_pkg_whatprovides (value rpmv, value pkgv)
Store_field (rv, i, caml_copy_string (rpmtdGetString (td)));
rpmtdFreeData (td);
- rpmtdFree (td);
++i;
}
+ rpmtdFree (td);
rpmdbFreeIterator (iter);
CAMLreturn (rv);
--
1.9.3

View File

@ -0,0 +1,35 @@
From c3638240da5f1b56a807cdf802495704bd395cc2 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Thu, 18 Sep 2014 16:58:54 +0200
Subject: [PATCH] rpm: reuse the same iteration set
When resolving the requirements of a package, use the same set with the
results, instead of creating a new set and merging it with the results
set.
---
src/rpm.ml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/rpm.ml b/src/rpm.ml
index 3a75ea0..4c2156a 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -212,13 +212,12 @@ let rpm_get_all_requires pkgs =
let provides =
try Hashtbl.find rpm_providers x
with Not_found -> rpm_pkg_whatprovides (get_rpm ()) x in
- let newset = Array.fold_left (
+ Array.fold_left (
fun newset p ->
match rpm_package_of_string p with
| None -> newset
| Some x -> StringSet.add p newset
- ) StringSet.empty provides in
- StringSet.union set newset
+ ) set provides
with Not_found -> set
) StringSet.empty reqs in
pkgs'
--
1.9.3

View File

@ -0,0 +1,27 @@
From 73e10157dc90309e9d2cea63e1be3c74ed4aa635 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Mon, 29 Sep 2014 16:53:55 +0200
Subject: [PATCH] chroot: fix quoting in cp invocation
Make sure to quote source and destination, to avoid failures when
dealing with paths with e.g. spaces, brackets, etc.
---
src/chroot.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/chroot.ml b/src/chroot.ml
index 63a5a79..d0ee4c3 100644
--- a/src/chroot.ml
+++ b/src/chroot.ml
@@ -60,7 +60,7 @@ let build_chroot debug files outputdir =
| S_REG | S_CHR | S_BLK | S_FIFO | S_SOCK ->
if debug >= 2 then printf "supermin: chroot: copy %s\n%!" opath;
- let cmd = sprintf "cp -p %s %s" path opath in
+ let cmd = sprintf "cp -p %s %s" (quote path) (quote opath) in
ignore (Sys.command cmd)
with Unix_error _ -> ()
) files;
--
1.9.3

View File

@ -0,0 +1,25 @@
From 17317277c8c7a7051502c975d3aa03d9863ca552 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 7 Oct 2014 10:51:01 +0200
Subject: [PATCH] rpm: use the proper parameter
---
src/rpm.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rpm.ml b/src/rpm.ml
index 4c2156a..b88ac73 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -137,7 +137,7 @@ let rpmh = Hashtbl.create 13
let rpm_package_of_string str =
let query rpm =
- let rpms = Array.to_list (rpm_installed (get_rpm ()) str) in
+ let rpms = Array.to_list (rpm_installed (get_rpm ()) rpm) in
(* RPM will return multiple hits when either multiple versions or
* multiple arches are installed at the same time. We are only
* interested in the highest version with the best
--
1.9.3

View File

@ -0,0 +1,29 @@
From 46f987c48296ebd35c153c04488fcf7ee97a41bd Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 7 Oct 2014 11:09:10 +0200
Subject: [PATCH] rpm: fix caching of provides
Now each provide is resolved really once.
---
src/rpm.ml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/rpm.ml b/src/rpm.ml
index b88ac73..71cdab2 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -211,7 +211,10 @@ let rpm_get_all_requires pkgs =
try
let provides =
try Hashtbl.find rpm_providers x
- with Not_found -> rpm_pkg_whatprovides (get_rpm ()) x in
+ with Not_found ->
+ let p = rpm_pkg_whatprovides (get_rpm ()) x in
+ Hashtbl.add rpm_providers x p;
+ p in
Array.fold_left (
fun newset p ->
match rpm_package_of_string p with
--
1.9.3

View File

@ -0,0 +1,38 @@
From d78c898c7e2bc5f12cbebef98b95a7908d9120f1 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 7 Oct 2014 11:51:15 +0200
Subject: [PATCH] rpm: check for providers for not found package
If a package is not found among the ones installed, check whether there
is any other package providing it (only a single one).
---
src/rpm.ml | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/rpm.ml b/src/rpm.ml
index 71cdab2..b5c5ff5 100644
--- a/src/rpm.ml
+++ b/src/rpm.ml
@@ -158,7 +158,18 @@ let rpm_package_of_string str =
Not_found ->
let r =
try Some (pkg_of_rpm (query str))
- with Not_found -> None in
+ with Not_found ->
+ try
+ let p = rpm_pkg_whatprovides (get_rpm ()) str in
+ (* Pick only a provided package when there is just one of them,
+ * otherwise there is no reliable way to know which one to pick
+ * if there are multiple providers.
+ *)
+ if Array.length p = 1 then
+ Some (pkg_of_rpm (query p.(0)))
+ else
+ None
+ with Not_found -> None in
Hashtbl.add rpmh str r;
r
--
1.9.3

View File

@ -1,7 +1,7 @@
Summary: Tool for creating supermin appliances Summary: Tool for creating supermin appliances
Name: supermin Name: supermin
Version: 5.1.10 Version: 5.1.10
Release: 1%{?dist} Release: 2%{?dist}
License: GPLv2+ License: GPLv2+
%if 0%{?rhel} >= 7 %if 0%{?rhel} >= 7
@ -11,8 +11,23 @@ ExclusiveArch: x86_64
URL: http://people.redhat.com/~rjones/supermin/ URL: http://people.redhat.com/~rjones/supermin/
Source0: http://libguestfs.org/download/supermin/%{name}-%{version}.tar.gz Source0: http://libguestfs.org/download/supermin/%{name}-%{version}.tar.gz
Patch1: 0001-ext2-fix-small-memory-leak-on-error.patch
Patch2: 0002-build-Add-some-more-debug-messages.patch
Patch3: 0003-rpm-Don-t-both-verifying-signatures-and-digests-when.patch
Patch4: 0004-Use-open_process_full-in-compressed-file-reading.patch
Patch5: 0005-package-handlers-add-possibility-for-final-teardown.patch
Patch6: 0006-rpm-use-the-rpm-library-instead-of-invoking-rpm.patch
Patch7: 0007-rpm-fix-typo-in-non-librpm-code.patch
Patch8: 0008-rpm-reuse-the-rpmtd-when-possible.patch
Patch9: 0009-rpm-reuse-the-same-iteration-set.patch
Patch10: 0010-chroot-fix-quoting-in-cp-invocation.patch
Patch11: 0011-rpm-use-the-proper-parameter.patch
Patch12: 0012-rpm-fix-caching-of-provides.patch
Patch13: 0013-rpm-check-for-providers-for-not-found-package.patch
BuildRequires: /usr/bin/pod2man BuildRequires: /usr/bin/pod2man
BuildRequires: rpm BuildRequires: rpm
BuildRequires: rpm-devel
BuildRequires: yum-utils BuildRequires: yum-utils
BuildRequires: /usr/sbin/mke2fs BuildRequires: /usr/sbin/mke2fs
BuildRequires: e2fsprogs-devel BuildRequires: e2fsprogs-devel
@ -21,6 +36,9 @@ BuildRequires: glibc-static, zlib-static
BuildRequires: xz-static, xz-devel BuildRequires: xz-static, xz-devel
BuildRequires: ocaml, ocaml-findlib-devel BuildRequires: ocaml, ocaml-findlib-devel
# autoreconf during build, since the patches change configure.ac
BuildRequires: automake, autoconf
# These are required only to run the tests. We could patch out the # These are required only to run the tests. We could patch out the
# tests to not require these packages. # tests to not require these packages.
BuildRequires: augeas hivex kernel tar BuildRequires: augeas hivex kernel tar
@ -52,6 +70,10 @@ second when you need to boot one of them.
%prep %prep
%setup -q %setup -q
%autopatch -p1
autoreconf -i
%build %build
%configure --disable-network-tests %configure --disable-network-tests
@ -84,6 +106,10 @@ make check || {
%changelog %changelog
* Tue Oct 7 2014 Pino Toscano <ptoscano@redhat.com> - 5.1.10-2
- Update to upstream commit d78c898c7e2bc5f12cbebef98b95a7908d9120f1.
- BR rpm-devel, since it is now used instead of invoking rpm.
* Thu Sep 4 2014 Richard W.M. Jones <rjones@redhat.com> - 5.1.10-1 * Thu Sep 4 2014 Richard W.M. Jones <rjones@redhat.com> - 5.1.10-1
- New upstream version 5.1.10. - New upstream version 5.1.10.
- Remove patch which is now included upstream. - Remove patch which is now included upstream.