Hilko Bengen
2014-Mar-13 19:39 UTC
Re: [Libguestfs] [supermin 3/3] Use the file tuple up to the point where files are copied into the filesystem / chroot
* Richard W.M. Jones:> This seems to change the result of this (very important and complex) > function.Since you didn't answer my followup message, I take it that I failed to convince you. I noticed that I can get away with leaving the structure of the function as-is, just changing the type... What do you think about this diff? Cheers, -Hilko diff --git a/src/build.ml b/src/build.ml index 9225184..0e2893d 100644 --- a/src/build.ml +++ b/src/build.ml @@ -345,21 +346,21 @@ and munge files let rec loop = function | [] -> [] - | "/" :: rest -> + | root :: rest when root.ft_path = "/" -> (* This is just to avoid a corner-case in subsequent rules. *) loop rest - | dir :: rest when stat_is_dir dir && dir_seen dir -> + | dir :: rest when stat_is_dir dir.ft_path && dir_seen dir.ft_path -> dir :: loop rest - | dir :: rest when is_lnk_to_dir dir -> - insert_dir dir; + | dir :: rest when is_lnk_to_dir dir.ft_path -> + insert_dir dir.ft_path; (* Symlink to a directory. Insert the target directory before * if we've not seen it yet. *) - let target = readlink dir in - let parent = Filename.dirname dir in + let target = readlink dir.ft_path in + let parent = Filename.dirname dir.ft_path in (* Make the target an absolute path. *) let target if String.length target < 1 || target.[0] <> '/' then @@ -367,24 +368,27 @@ and munge files else target in if not (dir_seen target) then + let target = {ft_path = target; ft_source_path = target; ft_config = false} in loop (target :: dir :: rest) else dir :: loop rest - | dir :: rest when stat_is_dir dir -> - insert_dir dir; + | dir :: rest when stat_is_dir dir.ft_path -> + insert_dir dir.ft_path; (* Have we seen the parent? *) - let parent = Filename.dirname dir in + let parent = Filename.dirname dir.ft_path in if not (dir_seen parent) then + let parent = {ft_path = parent; ft_source_path = parent; ft_config = false} in loop (parent :: dir :: rest) else dir :: loop rest | file :: rest -> (* Have we seen this parent directory before? *) - let dir = Filename.dirname file in + let dir = Filename.dirname file.ft_path in if not (dir_seen dir) then + let dir = {ft_path = dir; ft_source_path = dir; ft_config = false} in loop (dir :: file :: rest) else file :: loop rest
Richard W.M. Jones
2014-Mar-13 21:36 UTC
Re: [Libguestfs] [supermin 3/3] Use the file tuple up to the point where files are copied into the filesystem / chroot
On Thu, Mar 13, 2014 at 08:39:50PM +0100, Hilko Bengen wrote:> * Richard W.M. Jones: > > > This seems to change the result of this (very important and complex) > > function. > > Since you didn't answer my followup message, I take it that I failed to > convince you. I noticed that I can get away with leaving the structure > of the function as-is, just changing the type... What do you think about > this diff?This is certainly much simpler and (I think) obviously correct. However I'd like to see the complete patch series again so I can look at the whole thing and test it. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
--- configure.ac | 1 + src/config.ml.in | 1 + src/dpkg.ml | 1 + 3 files changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 2141540..99ea913 100644 --- a/configure.ac +++ b/configure.ac @@ -92,6 +92,7 @@ AC_PATH_PROG(APT_GET,[apt-get],[no]) AC_PATH_PROG(DPKG,[dpkg],[no]) AC_PATH_PROG(DPKG_DEB,[dpkg-deb],[no]) AC_PATH_PROG(DPKG_QUERY,[dpkg-query],[no]) +AC_PATH_PROG(DPKG_DIVERT,[[dpkg-divert]],[no]) dnl For FrugalWare handler (currently disabled). AC_PATH_PROG(PACMAN_G2,[pacman-g2],[no]) diff --git a/src/config.ml.in b/src/config.ml.in index 5326bb0..acf2912 100644 --- a/src/config.ml.in +++ b/src/config.ml.in @@ -26,6 +26,7 @@ let cpio = "@CPIO@" let dpkg = "@DPKG@" let dpkg_deb = "@DPKG_DEB@" let dpkg_query = "@DPKG_QUERY@" +let dpkg_divert = "@DPKG_DIVERT@" let fakeroot = "@FAKEROOT@" let makepkg = "@MAKEPKG@" let pacman = "@PACMAN@" diff --git a/src/dpkg.ml b/src/dpkg.ml index 71aa12c..c28354a 100644 --- a/src/dpkg.ml +++ b/src/dpkg.ml @@ -26,6 +26,7 @@ let dpkg_detect () Config.dpkg <> "no" && Config.dpkg_deb <> "no" && Config.dpkg_query <> "no" && + Config.dpkg_divert <> "no" && Config.apt_get <> "no" && file_exists "/etc/debian_version" -- 1.9.0