Create kernel-qubes-vm subpackage (#242)

Package containing kernel for VM with modules and firmware included.
This commit is contained in:
Marek Marczykowski 2011-06-30 01:11:56 +02:00
parent 63e7989ff6
commit dadf64bb25
2 changed files with 79 additions and 33 deletions

View File

@ -19,6 +19,7 @@
%define build_src_dir %my_builddir/linux-%version
%define src_install_dir /usr/src/kernels/%kernelrelease
%define kernel_build_dir %my_builddir/linux-obj
%define vm_install_dir /var/lib/qubes/vm-kernels/%kernelrelease
%(chmod +x %_sourcedir/{guards,apply-patches,check-for-config-changes})
@ -60,6 +61,7 @@ Source16: guards
Source17: apply-patches
Source33: check-for-config-changes
Source100: config-%{build_flavor}
# FIXME: Including dirs this way does NOT produce proper src.rpms
Source200: patches.arch
Source201: patches.drivers
Source202: patches.fixes
@ -68,6 +70,8 @@ Source204: patches.suse
Source205: patches.xen
Source207: patches.kernel.org
Source300: patches.qubes
Source301: u2mfn
Source302: vm-initramfs-pre-udev
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: x86_64
@ -127,6 +131,7 @@ rm -f source
find . ! -type d -printf '%%P\n' > %my_builddir/obj-files
%build
cd %kernel_build_dir
# If the %jobs macro is defined to a number, make will spawn that many jobs.
@ -138,6 +143,8 @@ cd %kernel_build_dir
# kernel-$flavor.spec
make %{?jobs:-j%jobs} all $MAKE_ARGS CONFIG_DEBUG_SECTION_MISMATCH=y
# Build u2mfn module
make -C %kernel_build_dir SUBDIRS=%_builddir/u2mfn modules
%install
@ -260,12 +267,6 @@ egrep -v \
rm -f modinfo modnames
# remove files that will be auto generated by depmod at rpm -i time
for i in alias alias.bin ccwmap dep dep.bin ieee1394map inputmap isapnpmap ofmap pcimap seriomap symbols symbols.bin usbmap
do
rm -f %buildroot/lib/modules/%kernelrelease/modules.$i
done
# Move the devel headers out of the root file system
mkdir -p %buildroot/usr/src/kernels
mv %buildroot/lib/modules/%kernelrelease/build/* %buildroot/%src_install_dir
@ -273,7 +274,6 @@ mv %buildroot/lib/modules/%kernelrelease/build/.config %buildroot/%src_install_d
rmdir %buildroot/lib/modules/%kernelrelease/build
ln -sf %src_install_dir %buildroot/lib/modules/%kernelrelease/build
# Abort if there are any undefined symbols
msg="$(/sbin/depmod -F %buildroot/boot/System.map-%kernelrelease \
-b %buildroot -ae %kernelrelease 2>&1)"
@ -282,6 +282,28 @@ if [ $? -ne 0 ] || echo "$msg" | grep 'needs unknown symbol'; then
exit 1
fi
# Prepare initramfs for Qubes VM
mkdir -p %buildroot/%vm_install_dir
/sbin/dracut --nomdadmconf --nolvmconf \
--kmoddir %buildroot/lib/modules/%kernelrelease \
--include %_sourcedir/vm-initramfs-pre-udev /pre-udev \
--add-drivers xenblk \
%buildroot/%vm_install_dir/initramfs %kernelrelease
cp -p arch/x86/boot/vmlinuz %buildroot/%vm_install_dir/vmlinuz
# Modules for Qubes VM
mkdir -p %buildroot%vm_install_dir/modules
cp -a %buildroot/lib/modules/%kernelrelease %buildroot%vm_install_dir/modules/
mkdir -p %buildroot%vm_install_dir/modules/firmware
cp -a %buildroot/lib/firmware/%kernelrelease %buildroot%vm_install_dir/modules/firmware/
# remove files that will be auto generated by depmod at rpm -i time
for i in alias alias.bin ccwmap dep dep.bin ieee1394map inputmap isapnpmap ofmap pcimap seriomap symbols symbols.bin usbmap
do
rm -f %buildroot/lib/modules/%kernelrelease/modules.$i
done
%post
/sbin/new-kernel-pkg --package %{name}-%{kernelrelease}\
--mkinitrd --depmod --dracut\
@ -341,7 +363,7 @@ fi
/usr/src/kernels/%{kernelrelease}
%package domU
%package qubes-vm
Summary: The Xen Kernel
Version: %{version}
Release: %{rel}
@ -350,15 +372,10 @@ Group: System/Kernel
Url: http://www.kernel.org/
AutoReqProv: on
BuildRequires: coreutils module-init-tools sparse
Provides: multiversion(kernel)
Provides: %name = %version-%kernelrelease
Provides: multiversion(kernel-qubes-vm)
Provides: kernel-xen-domU
Provides: kernel-qubes-domU
Provides: kernel-drm-nouveau = 16
Requires(post): /sbin/new-kernel-pkg
Requires(preun):/sbin/new-kernel-pkg
Requires(pre): coreutils gawk
Requires(post): dracut
@ -367,32 +384,30 @@ Conflicts: sysfsutils < 2.0
# root-lvm only works with newer udevs
Conflicts: udev < 118
Conflicts: lvm2 < 2.02.33
Provides: kernel = %version-%kernelrelease
Provides: kernel-qubes-vm = %version-%kernelrelease
%description domU
%description qubes-vm
Qubes domU kernel.
%post domU
/sbin/new-kernel-pkg --package %{name}-%{kernelrelease}\
--mkinitrd --depmod --dracut\
--banner="Qubes"\
--make-default --install %{kernelrelease}
%post qubes-vm
%posttrans domU
/sbin/new-kernel-pkg --package %{name}-%{kernelrelease} --rpmposttrans %{kernelrelease}
mkdir /tmp/qubes-modules-%kernelrelease
truncate -s 200M /tmp/qubes-modules-%kernelrelease.img
mkfs -t ext3 -F /tmp/qubes-modules-%kernelrelease.img > /dev/null
mount /tmp/qubes-modules-%kernelrelease.img /tmp/qubes-modules-%kernelrelease -o loop
cp -a -t /tmp/qubes-modules-%kernelrelease %vm_install_dir/modules/*
umount /tmp/qubes-modules-%kernelrelease
rmdir /tmp/qubes-modules-%kernelrelease
mv /tmp/qubes-modules-%kernelrelease.img %vm_install_dir/modules.img
%preun domU
/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{kernelrelease}
qvm-set-default-kernel %{kernelrelease}
%files domU
%files qubes-vm
%defattr(-, root, root)
%ghost /boot/initramfs-%{kernelrelease}.img
/boot/System.map-%{kernelrelease}
/boot/config-%{kernelrelease}
/boot/symvers-%kernelrelease.gz
%attr(0644, root, root) /boot/vmlinuz-%{kernelrelease}
/lib/firmware/%{kernelrelease}
/lib/modules/%{kernelrelease}
%ghost %attr(0644, root, root) %vm_install_dir/modules.img
%attr(0644, root, root) %vm_install_dir/initramfs
%attr(0644, root, root) %vm_install_dir/vmlinuz
%vm_install_dir/modules
%changelog

View File

@ -0,0 +1,31 @@
#
# This file should be places in pre-mount directory in dracut's initramfs
#
#!/bin/sh
echo "Qubes initramfs script here:"
if [ -e /dev/mapper/dmroot ] ; then
die "Qubes: FATAL error: /dev/mapper/dmroot already exists?!"
fi
modprobe xenblk || modprobe xen-blkfront || echo "Qubes: Cannot load Xen Block Frontend..."
echo "Waiting for /dev/xvda* devices..."
while ! [ -e /dev/xvda ]; do sleep 0.1; done
if [ `blockdev --getro /dev/xvda` = 1 ] ; then
echo "Qubes: Doing COW setup for AppVM..."
while ! [ -e /dev/xvdc ]; do sleep 0.1; done
while ! [ -e /dev/xvdc2 ]; do sleep 0.1; done
echo "0 `blockdev --getsz /dev/xvda` snapshot /dev/xvda /dev/xvdc2 P 16" | \
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; }
echo Qubes: done.
else
echo "Qubes: Doing R/W setup for TemplateVM..."
echo "0 `blockdev --getsz /dev/xvda` linear /dev/xvda 0" | \
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; exit 1; }
echo Qubes: done.
fi