summaryrefslogtreecommitdiffstats
path: root/py
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2009-08-11 16:58:49 -0500
committerClark Williams <williams@redhat.com>2009-11-09 13:23:33 -0600
commit725e8dd67a14cdec821dbd74df4467d9a76558c7 (patch)
tree0b6e69d1178507c02ac4bc7edcd9fc5a8e24719c /py
parentdb7deeb7ac09639ad8cf25011e10b4845ab0e3dd (diff)
downloadmock-725e8dd67a14cdec821dbd74df4467d9a76558c7.tar.gz
mock-725e8dd67a14cdec821dbd74df4467d9a76558c7.tar.xz
mock-725e8dd67a14cdec821dbd74df4467d9a76558c7.zip
conditionalize import of uuid package and avoid dependent code if
import fails (as it will on RHEL5)
Diffstat (limited to 'py')
-rw-r--r--py/mock/backend.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/py/mock/backend.py b/py/mock/backend.py
index 64d7455..3f60a08 100644
--- a/py/mock/backend.py
+++ b/py/mock/backend.py
@@ -13,8 +13,13 @@ import logging
import os
import shutil
import stat
-import uuid
import grp
+try:
+ import uuid
+ gotuuid = True
+except:
+ gotuuid = False
+
# our imports
import mock.util
@@ -244,14 +249,15 @@ class Root(object):
os.remove(hostspath)
shutil.copy2('/etc/hosts', etcdir)
- # Anything that tries to use libdbus inside the chroot will require this
- # FIXME - merge this code with other OS-image building code
- machine_uuid = uuid.uuid4().hex
- dbus_uuid_path = self.makeChrootPath('var', 'lib', 'dbus', 'machine-id')
- f = open(dbus_uuid_path, 'w')
- f.write(machine_uuid)
- f.write('\n')
- f.close()
+ if gotuuid:
+ # Anything that tries to use libdbus inside the chroot will require this
+ # FIXME - merge this code with other OS-image building code
+ machine_uuid = uuid.uuid4().hex
+ dbus_uuid_path = self.makeChrootPath('var', 'lib', 'dbus', 'machine-id')
+ f = open(dbus_uuid_path, 'w')
+ f.write(machine_uuid)
+ f.write('\n')
+ f.close()
# files in /etc that need doing
for key in self.chroot_file_contents: