Richard W.M. Jones
2011-Mar-18 14:58 UTC
[Libguestfs] [PATCH 0/2 febootstrap] Allow zero-size conflicting config files to be combined
It's a recurring bug in Fedora that two packages will both contain a config file with the same name (for example this currently is occurring in glibc & glibc-common in Fedora 13 with the file /etc/gai.conf). RPM appears to allow this, at least if both files are empty. If both files are empty then there appears to be no particular problem with combining the two file records in febootstrap into one. This pair of patches makes this change. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Richard W.M. Jones
2011-Mar-18 15:00 UTC
[Libguestfs] [PATCH 1/2 febootstrap] Collect the size (ft_size) of files from package handlers.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora -------------- next part -------------->From fb6a900047ba372ec933ebf1b3d7339c4f33243c Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 18 Mar 2011 14:53:04 +0000 Subject: [PATCH 1/2] Collect the size (ft_size) of files from package handlers. --- febootstrap.ml | 9 +++++---- febootstrap_debian.ml | 2 +- febootstrap_package_handlers.ml | 1 + febootstrap_package_handlers.mli | 1 + febootstrap_pacman.ml | 2 +- febootstrap_yum_rpm.ml | 13 ++++++++----- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/febootstrap.ml b/febootstrap.ml index 9ea9885..3c634c4 100644 --- a/febootstrap.ml +++ b/febootstrap.ml @@ -126,7 +126,8 @@ let () else ( insert_dir parent; let newdir = (parent, { ft_dir = true; ft_config = false; - ft_ghost = false; ft_mode = 0o40755 }, + ft_ghost = false; ft_mode = 0o40755; + ft_size = 0 }, "") in newdir :: loop parent ) @@ -140,12 +141,12 @@ let () if false then ( List.iter ( fun (name, { ft_dir = dir; ft_ghost = ghost; ft_config = config; - ft_mode = mode }, pkg) -> - printf "%s [%s%s%s%o] from %s\n" name + ft_mode = mode; ft_size = size }, pkg) -> + printf "%s [%s%s%s%o %d] from %s\n" name (if dir then "dir " else "") (if ghost then "ghost " else "") (if config then "config " else "") - mode + mode size pkg ) files ); diff --git a/febootstrap_debian.ml b/febootstrap_debian.ml index 83c6c1a..f0d0be5 100644 --- a/febootstrap_debian.ml +++ b/febootstrap_debian.ml @@ -112,7 +112,7 @@ let debian_list_files pkg let mode = statbuf.st_perm in (path, { ft_dir = is_dir; ft_config = config; ft_mode = mode; - ft_ghost = false }) + ft_ghost = false; ft_size = statbuf.st_size }) ) lines in files diff --git a/febootstrap_package_handlers.ml b/febootstrap_package_handlers.ml index 72bb172..ad3a233 100644 --- a/febootstrap_package_handlers.ml +++ b/febootstrap_package_handlers.ml @@ -33,6 +33,7 @@ and file_type = { ft_config : bool; ft_ghost : bool; ft_mode : int; + ft_size : int; } let tmpdir = tmpdir () diff --git a/febootstrap_package_handlers.mli b/febootstrap_package_handlers.mli index 673e448..c28d81f 100644 --- a/febootstrap_package_handlers.mli +++ b/febootstrap_package_handlers.mli @@ -50,6 +50,7 @@ and file_type = { ft_config : bool; (** Is a configuration file. *) ft_ghost : bool; (** Is a ghost (created empty) file. *) ft_mode : int; (** File mode. *) + ft_size : int; (** File size. *) } val register_package_handler : string -> package_handler -> unit diff --git a/febootstrap_pacman.ml b/febootstrap_pacman.ml index 760d0ef..96dfefa 100644 --- a/febootstrap_pacman.ml +++ b/febootstrap_pacman.ml @@ -111,7 +111,7 @@ let pacman_list_files pkg let mode = statbuf.st_perm in (path, { ft_dir = is_dir; ft_config = config; ft_mode = mode; - ft_ghost = false }) + ft_ghost = false; ft_size = statbuf.st_size }) ) lines in files diff --git a/febootstrap_yum_rpm.ml b/febootstrap_yum_rpm.ml index e70940d..f6644b8 100644 --- a/febootstrap_yum_rpm.ml +++ b/febootstrap_yum_rpm.ml @@ -163,7 +163,7 @@ f.close () let rec yum_rpm_list_files pkg (* Run rpm -qlp with some extra magic. *) let cmd - sprintf "rpm -q --qf '[%%{FILENAMES} %%{FILEFLAGS:fflags} %%{FILEMODES}\\n]' -p %s" + sprintf "rpm -q --qf '[%%{FILENAMES} %%{FILEFLAGS:fflags} %%{FILEMODES} %%{FILESIZES}\\n]' -p %s" pkg in let lines = run_command_get_lines cmd in @@ -171,15 +171,16 @@ let rec yum_rpm_list_files pkg filter_map ( fun line -> match string_split " " line with - | [filename; flags; mode] -> + | [filename; flags; mode; size] -> let test_flag = String.contains flags in let mode = int_of_string mode in + let size = int_of_string size in if test_flag 'd' then None (* ignore documentation *) else Some (filename, { ft_dir = mode land 0o40000 <> 0; ft_ghost = test_flag 'g'; ft_config = test_flag 'c'; - ft_mode = mode; + ft_mode = mode; ft_size = size; }) | _ -> eprintf "febootstrap: bad output from rpm command: '%s'" line; @@ -199,7 +200,8 @@ let rec yum_rpm_list_files pkg let dirs List.map (fun name -> name, { ft_dir = true; ft_ghost = false; - ft_config = false; ft_mode = 0o40755 }) dirs in + ft_config = false; ft_mode = 0o40755; + ft_size = 0 }) dirs in let devs = [ "/dev/null"; "/dev/full"; "/dev/zero"; "/dev/random"; "/dev/urandom"; "/dev/tty"; "/dev/console"; "/dev/ptmx"; "/dev/stdin"; "/dev/stdout"; "/dev/stderr" ] in @@ -207,7 +209,8 @@ let rec yum_rpm_list_files pkg let devs List.map (fun name -> name, { ft_dir = false; ft_ghost = false; - ft_config = false; ft_mode = 0o644 }) devs in + ft_config = false; ft_mode = 0o644; + ft_size = 0 }) devs in dirs @ devs @ files ) else files in -- 1.7.2.3
Richard W.M. Jones
2011-Mar-18 15:00 UTC
[Libguestfs] [PATCH 2/2 febootstrap] Allow config files from different packages if both files have zero size.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org -------------- next part -------------->From 48ba44a6751f5455a3afb37fb5809abc507696e1 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 18 Mar 2011 14:54:23 +0000 Subject: [PATCH 2/2] Allow config files from different packages if both files have zero size. Fairly recurrent bug in Fedora. It need not cause us to fail, provided that both config files are empty. --- febootstrap.ml | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/febootstrap.ml b/febootstrap.ml index 3c634c4..dc44d3d 100644 --- a/febootstrap.ml +++ b/febootstrap.ml @@ -79,16 +79,24 @@ let () let combine (name1, ft1, pkg1) (name2, ft2, pkg2) (* Rules for combining files. *) if ft1.ft_config || ft2.ft_config then ( - eprintf "febootstrap: error: %s is a config file which is listed in two packages (%s, %s)\n" - name1 pkg1 pkg2; - exit 1 - ); - if (ft1.ft_dir || ft2.ft_dir) && (not (ft1.ft_dir && ft2.ft_dir)) then ( + (* It's a fairly frequent bug in Fedora for two packages to + * incorrectly list the same config file. Allow this, provided + * the size of both files is 0. + *) + if ft1.ft_size = 0 && ft2.ft_size = 0 then + (name1, ft1, pkg1) + else ( + eprintf "febootstrap: error: %s is a config file which is listed in two packages (%s, %s)\n" + name1 pkg1 pkg2; + exit 1 + ) + ) + else if (ft1.ft_dir || ft2.ft_dir) && (not (ft1.ft_dir && ft2.ft_dir)) then ( eprintf "febootstrap: error: %s appears as both directory and ordinary file (%s, %s)\n" name1 pkg1 pkg2; exit 1 - ); - if ft1.ft_ghost then + ) + else if ft1.ft_ghost then (name2, ft2, pkg2) else (name1, ft1, pkg1) -- 1.7.2.3
Apparently Analagous Threads
- [PATCH febootstrap 0/8] Add support for building an ext2-based appliance
- febootstrap and zypper
- [PATCH febootstrap] Pull in febootstrap-supermin-helper (C version) from libguestfs.
- febootstrap - Arch User Repository
- building a supermin appliance with febootstrap...