Hilko Bengen
2014-Mar-15 12:59 UTC
[Libguestfs] [supermin 1/2] chroot: Fix corner case introduced with dpkg-divert support
--- src/chroot.ml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/chroot.ml b/src/chroot.ml index b5c1e53..9e522d9 100644 --- a/src/chroot.ml +++ b/src/chroot.ml @@ -26,7 +26,9 @@ let build_chroot debug files outputdir List.iter ( fun file -> try - let path = file.ft_source_path in + let path = if file_exists file.ft_source_path + then file.ft_source_path + else file.ft_path in let st = lstat path in let opath = outputdir // file.ft_path in match st.st_kind with @@ -68,7 +70,10 @@ let build_chroot debug files outputdir (* Second pass: fix up directory permissions in reverse. *) let dirs = filter_map ( fun file -> - let st = lstat file.ft_source_path in + let path + if file_exists file.ft_source_path then file.ft_source_path + else file.ft_path in + let st = lstat path in if st.st_kind = S_DIR then Some (file.ft_path, st) else None ) files in List.iter ( -- 1.9.0
Hilko Bengen
2014-Mar-15 12:59 UTC
[Libguestfs] [supermin 2/2] tests: Add "--use-installed" variants
--- tests/Makefile.am | 11 +++++++---- tests/test-binaries-exist-network.sh | 2 ++ tests/test-binaries-exist.sh | 4 +++- tests/test-build-bash-network.sh | 3 +++ tests/test-build-bash.sh | 4 +++- tests/test-harder-network.sh | 3 +++ tests/test-harder.sh | 4 +++- 7 files changed, 24 insertions(+), 7 deletions(-) create mode 100755 tests/test-binaries-exist-network.sh create mode 100755 tests/test-build-bash-network.sh create mode 100755 tests/test-harder-network.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index 9603e89..03c97b3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -22,11 +22,14 @@ EXTRA_DIST = \ $(TESTS) TESTS = \ - test-basic.sh - -if NETWORK_TESTS -TESTS += \ + test-basic.sh \ test-build-bash.sh \ test-binaries-exist.sh \ test-harder.sh + +if NETWORK_TESTS +TESTS += \ + test-build-bash-network.sh \ + test-binaries-exist-network.sh \ + test-harder-network.sh endif diff --git a/tests/test-binaries-exist-network.sh b/tests/test-binaries-exist-network.sh new file mode 100755 index 0000000..19c3830 --- /dev/null +++ b/tests/test-binaries-exist-network.sh @@ -0,0 +1,2 @@ +#!/bin/sh +USE_NETWORK=1 ./test-binaries-exist.sh diff --git a/tests/test-binaries-exist.sh b/tests/test-binaries-exist.sh index e9d2192..797c808 100755 --- a/tests/test-binaries-exist.sh +++ b/tests/test-binaries-exist.sh @@ -22,8 +22,10 @@ d1=test-binaries-exist.d1 d2=test-binaries-exist.d2 rm -rf $d1 $d2 +test "$USE_NETWORK" = 1 || USE_INSTALLED=--use-installed + # We assume that 'bash' and 'coreutils' package names exist in every distro. -../src/supermin -v --prepare bash coreutils -o $d1 +../src/supermin -v --prepare $USE_INSTALLED bash coreutils -o $d1 # Build a chroot. ../src/supermin -v --build -f chroot $d1 -o $d2 diff --git a/tests/test-build-bash-network.sh b/tests/test-build-bash-network.sh new file mode 100755 index 0000000..a80da4d --- /dev/null +++ b/tests/test-build-bash-network.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +USE_NETWORK=1 ./test-build-bash.sh diff --git a/tests/test-build-bash.sh b/tests/test-build-bash.sh index 6507683..0089666 100755 --- a/tests/test-build-bash.sh +++ b/tests/test-build-bash.sh @@ -27,8 +27,10 @@ d1=test-build-bash.d1 d2=test-build-bash.d2 rm -rf $d1 $d2 +test "$USE_NETWORK" = 1 || USE_INSTALLED=--use-installed + # We assume 'bash' is a package everywhere. -../src/supermin -v --prepare bash -o $d1 +../src/supermin -v --prepare $USE_INSTALLED bash -o $d1 arch="$(uname -m)" diff --git a/tests/test-harder-network.sh b/tests/test-harder-network.sh new file mode 100755 index 0000000..56619fb --- /dev/null +++ b/tests/test-harder-network.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +USE_NETWORK=1 ./test-build-hardser.sh diff --git a/tests/test-harder.sh b/tests/test-harder.sh index 25dad90..5bd44b1 100755 --- a/tests/test-harder.sh +++ b/tests/test-harder.sh @@ -54,7 +54,9 @@ case $distro in ;; esac -../src/supermin -v --prepare $pkgs -o $d1 +test "$USE_NETWORK" = 1 || USE_INSTALLED=--use-installed + +../src/supermin -v --prepare $USE_INSTALLED $pkgs -o $d1 # Build a chroot. ../src/supermin -v --build -f chroot $d1 -o $d2 -- 1.9.0
Hilko Bengen
2014-Mar-15 13:10 UTC
Re: [Libguestfs] [supermin 2/2] tests: Add "--use-installed" variants
* Hilko Bengen:> diff --git a/tests/test-harder-network.sh b/tests/test-harder-network.sh > new file mode 100755 > index 0000000..56619fb > --- /dev/null > +++ b/tests/test-harder-network.sh > @@ -0,0 +1,3 @@ > +#!/bin/sh > + > +USE_NETWORK=1 ./test-build-hardser.shObviously, this should be "./test-harder.sh" Cheers -Hilko
Richard W.M. Jones
2014-Mar-15 14:38 UTC
Re: [Libguestfs] [supermin 1/2] chroot: Fix corner case introduced with dpkg-divert support
On Sat, Mar 15, 2014 at 01:59:02PM +0100, Hilko Bengen wrote:> --- > src/chroot.ml | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/src/chroot.ml b/src/chroot.ml > index b5c1e53..9e522d9 100644 > --- a/src/chroot.ml > +++ b/src/chroot.ml > @@ -26,7 +26,9 @@ let build_chroot debug files outputdir > List.iter ( > fun file -> > try > - let path = file.ft_source_path in > + let path = if file_exists file.ft_source_path > + then file.ft_source_path > + else file.ft_path in > let st = lstat path in > let opath = outputdir // file.ft_path in > match st.st_kind with > @@ -68,7 +70,10 @@ let build_chroot debug files outputdir > (* Second pass: fix up directory permissions in reverse. *) > let dirs = filter_map ( > fun file -> > - let st = lstat file.ft_source_path in > + let path > + if file_exists file.ft_source_path then file.ft_source_path > + else file.ft_path in > + let st = lstat path in > if st.st_kind = S_DIR then Some (file.ft_path, st) else None > ) files in > List.iter ( > -- > 1.9.0ACK to both patches (second one with the 'test-harder' fix!) Thanks, 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 KVM guests. http://libguestfs.org/virt-v2v
Richard W.M. Jones
2014-Mar-15 20:03 UTC
Re: [Libguestfs] [supermin 2/2] tests: Add "--use-installed" variants
On Sat, Mar 15, 2014 at 01:59:03PM +0100, Hilko Bengen wrote:> --- > tests/Makefile.am | 11 +++++++---- > tests/test-binaries-exist-network.sh | 2 ++ > tests/test-binaries-exist.sh | 4 +++- > tests/test-build-bash-network.sh | 3 +++ > tests/test-build-bash.sh | 4 +++- > tests/test-harder-network.sh | 3 +++ > tests/test-harder.sh | 4 +++- > 7 files changed, 24 insertions(+), 7 deletions(-) > create mode 100755 tests/test-binaries-exist-network.sh > create mode 100755 tests/test-build-bash-network.sh > create mode 100755 tests/test-harder-network.shIt turns out this doesn't work when using parallel 'make check' (try setting 'export MAKEFLAGS=-jN' for N > 1). I pushed the following patch to fix it: https://github.com/libguestfs/supermin/commit/22b0662ebf64e93dc275acc1cc37ebd12cce6b49 Rich. -- 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#)