# # This SPEC is for bulding RPM packages that contain complete Qubes Template files # This includes the VM's root image, patched with all qubes rpms, etc # %{!?version: %define version %(cat version_appvm)} Name: qubes-template-%{template_name} Version: %{version} Release: 1 Summary: Qubes template for %{template_name} License: GPL URL: http://www.qubes-os.org Source: . Requires: qubes-core-dom0 xdg-utils %define _builddir %(pwd) %define _rpmdir %(pwd)/rpm %define dest_dir /var/lib/qubes/vm-templates/%{template_name} %description Qubes template for %{template_name} %build cd qubeized_images rm -f root.img.part.* tar --sparse -cf - %{template_name}-root.img | split -d -b 1G - root.img.part. cd .. ./create_apps_for_templatevm.sh qubeized_images/%{template_name}-apps.templates/ %{template_name} %{dest_dir} qubeized_images/%{template_name}-apps %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/%{dest_dir} for i in qubeized_images/root.img.part.* ; do ln $i $RPM_BUILD_ROOT/%{dest_dir}/`basename $i` ; done touch $RPM_BUILD_ROOT/%{dest_dir}/root.img # we will create the real file in %post touch $RPM_BUILD_ROOT/%{dest_dir}/private.img # we will create the real file in %post cp vm_conf_files/appvm-template.conf $RPM_BUILD_ROOT/%{dest_dir}/appvm-template.conf cp vm_conf_files/templatevm.conf $RPM_BUILD_ROOT/%{dest_dir}/templatevm.conf sed -e s/%TEMPLATENAME%/%{template_name}/ < vm_conf_files/templatevm.conf >\ $RPM_BUILD_ROOT/%{dest_dir}/%{template_name}.conf mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/kernels cp vm_kernels_appvm/vmlinuz $RPM_BUILD_ROOT/%{dest_dir}/kernels/vmlinuz cp vm_kernels_appvm/initramfs $RPM_BUILD_ROOT/%{dest_dir}/kernels/initramfs cp vm_initramfs_patches/qubes_cow_setup.sh $RPM_BUILD_ROOT/%{dest_dir}/kernels/qubes_cow_setup.sh mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps.templates mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps cp -r qubeized_images/%{template_name}-apps.templates/* $RPM_BUILD_ROOT/%{dest_dir}/apps.templates cp -r qubeized_images/%{template_name}-apps/* $RPM_BUILD_ROOT/%{dest_dir}/apps touch $RPM_BUILD_ROOT/%{dest_dir}/icon.png %post echo "--> Processing the root.img... (this might take a while)" cat %{dest_dir}/root.img.part.* | tar --sparse -xf - -C %{dest_dir} rm -f %{dest_dir}/root.img.part.* mv %{dest_dir}/%{template_name}-root.img %{dest_dir}/root.img chown root.qubes %{dest_dir}/root.img chmod 0660 %{dest_dir}/root.img if [ "$1" = 1 ] ; then # installing for the first time echo "--> Creating private.img..." truncate -s 2G %{dest_dir}/private.img mkfs.ext4 -q -F %{dest_dir}/private.img chown root.qubes %{dest_dir}/private.img chmod 0660 %{dest_dir}/private.img fi export XDG_DATA_DIRS=/usr/share/ if [ "$1" -gt 1 ] ; then # upgrading already installed template... echo "--> Removing previous menu shortcuts..." xdg-desktop-menu uninstall --mode system %{dest_dir}/apps/*.directory %{dest_dir}/apps/*.desktop fi echo "--> Instaling menu shortcuts..." ln -sf /usr/share/qubes/icons/template.png %{dest_dir}/icon.png xdg-desktop-menu install --mode system %{dest_dir}/apps/*.directory %{dest_dir}/apps/*.desktop if [ "$1" = 1 ] ; then # installing for the first time qvm-add-template --rpm %{template_name} fi %preun if [ "$1" = 0 ] ; then # no more packages left qvm-remove -q --just-db %{template_name} # we need to have it here, because rpm -U