summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gbp/config.py4
-rwxr-xr-xgbp/scripts/buildpackage.py10
-rw-r--r--gbp/scripts/common/buildpackage.py8
-rw-r--r--gbp/scripts/import_dsc.py14
-rw-r--r--gbp/scripts/import_orig.py6
-rwxr-xr-xgbp/scripts/pq.py9
-rw-r--r--tests/04_test_submodules.py8
7 files changed, 36 insertions, 23 deletions
diff --git a/gbp/config.py b/gbp/config.py
index 228c67c4..b275ab56 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -162,6 +162,7 @@ class GbpOptionParser(OptionParser):
'purge': 'True',
'drop': 'False',
'commit': 'False',
+ 'tmp-dir' : '/var/tmp/gbp/',
}
help = {
'debian-branch':
@@ -310,6 +311,9 @@ class GbpOptionParser(OptionParser):
"after export. Default is '%(drop)s'"),
'commit':
"commit changes after export, Default is '%(commit)s'",
+ 'tmp-dir':
+ ("Base directory under which temporary directories are "
+ "created, default is '%(tmp-dir)s'"),
}
def_config_files = [ '/etc/git-buildpackage/gbp.conf',
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 415ba031..b65f375c 100755
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -41,7 +41,8 @@ from gbp.scripts.common.buildpackage import (index_name, wc_names,
write_wc, drop_index)
from gbp.pkg import compressor_opts, compressor_aliases, parse_archive_filename
-def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules):
+def git_archive(repo, cp, output_dir, tmpdir_base, treeish, comp_type,
+ comp_level, with_submodules):
"create a compressed orig tarball in output_dir using git_archive"
try:
comp_opts = compressor_opts[comp_type][0]
@@ -54,8 +55,8 @@ def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submo
try:
if repo.has_submodules() and with_submodules:
repo.update_submodules()
- git_archive_submodules(repo, treeish, output, prefix,
- comp_type, comp_level, comp_opts)
+ git_archive_submodules(repo, treeish, output, tmpdir_base,
+ prefix, comp_type, comp_level, comp_opts)
else:
git_archive_single(repo, treeish, output, prefix,
@@ -279,7 +280,7 @@ def git_archive_build_orig(repo, cp, output_dir, options):
upstream_tree))
gbp.log.debug("Building upstream tarball with compression '%s -%s'" %
(options.comp_type, options.comp_level))
- if not git_archive(repo, cp, output_dir, upstream_tree,
+ if not git_archive(repo, cp, output_dir, options.tmp_dir, upstream_tree,
options.comp_type,
options.comp_level,
options.with_submodules):
@@ -405,6 +406,7 @@ def build_parser(name, prefix=None):
parser.add_config_file_option(option_name="color-scheme",
dest="color_scheme")
parser.add_config_file_option(option_name="notify", dest="notify", type='tristate')
+ parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
tag_group.add_option("--git-tag", action="store_true", dest="tag", default=False,
help="create a tag after a successful build")
tag_group.add_option("--git-tag-only", action="store_true", dest="tag_only", default=False,
diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py
index 303adaea..670f6823 100644
--- a/gbp/scripts/common/buildpackage.py
+++ b/gbp/scripts/common/buildpackage.py
@@ -19,10 +19,10 @@
"""Common functionality for Debian and RPM buildpackage scripts"""
import os, os.path
-import tempfile
import subprocess
import shutil
+import gbp.tmpfile as tempfile
from gbp.command_wrappers import (CatenateTarArchive, CatenateZipArchive)
from gbp.git.repository import GitRepository, GitRepositoryError
from gbp.errors import GbpError
@@ -74,8 +74,8 @@ def compress(cmd, options, output, input_data=None):
raise GbpError("Error creating %s: %s" % (output, err))
-def git_archive_submodules(repo, treeish, output, prefix, comp_type, comp_level,
- comp_opts, format='tar'):
+def git_archive_submodules(repo, treeish, output, tmpdir_base, prefix,
+ comp_type, comp_level, comp_opts, format='tar'):
"""
Create a source tree archive with submodules.
@@ -85,7 +85,7 @@ def git_archive_submodules(repo, treeish, output, prefix, comp_type, comp_level,
Exception handling is left to the caller.
"""
prefix = sanitize_prefix(prefix)
- tempdir = tempfile.mkdtemp()
+ tempdir = tempfile.mkdtemp(dir=tmpdir_base, prefix='git-archive_')
main_archive = os.path.join(tempdir, "main.%s" % format)
submodule_archive = os.path.join(tempdir, "submodule.%s" % format)
try:
diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py
index f1416d9f..304494f0 100644
--- a/gbp/scripts/import_dsc.py
+++ b/gbp/scripts/import_dsc.py
@@ -21,10 +21,10 @@ import sys
import re
import os
import shutil
-import tempfile
import glob
import pipes
import time
+import gbp.tmpfile as tempfile
import gbp.command_wrappers as gbpc
from gbp.deb.dscfile import DscFile
from gbp.deb.upstreamsource import DebianUpstreamSource
@@ -41,7 +41,7 @@ class SkipImport(Exception):
pass
-def download_source(pkg, dirs, unauth):
+def download_source(pkg, dirs, unauth, tmpdir_base):
opts = [ '--download-only' ]
if unauth:
opts.append('--allow-unauthenticated')
@@ -53,7 +53,8 @@ def download_source(pkg, dirs, unauth):
cmd = 'apt-get'
opts += ['-qq', 'source', pkg]
- dirs['download'] = os.path.abspath(tempfile.mkdtemp())
+ dirs['download'] = tempfile.mkdtemp(dir=tmpdir_base,
+ prefix='import-dsc_download_')
gbp.log.info("Downloading '%s' using '%s'..." % (pkg, cmd))
gbpc.RunAtCommand(cmd, opts, shell=False)(dir=dirs['download'])
@@ -227,6 +228,7 @@ def build_parser(name):
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
parser.add_config_file_option(option_name="color-scheme",
dest="color_scheme")
+ parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
parser.add_option("--download", action="store_true", dest="download", default=False,
help="download source package")
branch_group.add_config_file_option(option_name="debian-branch",
@@ -295,7 +297,8 @@ def main(argv):
if options.download:
dsc = download_source(pkg,
dirs=dirs,
- unauth=options.allow_unauthenticated)
+ unauth=options.allow_unauthenticated,
+ tmpdir_base=options.tmp_dir)
else:
dsc = pkg
@@ -327,7 +330,8 @@ def main(argv):
if repo.bare:
set_bare_repo_options(options)
- dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='..'))
+ dirs['tmp'] = tempfile.mkdtemp(dir=options.tmp_dir,
+ prefix='import-dsc_')
upstream = DebianUpstreamSource(src.tgz)
upstream = upstream.unpack(dirs['tmp'], options.filters)
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index 12134b74..901a5235 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -20,7 +20,7 @@
import ConfigParser
import os
import sys
-import tempfile
+import gbp.tmpfile as tempfile
import gbp.command_wrappers as gbpc
from gbp.deb import (DebianPkgPolicy, parse_changelog_repo)
from gbp.deb.upstreamsource import DebianUpstreamSource
@@ -200,6 +200,7 @@ def build_parser(name):
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
parser.add_config_file_option(option_name="color-scheme",
dest="color_scheme")
+ parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
# Accepted for compatibility
parser.add_option("--no-dch", dest='no_dch', action="store_true",
@@ -225,12 +226,13 @@ def parse_args(argv):
def main(argv):
ret = 0
- tmpdir = tempfile.mkdtemp(dir='../')
(options, args) = parse_args(argv)
if not options:
return 1
+ tmpdir = tempfile.mkdtemp(dir=options.tmp_dir, prefix='import-orig_')
+
try:
source = find_source(options.uscan, args)
if not source:
diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py
index 515c48aa..14214311 100755
--- a/gbp/scripts/pq.py
+++ b/gbp/scripts/pq.py
@@ -22,8 +22,8 @@ import errno
import os
import shutil
import sys
-import tempfile
import re
+import gbp.tmpfile as tempfile
from gbp.config import GbpOptionParserDebian
from gbp.git import (GitRepositoryError, GitRepository)
from gbp.command_wrappers import (GitCommand, CommandExecFailed)
@@ -196,7 +196,7 @@ def export_patches(repo, branch, options):
drop_pq(repo, branch)
-def safe_patches(series):
+def safe_patches(series, tmpdir_base):
"""
Safe the current patches in a temporary directory
below .git/
@@ -209,7 +209,7 @@ def safe_patches(series):
src = os.path.dirname(series)
name = os.path.basename(series)
- tmpdir = tempfile.mkdtemp(dir='.git/', prefix='gbp-pq')
+ tmpdir = tempfile.mkdtemp(dir=tmpdir_base, prefix='gbp-pq_')
patches = os.path.join(tmpdir, 'patches')
series = os.path.join(patches, name)
@@ -256,7 +256,7 @@ def import_quilt_patches(repo, branch, series, tries, force):
# If we go back in history we have to safe our pq so we always try to apply
# the latest one
if len(commits) > 1:
- tmpdir, series = safe_patches(series)
+ tmpdir, series = safe_patches(series, options.tmp_dir)
queue = PatchSeries.read_series_file(series)
@@ -343,6 +343,7 @@ def build_parser(name):
parser.add_config_file_option(option_name="color-scheme",
dest="color_scheme")
parser.add_config_file_option(option_name="meta-closes", dest="meta_closes")
+ parser.add_config_file_option(option_name="tmp-dir", dest="tmp_dir")
return parser
diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py
index 4b072201..1b45c86f 100644
--- a/tests/04_test_submodules.py
+++ b/tests/04_test_submodules.py
@@ -107,12 +107,12 @@ def test_create_tarballs():
"""Create an upstream tarball"""
# Tarball with submodules
changelog = { "Source": "test", "Upstream-Version": "0.1" }
- ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2",
- "9", True))
+ ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), str(TMPDIR),
+ "HEAD", "bzip2", "9", True))
# Tarball without submodules
changelog = { "Source": "test", "Upstream-Version": "0.2" }
- ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2",
- "9", False))
+ ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), str(TMPDIR),
+ "HEAD", "bzip2", "9", False))
def test_check_tarfiles():
"""Check the contents of the created tarfile"""