Exemplo n.º 1
0
 def test_guess_comp_type_no_pristine_tar_with_multiple_origs(self):
     open(self.tmpdir.join('source_1.2.orig.tar.gz'), "w").close()
     open(self.tmpdir.join('source_1.2.orig.tar.xz'), "w").close()
     repo = MockGitRepository(with_branch=False)
     with self.assertRaises(GbpError):
         export_orig.guess_comp_type('auto', self.source, repo,
                                     str(self.tmpdir))
Exemplo n.º 2
0
def overlay_extract_origs(source, tarball_dir, dest_dir, options):
    """Overlay extract orig tarballs to export dir before exporting debian dir from git"""

    comp_type = guess_comp_type(options.comp_type,
                                source,
                                repo=None,
                                tarball_dir=tarball_dir)
    tarball = os.path.join(tarball_dir,
                           source.upstream_tarball_name(comp_type))
    gbp.log.info("Extracting '%s' to '%s'" %
                 (os.path.basename(tarball), dest_dir))

    move_old_export(dest_dir)
    upstream = DebianUpstreamSource(tarball)
    upstream.unpack(dest_dir)

    # Check if tarball extracts into a single folder:
    if upstream.unpacked != dest_dir:
        # If it extracts a single folder, move its contents to dest_dir:
        gbp.log.debug("Moving %s to %s" % (upstream.unpacked, dest_dir))
        tmpdir = dest_dir + '.new'
        os.rename(upstream.unpacked, tmpdir)
        os.rmdir(dest_dir)
        os.rename(tmpdir, dest_dir)

    # Remove debian/ from unpacked upstream tarball in case of non 1.0 format
    underlay_debian_dir = os.path.join(dest_dir, 'debian')
    format_file = os.path.join('debian', 'source', 'format')
    if os.path.exists(underlay_debian_dir) and os.path.exists(format_file):
        format = DebianSourceFormat.parse_file(format_file)
        if format.version in ['2.0', '3.0']:
            gbp.log.info("Removing debian/ from unpacked upstream "
                         "source at %s" % underlay_debian_dir)
            shutil.rmtree(underlay_debian_dir)

    # Unpack additional tarballs
    for c in options.components:
        tarball = DebianAdditionalTarball(os.path.join(
            tarball_dir, source.upstream_tarball_name(comp_type, component=c)),
                                          component=c)
        gbp.log.info("Extracting '%s' to '%s/%s'" %
                     (os.path.basename(tarball.path), dest_dir, c))
        tarball.unpack(dest_dir, [])
Exemplo n.º 3
0
def overlay_extract_origs(source, tarball_dir, dest_dir, options):
    """Overlay extract orig tarballs to export dir before exporting debian dir from git"""

    comp_type = guess_comp_type(options.comp_type,
                                source,
                                repo=None,
                                tarball_dir=tarball_dir)
    tarball = os.path.join(tarball_dir, source.upstream_tarball_name(comp_type))
    gbp.log.info("Extracting '%s' to '%s'" % (os.path.basename(tarball), dest_dir))

    move_old_export(dest_dir)
    upstream = DebianUpstreamSource(tarball)
    upstream.unpack(dest_dir)

    # Check if tarball extracts into a single folder:
    if upstream.unpacked != dest_dir:
        # If it extracts a single folder, move its contents to dest_dir:
        gbp.log.debug("Moving %s to %s" % (upstream.unpacked, dest_dir))
        tmpdir = dest_dir + '.new'
        os.rename(upstream.unpacked, tmpdir)
        os.rmdir(dest_dir)
        os.rename(tmpdir, dest_dir)

    # Remove debian/ from unpacked upstream tarball in case of non 1.0 format
    underlay_debian_dir = os.path.join(dest_dir, 'debian')
    format_file = os.path.join('debian', 'source', 'format')
    if os.path.exists(underlay_debian_dir) and os.path.exists(format_file):
        format = DebianSourceFormat.parse_file(format_file)
        if format.version in ['2.0', '3.0']:
            gbp.log.info("Removing debian/ from unpacked upstream "
                         "source at %s" % underlay_debian_dir)
            shutil.rmtree(underlay_debian_dir)

    # Unpack additional tarballs
    for c in options.components:
        tarball = os.path.join(tarball_dir, source.upstream_tarball_name(
            comp_type, component=c))
        gbp.log.info("Extracting '%s' to '%s/%s'" % (os.path.basename(tarball), dest_dir, c))
        unpack_component_tarball(dest_dir, c, tarball, [])
Exemplo n.º 4
0
 def test_guess_comp_type_auto_bzip2(self):
     subject = 'pristine-tar data for source_1.2-3.orig.tar.bz2'
     repo = MockGitRepository(with_branch=True, subject=subject)
     guessed = export_orig.guess_comp_type('auto', self.source, repo,
                                           str(self.tmpdir))
     self.assertEqual("bzip2", guessed)
Exemplo n.º 5
0
 def test_guess_comp_type_no_pristine_tar_with_orig(self):
     open(self.tmpdir.join('source_1.2.orig.tar.bz2'), "w").close()
     repo = MockGitRepository(with_branch=False)
     guessed = export_orig.guess_comp_type('auto', self.source, repo,
                                           str(self.tmpdir))
     self.assertEqual('bzip2', guessed)
Exemplo n.º 6
0
 def test_guess_comp_type_no_pristine_tar_no_orig(self):
     repo = MockGitRepository(with_branch=False)
     guessed = export_orig.guess_comp_type('auto', self.source, repo,
                                           str(self.tmpdir))
     self.assertEqual('gzip', guessed)
Exemplo n.º 7
0
 def test_guess_comp_type_gz(self):
     repo = MockGitRepository(with_branch=False)
     guessed = export_orig.guess_comp_type('gz', self.source, repo, None)
     self.assertEqual("gzip", guessed)
Exemplo n.º 8
0
 def test_guess_comp_type_bz2(self):
     repo = MockGitRepository(with_branch=False)
     guessed = export_orig.guess_comp_type(repo, 'bz2', self.source, None)
     self.assertEqual("bzip2", guessed)
 def test_guess_comp_type_no_repo(self):
     guessed = export_orig.guess_comp_type('auto', self.source, None,
                                           str(self.tmpdir))
     self.assertEqual('gzip', guessed)
 def test_guess_comp_type_auto_bzip2(self):
     subject = 'pristine-tar data for source_1.2-3.orig.tar.bz2'
     repo = MockGitRepository(with_branch=True, subject=subject)
     guessed = export_orig.guess_comp_type(
         'auto', self.source, repo, str(self.tmpdir))
     self.assertEqual("bzip2", guessed)
 def test_guess_comp_type_no_pristine_tar_with_multiple_origs(self):
     open(self.tmpdir.join('source_1.2.orig.tar.gz'), "w").close()
     open(self.tmpdir.join('source_1.2.orig.tar.xz'), "w").close()
     repo = MockGitRepository(with_branch=False)
     with self.assertRaises(GbpError):
         export_orig.guess_comp_type('auto', self.source, repo, str(self.tmpdir))
 def test_guess_comp_type_no_pristine_tar_with_orig(self):
     open(self.tmpdir.join('source_1.2.orig.tar.bz2'), "w").close()
     repo = MockGitRepository(with_branch=False)
     guessed = export_orig.guess_comp_type(
         'auto', self.source, repo, str(self.tmpdir))
     self.assertEqual('bzip2', guessed)
 def test_guess_comp_type_no_pristine_tar_no_orig(self):
     repo = MockGitRepository(with_branch=False)
     guessed = export_orig.guess_comp_type(
         'auto', self.source, repo, str(self.tmpdir))
     self.assertEqual('gzip', guessed)
 def test_guess_comp_type_gz(self):
     repo = MockGitRepository(with_branch=False)
     guessed = export_orig.guess_comp_type(
         'gz', self.source, repo, None)
     self.assertEqual("gzip", guessed)