Provide a script to generate VM kernel files
This commit is contained in:
parent
2b6fd27839
commit
c64b94e9d6
@ -1,7 +1,11 @@
|
|||||||
ver := $(shell cat ../version)
|
ver := $(shell cat ../version)
|
||||||
srcdir := /usr/src/u2mfn-$(ver)
|
srcdir := /usr/src/u2mfn-$(ver)
|
||||||
|
|
||||||
install: install-u2mfn
|
install: install-u2mfn install-scripts
|
||||||
|
|
||||||
|
install-scripts:
|
||||||
|
install -d $(DESTDIR)/usr/sbin
|
||||||
|
install qubes-prepare-vm-kernel $(DESTDIR)/usr/sbin
|
||||||
|
|
||||||
install-u2mfn:
|
install-u2mfn:
|
||||||
install -d $(DESTDIR)$(srcdir)
|
install -d $(DESTDIR)$(srcdir)
|
||||||
|
87
kernel-modules/qubes-prepare-vm-kernel
Normal file
87
kernel-modules/qubes-prepare-vm-kernel
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# The Qubes OS Project, http://www.qubes-os.org
|
||||||
|
#
|
||||||
|
# Copyright (C) 2015 Marek Marczykowski-Górecki
|
||||||
|
# <marmarekp@invisiblethingslab.com>
|
||||||
|
#
|
||||||
|
# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
basedir=/var/lib/qubes/vm-kernels
|
||||||
|
|
||||||
|
function recompile_u2mfn() {
|
||||||
|
kver=$1
|
||||||
|
u2mfn_ver=`dkms status u2mfn|tail -n 1|cut -f 2 -d ' '|tr -d ':,'`
|
||||||
|
dkms install u2mfn/$u2mfn_ver -k $kver
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_modules_img() {
|
||||||
|
kver=$1
|
||||||
|
output_file=$2
|
||||||
|
|
||||||
|
mkdir /tmp/qubes-modules-$kver
|
||||||
|
truncate -s 400M /tmp/qubes-modules-$kver.img
|
||||||
|
mkfs -t ext3 -F /tmp/qubes-modules-$kver.img > /dev/null
|
||||||
|
mount /tmp/qubes-modules-$kver.img /tmp/qubes-modules-$kver -o loop
|
||||||
|
cp -a -t /tmp/qubes-modules-$kver /lib/modules/$kver
|
||||||
|
umount /tmp/qubes-modules-$kver
|
||||||
|
rmdir /tmp/qubes-modules-$kver
|
||||||
|
mv /tmp/qubes-modules-$kver.img $output_file
|
||||||
|
}
|
||||||
|
|
||||||
|
function build_initramfs() {
|
||||||
|
kver=$1
|
||||||
|
output_file=$2
|
||||||
|
|
||||||
|
/sbin/dracut --nomdadmconf --nolvmconf --force \
|
||||||
|
--modules "bash dm kernel-modules rootfs-block base fs-lib shutdown" \
|
||||||
|
--modules "qubes-vm" --conf /dev/null --confdir /var/empty \
|
||||||
|
-d "xenblk xen-blkfront cdrom ext4 jbd2 crc16 dm_snapshot" \
|
||||||
|
$output_file $kver
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: $0 <kernel-version> [<display-kernel-version>]" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -r /boot/vmlinuz-$1 -o ! -d /lib/modules/$1 ]; then
|
||||||
|
echo "ERROR: Kernel version $1 not installed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
kernel_version=$1
|
||||||
|
if [ -n "$2" ]; then
|
||||||
|
output_dir="$basedir/$2"
|
||||||
|
else
|
||||||
|
output_dir="$basedir/$kernel_version"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "--> Building files for $kernel_version in $output_dir"
|
||||||
|
|
||||||
|
echo "---> Recompiling kernel module (u2mfn)"
|
||||||
|
recompile_u2mfn "$kernel_version"
|
||||||
|
mkdir -p "$output_dir"
|
||||||
|
cp "/boot/vmlinuz-$kernel_version" "$output_dir/vmlinuz"
|
||||||
|
echo "---> Generating modules.img"
|
||||||
|
build_modules_img "$kernel_version" "$output_dir/modules.img"
|
||||||
|
echo "---> Generating initramfs"
|
||||||
|
build_initramfs "$kernel_version" "$output_dir/initramfs"
|
||||||
|
|
||||||
|
echo "--> Done."
|
@ -61,6 +61,7 @@ make install-kernel-support DESTDIR=%{buildroot}
|
|||||||
%files
|
%files
|
||||||
/usr/lib/dracut/modules.d/90qubes-vm
|
/usr/lib/dracut/modules.d/90qubes-vm
|
||||||
/usr/src/u2mfn-%{version}/
|
/usr/src/u2mfn-%{version}/
|
||||||
|
/usr/sbin/qubes-prepare-vm-kernel
|
||||||
|
|
||||||
%post
|
%post
|
||||||
dkms add -m u2mfn -v %{version} --rpm_safe_upgrade
|
dkms add -m u2mfn -v %{version} --rpm_safe_upgrade
|
||||||
|
Loading…
Reference in New Issue
Block a user