import errno
import os, os.path
import sys
-import tempfile
import shutil
import re
from datetime import datetime
import gzip
+import gbp.tmpfile as tempfile
import gbp.rpm as rpm
from gbp.rpm.policy import RpmPkgPolicy
from gbp.command_wrappers import (Command,
from gbp.scripts.pq_rpm import update_patch_series
-def git_archive(repo, spec, output_dir, treeish, prefix, comp_level, with_submodules):
+def git_archive(repo, spec, output_dir, tmpdir_base, treeish, prefix,
+ comp_level, with_submodules):
"create a compressed orig tarball in output_dir using git_archive"
comp_opts = ''
if spec.orig_src['compression']:
try:
if repo.has_submodules() and with_submodules:
repo.update_submodules()
- git_archive_submodules(repo, treeish, output, prefix,
- spec.orig_src['compression'], comp_level, comp_opts,
+ git_archive_submodules(repo, treeish, output, tmpdir_base,
+ prefix, spec.orig_src['compression'],
+ comp_level, comp_opts,
spec.orig_src['archive_fmt'])
else:
if spec.orig_src['compression']:
gbp.log.debug("Building upstream source archive with compression '%s -%s'" %
(spec.orig_src['compression'], options.comp_level))
- if not git_archive(repo, spec, output_dir, upstream_tree,
+ if not git_archive(repo, spec, output_dir, options.tmp_dir, upstream_tree,
options.orig_prefix,
options.comp_level,
options.with_submodules):
parser.add_boolean_config_file_option(option_name = "ignore-new", dest="ignore_new")
parser.add_option("--git-verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
+ parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
parser.add_config_file_option(option_name="notify", dest="notify", type='tristate')
parser.add_config_file_option(option_name="vendor", action="store", dest="vendor")
retval = 0
prefix = "git-"
spec = None
- dump_dir = None
options, gbp_args, builder_args = parse_args(argv, prefix)
if not options:
repo_dir = os.path.abspath(os.path.curdir)
try:
+ # Create base temporary directory for this run
+ options.tmp_dir = tempfile.mkdtemp(dir=options.tmp_dir,
+ prefix='buildpackage-rpm_')
+ except GbpError, err:
+ gbp.log.err(err)
+ return 1
+
+ try:
branch = repo.get_branch()
except GitRepositoryError:
branch = None
raise GbpError('Invalid treeish object %s' % tree)
# Dump from git to a temporary directory:
- dump_dir = tempfile.mkdtemp(dir=".")
+ dump_dir = tempfile.mkdtemp(dir=options.tmp_dir,
+ prefix='dump_tree_')
gbp.log.debug("Dumping tree '%s' to '%s'" % (options.export, dump_dir))
if not dump_tree(repo, dump_dir, tree, options.with_submodules):
raise GbpError
gbp.log.info("Creating (native) source archive %s from '%s'" % (spec.orig_src['filename'], tree))
if spec.orig_src['compression']:
gbp.log.debug("Building source archive with compression '%s -%s'" % (spec.orig_src['compression'], options.comp_level))
- if not git_archive(repo, spec, source_dir, tree, options.orig_prefix,
- options.comp_level, options.with_submodules):
+ if not git_archive(repo, spec, source_dir, options.tmp_dir,
+ tree, options.orig_prefix,
+ options.comp_level,
+ options.with_submodules):
raise GbpError, "Cannot create source tarball at '%s'" % export_dir
# Non-native packages: create orig tarball from upstream
elif spec.orig_src:
retval = 1
finally:
drop_index(repo)
-
- # Clean temporary dumpdir
- if dump_dir and retval == 0:
- shutil.rmtree(dump_dir)
+ shutil.rmtree(options.tmp_dir)
if not options.tag_only:
if spec and options.notify:
import ConfigParser
import os
import sys
-import tempfile
+import gbp.tmpfile as tempfile
import gbp.command_wrappers as gbpc
import string
from gbp.pkg import parse_archive_filename
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
+ parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
(options, args) = parser.parse_args(argv[1:])
gbp.log.setup(options.color, options.verbose)
if not options:
return 1
- tmpdir = tempfile.mkdtemp(dir='../')
+ tmpdir = tempfile.mkdtemp(dir=options.tmp_dir, prefix='import-orig-rpm_')
try:
source = find_source(options, args)
try:
import os
import shutil
import sys
-import tempfile
import re
import gzip
import subprocess
+import gbp.tmpfile as tempfile
from gbp.config import (GbpOptionParserRpm, GbpOptionGroup)
from gbp.rpm.git import (GitRepositoryError, RpmGitRepository)
from gbp.git.modifier import GitModifier, GitTz
@rtype: tuple
"""
- tmpdir = tempfile.mkdtemp(dir=tmpdir_base, prefix='gbp-pq')
+ tmpdir = tempfile.mkdtemp(dir=tmpdir_base, prefix='patchimport_')
safequeue=PatchSeries()
if len(queue) > 0:
queue = spec.patchseries()
packager = get_packager(spec)
# Put patches in a safe place
- tmpdir, queue = safe_patches(queue, repo.path)
+ tmpdir, queue = safe_patches(queue, options.tmp_dir)
for commit in commits:
try:
gbp.log.info("Trying to apply patches at '%s'" % commit)
else:
raise GbpError, "Couldn't apply patches"
- if tmpdir:
- gbp.log.debug("Remove temporary patch safe '%s'" % tmpdir)
- shutil.rmtree(tmpdir)
-
repo.set_branch(branch)
return os.path.basename(spec.specfile)
help="In case of import even import if the branch already exists")
parser.add_config_file_option(option_name="vendor", action="store", dest="vendor")
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
+ parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
parser.add_config_file_option(option_name="spec-file", dest="spec_file")
parser.add_config_file_option(option_name="packaging-dir", dest="packaging_dir")
os.chdir(repo.path)
try:
+ # Create base temporary directory for this run
+ options.tmp_dir = tempfile.mkdtemp(dir=options.tmp_dir,
+ prefix='gbp-pq-rpm_')
current = repo.get_branch()
if action == "export":
export_patches(repo, current, options)
if len(err.__str__()):
gbp.log.err(err)
retval = 1
+ finally:
+ shutil.rmtree(options.tmp_dir, ignore_errors=True)
return retval