Create kernel-qubes-vm subpackage (#242)
Package containing kernel for VM with modules and firmware included.
This commit is contained in:
parent
63e7989ff6
commit
dadf64bb25
@ -19,6 +19,7 @@
|
|||||||
%define build_src_dir %my_builddir/linux-%version
|
%define build_src_dir %my_builddir/linux-%version
|
||||||
%define src_install_dir /usr/src/kernels/%kernelrelease
|
%define src_install_dir /usr/src/kernels/%kernelrelease
|
||||||
%define kernel_build_dir %my_builddir/linux-obj
|
%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})
|
%(chmod +x %_sourcedir/{guards,apply-patches,check-for-config-changes})
|
||||||
|
|
||||||
@ -60,6 +61,7 @@ Source16: guards
|
|||||||
Source17: apply-patches
|
Source17: apply-patches
|
||||||
Source33: check-for-config-changes
|
Source33: check-for-config-changes
|
||||||
Source100: config-%{build_flavor}
|
Source100: config-%{build_flavor}
|
||||||
|
# FIXME: Including dirs this way does NOT produce proper src.rpms
|
||||||
Source200: patches.arch
|
Source200: patches.arch
|
||||||
Source201: patches.drivers
|
Source201: patches.drivers
|
||||||
Source202: patches.fixes
|
Source202: patches.fixes
|
||||||
@ -68,6 +70,8 @@ Source204: patches.suse
|
|||||||
Source205: patches.xen
|
Source205: patches.xen
|
||||||
Source207: patches.kernel.org
|
Source207: patches.kernel.org
|
||||||
Source300: patches.qubes
|
Source300: patches.qubes
|
||||||
|
Source301: u2mfn
|
||||||
|
Source302: vm-initramfs-pre-udev
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
ExclusiveArch: x86_64
|
ExclusiveArch: x86_64
|
||||||
|
|
||||||
@ -127,6 +131,7 @@ rm -f source
|
|||||||
find . ! -type d -printf '%%P\n' > %my_builddir/obj-files
|
find . ! -type d -printf '%%P\n' > %my_builddir/obj-files
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
cd %kernel_build_dir
|
cd %kernel_build_dir
|
||||||
|
|
||||||
# If the %jobs macro is defined to a number, make will spawn that many jobs.
|
# 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
|
# kernel-$flavor.spec
|
||||||
make %{?jobs:-j%jobs} all $MAKE_ARGS CONFIG_DEBUG_SECTION_MISMATCH=y
|
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
|
%install
|
||||||
|
|
||||||
@ -260,12 +267,6 @@ egrep -v \
|
|||||||
|
|
||||||
rm -f modinfo modnames
|
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
|
# Move the devel headers out of the root file system
|
||||||
mkdir -p %buildroot/usr/src/kernels
|
mkdir -p %buildroot/usr/src/kernels
|
||||||
mv %buildroot/lib/modules/%kernelrelease/build/* %buildroot/%src_install_dir
|
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
|
rmdir %buildroot/lib/modules/%kernelrelease/build
|
||||||
ln -sf %src_install_dir %buildroot/lib/modules/%kernelrelease/build
|
ln -sf %src_install_dir %buildroot/lib/modules/%kernelrelease/build
|
||||||
|
|
||||||
|
|
||||||
# Abort if there are any undefined symbols
|
# Abort if there are any undefined symbols
|
||||||
msg="$(/sbin/depmod -F %buildroot/boot/System.map-%kernelrelease \
|
msg="$(/sbin/depmod -F %buildroot/boot/System.map-%kernelrelease \
|
||||||
-b %buildroot -ae %kernelrelease 2>&1)"
|
-b %buildroot -ae %kernelrelease 2>&1)"
|
||||||
@ -282,6 +282,28 @@ if [ $? -ne 0 ] || echo "$msg" | grep 'needs unknown symbol'; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
%post
|
||||||
/sbin/new-kernel-pkg --package %{name}-%{kernelrelease}\
|
/sbin/new-kernel-pkg --package %{name}-%{kernelrelease}\
|
||||||
--mkinitrd --depmod --dracut\
|
--mkinitrd --depmod --dracut\
|
||||||
@ -341,7 +363,7 @@ fi
|
|||||||
/usr/src/kernels/%{kernelrelease}
|
/usr/src/kernels/%{kernelrelease}
|
||||||
|
|
||||||
|
|
||||||
%package domU
|
%package qubes-vm
|
||||||
Summary: The Xen Kernel
|
Summary: The Xen Kernel
|
||||||
Version: %{version}
|
Version: %{version}
|
||||||
Release: %{rel}
|
Release: %{rel}
|
||||||
@ -350,15 +372,10 @@ Group: System/Kernel
|
|||||||
Url: http://www.kernel.org/
|
Url: http://www.kernel.org/
|
||||||
AutoReqProv: on
|
AutoReqProv: on
|
||||||
BuildRequires: coreutils module-init-tools sparse
|
BuildRequires: coreutils module-init-tools sparse
|
||||||
Provides: multiversion(kernel)
|
Provides: multiversion(kernel-qubes-vm)
|
||||||
Provides: %name = %version-%kernelrelease
|
|
||||||
|
|
||||||
Provides: kernel-xen-domU
|
Provides: kernel-xen-domU
|
||||||
Provides: kernel-qubes-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(pre): coreutils gawk
|
||||||
Requires(post): dracut
|
Requires(post): dracut
|
||||||
@ -367,32 +384,30 @@ Conflicts: sysfsutils < 2.0
|
|||||||
# root-lvm only works with newer udevs
|
# root-lvm only works with newer udevs
|
||||||
Conflicts: udev < 118
|
Conflicts: udev < 118
|
||||||
Conflicts: lvm2 < 2.02.33
|
Conflicts: lvm2 < 2.02.33
|
||||||
Provides: kernel = %version-%kernelrelease
|
Provides: kernel-qubes-vm = %version-%kernelrelease
|
||||||
|
|
||||||
%description domU
|
%description qubes-vm
|
||||||
Qubes domU kernel.
|
Qubes domU kernel.
|
||||||
|
|
||||||
%post domU
|
%post qubes-vm
|
||||||
/sbin/new-kernel-pkg --package %{name}-%{kernelrelease}\
|
|
||||||
--mkinitrd --depmod --dracut\
|
|
||||||
--banner="Qubes"\
|
|
||||||
--make-default --install %{kernelrelease}
|
|
||||||
|
|
||||||
%posttrans domU
|
mkdir /tmp/qubes-modules-%kernelrelease
|
||||||
/sbin/new-kernel-pkg --package %{name}-%{kernelrelease} --rpmposttrans %{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
|
qvm-set-default-kernel %{kernelrelease}
|
||||||
/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{kernelrelease}
|
|
||||||
|
|
||||||
%files domU
|
%files qubes-vm
|
||||||
%defattr(-, root, root)
|
%defattr(-, root, root)
|
||||||
%ghost /boot/initramfs-%{kernelrelease}.img
|
%ghost %attr(0644, root, root) %vm_install_dir/modules.img
|
||||||
/boot/System.map-%{kernelrelease}
|
%attr(0644, root, root) %vm_install_dir/initramfs
|
||||||
/boot/config-%{kernelrelease}
|
%attr(0644, root, root) %vm_install_dir/vmlinuz
|
||||||
/boot/symvers-%kernelrelease.gz
|
%vm_install_dir/modules
|
||||||
%attr(0644, root, root) /boot/vmlinuz-%{kernelrelease}
|
|
||||||
/lib/firmware/%{kernelrelease}
|
|
||||||
/lib/modules/%{kernelrelease}
|
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
31
vm-initramfs-pre-udev/90_qubes_cow_setup.sh
Executable file
31
vm-initramfs-pre-udev/90_qubes_cow_setup.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user