chiark / gitweb /
vmtools: in KVM mode, only call sudo hack when file is not readable
authorHans-Christoph Steiner <hans@eds.org>
Wed, 29 Nov 2017 19:04:18 +0000 (20:04 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 29 Nov 2017 20:06:35 +0000 (21:06 +0100)
fdroidserver/vmtools.py

index aae46c75cc8cfe44a093529a84d655c5e8163b60..aab7eb0daaff15b31570f8a5a096fbd34c10b7e8 100644 (file)
@@ -29,6 +29,8 @@ import textwrap
 from .common import FDroidException
 from logging import getLogger
 
+from fdroidserver import _
+
 logger = getLogger('fdroidserver-vmtools')
 
 
@@ -383,7 +385,9 @@ class LibvirtBuildVm(FDroidBuildVm):
             vol = storagePool.storageVolLookupByName(self.srvname + '.img')
             imagepath = vol.path()
             # TODO use a libvirt storage pool to ensure the img file is readable
-            _check_call(['sudo', '/bin/chmod', '-R', 'a+rX', '/var/lib/libvirt/images'])
+            if not os.access(imagepath, os.R_OK):
+                logger.warning(_('Cannot read "{path}"!').format(path=imagepath))
+                _check_call(['sudo', '/bin/chmod', '-R', 'a+rX', '/var/lib/libvirt/images'])
             shutil.copy2(imagepath, 'box.img')
             _check_call(['qemu-img', 'rebase', '-p', '-b', '', 'box.img'])
             img_info_raw = _check_output(['qemu-img', 'info', '--output=json', 'box.img'])