return None
-def has_orig(cp, compression, dir):
- "Check if orig.tar.gz exists in dir"
+def has_orig(orig_file, dir):
+ "Check if orig tarball exists in dir"
try:
- os.stat( os.path.join(dir, orig_file(cp, compression)) )
+ os.stat( os.path.join(dir, orig_file) )
except OSError:
return False
return True
else:
gbp.log.info("Orig tarball '%s' found at '%s'" % (orig_file, tarball_dir))
# build an orig unless the user forbids it, always build (and overwrite pre-existing) if user forces it
- if options.force_create or (not options.no_create_orig and not du.has_orig(cp, options.comp_type, output_dir)):
+ if options.force_create or (not options.no_create_orig and not du.has_orig(orig_file, output_dir)):
if not pristine_tar_build_orig(repo, cp, output_dir, options):
git_archive_build_orig(repo, cp, output_dir, options)
tarball_dir = '..'
detected = None
for comp in du.compressor_opts.keys():
- if du.has_orig(cp, comp, tarball_dir):
+ if du.has_orig(du.orig_file(cp, comp), tarball_dir):
if detected is not None:
raise GbpError, "Multiple orig tarballs found."
detected = comp
import unittest
from gbp.scripts import buildpackage
-from gbp.deb import has_orig
+from gbp.deb import (has_orig, orig_file)
from gbp.errors import GbpError
class MockGitRepository:
self.assertEqual("bzip2", guessed)
def test_has_orig_false(self):
- self.assertFalse(has_orig(self.cp, 'gzip', self.tmpdir))
+ self.assertFalse(has_orig(orig_file(self.cp, 'gzip'), self.tmpdir))
def test_has_orig_true(self):
open(os.path.join(self.tmpdir, 'source_1.2.orig.tar.gz'), "w").close()
- self.assertTrue(has_orig(self.cp, 'gzip', self.tmpdir))
+ self.assertTrue(has_orig(orig_file(self.cp, 'gzip'), self.tmpdir))
def test_guess_comp_type_bzip2(self):
repo = MockGitRepository(with_branch=False)