Use proper temp directories to build.

This commit is contained in:
Devan Goodwin 2011-11-25 11:31:21 -04:00
parent 8246ec2b79
commit 2703e77cac
2 changed files with 6 additions and 8 deletions

View file

@ -20,6 +20,7 @@ import re
import commands import commands
from pkg_resources import require from pkg_resources import require
from distutils.version import LooseVersion as loose_version from distutils.version import LooseVersion as loose_version
from tempfile import mkdtemp
from tito.common import * from tito.common import *
from tito.release import * from tito.release import *
@ -124,11 +125,9 @@ class Builder(object):
self.tgz_dir = tgz_base self.tgz_dir = tgz_base
self.artifacts = [] self.artifacts = []
temp_dir = "rpmbuild-%s" % self.project_name_and_sha1 self.rpmbuild_dir = mkdtemp(dir=self.rpmbuild_basedir,
self.rpmbuild_dir = os.path.join(self.rpmbuild_basedir, temp_dir) prefix="rpmbuild-%s" % self.project_name_and_sha1)
if os.path.exists(self.rpmbuild_dir): debug("Building in temp dir: %s" % self.rpmbuild_dir)
print("WARNING: rpmbuild directory already exists, removing...")
run_command("rm -rf self.rpmbuild_dir")
self.rpmbuild_sourcedir = os.path.join(self.rpmbuild_dir, "SOURCES") self.rpmbuild_sourcedir = os.path.join(self.rpmbuild_dir, "SOURCES")
self.rpmbuild_builddir = os.path.join(self.rpmbuild_dir, "BUILD") self.rpmbuild_builddir = os.path.join(self.rpmbuild_dir, "BUILD")
@ -363,7 +362,7 @@ class Builder(object):
debug("Cleaning up [%s]" % self.rpmbuild_dir) debug("Cleaning up [%s]" % self.rpmbuild_dir)
commands.getoutput("rm -rf %s" % self.rpmbuild_dir) commands.getoutput("rm -rf %s" % self.rpmbuild_dir)
else: else:
print("Leaving rpmbuild files in: %s" % self.rpmbuild_dir) print("WARNING: Leaving rpmbuild files in: %s" % self.rpmbuild_dir)
def _check_build_dirs_access(self): def _check_build_dirs_access(self):
""" """

View file

@ -22,7 +22,6 @@ import tempfile
import subprocess import subprocess
from tempfile import mkdtemp from tempfile import mkdtemp
from shutil import rmtree, copy
from tito.common import * from tito.common import *
from tito.exception import TitoException from tito.exception import TitoException
@ -268,7 +267,7 @@ class YumRepoReleaser(Releaser):
os.environ[RSYNC_USERNAME])) os.environ[RSYNC_USERNAME]))
rsync_location = "%s@%s" % (os.environ[RSYNC_USERNAME], rsync_location) rsync_location = "%s@%s" % (os.environ[RSYNC_USERNAME], rsync_location)
# Make a temp directory to sync the existing repo contents into: # Make a temp directory to sync the existing repo contents into:
yum_temp_dir = mkdtemp(dir=self.build_dir, prefix="tito-yumrepo-") yum_temp_dir = mkdtemp(dir=self.build_dir, prefix="yumrepo-")
print("Syncing yum repo: %s -> %s" % (rsync_location, yum_temp_dir)) print("Syncing yum repo: %s -> %s" % (rsync_location, yum_temp_dir))
output = run_command("rsync -avtz %s %s" % (rsync_location, yum_temp_dir)) output = run_command("rsync -avtz %s %s" % (rsync_location, yum_temp_dir))
debug(output) debug(output)