Skip to content

Commit

Permalink
Build modules.img at module build time
Browse files Browse the repository at this point in the history
This will make package installation a little faster, more reproducible
(mkfs.ext3 -d is easier to make/replace with reproducible tool than
kernel driver), and also make disk space estimation more accurate.

(cherry picked from commit eb4c9ed)
(cherry picked from commit 1fe8359)
  • Loading branch information
marmarek committed Mar 19, 2019
1 parent 2df4b71 commit 72e769e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions kernel.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ BuildRequires: gcc-plugin-devel
BuildRequires: elfutils-libelf-devel
BuildRequires: bison
BuildRequires: flex
BuildRequires: e2fsprogs

# gcc with support for BTI mitigation
%if 0%{?fedora} == 23
Expand Down Expand Up @@ -389,6 +390,19 @@ cp -a %buildroot/lib/firmware/%kernelrelease %buildroot%vm_install_dir/modules/f
rm -f %buildroot%vm_install_dir/modules/%kernelrelease/build
cp -a %buildroot/%src_install_dir %buildroot%vm_install_dir/modules/%kernelrelease/build

# include kernel+initramfs also inside modules.img, for direct kernel boot with
# stubdomain
cp %buildroot%vm_install_dir/vmlinuz %buildroot%vm_install_dir/modules/
cp %buildroot%vm_install_dir/initramfs %buildroot%vm_install_dir/modules/
if [ -n "$SOURCE_DATE_EPOCH" ]; then
find %buildroot%vm_install_dir/modules \
-exec touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" {} +
fi
PATH="/sbin:$PATH" mkfs.ext3 -d %buildroot%vm_install_dir/modules \
-U dcee2318-92bd-47a5-a15d-e79d1412cdce \
%buildroot%vm_install_dir/modules.img 500M
rm -rf %buildroot%vm_install_dir/modules

# 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
Expand Down Expand Up @@ -484,19 +498,6 @@ Qubes domU kernel.

%post qubes-vm

mkdir /tmp/qubes-modules-%kernelrelease
truncate -s 500M /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/%kernelrelease
mkdir /tmp/qubes-modules-%kernelrelease/firmware
cp -a -t /tmp/qubes-modules-%kernelrelease/firmware %vm_install_dir/modules/firmware/%kernelrelease
cp %vm_install_dir/vmlinuz /tmp/qubes-modules-%kernelrelease/
cp %vm_install_dir/initramfs /tmp/qubes-modules-%kernelrelease/
umount /tmp/qubes-modules-%kernelrelease
rmdir /tmp/qubes-modules-%kernelrelease
mv /tmp/qubes-modules-%kernelrelease.img %vm_install_dir/modules.img

%if "%{name_suffix}" == ""
# Set kernel as default VM kernel if we are the default package.

Expand All @@ -523,10 +524,9 @@ exit 0
%files qubes-vm
%defattr(-, root, root)
%dir %vm_install_dir
%ghost %attr(0644, root, root) %vm_install_dir/modules.img
%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
@CHANGELOG@

0 comments on commit 72e769e

Please sign in to comment.