2010-04-05 22:25:37 +00:00
|
|
|
#
|
|
|
|
# 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: .
|
|
|
|
|
2011-03-23 01:07:44 +00:00
|
|
|
Requires: qubes-core-dom0 >= 1.4.1
|
2011-06-29 23:22:58 +00:00
|
|
|
Requires: kernel-qubes-vm
|
2010-09-30 15:28:58 +00:00
|
|
|
Requires: xdg-utils
|
2010-04-05 22:25:37 +00:00
|
|
|
|
|
|
|
%define _builddir %(pwd)
|
|
|
|
%define _rpmdir %(pwd)/rpm
|
|
|
|
%define dest_dir /var/lib/qubes/vm-templates/%{template_name}
|
|
|
|
|
2010-09-16 17:23:32 +00:00
|
|
|
%define _binaries_in_noarch_packages_terminate_build 0
|
2010-04-05 22:25:37 +00:00
|
|
|
%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 ..
|
2011-03-28 23:49:52 +00:00
|
|
|
./create_apps_for_templatevm.sh appmenus/apps_templates_for_templatevm %{template_name} %{dest_dir} qubeized_images/%{template_name}-apps
|
2010-04-05 22:25:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
%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
|
|
|
|
|
2011-03-19 02:30:23 +00:00
|
|
|
cp clean_images/clean-volatile.img.tar $RPM_BUILD_ROOT/%{dest_dir}/clean-volatile.img.tar
|
|
|
|
|
2010-07-27 13:04:56 +00:00
|
|
|
cp vm_conf_files/dispvm-prerun.sh $RPM_BUILD_ROOT/%{dest_dir}/
|
|
|
|
|
2010-04-05 22:25:37 +00:00
|
|
|
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps.templates
|
2011-04-19 13:56:28 +00:00
|
|
|
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/apps-template.templates
|
2010-04-05 22:25:37 +00:00
|
|
|
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
|
2011-04-19 13:56:28 +00:00
|
|
|
cp -r appmenus/apps_templates_for_templatevm/* $RPM_BUILD_ROOT/%{dest_dir}/apps-template.templates
|
2011-04-19 14:52:00 +00:00
|
|
|
cp appmenus/qubes-templatevm.directory.template $RPM_BUILD_ROOT/%{dest_dir}/apps-template.templates
|
2010-04-05 22:25:37 +00:00
|
|
|
touch $RPM_BUILD_ROOT/%{dest_dir}/icon.png
|
|
|
|
|
2010-10-01 13:40:01 +00:00
|
|
|
%pre
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2010-04-05 22:25:37 +00:00
|
|
|
%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
|
|
|
|
|
2011-03-19 21:12:52 +00:00
|
|
|
echo "--> Processing the volatile.img..."
|
|
|
|
tar --sparse -xf %{dest_dir}/clean-volatile.img.tar -C %{dest_dir}
|
|
|
|
chown root.qubes %{dest_dir}/volatile.img
|
|
|
|
chmod 0660 %{dest_dir}/volatile.img
|
2011-03-19 02:30:23 +00:00
|
|
|
|
2010-04-05 22:25:37 +00:00
|
|
|
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/
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-03-16 08:52:21 +00:00
|
|
|
qvm-template-commit %{template_name}
|
|
|
|
|
2010-04-05 22:25:37 +00:00
|
|
|
%preun
|
|
|
|
if [ "$1" = 0 ] ; then
|
|
|
|
# no more packages left
|
2011-04-05 13:20:10 +00:00
|
|
|
# First remove DispVM template (even if not exists...)
|
|
|
|
qvm-remove -q %{template_name}-dvm
|
|
|
|
|
|
|
|
if ! qvm-remove -q --just-db %{template_name}; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2010-04-05 22:25:37 +00:00
|
|
|
|
|
|
|
# we need to have it here, because rpm -U <template>
|
|
|
|
# apparently executes %preun of the old package *after* %post of the new packages...
|
|
|
|
echo "--> Removing menu shortcuts..."
|
|
|
|
export XDG_DATA_DIRS=/usr/share/
|
|
|
|
xdg-desktop-menu uninstall --mode system %{dest_dir}/apps/*.directory %{dest_dir}/apps/*.desktop
|
|
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
%clean
|
|
|
|
rm -rf $RPM_BUILD_ROOT
|
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr(660,root,qubes,770)
|
|
|
|
%dir %{dest_dir}
|
|
|
|
%ghost %{dest_dir}/root.img
|
|
|
|
%{dest_dir}/root.img.part.*
|
2011-03-19 02:30:23 +00:00
|
|
|
%{dest_dir}/clean-volatile.img.tar
|
2011-03-19 21:12:52 +00:00
|
|
|
%ghost %{dest_dir}/volatile.img
|
2010-04-05 22:25:37 +00:00
|
|
|
%ghost %{dest_dir}/private.img
|
2010-07-27 13:04:56 +00:00
|
|
|
%{dest_dir}/dispvm-prerun.sh
|
2010-04-05 22:25:37 +00:00
|
|
|
%attr (775,root,qubes) %dir %{dest_dir}/apps
|
|
|
|
%attr (664,root,qubes) %{dest_dir}/apps/*
|
|
|
|
%attr (775,root,qubes) %dir %{dest_dir}/apps.templates
|
|
|
|
%attr (664,root,qubes) %{dest_dir}/apps.templates/*
|
2011-04-19 13:56:28 +00:00
|
|
|
%attr (775,root,qubes) %dir %{dest_dir}/apps-template.templates
|
|
|
|
%attr (664,root,qubes) %{dest_dir}/apps-template.templates/*
|
2010-04-05 22:25:37 +00:00
|
|
|
%{dest_dir}/icon.png
|