Example #1
0
    def test_update_component_tarballs(self):
        """
        Test importing new version with additional tarballs works
        """
        dsc = self._dsc('2.6-2')
        ok_(import_dsc(['arg0', '--pristine-tar', dsc]) == 0)
        repo = ComponentTestGitRepository(self.pkg)
        os.chdir(self.pkg)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'])

        # Import 2.8
        orig = self._orig('2.8', dir='dsc-3.0-additional-tarballs')
        ok_(import_orig(['arg0', '--component=foo', '--no-interactive', '--pristine-tar', orig]) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])
        self._check_component_tarballs(repo, ['foo/test1', 'foo/test2'])

        dsc = DscFile.parse(self._dsc('2.8-1', dir='dsc-3.0-additional-tarballs'))
        # Check if we can rebuild the upstream tarball and additional tarball
        ptars = [('hello-debhelper_2.8.orig.tar.gz', 'pristine-tar', '', dsc.tgz),
                 ('hello-debhelper_2.8.orig-foo.tar.gz', 'pristine-tar^', 'foo', dsc.additional_tarballs['foo'])]

        p = DebianPristineTar(repo)
        outdir = os.path.abspath('.')
        for f, w, s, o in ptars:
            eq_(repo.get_subject(w), 'pristine-tar data for %s' % f)
            old = self.hash_file(o)
            p.checkout('hello-debhelper', '2.8', 'gzip', outdir, component=s)
            out = os.path.join(outdir, f)
            new = self.hash_file(out)
            eq_(old, new, "Checksum %s of regenerated tarball %s does not match original %s" %
                (f, old, new))
            os.unlink(out)

        # Import 2.9
        orig = self._orig('2.9', dir='dsc-3.0-additional-tarballs')
        ok_(import_orig(['arg0', '--component=foo', '--no-interactive', '--pristine-tar', orig]) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8', 'upstream/2.9'])
        self._check_component_tarballs(repo, ['foo/test1', 'foo/test2', 'foo/test3'])

        dsc = DscFile.parse(self._dsc('2.9-1', dir='dsc-3.0-additional-tarballs'))
        # Check if we can rebuild the upstream tarball and additional tarball
        ptars = [('hello-debhelper_2.9.orig.tar.gz', 'pristine-tar', '', dsc.tgz),
                 ('hello-debhelper_2.9.orig-foo.tar.gz', 'pristine-tar^', 'foo', dsc.additional_tarballs['foo'])]

        p = DebianPristineTar(repo)
        outdir = os.path.abspath('.')
        for f, w, s, o in ptars:
            eq_(repo.get_subject(w), 'pristine-tar data for %s' % f)
            old = self.hash_file(o)
            p.checkout('hello-debhelper', '2.9', 'gzip', outdir, component=s)
            new = self.hash_file(os.path.join(outdir, f))
            eq_(old, new, "Checksum %s of regenerated tarball %s does not match original %s" %
                (f, old, new))
 def test_tag_exists(self):
     """Test that importing an already imported version fails"""
     repo = GitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._orig('2.6')
     # First import
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0)
     heads = self.rem_refs(repo, self.def_branches)
     # Second import must fail
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)
     self._check_log(0, "gbp:error: Upstream tag 'upstream/2.6' already exists")
     # Check that the second import didn't change any refs
     self.check_refs(repo, heads)
    def test_filter_unpacked_dir(self, repo):
        """
        Test that importing and filtering unpacked upstream source works.
        """
        f = 'hello-debhelper_2.8.orig.tar.gz'
        src = os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0', f)

        # Create an unpacked tarball we can import
        UnpackTarArchive(src, '..')()
        ok_(os.path.exists('../hello-2.8'))

        ok_(import_orig(['arg0',
                         '--no-interactive',
                         '--pristine-tar',
                         '--filter-pristine-tar',
                         '--filter=README*',
                         '../hello-2.8']) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])

        filtered = os.path.join('..', f)
        ok_(os.path.exists(filtered))
        # Check if tar got filtered properly
        t = tarfile.open(name=filtered, mode="r:gz")
        for f in ['hello-2.8/configure']:
            i = t.getmember(f)
            eq_(type(i), tarfile.TarInfo)
        for f in ['hello-2.8/README']:
            with assert_raises(KeyError):
                t.getmember(f)
        t.close()
    def test_filter_with_orig_tarball(self, repo):
        """
        Test that using a filter works with an upstream tarball that has
        already the correct name (#558777)
        """
        f = 'hello-debhelper_2.8.orig.tar.gz'
        src = os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0', f)
        shutil.copy(src, '..')

        ok_(import_orig(['arg0',
                         '--no-interactive',
                         '--pristine-tar',
                         '--filter-pristine-tar',
                         '--filter=README*',
                         '../hello-debhelper_2.8.orig.tar.gz']) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])

        filtered = os.path.join('..', f)
        ok_(os.path.exists(filtered))
        eq_(os.readlink(filtered).split('/')[-1],
            'hello-debhelper_2.8.orig.gbp.tar.gz')
        # Check if tar got filtered properly
        t = tarfile.open(name=filtered, mode="r:gz")
        for f in ['hello-2.8/configure']:
            i = t.getmember(f)
            eq_(type(i), tarfile.TarInfo)
        for f in ['hello-2.8/README']:
            with assert_raises(KeyError):
                t.getmember(f)
        t.close()
    def test_filter_with_component_tarballs(self, repo):
        """
        Test that using a filter works with component tarballs (#840602)
        """
        # copy data since we don't want the repacked tarball to end up in DEB_TEST_DATA_DIR
        os.mkdir('../tarballs')
        for f in ['hello-debhelper_2.8.orig-foo.tar.gz', 'hello-debhelper_2.8.orig.tar.gz']:
            src = os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0-additional-tarballs', f)
            shutil.copy(src, '../tarballs')

        ok_(import_orig(['arg0',
                         '--component=foo',
                         '--no-interactive',
                         '--pristine-tar',
                         '--filter-pristine-tar',
                         '--filter=README*',
                         '../tarballs/hello-debhelper_2.8.orig.tar.gz']) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])
        self._check_component_tarballs(repo, ['foo/test1', 'foo/test2'])

        ok_('README' not in repo.ls_tree('HEAD'),
            "README not filtered out of %s" % repo.ls_tree('HEAD'))
        tar = '../hello-debhelper_2.8.orig.tar.gz'

        # Check if tar got filtered properly
        ok_(os.path.exists(tar))
        t = tarfile.open(name=tar, mode="r:gz")
        for f in ['hello-2.8/configure']:
            i = t.getmember(f)
            eq_(type(i), tarfile.TarInfo)
        for f in ['hello-2.8/README']:
            with assert_raises(KeyError):
                t.getmember(f)
        t.close()
    def test_initial_import_fail_create_upstream_tag(self, RepoMock):
        repo = GitRepository.create(self.pkg)
        os.chdir(self.pkg)
        orig = self._orig('2.6')
        ok_(import_orig(['arg0', '--no-interactive', orig]) == 1)

        self._check_repo_state(repo, None, [], tags=[])
 def test_download(self):
     """Test that importing via download works"""
     repo = GitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._download_url('2.6')
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0)
     self._check_repo_state(repo, 'master', self.def_branches,
                            tags=['upstream/2.6'])
 def test_initial_import(self):
     """Test that importing into an empty repo works"""
     repo = GitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._orig('2.6')
     ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 0)
     self._check_repo_state(repo, 'master', self.def_branches,
                            tags=['upstream/2.6'])
    def test_initial_import_fail_create_debian_branch(self):
        repo = GitRepository.create(self.pkg)
        os.chdir(self.pkg)
        orig = self._orig('2.6')

        with patch('gbp.git.repository.GitRepository.create_branch',
                   side_effect=GitRepositoryError('this is a create branch error mock')):
            ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)

        self._check_repo_state(repo, None, [], tags=[])
    def test_initial_import_fail_create_upstream_tag(self, RepoMock):
        """
        Test that we can rollback from a failure to create the upstream
        tag on initial import
        """
        repo = GitRepository.create(self.pkg)
        os.chdir(repo.path)
        orig = self._orig('2.6')
        ok_(import_orig(['arg0', '--no-interactive', orig]) == 1)

        self._check_repo_state(repo, None, [], tags=[])
 def test_update_fail_merge(self, repo):
     """
     Test that we can rollback from a failed merge
     """
     heads = self.rem_refs(repo, self.def_branches)
     orig = self._orig('2.8')
     with patch('gbp.scripts.import_orig.debian_branch_merge',
                side_effect=GitRepositoryError('this is a fail merge error mock')):
         ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)
     self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                            tags=['debian/2.6-2', 'upstream/2.6'])
     self.check_refs(repo, heads)
 def test_update_fail_create_upstream_tag(self, repo):
     """
     Test that we can rollback from a failure to create the upstream
     tag
     """
     heads = self.rem_refs(repo, self.def_branches)
     orig = self._orig('2.8')
     with patch('gbp.git.repository.GitRepository.create_tag',
                side_effect=GitRepositoryError('this is a create tag error mock')):
         ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)
     self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                            tags=['debian/2.6-2', 'upstream/2.6'])
     self.check_refs(repo, heads)
 def test_import_in_submodule(self, repo):
     """
     Test that importing works if repo is a git submodule (#674015)
     """
     parent_repo = GitRepository.create('../parent')
     parent_repo.add_submodule(repo.path)
     parent_repo.update_submodules(init=True, recursive=True)
     submodule = GitRepository(os.path.join(parent_repo.path,
                                            'hello-debhelper'))
     ok_(submodule.path.endswith, 'parent/hello-debhelper')
     os.chdir(submodule.path)
     orig = self._orig('2.8')
     submodule.create_branch('upstream', 'origin/upstream')
     ok_(import_orig(['arg0', '--no-interactive', orig]) == 0)
 def test_update(self, repo):
     """
     Test that importing a new version works
     """
     orig = self._orig('2.8')
     ok_(import_orig(['arg0',
                      '--postimport=printenv > ../postimport.out',
                      '--no-interactive', '--pristine-tar', orig]) == 0)
     self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                            tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])
     ok_(os.path.exists('debian/changelog'))
     ok_(os.path.exists('../postimport.out'))
     self.check_hook_vars('../postimport', [("GBP_BRANCH", "master"),
                                            ("GBP_TAG", "upstream/2.8"),
                                            ("GBP_UPSTREAM_VERSION", "2.8"),
                                            ("GBP_DEBIAN_VERSION", "2.8-1")])
Example #15
0
 def test_update(self, repo):
     """
     Test that importing a new version works
     """
     orig = self._orig('2.8')
     ok_(import_orig(['arg0',
                      '--postimport=printenv > ../postimport.out',
                      '--postunpack=printenv > ../postunpack.out',
                      '--no-interactive', '--pristine-tar', orig]) == 0)
     self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                            tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])
     ok_(os.path.exists('debian/changelog'))
     ok_(os.path.exists('../postimport.out'))
     self.check_hook_vars('../postimport', [("GBP_BRANCH", "master"),
                                            ("GBP_TAG", "upstream/2.8"),
                                            ("GBP_UPSTREAM_VERSION", "2.8"),
                                            ("GBP_DEBIAN_VERSION", "2.8-1")])
    def test_update_fail_create_upstream_tag(self):
        repo = GitRepository.create(self.pkg)
        os.chdir(self.pkg)

        dsc = self._dsc('2.6-2')
        ok_(import_dsc(['arg0', '--pristine-tar', dsc]) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'])

        heads = self.rem_refs(repo, self.def_branches)

        orig = self._orig('2.8')
        with patch('gbp.git.repository.GitRepository.create_tag',
                   side_effect=GitRepositoryError('this is a create tag error mock')):
            ok_(import_orig(['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6'])
        self.check_refs(repo, heads)
Example #17
0
    def test_initial_import_fail_create_debian_branch(self):
        """
        Test that we can rollback from creating the Debian branch on
        initial import
        """
        repo = GitRepository.create(self.pkg)
        os.chdir(self.pkg)
        orig = self._orig('2.6')

        with patch('gbp.git.repository.GitRepository.create_branch',
                   side_effect=GitRepositoryError(
                       'this is a create branch error mock')):
            ok_(
                import_orig(
                    ['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)

        self._check_repo_state(repo, None, [], tags=[])
Example #18
0
 def test_update_fail_merge(self, repo):
     """
     Test that we can rollback from a failed merge
     """
     heads = self.rem_refs(repo, self.def_branches)
     orig = self._orig('2.8')
     with patch('gbp.scripts.import_orig.debian_branch_merge',
                side_effect=GitRepositoryError(
                    'this is a fail merge error mock')):
         ok_(
             import_orig(
                 ['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)
     self._check_repo_state(repo,
                            'master',
                            ['master', 'upstream', 'pristine-tar'],
                            tags=['debian/2.6-2', 'upstream/2.6'])
     self.check_refs(repo, heads)
Example #19
0
 def test_update_fail_create_upstream_tag(self, repo):
     """
     Test that we can rollback from a failure to create the upstream
     tag
     """
     heads = self.rem_refs(repo, self.def_branches)
     orig = self._orig('2.8')
     with patch('gbp.git.repository.GitRepository.create_tag',
                side_effect=GitRepositoryError(
                    'this is a create tag error mock')):
         ok_(
             import_orig(
                 ['arg0', '--no-interactive', '--pristine-tar', orig]) == 1)
     self._check_repo_state(repo,
                            'master',
                            ['master', 'upstream', 'pristine-tar'],
                            tags=['debian/2.6-2', 'upstream/2.6'])
     self.check_refs(repo, heads)
Example #20
0
    def test_filter_with_component_tarballs(self, repo):
        """
        Test that using a filter works with component tarballs (#840602)
        """
        # copy data since we don't want the repacked tarball to end up in DEB_TEST_DATA_DIR
        os.mkdir('../tarballs')
        for f in [
                'hello-debhelper_2.8.orig-foo.tar.gz',
                'hello-debhelper_2.8.orig.tar.gz'
        ]:
            src = os.path.join(DEB_TEST_DATA_DIR,
                               'dsc-3.0-additional-tarballs', f)
            shutil.copy(src, '../tarballs')

        ok_(
            import_orig([
                'arg0', '--component=foo', '--no-interactive',
                '--pristine-tar', '--filter-pristine-tar', '--filter=README*',
                '../tarballs/hello-debhelper_2.8.orig.tar.gz'
            ]) == 0)
        self._check_repo_state(
            repo,
            'master', ['master', 'upstream', 'pristine-tar'],
            tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])
        self._check_component_tarballs(repo, ['foo/test1', 'foo/test2'])

        ok_(b'COPYING' in repo.ls_tree('HEAD'))
        ok_(b'README' not in repo.ls_tree('HEAD'),
            "README not filtered out of %s" % repo.ls_tree('HEAD'))
        tar = '../hello-debhelper_2.8.orig.tar.gz'

        # Check if tar got filtered properly
        ok_(os.path.exists(tar))
        t = tarfile.open(name=tar, mode="r:gz")
        for f in ['hello-2.8/configure']:
            i = t.getmember(f)
            eq_(type(i), tarfile.TarInfo)
        for f in ['hello-2.8/README']:
            with assert_raises(KeyError):
                t.getmember(f)
        t.close()
Example #21
0
    def test_update(self):
        """
        Test that importing a new version works
        """
        dsc = self._dsc('2.6-2')
        ok_(import_dsc(['arg0', '--pristine-tar', dsc]) == 0)
        repo = ComponentTestGitRepository(self.pkg)
        os.chdir(self.pkg)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'])

        orig = self._orig('2.8')
        ok_(import_orig(['arg0',
                         '--postimport=printenv > postimport.out',
                         '--no-interactive', '--pristine-tar', orig]) == 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                               tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])
        eq_(os.path.exists('postimport.out'), True)
        self.check_hook_vars('postimport', [("GBP_BRANCH", "master"),
                                            ("GBP_TAG", "upstream/2.8"),
                                            ("GBP_UPSTREAM_VERSION", "2.8"),
                                            ("GBP_DEBIAN_VERSION", "2.8-1")])
def mock_import(args, stdin_data="\n\n", cwd=None):
    """Wrapper for import-orig for feeding mock stdin data to it"""
    old_cwd = os.path.abspath(os.path.curdir)
    if cwd:
        os.chdir(cwd)

    # Create stub file with mock data
    mock_stdin = StringIO()
    mock_stdin.write(stdin_data)
    mock_stdin.seek(0)

    # Call import-orig-rpm with mock data
    sys.stdin = mock_stdin
    ret = import_orig(['arg0'] + args)
    sys.stdin = sys.__stdin__
    mock_stdin.close()

    # Return to original working directory
    if cwd:
        os.chdir(old_cwd)
    return ret
def mock_import(args, stdin_data="\n\n", cwd=None):
    """Wrapper for import-orig for feeding mock stdin data to it"""
    old_cwd = os.path.abspath(os.path.curdir)
    if cwd:
        os.chdir(cwd)

    # Create stub file with mock data
    mock_stdin = StringIO()
    mock_stdin.write(stdin_data)
    mock_stdin.seek(0)

    # Call import-orig-rpm with mock data
    sys.stdin = mock_stdin
    ret = import_orig(['arg0'] + args)
    sys.stdin = sys.__stdin__
    mock_stdin.close()

    # Return to original working directory
    if cwd:
        os.chdir(old_cwd)
    return ret
Example #24
0
 def test_with_signaturefile(self):
     """
     Test that importing a new version with a signature file works
     """
     repo = ComponentTestGitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._orig('2.8')
     ok_(import_orig(['arg0',
                      '--postimport=printenv > ../postimport.out',
                      '--postunpack=printenv > ../postunpack.out',
                      '--no-interactive', '--pristine-tar',
                      '--upstream-signatures=on', orig]) == 0)
     self._check_repo_state(repo, 'master', ['master', 'upstream', 'pristine-tar'],
                            tags=['upstream/2.8'])
     ok_(os.path.exists('../postimport.out'))
     eq_(repo.ls_tree('pristine-tar'), {b'hello-debhelper_2.8.orig.tar.gz.id',
                                        b'hello-debhelper_2.8.orig.tar.gz.delta',
                                        b'hello-debhelper_2.8.orig.tar.gz.asc'})
     self.check_hook_vars('../postimport', [("GBP_BRANCH", "master"),
                                            ("GBP_TAG", "upstream/2.8"),
                                            ("GBP_UPSTREAM_VERSION", "2.8"),
                                            ("GBP_DEBIAN_VERSION", "2.8-1")])
Example #25
0
    def test_filter_with_orig_tarball_and_postunpack_changes(self, repo):
        """
        Test that using a filter works with an upstream tarball that has
        already the correct name (#558777) and that the postunpack hook can
        be used to do more sophisticated changes to the orig (#951534).
        """
        f = 'hello-debhelper_2.8.orig.tar.gz'
        src = os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0', f)
        shutil.copy(src, '..')

        ok_(
            import_orig([
                'arg0', '--no-interactive', '--pristine-tar',
                '--filter-pristine-tar', '--filter=README*',
                '--postunpack=printenv > $GBP_SOURCES_DIR/postunpack.out;' +
                'rm $GBP_SOURCES_DIR/TODO',
                '../hello-debhelper_2.8.orig.tar.gz'
            ]) == 0)
        self._check_repo_state(
            repo,
            'master', ['master', 'upstream', 'pristine-tar'],
            tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])

        filtered = os.path.join('..', f)
        ok_(os.path.exists(filtered))
        eq_(
            os.readlink(filtered).split('/')[-1],
            'hello-debhelper_2.8.orig.gbp.tar.gz')
        # Check if tar got filtered properly
        t = tarfile.open(name=filtered, mode="r:gz")
        for f in ['hello-2.8/configure', 'hello-2.8/postunpack.out']:
            i = t.getmember(f)
            eq_(type(i), tarfile.TarInfo)
        for f in ['hello-2.8/README', 'hello-2.8/TODO']:
            with assert_raises(KeyError):
                t.getmember(f)
        t.close()
Example #26
0
    def test_filter_unpacked_dir_with_postunpack_changes(self, repo):
        """
        Test that importing and filtering unpacked upstream source works and
        that the postunpack hook can be used to do more sophisticated changes
        to the orig (#951534).
        """
        f = 'hello-debhelper_2.8.orig.tar.gz'
        src = os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0', f)

        # Create an unpacked tarball we can import
        UnpackTarArchive(src, '..')()
        ok_(os.path.exists('../hello-2.8'))

        ok_(
            import_orig([
                'arg0', '--no-interactive', '--pristine-tar',
                '--filter-pristine-tar', '--filter=README*',
                '--postunpack=printenv > $GBP_SOURCES_DIR/postunpack.out;' +
                'rm $GBP_SOURCES_DIR/TODO', '../hello-2.8'
            ]) == 0)
        self._check_repo_state(
            repo,
            'master', ['master', 'upstream', 'pristine-tar'],
            tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])

        filtered = os.path.join('..', f)
        ok_(os.path.exists(filtered))
        # Check if tar got filtered properly
        t = tarfile.open(name=filtered, mode="r:gz")
        for f in ['hello-2.8/configure', 'hello-2.8/postunpack.out']:
            i = t.getmember(f)
            eq_(type(i), tarfile.TarInfo)
        for f in ['hello-2.8/README', 'hello-2.8/TODO']:
            with assert_raises(KeyError):
                t.getmember(f)
        t.close()
Example #27
0
    def test_update_component_tarballs(self, repo):
        """
        Test importing new version with additional tarballs works
        """
        # Import 2.8
        orig = self._orig('2.8', dir='dsc-3.0-additional-tarballs')
        ok_(
            import_orig([
                'arg0', '--component=foo', '--no-interactive',
                '--pristine-tar', orig
            ]) == 0)
        self._check_repo_state(
            repo,
            'master', ['master', 'upstream', 'pristine-tar'],
            tags=['debian/2.6-2', 'upstream/2.6', 'upstream/2.8'])
        self._check_component_tarballs(repo, [b'foo/test1', b'foo/test2'])
        ok_(os.path.exists('debian/changelog'))

        dsc = DscFile.parse(
            _dsc_file(self.pkg, '2.8-1', dir='dsc-3.0-additional-tarballs'))
        # Check if we can rebuild the upstream tarball and additional tarball
        ptars = [('hello-debhelper_2.8.orig.tar.gz', 'pristine-tar', '',
                  dsc.tgz),
                 ('hello-debhelper_2.8.orig-foo.tar.gz', 'pristine-tar^',
                  'foo', dsc.additional_tarballs['foo'])]

        p = DebianPristineTar(repo)
        outdir = os.path.abspath('.')
        for f, w, s, o in ptars:
            eq_(repo.get_subject(w), 'pristine-tar data for %s' % f)
            old = self.hash_file(o)
            p.checkout('hello-debhelper', '2.8', 'gzip', outdir, component=s)
            out = os.path.join(outdir, f)
            new = self.hash_file(out)
            eq_(
                old, new,
                "Checksum %s of regenerated tarball %s does not match original %s"
                % (f, old, new))
            os.unlink(out)

        # Import 2.9
        orig = self._orig('2.9', dir='dsc-3.0-additional-tarballs')
        ok_(
            import_orig([
                'arg0', '--component=foo', '--no-interactive',
                '--pristine-tar', orig
            ]) == 0)
        self._check_repo_state(repo,
                               'master',
                               ['master', 'upstream', 'pristine-tar'],
                               tags=[
                                   'debian/2.6-2', 'upstream/2.6',
                                   'upstream/2.8', 'upstream/2.9'
                               ])
        self._check_component_tarballs(repo,
                                       ['foo/test1', 'foo/test2', 'foo/test3'])
        ok_(os.path.exists('debian/changelog'))

        dsc = DscFile.parse(
            _dsc_file(self.pkg, '2.9-1', dir='dsc-3.0-additional-tarballs'))
        # Check if we can rebuild the upstream tarball and additional tarball
        ptars = [('hello-debhelper_2.9.orig.tar.gz', 'pristine-tar', '',
                  dsc.tgz),
                 ('hello-debhelper_2.9.orig-foo.tar.gz', 'pristine-tar^',
                  'foo', dsc.additional_tarballs['foo'])]

        p = DebianPristineTar(repo)
        outdir = os.path.abspath('.')
        for f, w, s, o in ptars:
            eq_(repo.get_subject(w), 'pristine-tar data for %s' % f)
            old = self.hash_file(o)
            p.checkout('hello-debhelper', '2.9', 'gzip', outdir, component=s)
            new = self.hash_file(os.path.join(outdir, f))
            eq_(
                old, new,
                "Checksum %s of regenerated tarball %s does not match original %s"
                % (f, old, new))