Create appmenus not only for AppVM (#225)

Needed also by TemplateVM, and maybe others (service VMs)
For TemplateVM uses separate appmenus template (apps-template.templates).
This commit is contained in:
Marek Marczykowski 2011-04-19 13:38:24 +02:00
parent ec3f427988
commit 1e53115eab
2 changed files with 37 additions and 17 deletions

View File

@ -22,11 +22,15 @@
SRCDIR=$1 SRCDIR=$1
VMNAME=$2 VMNAME=$2
VMDIR=/var/lib/qubes/appvms/$VMNAME VMTYPE=$3
if [ -z "$VMTYPE" ]; then
VMTYPE=appvms
fi
VMDIR=/var/lib/qubes/$VMTYPE/$VMNAME
APPSDIR=$VMDIR/apps APPSDIR=$VMDIR/apps
if [ $# != 2 ]; then if [ $# -lt 2 ]; then
echo "usage: $0 <apps_templates_dir> <vmname>" echo "usage: $0 <apps_templates_dir> <vmname> [appvms|vm-templates|servicevms]"
exit exit
fi fi
mkdir -p $APPSDIR mkdir -p $APPSDIR

View File

@ -679,6 +679,19 @@ class QubesVm(object):
# Create volatile.img # Create volatile.img
self.reset_volatile_storage(source_template = source_template) self.reset_volatile_storage(source_template = source_template)
def create_appmenus(self, verbose, source_template = None):
if source_template is None:
source_template = self.template_vm
try:
if source_template is not None:
subprocess.check_call ([qubes_appmenu_create_cmd, source_template.appmenus_templates_dir, self.name])
else:
# Only add apps to menu
subprocess.check_call ([qubes_appmenu_create_cmd, "none", self.name, vmtype])
except subprocess.CalledProcessError:
print "Ooops, there was a problem creating appmenus for {0} VM!".format (self.name)
def verify_files(self): def verify_files(self):
if dry_run: if dry_run:
return return
@ -1126,13 +1139,29 @@ class QubesTemplateVm(QubesVm):
shutil.copytree (src_template_vm.kernels_dir, self.kernels_dir) shutil.copytree (src_template_vm.kernels_dir, self.kernels_dir)
if verbose: if verbose:
print "--> Copying the template's appvm templates dir:\n{0} ==>\n{1}".\ print "--> Copying the template's appmenus templates dir:\n{0} ==>\n{1}".\
format(src_template_vm.appmenus_templates_dir, self.appmenus_templates_dir) format(src_template_vm.appmenus_templates_dir, self.appmenus_templates_dir)
shutil.copytree (src_template_vm.appmenus_templates_dir, self.appmenus_templates_dir) shutil.copytree (src_template_vm.appmenus_templates_dir, self.appmenus_templates_dir)
# Create root-cow.img # Create root-cow.img
self.commit_changes() self.commit_changes()
# Create appmenus
self.create_appmenus(verbose, source_template = self)
def create_appmenus(self, verbose, source_template = None):
if source_template is None:
source_template = self.template_vm
try:
if source_template is not None:
subprocess.check_call ([qubes_appmenu_create_cmd, source_template.dir_path + "/apps-template.templates", self.name, "vm-templates"])
else:
# Only add apps to menu
subprocess.check_call ([qubes_appmenu_create_cmd, "none", self.name, vmtype])
except subprocess.CalledProcessError:
print "Ooops, there was a problem creating appmenus for {0} VM!".format (self.name)
def verify_files(self): def verify_files(self):
if dry_run: if dry_run:
return return
@ -1605,19 +1634,6 @@ class QubesAppVm(QubesVm):
subprocess.check_call ([qubes_appmenu_remove_cmd, self.name]) subprocess.check_call ([qubes_appmenu_remove_cmd, self.name])
super(QubesAppVm, self).remove_from_disk() super(QubesAppVm, self).remove_from_disk()
def create_appmenus(self, verbose, source_template = None):
if source_template is None:
source_template = self.template_vm
try:
if source_template is not None:
subprocess.check_call ([qubes_appmenu_create_cmd, source_template.appmenus_templates_dir, self.name])
else:
# Only add apps to menu
subprocess.check_call ([qubes_appmenu_create_cmd, "none", self.name])
except subprocess.CalledProcessError:
print "Ooops, there was a problem creating appmenus for {0} VM!".format (self.name)
class QubesVmCollection(dict): class QubesVmCollection(dict):
""" """