From 4ae720956d4d8aa7e7edd65f7b39a1d3e981db25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 30 Jul 2013 11:27:46 +0200 Subject: [PATCH] Use file copy instead of symlink on Windows --- core-modules/000QubesVm.py | 13 ++++++++++--- core-modules/01QubesHVm.py | 15 +++++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index ea48c3a1..fe20c133 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -392,8 +392,12 @@ class QubesVm(object): os.remove(self.icon_path) except: pass - os.symlink (new_label.icon_path, self.icon_path) - subprocess.call(['sudo', 'xdg-icon-resource', 'forceupdate']) + if hasattr(os, "symlink"): + os.symlink (new_label.icon_path, self.icon_path) + # FIXME: some os-independent wrapper? + subprocess.call(['sudo', 'xdg-icon-resource', 'forceupdate']) + else: + shutil.copy(new_label.icon_path, self.icon_path) # fire hooks for hook in self.hooks_label_setter: @@ -1106,7 +1110,10 @@ class QubesVm(object): if verbose: print >> sys.stderr, "--> Creating icon symlink: {0} -> {1}".format(self.icon_path, self.label.icon_path) - os.symlink (self.label.icon_path, self.icon_path) + if hasattr(os, "symlink"): + os.symlink (self.label.icon_path, self.icon_path) + else: + shutil.copy(self.label.icon_path, self.icon_path) # fire hooks for hook in self.hooks_create_on_disk: diff --git a/core-modules/01QubesHVm.py b/core-modules/01QubesHVm.py index 3a75f3e9..f8e417e0 100644 --- a/core-modules/01QubesHVm.py +++ b/core-modules/01QubesHVm.py @@ -29,6 +29,7 @@ import subprocess import stat import sys import re +import shutil import stat from qubes.qubes import QubesVm,register_qubes_vm_class,vmm,dry_run @@ -198,10 +199,6 @@ class QubesHVm(QubesVm): print >> sys.stderr, "--> Creating directory: {0}".format(self.dir_path) os.mkdir (self.dir_path) - if verbose: - print >> sys.stderr, "--> Creating icon symlink: {0} -> {1}".format(self.icon_path, self.label.icon_path) - os.symlink (self.label.icon_path, self.icon_path) - self.create_config_file() # create empty disk @@ -233,6 +230,16 @@ class QubesHVm(QubesVm): if retcode != 0: raise IOError ("Error while copying {0} to {1}".\ format(template_priv, self.private_img)) + if verbose: + print >> sys.stderr, "--> Creating icon symlink: {0} -> {1}".format(self.icon_path, self.label.icon_path) + + try: + if hasattr(os, "symlink"): + os.symlink (self.label.icon_path, self.icon_path) + else: + shutil.copy(self.label.icon_path, self.icon_path) + except Exception as e: + print >> sys.stderr, "WARNING: Failed to set VM icon: %s" % str(e) # fire hooks for hook in self.hooks_create_on_disk: