Build universal (appvm,netvm,proxyvm), cow-based template

This commit is contained in:
Marek Marczykowski 2011-03-16 09:52:21 +01:00
parent b0228da0db
commit dced8dafef
45 changed files with 64 additions and 285 deletions

2
README
View File

@ -1,8 +1,6 @@
The Template Builder The Template Builder
====================== ======================
(applies also to the netvm builder)
1) First, create a clean image of Fedora Linux install. You can use the fedoraize_image 1) First, create a clean image of Fedora Linux install. You can use the fedoraize_image
script for this: script for this:

View File

@ -1,17 +0,0 @@
#!/bin/sh
SRC=$1
DSTDIR=$2
DST=$DSTDIR/$(basename $SRC)
sed -e "s/^\(Name.*\)=\(.*\)/\1=%VMNAME%: \2/" \
-e "s/^\(GenericName.*\)=\(.*\)/\1=%VMNAME%: \2/" \
-e "s/^Exec=\(.*\)/Exec=qvm-run -q --tray -a --user=root %VMNAME% \"\1\"/" \
<$SRC | \
grep -v "^Mime" | \
grep -v "^TryExec" | \
grep -v "^Startup" >$DST
#echo "Categories=%VMNAME%" >> $DST
echo X-Qubes-VmName=%VMNAME% >> $DST
echo Icon=%VMDIR%/icon.png >> $DST

View File

@ -1,5 +0,0 @@
[Desktop Entry]
Encoding=UTF-8
Type=Directory
Name=%VMNAME% (NetVM)
Icon=/usr/share/qubes/icons/netvm.png

View File

@ -1,9 +0,0 @@
#!/bin/sh
NAME=$1
if [ x$NAME = x ] ; then
echo "usage $0 <netvm_name>"
exit
fi
rpmbuild --sign --target noarch --define "netvm_name $NAME" -bb netvm.spec

View File

@ -0,0 +1,24 @@
@base
@core
@editors
@hardware-support
@fonts
@base-x
@printing
@kde-desktop
@graphics
@input-methods
@system-tools
@admin-tools
@sound-and-video
@office
NetworkManager-gnome
bridge-utils
ethtool
xterm
stalonetray
firefox
thunderbird
keepassx
perl-File-MimeInfo
--exclude=kdegames

View File

@ -1,15 +0,0 @@
#!/bin/sh
SRCDIR=$1
VMNAME=$2
VMDIR=$3
APPSDIR=$4
if [ $# != 4 ]; then
echo "usage: $0 <apps_templates_dir> <vmname> <vmdir> <apps_dir>"
exit
fi
mkdir -p $APPSDIR
find $SRCDIR -name "*.desktop" -exec appmenus/convert_apptemplate2vm.sh {} $APPSDIR $VMNAME $VMDIR \;
appmenus/convert_dirtemplate2vm.sh appmenus/qubes-netvm.directory.template $APPSDIR/$VMNAME-vm.directory $VMNAME $VMDIR

View File

@ -1,14 +0,0 @@
#!/bin/sh
APPSORIG=$1
APPSTMPL=$2
if [ $# != 2 ]; then
echo "usage $0 <apps_orig_dir> <apps_templ_dir>"
exit 0
fi
#rm -f $APPSTMPL/*
mkdir -p $APPSTMPL
find $APPSORIG -name "*.desktop" -exec appmenus/convert_app2template_for_netvm.sh {} $APPSTMPL \;
cp appmenus/qubes-vm.directory.template $APPSTMPL

View File

@ -1,14 +0,0 @@
#!/bin/sh
APPSORIG=$1
APPSTMPL=$2
if [ $# != 2 ]; then
echo "usage $0 <apps_orig_dir> <apps_templ_dir>"
exit 0
fi
rm -f $APPSTMPL/*
mkdir -p $APPSTMPL
find $APPSORIG -name "*.desktop" -exec appmenus/convert_app2template_for_templatevm.sh {} $APPSTMPL \;
cp appmenus/qubes-vm.directory.template $APPSTMPL

View File

@ -1,110 +0,0 @@
#
# This SPEC is for bulding RPM packages that contain complete Qubes NetVM files
# This includes the VM's root image, patched with all qubes rpms, etc
#
%{!?version: %define version %(cat version_netvm)}
%define _binaries_in_noarch_packages_terminate_build 0
Name: qubes-servicevm-%{netvm_name}
Version: %{version}
Release: 1
Summary: Qubes NetVM image for '%{netvm_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/servicevms/%{netvm_name}
%description
Qubes NetVM image for '%{netvm_name}'.
%build
cd qubeized_images
rm -f %{netvm_name}-root.img.tar
tar --sparse -cf %{netvm_name}-root.img.tar %{netvm_name}-root.img
cd ..
./create_apps_for_netvm.sh netvm/apps.templates/ %{netvm_name} %{dest_dir} qubeized_images/%{netvm_name}-apps
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}
ln qubeized_images/%{netvm_name}-root.img.tar $RPM_BUILD_ROOT/%{dest_dir}/root.img.tar
touch $RPM_BUILD_ROOT/%{dest_dir}/root.img # we will create the real file in %post
sed -e s/%NETVMNAME%/%{netvm_name}/ < vm_conf_files/netvm.conf >\
$RPM_BUILD_ROOT/%{dest_dir}/%{netvm_name}.conf
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/kernels
cp vm_kernels_netvm/vmlinuz $RPM_BUILD_ROOT/%{dest_dir}/kernels/vmlinuz
cp vm_kernels_netvm/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
cp -r qubeized_images/%{netvm_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)"
tar --sparse -xf %{dest_dir}/root.img.tar -C %{dest_dir}
rm -f %{dest_dir}/root.img.tar
mv %{dest_dir}/%{netvm_name}-root.img %{dest_dir}/root.img
chown root.qubes %{dest_dir}/root.img
chmod 0660 %{dest_dir}/root.img
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/netvm.png %{dest_dir}/icon.png
xdg-desktop-menu install --mode system %{dest_dir}/apps/*.directory %{dest_dir}/apps/*.desktop
echo "--> Adding to Qubes DB..."
if [ "$1" = 1 ] ; then
# installing for the first time
qvm-add-netvm %{netvm_name}
else
qvm-remove -q --just-db %{netvm_name}
qvm-add-netvm %{netvm_name}
fi
%preun
if [ "$1" = 0 ] ; then
# no more packages left
qvm-remove -q --just-db %{netvm_name}
# 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.tar
%{dest_dir}/%{netvm_name}.conf
%dir %{dest_dir}/kernels
%{dest_dir}/kernels/vmlinuz
%{dest_dir}/kernels/initramfs
%{dest_dir}/kernels/qubes_cow_setup.sh
%attr (775,root,qubes) %dir %{dest_dir}/apps
%attr (664,root,qubes) %{dest_dir}/apps/*
%{dest_dir}/icon.png

View File

@ -36,7 +36,7 @@ mkdir -p mnt
mount -o loop,offset=$((63*512)) $IMG mnt || exit 1 mount -o loop,offset=$((63*512)) $IMG mnt || exit 1
echo "--> Installing RPMs..." echo "--> Installing RPMs..."
rpm --force --root=$(pwd)/mnt -ihv rpms_to_install_appvm/* rpm --force --root=$(pwd)/mnt -ihv rpms_to_install/*
echo "--> Copying the Apps Menu shortcuts..." echo "--> Copying the Apps Menu shortcuts..."

View File

@ -1,57 +0,0 @@
#!/bin/sh
CLEANIMG=$1
NAME=$2
if [ $# -eq 0 ]; then
echo "usage $0 <clean_image_file> <template_name>"
exit
fi
if [ x$CLEANIMG = x ]; then
echo "Image file not specified!"
exit 1
fi
if [ x$NAME = x ]; then
echo "Name not given!"
exit 1
fi
ID=$(id -ur)
if [ $ID != 0 ] ; then
echo "This script should be run as root user."
exit 1
fi
IMG=qubeized_images/$NAME-root.img
echo "--> Copying $CLEANIMG to $IMG..."
cp $CLEANIMG $IMG || exit 1
echo "--> Mouting $IMG"
mkdir -p mnt
mount -o loop,offset=$((63*512)) qubeized_images/$NAME-root.img mnt || exit 1
echo "--> Installing RPMs..."
rpm --force --nodeps --root=$(pwd)/mnt -ihv rpms_to_install_netvm/*
echo "--> Copying the Apps Menu shortcuts..."
APPSORIG=qubeized_images/$NAME-apps.orig
APPSTEMPL=qubeized_images/$NAME-apps.templates
mkdir -p $APPSORIG
cp -r $(pwd)/mnt/usr/share/applications/* $APPSORIG
if ! [ -d netvm/apps.templates ] ; then
echo "--> ERROR: Missing netvm/apps.templates directory."
exit 1
fi
echo "--> Unmounting $IMG"
umount mnt
echo "Qubeized image stored at: $IMG"

1
rpms_to_install Symbolic link
View File

@ -0,0 +1 @@
rpms_to_install_x64

View File

@ -1 +0,0 @@
rpms_to_install_appvm_x64/

View File

@ -1 +0,0 @@
../../gui/rpm/x86_64/qubes-gui-vm-1.1.12-1.x86_64.rpm

View File

@ -1 +0,0 @@
../../xen/rpm/x86_64/xen-libs-3.4.3-3.qubes.x86_64.rpm

View File

@ -1 +0,0 @@
../../xen/rpm/x86_64/xen-qubes-vm-essentials-3.4.3-3.qubes.x86_64.rpm

View File

@ -1 +0,0 @@
rpms_to_install_netvm_x64/

View File

@ -1 +0,0 @@
../../kernel-dom0/rpm/x86_64/kernel-domU-2.6.34.1-12.xenlinux.qubes.x86_64.rpm

View File

@ -1 +0,0 @@
../../core/rpm/x86_64/qubes-core-netvm-1.3.8-1.x86_64.rpm

View File

@ -1 +0,0 @@
../../gui/rpm/x86_64/qubes-gui-vm-1.1.12-1.x86_64.rpm

View File

@ -1 +0,0 @@
../../gui/rpm/x86_64/qubes-vchan-vm-{kernel-2.6.34.1-12.xenlinux.qubes.x86_64}-1.1.1-1.x86_64.rpm

View File

@ -1 +0,0 @@
../../xen/rpm/x86_64/xen-libs-3.4.3-3.qubes.x86_64.rpm

View File

@ -1 +0,0 @@
../../xen/rpm/x86_64/xen-qubes-vm-essentials-3.4.3-3.qubes.x86_64.rpm

View File

@ -0,0 +1 @@
../../core/rpm/x86_64/qubes-core-commonvm-1.3.13-1.x86_64.rpm

View File

@ -0,0 +1 @@
../../core/rpm/x86_64/qubes-core-netvm-1.3.13-1.x86_64.rpm

View File

@ -0,0 +1 @@
../../core/rpm/x86_64/qubes-core-proxyvm-1.3.13-1.x86_64.rpm

View File

@ -0,0 +1 @@
../../gui/rpm/x86_64/qubes-gui-vm-1.1.13-1.x86_64.rpm

View File

@ -0,0 +1 @@
../../xen/rpm/x86_64/xen-libs-3.4.3-5.qubes.x86_64.rpm

View File

@ -0,0 +1 @@
../../xen/rpm/x86_64/xen-qubes-vm-essentials-3.4.3-5.qubes.x86_64.rpm

View File

@ -41,6 +41,7 @@ touch $RPM_BUILD_ROOT/%{dest_dir}/root.img # we will create the real file in %po
touch $RPM_BUILD_ROOT/%{dest_dir}/private.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/appvm-template.conf $RPM_BUILD_ROOT/%{dest_dir}/appvm-template.conf
cp vm_conf_files/netvm-template.conf $RPM_BUILD_ROOT/%{dest_dir}/netvm-template.conf
cp vm_conf_files/templatevm.conf $RPM_BUILD_ROOT/%{dest_dir}/templatevm.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 >\ sed -e s/%TEMPLATENAME%/%{template_name}/ < vm_conf_files/templatevm.conf >\
$RPM_BUILD_ROOT/%{dest_dir}/%{template_name}.conf $RPM_BUILD_ROOT/%{dest_dir}/%{template_name}.conf
@ -48,8 +49,8 @@ sed -e s/%TEMPLATENAME%/%{template_name}/ < vm_conf_files/templatevm.conf >\
cp vm_conf_files/dispvm-prerun.sh $RPM_BUILD_ROOT/%{dest_dir}/ cp vm_conf_files/dispvm-prerun.sh $RPM_BUILD_ROOT/%{dest_dir}/
mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/kernels mkdir -p $RPM_BUILD_ROOT/%{dest_dir}/kernels
cp vm_kernels_appvm/vmlinuz $RPM_BUILD_ROOT/%{dest_dir}/kernels/vmlinuz cp vm_kernels/vmlinuz $RPM_BUILD_ROOT/%{dest_dir}/kernels/vmlinuz
cp vm_kernels_appvm/initramfs $RPM_BUILD_ROOT/%{dest_dir}/kernels/initramfs cp vm_kernels/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 cp vm_initramfs_patches/qubes_cow_setup.sh $RPM_BUILD_ROOT/%{dest_dir}/kernels/qubes_cow_setup.sh
@ -101,6 +102,8 @@ fi
echo "--> Recreating VM conf files..." echo "--> Recreating VM conf files..."
/usr/lib/qubes/reset_vm_configs.py %{template_name} /usr/lib/qubes/reset_vm_configs.py %{template_name}
qvm-template-commit %{template_name}
%preun %preun
if [ "$1" = 0 ] ; then if [ "$1" = 0 ] ; then
# no more packages left # no more packages left
@ -125,6 +128,7 @@ rm -rf $RPM_BUILD_ROOT
%{dest_dir}/root.img.part.* %{dest_dir}/root.img.part.*
%ghost %{dest_dir}/private.img %ghost %{dest_dir}/private.img
%{dest_dir}/appvm-template.conf %{dest_dir}/appvm-template.conf
%{dest_dir}/netvm-template.conf
%{dest_dir}/templatevm.conf %{dest_dir}/templatevm.conf
%{dest_dir}/%{template_name}.conf %{dest_dir}/%{template_name}.conf
%{dest_dir}/dispvm-prerun.sh %{dest_dir}/dispvm-prerun.sh

View File

@ -1 +0,0 @@
1.1.6b

View File

@ -0,0 +1,25 @@
#
# This is a Xen VM config file for AppVMs
#
kernel="%TEMPLATEDIR%/kernels/vmlinuz"
ramdisk="%TEMPLATEDIR%/kernels/initramfs"
extra="ro nomodeset xencons=hvc swiotlb=force pci=nomsird_NO_PLYMOUTH 3"
root="/dev/mapper/dmroot"
memory = 400
name = "%VMNAME%"
pci = [ %PCIDEVS% ]
disk = [ 'snapshot:%TEMPLATEDIR%/root.img:%TEMPLATEDIR%/root-cow.img,xvda,r',
'file:%VMDIR%/private.img,xvdb,w',
'file:%VMDIR%/root-cow.img,xvdc,w',
'file:%VMDIR%/swap-cow.img,xvdd,w'
]
vcpus = 1
on_poweroff = 'destroy'
on_reboot = 'destroy'
on_crash = 'destroy'

View File

@ -1,21 +0,0 @@
#
# This is a Xen VM config file for the netvm
#
kernel="/var/lib/qubes/servicevms/%NETVMNAME%/kernels/vmlinuz"
ramdisk="/var/lib/qubes/servicevms/%NETVMNAME%/kernels/initramfs"
extra="ro nomodeset xencons=hvc swiotlb=force rd_NO_PLYMOUTH 3 pci=nomsi"
root="/dev/mapper/dmroot"
memory = 200
name = "%NETVMNAME%"
pci = [ %NETVMPCIDEVS% ]
disk = [ 'file:/var/lib/qubes/servicevms/%NETVMNAME%/root.img,xvda,w',
]
vcpus = 1
on_poweroff = 'destroy'
on_reboot = 'destroy'
on_crash = 'destroy'

1
vm_kernels Symbolic link
View File

@ -0,0 +1 @@
vm_kernels_x64

View File

@ -1 +0,0 @@
vm_kernels_appvm_x64/

View File

@ -1 +0,0 @@
vm_kernels_netvm_x64/

View File

@ -1,2 +0,0 @@
initramfs-*
vmlinuz-*

View File

@ -1 +0,0 @@
initramfs-2.6.34.1-12.xenlinux.qubes.x86_64.qubeized.img

View File

@ -1 +0,0 @@
vmlinuz-2.6.34.1-12.xenlinux.qubes.x86_64