From 5088f91ab235fe85c881dcac2e87a1e828fc1752 Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Sat, 14 Sep 2013 20:54:06 -0400 Subject: Fixup directory and file installation code in jc_install Use mkpath to prevent failure if the path already exists. Write data to a temp file and call copy_file to install to avoid a race condition if with concurrent build processes. --- setup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index ec54b37..7aff539 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ from distutils.cmd import Command from distutils.command.build import build from distutils.command.install import install from distutils.command.sdist import sdist -import fileinput, os, subprocess, sys, unittest +import fileinput, os, subprocess, sys, tempfile, unittest class jc_build(build): @@ -87,10 +87,13 @@ class jc_install(install): elif arch in ['hpux']: defaults = '*= hp-jdk-bin' - os.mkdirs(self.root + '/usr/share/java-config-2/config/') - with open(self.root + '/usr/share/java-config-2/config/jdk-defaults.conf', 'w') as f: + with tempfile.NamedTemporaryFile(mode='w', delete=False) as f: f.write("# This files contain the default support jdk's\n") f.write(defaults + "\n") + confdir = self.root + '/usr/share/java-config-2/config/' + self.mkpath(confdir) + self.copy_file(f.name, confdir + 'jdk-defaults.conf', preserve_mode=0) + os.remove(f.name) class jc_sdist(sdist): -- cgit v1.2.3-65-gdbad