summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJF Ding <jian-feng.ding@intel.com>2012-05-02 15:05:43 +0800
committerJF Ding <jian-feng.ding@intel.com>2012-05-02 15:05:43 +0800
commit00ffa4193ed32bf1501fd3b819d9e4026b41cb74 (patch)
tree8138e49fe1b108332d4478c8c6814f83201a43cc /setup.py
parentd311fb0bef27f23938c35ea250b12988d8fc9e9d (diff)
downloadmic-00ffa4193ed32bf1501fd3b819d9e4026b41cb74.tar.gz
mic-00ffa4193ed32bf1501fd3b819d9e4026b41cb74.tar.bz2
mic-00ffa4193ed32bf1501fd3b819d9e4026b41cb74.zip
do not overwrite any existing mic.conf in setup.py
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/setup.py b/setup.py
index e4dee0f..1056554 100644
--- a/setup.py
+++ b/setup.py
@@ -70,17 +70,21 @@ for arg in sys.argv:
elif '--prefix' == arg:
is_next = True
-# expand the path, for user may type some unexcepted format
+# get the installation path of mic.conf
prefix = os.path.abspath(os.path.expanduser(prefix)).rstrip('/')
if prefix.lstrip('/') == 'usr':
etc_prefix = '/etc'
else:
etc_prefix = os.path.join(prefix, 'etc')
+conffile = 'distfiles/mic.conf'
+if os.path.isfile('%s/mic/mic.conf' % etc_prefix):
+ conffile += '.new'
+
# apply prefix to mic.conf.in to generate actual mic.conf
conf_str = file('distfiles/mic.conf.in').read()
conf_str = conf_str.replace('@PREFIX@', prefix)
-with file('distfiles/mic.conf', 'w') as wf:
+with file(conffile, 'w') as wf:
wf.write(conf_str)
try:
@@ -96,9 +100,9 @@ try:
packages = PACKAGES,
data_files = [("%s/lib/mic/plugins/imager" % prefix, IMAGER_PLUGINS),
("%s/lib/mic/plugins/backend" % prefix, BACKEND_PLUGINS),
- ("%s/mic" % etc_prefix, ["distfiles/mic.conf"])]
+ ("%s/mic" % etc_prefix, [conffile])]
)
finally:
# remove dynamic file distfiles/mic.conf
- os.unlink('distfiles/mic.conf')
+ os.unlink(conffile)