SHA256
1
0
forked from pool/libguestfs

- build appliance as initramfs image with the help of mkinitrd

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=27
This commit is contained in:
Olaf Hering 2012-08-29 17:43:39 +00:00 committed by Git OBS Bridge
parent a097a6c48f
commit 86bc25c3c2
4 changed files with 124 additions and 1 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Aug 29 19:40:04 CEST 2012 - ohering@suse.de
- build appliance as initramfs image with the help of mkinitrd
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Aug 29 17:26:45 CEST 2012 - ohering@suse.de Wed Aug 29 17:26:45 CEST 2012 - ohering@suse.de

View File

@ -0,0 +1,77 @@
#!/bin/bash
#%stage: block
#%modules: dm-mod virtio_blk virtio_console virtio_net virtio_pci virtio_scsi
#%programs: guestfsd lvm mdadm lsmod ip date cat
#
# from libguestfs-1.19.34/appliance/init:
# Scan for MDs.
mdadm -As --auto=yes --run
# Scan for LVM.
modprobe dm_mod ||:
lvm vgscan --ignorelockingfailure
lvm vgchange -ay --ignorelockingfailure
# Improve virtio-blk performance (RHBZ#509383).
for f in /sys/block/vd*/queue/rotational; do echo 1 > $f; done
# These are useful when debugging.
if grep -sq guestfs_verbose=1 /proc/cmdline; then
ls -lR /dev
cat /proc/mounts
lvm pvs
lvm vgs
lvm lvs
ip a
ip r
lsmod
#hwclock -r
date
#ping -n -v -c 5 10.0.2.2
#ping -n -v -c 5 10.0.2.4
echo -n "uptime: "; cat /proc/uptime
fi
if ! grep -sq guestfs_rescue=1 /proc/cmdline; then
# Run the daemon under valgrind if ./configure --enable-valgrind-daemon
vg_channel=/dev/virtio-ports/org.libguestfs.valgrind
if [ -w $vg_channel ]; then
if [ -r /etc/guestfsd.suppressions ]; then
suppressions="--suppressions=/etc/guestfsd.suppressions"
fi
exec 3>$vg_channel
vg="valgrind --leak-check=full --log-fd=3 --error-exitcode=119 --max-stackframe=8388608 --child-silent-after-fork=yes $suppressions"
echo "enabling valgrind: $vg"
fi
# The host will kill qemu abruptly if guestfsd shuts down normally
$vg guestfsd
# Otherwise we try to clean up gracefully. For example, this ensures that a
# core dump generated by the guest daemon will be written to disk.
else
# Use appliance in rescue mode, also used by the virt-rescue command.
eval $(grep -Eo 'TERM=[^[:space:]]+' /proc/cmdline)
PS1='><rescue> '
export TERM PS1
echo
echo "------------------------------------------------------------"
echo
echo "Welcome to virt-rescue, the libguestfs rescue shell."
echo
echo "Note: The contents of / are the rescue appliance."
echo "You have to mount the guest's partitions under /sysroot"
echo "before you can examine them."
echo
bash -i
echo
echo "virt-rescue: Syncing the disk now before exiting ..."
echo
fi
echo s > /proc/sysrq-trigger
echo o > /proc/sysrq-trigger

View File

@ -0,0 +1,3 @@
#!/bin/bash
#%stage: block
#

View File

@ -35,6 +35,9 @@
Name: libguestfs Name: libguestfs
ExclusiveArch: %ix86 x86_64 ExclusiveArch: %ix86 x86_64
Requires: kvm >= 1.1 Requires: kvm >= 1.1
%if %{?sles_version}0 > 0
BuildRequires: sles-release
%endif
%if %suse_version >= 1140 %if %suse_version >= 1140
BuildRequires: augeas-devel BuildRequires: augeas-devel
%endif %endif
@ -47,12 +50,16 @@ BuildRequires: gcc-c++
BuildRequires: genisoimage BuildRequires: genisoimage
BuildRequires: gperf BuildRequires: gperf
BuildRequires: hivex-devel BuildRequires: hivex-devel
BuildRequires: kernel-default
BuildRequires: kvm >= 1.1 BuildRequires: kvm >= 1.1
BuildRequires: lvm2
%if %suse_version >= 1220 %if %suse_version >= 1220
BuildRequires: libconfig-devel BuildRequires: libconfig-devel
%endif %endif
BuildRequires: libtool BuildRequires: libtool
BuildRequires: libvirt-devel BuildRequires: libvirt-devel
BuildRequires: mdadm
BuildRequires: mkinitrd
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
BuildRequires: pcre-devel BuildRequires: pcre-devel
BuildRequires: pkg-config BuildRequires: pkg-config
@ -131,6 +138,8 @@ Patch100: libguestfs.perl.install_vendor.patch
Patch101: libguestfs.perl.no-rpath.patch Patch101: libguestfs.perl.no-rpath.patch
Source0: %{name}-%{version}.tar.gz Source0: %{name}-%{version}.tar.gz
Source1: guestfs.tar.xz Source1: guestfs.tar.xz
Source10: libguestfs.mkinitrd.boot.sh
Source11: libguestfs.mkinitrd.setup.sh
Recommends: %{name}-data Recommends: %{name}-data
%description %description
@ -308,10 +317,39 @@ make %{?jobs:-j%jobs}
%makeinstall %makeinstall
find $RPM_BUILD_ROOT \( -name "*.pod" -o -name ".packlist" \) -print0 | xargs -0 --no-run-if-empty rm -fv find $RPM_BUILD_ROOT \( -name "*.pod" -o -name ".packlist" \) -print0 | xargs -0 --no-run-if-empty rm -fv
rm -f $RPM_BUILD_ROOT/%{_libdir}/*.{l,}a rm -f $RPM_BUILD_ROOT/%{_libdir}/*.{l,}a
xz -cd %{S:1} | tar -C $RPM_BUILD_ROOT/%{_libdir} -xvf - #xz -cd %{S:1} | tar -C $RPM_BUILD_ROOT/%{_libdir} -xvf -
touch %{name}.lang touch %{name}.lang
%find_lang %{name} %find_lang %{name}
# #
rm -rf mkinitrd
cp -av /lib/mkinitrd .
for bad in \
setup-dm.sh \
setup-storage.sh
do
rm mkinitrd/scripts/${bad}
done
cp -avL %{S:10} mkinitrd/scripts/boot-guestfs.sh
cp -avL %{S:11} mkinitrd/scripts/setup-guestfs.sh
chmod 755 mkinitrd/scripts/*guestfs.sh
/sbin/mkinitrd_setup \
-s $PWD/mkinitrd/scripts \
-i $PWD/mkinitrd
mkdir mkinitrd/boot_tmp
kver=`/sbin/get_kernel_version /boot/vmlinuz`
cp -avL /boot/vmlinuz /boot/System.map-${kver} mkinitrd/boot_tmp
env PATH=${RPM_BUILD_ROOT}/usr/bin:${RPM_BUILD_ROOT}/usr/sbin:${PATH} \
/sbin/mkinitrd \
-l $PWD/mkinitrd \
-k vmlinuz \
-i initrd \
-b $PWD/mkinitrd/boot_tmp \
-m 'dm-mod loop' \
-B
#
mkdir -vp $RPM_BUILD_ROOT%{_libdir}/guestfs
cp -avL mkinitrd/boot_tmp/initrd $RPM_BUILD_ROOT%{_libdir}/guestfs/initramfs.`arch`.img
cp -avL mkinitrd/boot_tmp/vmlinuz $RPM_BUILD_ROOT%{_libdir}/guestfs/vmlinuz.`arch`
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT