From a1e8cdf2a254c5eddaf525cd7c34e4c937690204 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 28 May 2009 13:00:31 +0100 Subject: Move the appliance and build scripts into new appliance/ subdirectory. --- .gitignore | 10 +-- HACKING | 3 + Makefile.am | 60 +-------------- appliance/Makefile.am | 82 ++++++++++++++++++++ appliance/make-initramfs.sh.in | 162 +++++++++++++++++++++++++++++++++++++++ appliance/update-initramfs.sh.in | 36 +++++++++ configure.ac | 5 +- examples/README | 2 +- fish/fish.c | 9 ++- haskell/Makefile.am | 4 +- inspector/run-inspector-locally | 2 +- java/Makefile.am | 2 +- make-initramfs.sh.in | 160 -------------------------------------- ocaml/Makefile.am | 2 +- perl/examples/README | 2 +- perl/run-perl-tests | 2 +- python/Makefile.am | 4 +- recipes/README | 2 +- ruby/run-ruby-tests | 2 +- src/generator.ml | 2 +- tests.c | 2 +- update-initramfs.sh.in | 34 -------- 22 files changed, 311 insertions(+), 278 deletions(-) create mode 100644 appliance/Makefile.am create mode 100755 appliance/make-initramfs.sh.in create mode 100755 appliance/update-initramfs.sh.in delete mode 100755 make-initramfs.sh.in delete mode 100755 update-initramfs.sh.in diff --git a/.gitignore b/.gitignore index 5032bf3e..a002cab5 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,11 @@ ChangeLog Makefile.in Makefile aclocal.m4 +appliance/initramfs.*.img +appliance/make-initramfs.sh +appliance/make-initramfs.sh.in.old +appliance/update-initramfs.sh +appliance/vmlinuz.* autom4te.cache compile config.h @@ -47,7 +52,6 @@ html/recipes.html html/virt-inspector.1.html initramfs initramfs.timestamp -initramfs.*.img inspector/virt-inspector.1 install-sh java/api @@ -59,8 +63,6 @@ libguestfs.spec libguestfs-*.tar.gz libtool ltmain.sh -make-initramfs.sh -make-initramfs.sh.in.old m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 @@ -93,5 +95,3 @@ test-command test*.img test*.tmp tests -update-initramfs.sh -vmlinuz.* diff --git a/HACKING b/HACKING index 4e6ac4ce..4f88e884 100644 --- a/HACKING +++ b/HACKING @@ -31,6 +31,9 @@ Please test any changes. Directories ---------------------------------------------------------------------- +appliance/ + The qemu appliance, build scripts and so on. + contrib/ Outside contributions, experimental parts. diff --git a/Makefile.am b/Makefile.am index c8cf76c6..17adf1ca 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,7 +17,7 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = src daemon fish po examples images +SUBDIRS = src daemon appliance fish po examples images if HAVE_OCAML SUBDIRS += ocaml @@ -43,7 +43,6 @@ endif EXTRA_DIST = \ config.rpath \ - make-initramfs.sh update-initramfs.sh \ guestfs.pod guestfs-actions.pod guestfs-structs.pod \ guestfish.pod guestfish-actions.pod \ html/pod.css \ @@ -65,33 +64,6 @@ EXTRA_DIST = \ contrib/febootstrap/install.sh \ test-bootbootboot.sh -# Build the root filesystem. -# Currently this is arch-dependent, so it seems like putting it in -# $(libdir) is best. When we build cross-architecture filesystems we -# should probably move them to $(datadir). - -fsdir = $(libdir)/guestfs - -INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img -VMLINUZ = vmlinuz.$(REPO).$(host_cpu) - -fs_DATA = $(INITRAMFSIMG) $(VMLINUZ) - -$(INITRAMFSIMG) $(VMLINUZ): initramfs/fakeroot.log - -initramfs/fakeroot.log: make-initramfs.sh.in - -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak - -mv $(VMLINUZ) $(VMLINUZ).bak - if ! bash $(top_builddir)/make-initramfs.sh; then rm -f $@; exit 1; fi - -$(INITRAMFSIMG): initramfs/fakeroot.log daemon/guestfsd - rm -f $@ - bash $(top_builddir)/update-initramfs.sh - touch $@ - -make-initramfs.sh: make-initramfs.sh.in - ./config.status $@ - # Tests. These are auto-generated from the test descriptions # in the generator. @@ -109,8 +81,6 @@ TESTS_ENVIRONMENT = \ SKIP_TEST_ZEROFREE=$(shell test -x initramfs/usr/sbin/zerofree || echo 1) \ $(VG) -$(TESTS): $(INITRAMFS) $(VMLINUZ) - # Run the tests under valgrind. valgrind: @@ -204,34 +174,6 @@ dist-hook: pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libguestfs.pc -# Test-boot the image. - -test-boot: emptydisk - qemu-system-$(host_cpu) \ - -m 384 \ - -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \ - -hda emptydisk - -emptydisk: - rm -f emptydisk - dd if=/dev/zero of=emptydisk bs=1024 count=1440 - echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null - -# This is a more realistic test boot command line which better -# reflects what the library does. - -test-boot-realistic: emptydisk - qemu-system-$(host_cpu) \ - -m 384 \ - -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \ - -hda emptydisk \ - -append "console=ttyS0 guestfs=10.0.2.4:6666" \ - -nographic \ - -serial stdio \ - -net channel,6666:unix:/tmp/sock,server,nowait \ - -net user,vlan=0 \ - -net nic,model=virtio,vlan=0 - # Make clean. CLEANFILES = $(fs_DATA) emptydisk pod2htm?.tmp diff --git a/appliance/Makefile.am b/appliance/Makefile.am new file mode 100644 index 00000000..0002663c --- /dev/null +++ b/appliance/Makefile.am @@ -0,0 +1,82 @@ +# libguestfs +# Copyright (C) 2009 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +EXTRA_DIST = \ + make-initramfs.sh update-initramfs.sh + +# Build the root filesystem (appliance). +# Currently this is arch-dependent, so it seems like putting it in +# $(libdir) is best. When we build cross-architecture filesystems we +# should probably move them to $(datadir). + +fsdir = $(libdir)/guestfs + +INITRAMFSIMG = initramfs.$(REPO).$(host_cpu).img +VMLINUZ = vmlinuz.$(REPO).$(host_cpu) + +fs_DATA = $(INITRAMFSIMG) $(VMLINUZ) + +$(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log + +$(top_builddir)/initramfs/fakeroot.log: make-initramfs.sh.in + -mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak + -mv $(VMLINUZ) $(VMLINUZ).bak + if ! bash make-initramfs.sh; then rm -f $@; exit 1; fi + +$(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd + rm -f $@ + bash update-initramfs.sh + touch $@ + +make-initramfs.sh: make-initramfs.sh.in + ./config.status $@ + +# Test-boot the image. + +test-boot: emptydisk + qemu-system-$(host_cpu) \ + -m 384 \ + -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \ + -hda emptydisk + +emptydisk: + rm -f emptydisk + dd if=/dev/zero of=emptydisk bs=1024 count=1440 + echo 0, | sfdisk -q -C 80 -H 2 -S 18 emptydisk > /dev/null + +# This is a more realistic test boot command line which better +# reflects what the library does. + +test-boot-realistic: emptydisk + qemu-system-$(host_cpu) \ + -m 384 \ + -kernel $(VMLINUZ) -initrd $(INITRAMFSIMG) \ + -hda emptydisk \ + -append "console=ttyS0 guestfs=10.0.2.4:6666" \ + -nographic \ + -serial stdio \ + -net channel,6666:unix:/tmp/sock,server,nowait \ + -net user,vlan=0 \ + -net nic,model=virtio,vlan=0 + +# Make clean. + +CLEANFILES = $(fs_DATA) + +clean-local: + rm -rf $(top_builddir)/initramfs + diff --git a/appliance/make-initramfs.sh.in b/appliance/make-initramfs.sh.in new file mode 100755 index 00000000..248f2e2d --- /dev/null +++ b/appliance/make-initramfs.sh.in @@ -0,0 +1,162 @@ +#!/bin/bash - +# @configure_input@ +# Copyright (C) 2009 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# This is called from the Makefile to build the initramfs. + +unset CDPATH + +set -e + +cd @top_builddir@ + +modules=" +-i augeas-libs +-i bash +-i binutils +-i coreutils +-i dosfstools +-i file +-i grub +-i iputils +-i kernel +-i lvm2 +-i MAKEDEV +-i module-init-tools +-i net-tools +-i ntfs-3g +-i ntfsprogs +-i procps +-i strace +-i util-linux-ng +-i zerofree +" + +# Decide on names for the final output. These have to match Makefile.am. +output=appliance/initramfs.@REPO@.@host_cpu@.img +koutput=appliance/vmlinuz.@REPO@.@host_cpu@ +rm -f $output +rm -f $koutput + +# Create the basic initramfs. +@FEBOOTSTRAP@ $modules -u @UPDATES@ @REPO@ initramfs @MIRROR@ + +# /sysroot is where the guest root filesystem will be mounted. +@FEBOOTSTRAP_RUN@ initramfs -- mkdir -p --mode=0777 /sysroot + +# Create /tmp if it is missing. +@FEBOOTSTRAP_RUN@ initramfs -- mkdir -p --mode=0777 /tmp + +# Nuke some stuff. The kernel pulls mkinitrd and plymouth which pulls in +# all of Python. Sheez. +(cd initramfs && find -name '*plymouth*' -print0) | + xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf +(cd initramfs && find -name '*python*' -print0) | + xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf + +# In Fedora >= 11, it pulls in all of Perl from somewhere. Nuke from orbit. +@FEBOOTSTRAP_RUN@ initramfs -- rm -rf /usr/lib/perl5 /usr/lib64/perl5 + +# Anaconda? JPEG images? +@FEBOOTSTRAP_RUN@ initramfs -- rm -rf /usr/lib/anaconda-runtime + +# Modules take up nearly half of the image. It's a rough guess that +# we don't need many drivers (which take up most of the space). +(cd initramfs && find lib/modules/*/kernel \ + -name '*.ko' \ + -a ! -name 'virtio.ko' \ + -a ! -name 'virtio_net.ko' \ + -a ! -name 'virtio_pci.ko' \ + -a ! -name 'virtio_ring.ko' \ + -a ! -name 'ext2.ko' \ + -a ! -name 'ext3.ko' \ + -a ! -name 'ext4*.ko' \ + -a ! -name 'crc16.ko' \ + -a ! -name 'jbd.ko' \ + -a ! -name 'jbd2.ko' \ + -a ! -name 'fuse.ko' \ + -a ! -name 'vfat.ko' \ + -a ! -name 'fat.ko' \ + -a ! -name 'udf.ko' \ + -a ! -name 'crc_itu_t.ko' \ + -a ! -name 'nls_utf8.ko' \ + -a ! -name 'dm-*.ko' \ + -a -print0 ) | + xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm + +# Pull the kernel out into the current directory. We don't want it in +# the initramfs image. +cp initramfs/boot/vmlinuz* $koutput +@FEBOOTSTRAP_RUN@ initramfs -- rm -rf boot + +# Minimize the image. +@FEBOOTSTRAP_MINIMIZE@ initramfs + +# Add some missing configuration files. +if [ ! -f initramfs/etc/hosts ]; then + cat > hosts.new <<'__EOF__' +127.0.0.1 guestfs localhost.localdomain localhost +::1 localhost6.localdomain6 localhost6 +__EOF__ + @FEBOOTSTRAP_INSTALL@ initramfs hosts.new /etc/hosts 0644 root.root + rm hosts.new +fi + +if [ ! -f initramfs/etc/fstab ]; then + @FEBOOTSTRAP_RUN@ initramfs -- touch /etc/fstab +fi + +echo nameserver 10.0.2.3 > resolv.conf.new +@FEBOOTSTRAP_INSTALL@ initramfs resolv.conf.new /etc/resolv.conf 0644 root.root +rm resolv.conf.new + +# Create the init script. +cat > init.new <<'__EOF__' +#!/bin/sh +echo Starting /init script ... +PATH=/sbin:/usr/sbin:$PATH +MAKEDEV mem null port zero core full ram tty console fd \ + hda hdb hdc hdd sda sdb sdc sdd loop sd +mount -t proc /proc /proc +mount -t sysfs /sys /sys +mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts +modprobe virtio_pci +modprobe virtio_net +modprobe dm_mod ||: +/sbin/ifconfig lo 127.0.0.1 +/sbin/ifconfig eth0 10.0.2.10 +/sbin/route add default gw 10.0.2.2 +lvm vgscan --ignorelockingfailure +lvm vgchange -ay --ignorelockingfailure +exec guestfsd -f +__EOF__ + +@FEBOOTSTRAP_INSTALL@ initramfs init.new /init 0755 root.root +rm init.new + +# Just in case the kernel isn't looking for /init, make /sbin/init +# be our script, not the real init. +#@FEBOOTSTRAP_RUN@ initramfs -- ln -f /init /sbin/init + +# Copy the daemon into the filesystem. +@FEBOOTSTRAP_INSTALL@ initramfs daemon/guestfsd /sbin/guestfsd 0755 root.root + +# Generate final image. +@FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t +mv $output-t $output +ls -lh $output +ls -lh $koutput diff --git a/appliance/update-initramfs.sh.in b/appliance/update-initramfs.sh.in new file mode 100755 index 00000000..3b779f85 --- /dev/null +++ b/appliance/update-initramfs.sh.in @@ -0,0 +1,36 @@ +#!/bin/bash - +# @configure_input@ +# Copyright (C) 2009 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Update the daemon inside an existing initramfs. Avoids the +# timeconsuming rebuild. + +unset CDPATH + +set -e + +cd @top_builddir@ + +output=appliance/initramfs.@REPO@.@host_cpu@.img + +# Copy the daemon into the filesystem. +@FEBOOTSTRAP_INSTALL@ initramfs daemon/guestfsd /sbin/guestfsd 0755 root.root + +# Generate final image. +@FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t +mv $output-t $output +ls -lh $output diff --git a/configure.ac b/configure.ac index bca88d7d..d40464d7 100644 --- a/configure.ac +++ b/configure.ac @@ -446,6 +446,8 @@ dnl Produce output files. AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile src/Makefile fish/Makefile po/Makefile.in examples/Makefile + appliance/Makefile + appliance/make-initramfs.sh appliance/update-initramfs.sh images/Makefile ocaml/Makefile ocaml/examples/Makefile perl/Makefile @@ -454,13 +456,12 @@ AC_CONFIG_FILES([Makefile java/Makefile haskell/Makefile inspector/Makefile - make-initramfs.sh update-initramfs.sh libguestfs.pc ocaml/META perl/Makefile.PL]) AC_OUTPUT dnl WTF? -chmod +x make-initramfs.sh update-initramfs.sh +chmod +x appliance/make-initramfs.sh appliance/update-initramfs.sh dnl Produce summary. echo diff --git a/examples/README b/examples/README index 77bf6a41..408d6a23 100644 --- a/examples/README +++ b/examples/README @@ -10,6 +10,6 @@ Tips: LIBGUESTFS_DEBUG=1 (2) If you haven't installed libguestfs, run the examples like this: -LIBGUESTFS_PATH=. examples/to-xml +LIBGUESTFS_PATH=appliance examples/to-xml (the path should point to the directory containing vmlinuz.* and initramfs.* files). diff --git a/fish/fish.c b/fish/fish.c index 79f77fe9..18d3880d 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -137,9 +137,10 @@ main (int argc, char *argv[]) guestfs_set_autosync (g, 1); - /* If developing, add . to the path. Note that libtools interferes - * with this because uninstalled guestfish is a shell script that runs - * the real program with an absolute path. Detect that too. + /* If developing, add ./appliance to the path. Note that libtools + * interferes with this because uninstalled guestfish is a shell + * script that runs the real program with an absolute path. Detect + * that too. * * BUT if LIBGUESTFS_PATH environment variable is already set by * the user, then don't override it. @@ -147,7 +148,7 @@ main (int argc, char *argv[]) if (getenv ("LIBGUESTFS_PATH") == NULL && argv[0] && (argv[0][0] != '/' || strstr (argv[0], "/.libs/lt-") != NULL)) - guestfs_set_path (g, ".:" GUESTFS_DEFAULT_PATH); + guestfs_set_path (g, "appliance:" GUESTFS_DEFAULT_PATH); for (;;) { c = getopt_long (argc, argv, options, long_options, NULL); diff --git a/haskell/Makefile.am b/haskell/Makefile.am index 06efdfdc..1086ee97 100644 --- a/haskell/Makefile.am +++ b/haskell/Makefile.am @@ -22,8 +22,8 @@ CLEANFILES = *~ if HAVE_HASKELL TESTS_ENVIRONMENT = \ - LD_LIBRARY_PATH=$(abs_top_builddir)/src/.libs \ - LIBGUESTFS_PATH=$(abs_top_builddir) \ + LD_LIBRARY_PATH=$(top_builddir)/src/.libs \ + LIBGUESTFS_PATH=$(top_builddir)/appliance \ $(VG) TESTS = Guestfs005Load Guestfs010Launch Guestfs050LVCreate diff --git a/inspector/run-inspector-locally b/inspector/run-inspector-locally index 9aebfd7f..3f2d6004 100755 --- a/inspector/run-inspector-locally +++ b/inspector/run-inspector-locally @@ -24,6 +24,6 @@ # ./inspector/run-inspector-locally [usual virt-inspector args ...] export LD_LIBRARY_PATH=$(pwd)/src/.libs -export LIBGUESTFS_PATH=$(pwd) +export LIBGUESTFS_PATH=$(pwd)/appliance export PERL5LIB=$(pwd)/perl/blib/lib:$(pwd)/perl/blib/arch perl ./inspector/virt-inspector.pl "$@" diff --git a/java/Makefile.am b/java/Makefile.am index b49c3034..cc9891b6 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -90,7 +90,7 @@ TESTS = $(java_tests:.java=.class) TESTS_ENVIRONMENT = \ JAVA=$(JAVA) \ CLASSPATH=t:libguestfs-$(VERSION).jar \ - LIBGUESTFS_PATH=$(abs_top_builddir) \ + LIBGUESTFS_PATH=$(top_builddir)/appliance \ ./run-java-test t/%.class: t/%.java diff --git a/make-initramfs.sh.in b/make-initramfs.sh.in deleted file mode 100755 index aa61811c..00000000 --- a/make-initramfs.sh.in +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/bash - -# @configure_input@ -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# This is called from the Makefile to build the initramfs. - -set -e - -unset CDPATH - -modules=" --i augeas-libs --i bash --i binutils --i coreutils --i dosfstools --i file --i grub --i iputils --i kernel --i lvm2 --i MAKEDEV --i module-init-tools --i net-tools --i ntfs-3g --i ntfsprogs --i procps --i strace --i util-linux-ng --i zerofree -" - -# Decide on names for the final output. These have to match Makefile.am. -output=initramfs.@REPO@.@host_cpu@.img -koutput=vmlinuz.@REPO@.@host_cpu@ -rm -f $output -rm -f $koutput - -# Create the basic initramfs. -@FEBOOTSTRAP@ $modules -u @UPDATES@ @REPO@ initramfs @MIRROR@ - -# /sysroot is where the guest root filesystem will be mounted. -@FEBOOTSTRAP_RUN@ initramfs -- mkdir -p --mode=0777 /sysroot - -# Create /tmp if it is missing. -@FEBOOTSTRAP_RUN@ initramfs -- mkdir -p --mode=0777 /tmp - -# Nuke some stuff. The kernel pulls mkinitrd and plymouth which pulls in -# all of Python. Sheez. -(cd initramfs && find -name '*plymouth*' -print0) | - xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf -(cd initramfs && find -name '*python*' -print0) | - xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf - -# In Fedora >= 11, it pulls in all of Perl from somewhere. Nuke from orbit. -@FEBOOTSTRAP_RUN@ initramfs -- rm -rf /usr/lib/perl5 /usr/lib64/perl5 - -# Anaconda? JPEG images? -@FEBOOTSTRAP_RUN@ initramfs -- rm -rf /usr/lib/anaconda-runtime - -# Modules take up nearly half of the image. It's a rough guess that -# we don't need many drivers (which take up most of the space). -(cd initramfs && find lib/modules/*/kernel \ - -name '*.ko' \ - -a ! -name 'virtio.ko' \ - -a ! -name 'virtio_net.ko' \ - -a ! -name 'virtio_pci.ko' \ - -a ! -name 'virtio_ring.ko' \ - -a ! -name 'ext2.ko' \ - -a ! -name 'ext3.ko' \ - -a ! -name 'ext4*.ko' \ - -a ! -name 'crc16.ko' \ - -a ! -name 'jbd.ko' \ - -a ! -name 'jbd2.ko' \ - -a ! -name 'fuse.ko' \ - -a ! -name 'vfat.ko' \ - -a ! -name 'fat.ko' \ - -a ! -name 'udf.ko' \ - -a ! -name 'crc_itu_t.ko' \ - -a ! -name 'nls_utf8.ko' \ - -a ! -name 'dm-*.ko' \ - -a -print0 ) | - xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm - -# Pull the kernel out into the current directory. We don't want it in -# the initramfs image. -cp initramfs/boot/vmlinuz* $koutput -@FEBOOTSTRAP_RUN@ initramfs -- rm -rf boot - -# Minimize the image. -@FEBOOTSTRAP_MINIMIZE@ initramfs - -# Add some missing configuration files. -if [ ! -f initramfs/etc/hosts ]; then - cat > hosts.new <<'__EOF__' -127.0.0.1 guestfs localhost.localdomain localhost -::1 localhost6.localdomain6 localhost6 -__EOF__ - @FEBOOTSTRAP_INSTALL@ initramfs hosts.new /etc/hosts 0644 root.root - rm hosts.new -fi - -if [ ! -f initramfs/etc/fstab ]; then - @FEBOOTSTRAP_RUN@ initramfs -- touch /etc/fstab -fi - -echo nameserver 10.0.2.3 > resolv.conf.new -@FEBOOTSTRAP_INSTALL@ initramfs resolv.conf.new /etc/resolv.conf 0644 root.root -rm resolv.conf.new - -# Create the init script. -cat > init.new <<'__EOF__' -#!/bin/sh -echo Starting /init script ... -PATH=/sbin:/usr/sbin:$PATH -MAKEDEV mem null port zero core full ram tty console fd \ - hda hdb hdc hdd sda sdb sdc sdd loop sd -mount -t proc /proc /proc -mount -t sysfs /sys /sys -mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts -modprobe virtio_pci -modprobe virtio_net -modprobe dm_mod ||: -/sbin/ifconfig lo 127.0.0.1 -/sbin/ifconfig eth0 10.0.2.10 -/sbin/route add default gw 10.0.2.2 -lvm vgscan --ignorelockingfailure -lvm vgchange -ay --ignorelockingfailure -exec guestfsd -f -__EOF__ - -@FEBOOTSTRAP_INSTALL@ initramfs init.new /init 0755 root.root -rm init.new - -# Just in case the kernel isn't looking for /init, make /sbin/init -# be our script, not the real init. -#@FEBOOTSTRAP_RUN@ initramfs -- ln -f /init /sbin/init - -# Copy the daemon into the filesystem. -@FEBOOTSTRAP_INSTALL@ initramfs @abs_builddir@/daemon/guestfsd /sbin/guestfsd 0755 root.root - -# Generate final image. -@FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t -mv $output-t $output -ls -lh $output -ls -lh $koutput diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 760caf62..b43049aa 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -44,7 +44,7 @@ guestfs_c_actions.o: guestfs_c_actions.c TESTS_ENVIRONMENT = \ LD_LIBRARY_PATH=$(top_builddir)/src/.libs \ - LIBGUESTFS_PATH=$(top_builddir) \ + LIBGUESTFS_PATH=$(top_builddir)/appliance \ $(VG) TESTS = t/guestfs_005_load t/guestfs_010_launch t/guestfs_050_lvcreate diff --git a/perl/examples/README b/perl/examples/README index a7c654f7..e5385583 100644 --- a/perl/examples/README +++ b/perl/examples/README @@ -12,6 +12,6 @@ Tips: LIBGUESTFS_PATH as in this example (if run from the root directory of the source distribution): - LIBGUESTFS_PATH=$(pwd) \ + LIBGUESTFS_PATH=$(pwd)/appliance \ PERL5LIB=$(pwd)/perl/blib/lib:$(pwd)/perl/blib/arch/auto/Sys/Guestfs \ perl/examples/foo diff --git a/perl/run-perl-tests b/perl/run-perl-tests index 228fb17c..e3f315e9 100755 --- a/perl/run-perl-tests +++ b/perl/run-perl-tests @@ -17,5 +17,5 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. export LD_LIBRARY_PATH=../src/.libs -export LIBGUESTFS_PATH=$(cd .. > /dev/null && pwd) +export LIBGUESTFS_PATH=../appliance make -f Makefile-pl test "$@" diff --git a/python/Makefile.am b/python/Makefile.am index bab869e7..4c72bbd4 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -33,8 +33,8 @@ libguestfsmod_la_CFLAGS = -Wall -I$(PYTHON_INCLUDEDIR) -I$(top_builddir)/src libguestfsmod_la_LIBADD = $(top_builddir)/src/libguestfs.la TESTS_ENVIRONMENT = \ - LIBGUESTFS_PATH=$(abs_top_builddir) \ - PYTHONPATH=$(abs_top_builddir)/python:$(abs_top_builddir)/python/.libs \ + LIBGUESTFS_PATH=$(top_builddir)/appliance \ + PYTHONPATH=$(top_builddir)/python:$(top_builddir)/python/.libs \ $(PYTHON) TESTS = t/005-import.py t/010-launch.py t/050-lvcreate.py diff --git a/recipes/README b/recipes/README index 6a1f7288..6f7e2558 100644 --- a/recipes/README +++ b/recipes/README @@ -17,7 +17,7 @@ without restrictions. To run a script before libguestfs has been installed, you can do something like this: - LIBGUESTFS_PATH=.. PATH=../fish:$PATH ./show-devices.sh disk.img + LIBGUESTFS_PATH=../appliance PATH=../fish:$PATH ./show-devices.sh disk.img You can apply these recipes in your own programs by translating the guestfish commands into API calls in the language of your choice. The diff --git a/ruby/run-ruby-tests b/ruby/run-ruby-tests index 3bf55776..8232b29a 100755 --- a/ruby/run-ruby-tests +++ b/ruby/run-ruby-tests @@ -17,6 +17,6 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. export LD_LIBRARY_PATH=../src/.libs -export LIBGUESTFS_PATH=$(cd .. > /dev/null && pwd) +export LIBGUESTFS_PATH=../appliance rake test "$@" diff --git a/src/generator.ml b/src/generator.ml index 4e18f985..03439aa0 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -3720,7 +3720,7 @@ int main (int argc, char *argv[]) srcdir = getenv (\"srcdir\"); if (!srcdir) srcdir = \".\"; chdir (srcdir); - guestfs_set_path (g, \".\"); + guestfs_set_path (g, \"appliance\"); filename = \"test1.img\"; fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666); diff --git a/tests.c b/tests.c index 4baf4867..11bd2a52 100644 --- a/tests.c +++ b/tests.c @@ -15702,7 +15702,7 @@ int main (int argc, char *argv[]) srcdir = getenv ("srcdir"); if (!srcdir) srcdir = "."; chdir (srcdir); - guestfs_set_path (g, "."); + guestfs_set_path (g, "appliance"); filename = "test1.img"; fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666); diff --git a/update-initramfs.sh.in b/update-initramfs.sh.in deleted file mode 100755 index 080cfdd2..00000000 --- a/update-initramfs.sh.in +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# @configure_input@ -# Copyright (C) 2009 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -# Update the daemon inside an existing initramfs. Avoids the -# timeconsuming rebuild. - -unset CDPATH - -set -e - -output=initramfs.@REPO@.@host_cpu@.img - -# Copy the daemon into the filesystem. -@FEBOOTSTRAP_INSTALL@ initramfs @abs_builddir@/daemon/guestfsd /sbin/guestfsd 0755 root.root - -# Generate final image. -@FEBOOTSTRAP_TO_INITRAMFS@ initramfs > $output-t -mv $output-t $output -ls -lh $output -- cgit