diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2010-12-04 21:14:17 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2010-12-05 11:23:23 +0000 |
commit | 6d75ce8e6ca1f3f0a946ee4e214f6d2bff07adc4 (patch) | |
tree | eabf83eb465fa7f7ff7347ee26547a18675b476d /appliance | |
parent | 078fbee4e73036783aefef9401735f8b80e81bb2 (diff) | |
download | libguestfs-6d75ce8e6ca1f3f0a946ee4e214f6d2bff07adc4.tar.gz libguestfs-6d75ce8e6ca1f3f0a946ee4e214f6d2bff07adc4.tar.xz libguestfs-6d75ce8e6ca1f3f0a946ee4e214f6d2bff07adc4.zip |
appliance: Change to using febootstrap 3.x supermin appliance.
This removes all support for building the ordinary / old
style appliance using febootstrap 2.x, debootstrap, debirf,
fakeroot and fakechroot.
Instead this uses febootstrap 3.x to build the supermin appliance
in a simpler cross-distro manner.
Diffstat (limited to 'appliance')
-rw-r--r-- | appliance/Makefile.am | 88 | ||||
-rw-r--r-- | appliance/debian/debirf.conf.in | 5 | ||||
l--------- | appliance/debian/modules/a0_prep-root | 1 | ||||
l--------- | appliance/debian/modules/install-kernel | 1 | ||||
-rwxr-xr-x | appliance/debian/modules/y0_install-guestfsd | 40 | ||||
l--------- | appliance/debian/modules/z0_remove-aptitude | 1 | ||||
l--------- | appliance/debian/modules/z0_remove-locales | 1 | ||||
l--------- | appliance/debian/modules/z1_clean-root | 1 | ||||
-rwxr-xr-x | appliance/debian/modules/z99_final-cleanups | 3 | ||||
-rw-r--r-- | appliance/kmod.whitelist.in | 86 | ||||
-rwxr-xr-x | appliance/make.sh.in | 193 | ||||
-rwxr-xr-x | appliance/update.sh.in | 49 |
12 files changed, 49 insertions, 420 deletions
diff --git a/appliance/Makefile.am b/appliance/Makefile.am index dec1c156..cd4952a1 100644 --- a/appliance/Makefile.am +++ b/appliance/Makefile.am @@ -18,46 +18,19 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ - kmod.whitelist.in \ packagelist.in \ init \ - debian/modules/y0_install-guestfsd \ - debian/modules/z99_final-cleanups \ - debian/debirf.conf.in \ make.sh.in -# 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 superminfsdir = $(libdir)/guestfs/supermin.d -# These are the resulting output files from the whole process: -# VMLINUZ kernel for the full appliance -# INITRAMFSIMG initramfs (ie. root fs) for the full appliance -# For details of the supermin appliance, read the README file. -fs_DATA = $(INITRAMFSIMG) $(VMLINUZ) -if SUPERMIN -fs_DATA += kmod.whitelist +fs_DATA = superminfs_DATA = \ supermin.d/base.img \ supermin.d/daemon.img \ supermin.d/init.img \ supermin.d/hostfiles -endif - -# Don't change these names - they must be the same as in '*.sh' scripts. -INITRAMFSIMG = initramfs.$(host_cpu).img -VMLINUZ = vmlinuz.$(host_cpu) - -# This is for building the normal appliance: -$(INITRAMFSIMG) $(VMLINUZ): $(top_builddir)/initramfs/fakeroot.log - -$(top_builddir)/initramfs/fakeroot.log: make.sh kmod.whitelist packagelist - mv $(INITRAMFSIMG) $(INITRAMFSIMG).bak 2>/dev/null; : - mv $(VMLINUZ) $(VMLINUZ).bak 2>/dev/null; : - if ! bash make.sh; then rm -f $@; exit 1; fi # This used to be a configure-generated file (as is update.sh still). # However config.status always touches the destination file, which @@ -68,70 +41,35 @@ make.sh: make.sh.in chmod +x $@-t mv $@-t $@ -$(INITRAMFSIMG): $(top_builddir)/initramfs/fakeroot.log $(top_builddir)/daemon/guestfsd init update.sh - rm -f $@ - bash update.sh - touch $@ - -kmod.whitelist: kmod.whitelist.in - grep -v '^[[:space:]]*$$' < $< | grep -v '^#' > $@ - packagelist: packagelist.in - cpp -undef -D$(DIST)=1 < $< | \ + cpp -undef -D$(DISTRO)=1 < $< | \ grep -v '^[[:space:]]*$$' | grep -v '^#' > $@ -# This is for building the supermin appliance. It has to be enabled -# specifically with './configure --enable-supermin'. You really need -# to read the README file. - -if SUPERMIN - supermin.d/base.img supermin.d/hostfiles: stamp-supermin -stamp-supermin: $(INITRAMFSIMG) +stamp-supermin: make.sh packagelist mkdir -p supermin.d rm -f $@ supermin.d/base.img supermin.d/hostfiles - febootstrap-to-supermin $(top_builddir)/initramfs supermin.d/base.img supermin.d/hostfiles - if grep -q /usr/share/augeas/lenses supermin.d/hostfiles; then \ - echo "./usr/share/augeas/lenses/*.aug" >> supermin.d/hostfiles; \ - fi + ./make.sh touch $@ -supermin.d/daemon.img: $(INITRAMFSIMG) +supermin.d/daemon.img: ../daemon/guestfsd mkdir -p supermin.d rm -f $@ $@-t - (cd $(top_builddir)/initramfs && \ - echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc ) > $@-t + mkdir sbin + cd sbin && ln ../../daemon/guestfsd + echo -e "sbin\nsbin/guestfsd" | cpio --quiet -o -H newc > $@-t + rm -r sbin mv $@-t $@ -supermin.d/init.img: $(INITRAMFSIMG) +supermin.d/init.img: init mkdir -p supermin.d rm -f $@ $@-t - (cd $(top_builddir)/initramfs && \ - echo -e "init\n" | cpio --quiet -o -H newc ) > $@-t + echo "init" | cpio --quiet -o -H newc > $@-t mv $@-t $@ -endif - -# Extra symlinks needed by the Debian appliance. -debirf_symlinks = \ - a0_prep-root \ - install-kernel \ - z0_remove-aptitude \ - z0_remove-locales \ - z1_clean-root -noinst_DATA = $(debirf_symlinks:%=debian/modules/%) -$(debirf_symlinks:%=debian/modules/%): stamp-debirf-modules -stamp-debirf-modules: - mkdir -p debian/modules - for f in $(debirf_symlinks); do \ - ln -sf /usr/share/debirf/modules/$$f debian/modules/$$f; \ - done - touch $@ - # Make clean. -CLEANFILES = packagelist kmod.whitelist +CLEANFILES = packagelist clean-local: - rm -f supermin.d/* - rm -rf $(top_builddir)/initramfs + rm -rf supermin.d diff --git a/appliance/debian/debirf.conf.in b/appliance/debian/debirf.conf.in deleted file mode 100644 index 7efe25b3..00000000 --- a/appliance/debian/debirf.conf.in +++ /dev/null @@ -1,5 +0,0 @@ -DEBIRF_LABEL="debirf-libguestfs" -DEBIRF_SUITE=@REPO@ -DEBIRF_MIRROR=@MIRROR@/${DEBIRF_DISTRO} -DEBIRF_KERNEL_ARCH=@DEBIAN_KERNEL_ARCH@ -DEBIRF_METHOD=stupid_simple diff --git a/appliance/debian/modules/a0_prep-root b/appliance/debian/modules/a0_prep-root deleted file mode 120000 index 654bc70a..00000000 --- a/appliance/debian/modules/a0_prep-root +++ /dev/null @@ -1 +0,0 @@ -/usr/share/debirf/modules/a0_prep-root
\ No newline at end of file diff --git a/appliance/debian/modules/install-kernel b/appliance/debian/modules/install-kernel deleted file mode 120000 index a1be2bc8..00000000 --- a/appliance/debian/modules/install-kernel +++ /dev/null @@ -1 +0,0 @@ -/usr/share/debirf/modules/install-kernel
\ No newline at end of file diff --git a/appliance/debian/modules/y0_install-guestfsd b/appliance/debian/modules/y0_install-guestfsd deleted file mode 100755 index 2d895a05..00000000 --- a/appliance/debian/modules/y0_install-guestfsd +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -e -# install guestfsd specific stuff - -# Kernel modules take up nearly half of the image. Only include ones -# which are on the whitelist. -exec 5<../appliance/kmod.whitelist -whitelist= -while read kmod 0<&5; do - whitelist="$whitelist -a -not -name $kmod" -done -exec 5<&- - -echo "Module whitelist: $whitelist" -find $DEBIRF_ROOT/lib/modules/*/kernel -name '*.ko' $whitelist -a -exec rm '{}' \; - -# install additional packages from the package list, but -# only ones which exist in the repository -PKGLIST= -for pkg in $(< packagelist); do - if [ "$(debirf_exec apt-get -s install $pkg 3>&1 1>&2 2>&3 1>&- | grep '^E:' | wc -l)" -gt 0 ]; then - echo "Ignoring package $pkg, because it was not found in this repository." - else - PKGLIST="$PKGLIST $pkg" - fi -done -echo "Will add $PKGLIST" -debirf_exec apt-get --assume-yes install $PKGLIST -debirf_exec apt-get --assume-yes remove vim-tiny dhcp3-client iptables - -debirf_exec mkdir -p --mode=0777 /sysroot - -# cleanup some other heavy lifters: -rm -rf "$DEBIRF_ROOT"/usr/share/doc/ -rm -rf "$DEBIRF_ROOT"/usr/share/zoneinfo/ -rm -rf "$DEBIRF_ROOT"/usr/share/man/ - -# Install the actual appliance: -echo $PWD -install -o root -g root -m 0755 ../daemon/guestfsd "$DEBIRF_ROOT"/sbin/guestfsd -install -o root -g root -m 0755 init "$DEBIRF_ROOT"/sbin/init diff --git a/appliance/debian/modules/z0_remove-aptitude b/appliance/debian/modules/z0_remove-aptitude deleted file mode 120000 index 7c56260c..00000000 --- a/appliance/debian/modules/z0_remove-aptitude +++ /dev/null @@ -1 +0,0 @@ -/usr/share/debirf/modules/z0_remove-aptitude
\ No newline at end of file diff --git a/appliance/debian/modules/z0_remove-locales b/appliance/debian/modules/z0_remove-locales deleted file mode 120000 index 80a82fab..00000000 --- a/appliance/debian/modules/z0_remove-locales +++ /dev/null @@ -1 +0,0 @@ -/usr/share/debirf/modules/z0_remove-locales
\ No newline at end of file diff --git a/appliance/debian/modules/z1_clean-root b/appliance/debian/modules/z1_clean-root deleted file mode 120000 index f0d3aad9..00000000 --- a/appliance/debian/modules/z1_clean-root +++ /dev/null @@ -1 +0,0 @@ -/usr/share/debirf/modules/z1_clean-root
\ No newline at end of file diff --git a/appliance/debian/modules/z99_final-cleanups b/appliance/debian/modules/z99_final-cleanups deleted file mode 100755 index ef5fac79..00000000 --- a/appliance/debian/modules/z99_final-cleanups +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -rm -rf "$DEBIRF_ROOT"/var/lib/dpkg/info diff --git a/appliance/kmod.whitelist.in b/appliance/kmod.whitelist.in deleted file mode 100644 index 850b7b88..00000000 --- a/appliance/kmod.whitelist.in +++ /dev/null @@ -1,86 +0,0 @@ -# List of kernel modules that we leave in the appliance. This has to -# include any dependencies needed by modules. - -# Any kernel module not listed here is deleted from the appliance. - -# Wildcards are permitted. - -virtio*.ko - -# We normally use virtio_net, but keep these in reserve. -8390.ko -ne2k-pci.ko - -# drivers for QEMUs IDE/SCSI device emulation -cdrom.ko -i2c-piix4.ko -i2c-core.ko -ide-*.ko -libata.ko -piix.ko -scsi_transport_spi.ko -scsi_mod.ko -sd_mod.ko -sym53c8xx.ko -ata_piix.ko -sr_mod.ko - -ext2.ko -ext3.ko -ext4*.ko - -jbd.ko -jbd2.ko -mbcache.ko - -fuse.ko - -vfat.ko -fat.ko - -minix.ko - -udf.ko -nls_utf8.ko -nls_cp437.ko -nls_base.ko - -isofs.ko -zlib_inflate.ko - -dm-*.ko - -cramfs.ko -squashfs.ko - -hfs.ko -hfsplus.ko -ufs.ko -exportfs.ko -xfs.ko - -reiserfs.ko - -crc*.ko -libcrc*.ko - -loop.ko - -gfs2.ko -dlm.ko -configfs.ko - -# Used by dm-crypt. Probably many more crypto modules -# should be added here. -aes*.ko -blkcipher.ko -cbc.ko -cryptd.ko -crypto_blkcipher.ko -gf128mul.ko -padlock-aes.ko -sha256*.ko -sha512*.ko -xor.ko -xts.ko -zlib.ko diff --git a/appliance/make.sh.in b/appliance/make.sh.in index 64bcb5a4..bab0529c 100755 --- a/appliance/make.sh.in +++ b/appliance/make.sh.in @@ -1,6 +1,6 @@ #!/bin/bash - # @configure_input@ -# Copyright (C) 2009 Red Hat Inc. +# Copyright (C) 2009-2010 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 @@ -16,167 +16,46 @@ # 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 -set -x - -if [ "@DIST@" = "REDHAT" ]; then - cd @top_builddir@ - # Decide on names for the final output. These have to match Makefile.am. - output=appliance/initramfs.@host_cpu@.img - koutput=appliance/vmlinuz.@host_cpu@ - rm -f $output - rm -f $koutput - - # Create the basic initramfs. - exec 5<appliance/packagelist - packages= - while read pkg 0<&5; do - packages="$packages -i $pkg" - done - exec 5<&- - - @FEBOOTSTRAP@ $packages -u @UPDATES@ @REPO@ initramfs @MIRROR@ - - # Create modules.dep. This is only used in the normal appliance - # (not supermin). - kversion=$(basename initramfs/lib/modules/*) - @FEBOOTSTRAP_RUN@ initramfs -- /sbin/depmod -a $kversion - - # /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 - - # Create /selinux if it is missing. - @FEBOOTSTRAP_RUN@ initramfs -- mkdir -p --mode=0755 /selinux - - # Nuke some stuff. The kernel pulls mkinitrd and plymouth which pulls in - # all of Python. Sheez. - (cd initramfs && find -name '*python*' -print0) | - xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf - (cd initramfs && find -name '*plymouth*' -print0) | - xargs -0 @FEBOOTSTRAP_RUN@ initramfs -- rm -rf - (cd initramfs && find -name 'libply-*' -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 - - # Don't need any firmware. - @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /lib/firmware - - # Don't need any keyboard maps. - @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /lib/kbd - # Remove anything in home directory. Because of the potential for disaster - # we don't put a slash before 'home'. - (cd initramfs && echo home/*) | - xargs @FEBOOTSTRAP_RUN@ initramfs -- rm -rf +# XXX Distro-dependent in future. +excludes="--exclude '^perl' --exclude '^python' --exclude '^fedora-logos' --exclude '^redhat-logos' --exclude '^dracut' --exclude '^upstart' --exclude '^plymouth' --exclude '^systemd' --exclude '^linux-firmware' --exclude '^kbd-misc'" - # Remove /var/lib/yum stuff. - @FEBOOTSTRAP_RUN@ initramfs -- rm -rf /var/lib/yum - - # Remove some unreadable binaries which are incompatible with - # the supermin appliance. Since these binaries can't be read - # from the host filesystem, they cannot be added to the supermin - # appliance at run time. XXX Need a better fix for this. - # Probably we should change febootstrap-supermin-helper to just - # ignore such files. - @FEBOOTSTRAP_RUN@ initramfs -- rm -f \ - /usr/bin/chfn \ - /usr/bin/chsh \ - /usr/libexec/pt_chown \ - /usr/libexec/utempter/utempter \ - /usr/sbin/groupdel \ - /usr/sbin/groupadd \ - /usr/sbin/useradd \ - /usr/sbin/tzdata-update \ - /usr/sbin/userdel \ - /usr/sbin/usermod \ - /usr/sbin/groupmod \ - /usr/sbin/groupmems \ - /sbin/unix_update \ - /usr/sbin/tcpd \ - /usr/share/dbus-1/services/org.selinux.Restorecond.service \ - /lib/dbus-1/dbus-daemon-launch-helper \ - /lib64/dbus-1/dbus-daemon-launch-helper \ - /etc/passwd- \ - /etc/group- \ - /etc/gshadow \ - /etc/gshadow- \ - /etc/shadow \ - /etc/shadow- \ - /etc/securetty \ - /etc/sysconfig/iptables-config \ - /etc/default/useradd \ - /etc/security/opasswd \ - /etc/libaudit.conf \ - /var/log/tallylog \ - /var/log/maillog \ - /var/log/secure \ - /var/log/spooler \ - /var/log/messages \ - /var/log/btmp \ - /var/log/yum.log \ - $(cd initramfs && echo usr/sbin/glibc_post_upgrade.*) - - # Remove all .*.hmac files (RHBZ#654638). These are not used unless - # you are using FIPS, and they cause hard dependencies on files - # which change whenever a library version is bumped. - @FEBOOTSTRAP_RUN@ initramfs -- rm -f $(cd initramfs && find -name '.*.hmac') - - # Kernel modules take up nearly half of the image. Only include ones - # which are on the whitelist. - exec 5<appliance/kmod.whitelist - whitelist= - while read kmod 0<&5; do - whitelist="$whitelist -a -not -name $kmod" - done - exec 5<&- - - (cd initramfs && \ - find lib/modules/*/kernel -name '*.ko' $whitelist -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 169.254.2.3 > resolv.conf.new - @FEBOOTSTRAP_INSTALL@ initramfs resolv.conf.new /etc/resolv.conf 0644 root.root - rm resolv.conf.new +# Run febootstrap on the package list. +if [ -z "@PACKAGE_DIRECTORY@" ]; then + @FEBOOTSTRAP@ -v -o supermin.d $excludes --names $(< packagelist ) +else + @FEBOOTSTRAP@ -v -o supermin.d $excludes @PACKAGE_DIRECTORY@/* +fi - ls -lh $koutput +# Remove some things that we don't want in the appliance. This is +# copied from the old febootstrap-minimize. However minimization is +# not so important now that we are caching the appliance. +< supermin.d/hostfiles \ +grep -v '^/usr/lib/locale' | +grep -v '^/usr/share/locale' | +grep -v '^/usr/lib/gconv' | +grep -v '^/usr/lib64/gconv' | +grep -v '^/usr/bin/localedef' | +grep -v '^/usr/sbin/build-locale-archive' | +grep -v '^/usr/share/man/' | +grep -v '^/usr/share/doc/' | +grep -v '^/usr/share/info/' | +grep -v '^/usr/share/gnome/help/' | +grep -v '^/usr/share/cracklib/' | +grep -v '^/usr/share/i18n/' > supermin.d/hostfiles-t + +# XXX resolv.conf? The old script had: +# echo nameserver 169.254.2.3 > resolv.conf +if ! grep -q /etc/resolv.conf supermin.d/hostfiles-t; then + echo /etc/resolv.conf >> supermin.d/hostfiles-t +fi -elif [ "@DIST@" = "DEBIAN" ]; then - cd @top_builddir@/appliance - debirf make -n debian - mkdir -p @top_builddir@/initramfs - touch @top_builddir@/initramfs/fakeroot.log +# Include any Augeas lenses from the host. +if grep -q /usr/share/augeas/lenses supermin.d/hostfiles-t; then + echo "/usr/share/augeas/lenses/*.aug" >> supermin.d/hostfiles-t fi + +mv supermin.d/hostfiles-t supermin.d/hostfiles diff --git a/appliance/update.sh.in b/appliance/update.sh.in deleted file mode 100755 index 98d785eb..00000000 --- a/appliance/update.sh.in +++ /dev/null @@ -1,49 +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 init script or daemon inside an existing initramfs. -# Avoids the timeconsuming rebuild. - -unset CDPATH - -set -e - -if [ "@DIST@" = "REDHAT" ]; then - cd @top_builddir@ - output=appliance/initramfs.@host_cpu@.img - - # Create the init script. - @FEBOOTSTRAP_INSTALL@ initramfs appliance/@top_srcdir@/appliance/init /init 0755 root.root - - # 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 -elif [ "@DIST@" = "DEBIAN" ]; then - cd @top_builddir@/appliance - - output=initramfs.@host_cpu@.img - vmlinuz=vmlinuz.@host_cpu@ - - rm -f debian/debirf-libguestfs_@REPO@_.cgz - ln -sf debian/debirf-libguestfs_@REPO@*.cgz $output - ln -sf debian/vmlinuz-* $vmlinuz -fi |