示例#1
0
    def test_bare(self):
        """Test that importing into bare repository works"""
        dsc = self._dsc30('2.6-2')
        assert import_dsc(['arg0',
                           '--verbose',
                           '--pristine-tar',
                           '--debian-branch=master',
                           '--upstream-branch=upstream',
                           dsc]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        os.chdir('hello-debhelper')
        assert len(repo.get_commits()) == 2
        self._check_reflog(repo)
        self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
        commitmsg = repo.get_commit_info('HEAD')['body']
        ok_("hello-debhelper (2.6-2) unstable; urgency=medium" in commitmsg)
        ok_("hello (1.3-7) experimental; urgency=LOW" in commitmsg)

        dsc = self._dsc30('2.8-1')
        assert import_dsc(['arg0',
                           '--verbose',
                           '--pristine-tar',
                           '--debian-branch=master',
                           '--upstream-branch=upstream',
                           dsc]) == 0
        commits, expected = len(repo.get_commits()), 4
        ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
        commitmsg = repo.get_commit_info('HEAD')['body']
        ok_("hello-debhelper (2.8-1) unstable; urgency=low" in commitmsg)
        ok_("ello-debhelper (2.7-1) unstable; urgency=low" in commitmsg)
        ok_("hello-debhelper (2.6-2) unstable; urgency=medium" not in commitmsg)
示例#2
0
    def test_create_branches(self):
        """Test if creating missing branches works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR, 'dsc-3.0',
                                'hello-debhelper_%s.dsc' % version)

        dsc = _dsc('2.6-2')
        assert import_dsc([
            'arg0', '--pristine-tar', '--debian-branch=master',
            '--upstream-branch=upstream', dsc
        ]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        os.chdir('hello-debhelper')
        assert len(repo.get_commits()) == 2
        self._check_repo_state(repo, 'master',
                               ['master', 'pristine-tar', 'upstream'])
        dsc = _dsc('2.8-1')
        assert import_dsc([
            'arg0', '--pristine-tar', '--debian-branch=foo',
            '--upstream-branch=bar', '--create-missing-branches', dsc
        ]) == 0
        self._check_repo_state(
            repo, 'master',
            ['bar', 'foo', 'master', 'pristine-tar', 'upstream'])
        commits, expected = len(repo.get_commits()), 2
        ok_(commits == expected,
            "Found %d commit instead of %d" % (commits, expected))
示例#3
0
 def test_create_branches(self):
     """Test that creating missing branches works"""
     dsc = self._dsc30('2.6-2')
     assert import_dsc(['arg0',
                        '--verbose',
                        '--pristine-tar',
                        '--debian-branch=master',
                        '--upstream-branch=upstream',
                        dsc]) == 0
     repo = ComponentTestGitRepository('hello-debhelper')
     os.chdir('hello-debhelper')
     assert len(repo.get_commits()) == 2
     self._check_reflog(repo)
     self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
     dsc = self._dsc30('2.8-1')
     assert import_dsc(['arg0',
                        '--verbose',
                        '--pristine-tar',
                        '--debian-branch=foo',
                        '--upstream-branch=bar',
                        '--create-missing-branches',
                        dsc]) == 0
     self._check_repo_state(repo, 'master', ['bar', 'foo', 'master', 'pristine-tar', 'upstream'])
     commits, expected = len(repo.get_commits()), 2
     ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
示例#4
0
    def test_create_branches(self):
        """Test if creating missing branches works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR,
                                'dsc-3.0',
                                'hello-debhelper_%s.dsc' % version)

        dsc = _dsc('2.6-2')
        assert import_dsc(['arg0',
                           '--verbose',
                           '--pristine-tar',
                           '--debian-branch=master',
                           '--upstream-branch=upstream',
                           dsc]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        os.chdir('hello-debhelper')
        assert len(repo.get_commits()) == 2
        reflog, ret = repo._git_getoutput('reflog')
        ok_("gbp: Import Debian changes" in reflog[1])
        ok_("gbp: Import Upstream version 2.6" in reflog[2])
        self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
        dsc = _dsc('2.8-1')
        assert import_dsc(['arg0',
                           '--verbose',
                           '--pristine-tar',
                           '--debian-branch=foo',
                           '--upstream-branch=bar',
                           '--create-missing-branches',
                           dsc]) == 0
        self._check_repo_state(repo, 'master', ['bar', 'foo', 'master', 'pristine-tar', 'upstream'])
        commits, expected = len(repo.get_commits()), 2
        ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
示例#5
0
 def test_create_branches(self):
     """Test if creating missing branches works"""
     dsc = self._dsc30('2.6-2')
     assert import_dsc(['arg0',
                        '--verbose',
                        '--pristine-tar',
                        '--debian-branch=master',
                        '--upstream-branch=upstream',
                        dsc]) == 0
     repo = ComponentTestGitRepository('hello-debhelper')
     os.chdir('hello-debhelper')
     assert len(repo.get_commits()) == 2
     self._check_reflog(repo)
     self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
     dsc = self._dsc30('2.8-1')
     assert import_dsc(['arg0',
                        '--verbose',
                        '--pristine-tar',
                        '--debian-branch=foo',
                        '--upstream-branch=bar',
                        '--create-missing-branches',
                        dsc]) == 0
     self._check_repo_state(repo, 'master', ['bar', 'foo', 'master', 'pristine-tar', 'upstream'])
     commits, expected = len(repo.get_commits()), 2
     ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
示例#6
0
    def test_component_generation(self):
        """Test that generating tarball and additional tarball works without pristine-tar"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
        tarballs = [
            "../%s_2.8.orig-foo.tar.gz" % pkg,
            "../%s_2.8.orig.tar.gz" % pkg
        ]

        assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
        repo = ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        assert_false(repo.has_branch('pristine-tar'),
                     "Pristine-tar branch must not exist")
        for t in tarballs:
            self.assertFalse(os.path.exists(t),
                             "Tarball %s must not exist" % t)
        ret = buildpackage([
            'arg0', '--git-component=foo', '--git-no-pristine-tar',
            '--git-posttag=printenv > posttag.out',
            '--git-builder=touch builder-run.stamp', '--git-cleaner=/bin/true'
        ])
        ok_(ret == 0, "Building the package failed")
        for t in tarballs:
            self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)
    def test_create_branches(self):
        """Test if creating missing branches works"""

        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR, "dsc-3.0", "hello-debhelper_%s.dsc" % version)

        dsc = _dsc("2.6-2")
        assert (
            import_dsc(
                ["arg0", "--verbose", "--pristine-tar", "--debian-branch=master", "--upstream-branch=upstream", dsc]
            )
            == 0
        )
        repo = ComponentTestGitRepository("hello-debhelper")
        os.chdir("hello-debhelper")
        assert len(repo.get_commits()) == 2
        self._check_repo_state(repo, "master", ["master", "pristine-tar", "upstream"])
        dsc = _dsc("2.8-1")
        assert (
            import_dsc(
                [
                    "arg0",
                    "--verbose",
                    "--pristine-tar",
                    "--debian-branch=foo",
                    "--upstream-branch=bar",
                    "--create-missing-branches",
                    dsc,
                ]
            )
            == 0
        )
        self._check_repo_state(repo, "master", ["bar", "foo", "master", "pristine-tar", "upstream"])
        commits, expected = len(repo.get_commits()), 2
        ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
 def test_invalid_config_file(self):
     """Test invalid config file"""
     # Create dummy invalid config file and try to import (should fail)
     ComponentTestGitRepository.create('.')
     with open('.gbp.conf', 'w') as conffd:
         conffd.write('foobar\n')
     eq_(mock_import(['foo']), 3)
     self._check_log(0, 'gbp:error: File contains no section headers.')
 def test_invalid_config_file(self):
     """Test invalid config file"""
     # Create dummy invalid config file and try to import (should fail)
     ComponentTestGitRepository.create('.')
     with open('.gbp.conf', 'w') as conffd:
         conffd.write('foobar\n')
     eq_(mock_import(['foo']), 3)
     self._check_log(0, 'gbp:error: File contains no section headers.')
示例#10
0
 def test_clone_native(self, repo):
     """Test that cloning of debian native packages works"""
     dest = os.path.join(self._tmpdir, 'cloned_repo')
     clone(
         ['arg0', '--postclone=printenv > postclone.out', repo.path, dest])
     cloned = ComponentTestGitRepository(dest)
     self._check_repo_state(cloned, 'master', ['master'])
     assert len(cloned.get_commits()) == 1
     self.check_hook_vars('postclone', ["GBP_GIT_DIR"])
    def test_download(self):
        def _dsc(version):
            return os.path.join(DEB_TEST_DOWNLOAD_URL, 'dsc-native',
                                'git-buildpackage_%s.dsc' % version)

        dsc = _dsc('0.4.14')
        assert import_dsc(['arg0', '--allow-unauthenticated', dsc]) == 0
        repo = ComponentTestGitRepository('git-buildpackage')
        self._check_repo_state(repo, 'master', ['master'])
        assert len(repo.get_commits()) == 1
示例#12
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))
示例#13
0
 def test_clone_native(self, repo):
     """Test that cloning of debian native packages works"""
     dest = os.path.join(self._tmpdir,
                         'cloned_repo')
     clone(['arg0',
            '--postclone=printenv > ../postclone.out',
            repo.path, dest])
     cloned = ComponentTestGitRepository(dest)
     self._check_repo_state(cloned, 'master', ['master'])
     assert len(cloned.get_commits()) == 1
     self.check_hook_vars('../postclone', ["GBP_GIT_DIR"])
示例#14
0
 def test_download(self):
     def _dsc(version):
         return os.path.join(DEB_TEST_DOWNLOAD_URL,
                             'dsc-native',
                             'git-buildpackage_%s.dsc' % version)
     dsc = _dsc('0.4.14')
     assert import_dsc(['arg0',
                        '--allow-unauthenticated',
                        dsc]) == 0
     repo = ComponentTestGitRepository('git-buildpackage')
     self._check_repo_state(repo, 'master', ['master'])
     assert len(repo.get_commits()) == 1
 def test_debian_branch_not_master(self):
     """Make sure we only have debian-branch and upstream-branch after an initial import"""
     dsc = self._dsc30('2.6-2')
     assert import_dsc([
         'arg0', '--verbose', '--no-pristine-tar', '--debian-branch=pk4',
         '--upstream-branch=upstream', dsc
     ]) == 0
     repo = ComponentTestGitRepository('hello-debhelper')
     self._check_repo_state(repo, 'pk4', ['pk4', 'upstream'])
     commits, expected = len(repo.get_commits()), 2
     ok_(commits == expected,
         "Found %d commit instead of %d" % (commits, expected))
 def test_upstream_branch_is_master(self):
     """Make sure we can import when upstream-branch == master (#750962)"""
     dsc = self._dsc30('2.6-2')
     assert import_dsc([
         'arg0', '--verbose', '--no-pristine-tar', '--debian-branch=debian',
         '--upstream-branch=master', dsc
     ]) == 0
     repo = ComponentTestGitRepository('hello-debhelper')
     self._check_repo_state(repo, 'debian', ['debian', 'master'])
     commits, expected = len(repo.get_commits()), 2
     ok_(commits == expected,
         "Found %d commit instead of %d" % (commits, expected))
示例#17
0
    def test_import_10(self):
        """Test if importing a 1.0 source format package works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR,
                                'dsc-1.0',
                                'hello-debhelper_%s.dsc' % version)

        dsc = _dsc('2.6-2')
        assert import_dsc(['arg0', dsc]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        self._check_repo_state(repo, 'master', ['master', 'upstream'],
                               tags=['upstream/2.6', 'debian/2.6-2'])
        assert len(repo.get_commits()) == 2
示例#18
0
 def test_debian_branch_not_master(self):
     """Make sure we only have debian-branch and upstream-branch after an initial import"""
     dsc = self._dsc30('2.6-2')
     assert import_dsc(['arg0',
                        '--verbose',
                        '--no-pristine-tar',
                        '--debian-branch=pk4',
                        '--upstream-branch=upstream',
                        dsc]) == 0
     repo = ComponentTestGitRepository('hello-debhelper')
     self._check_repo_state(repo, 'pk4', ['pk4', 'upstream'])
     commits, expected = len(repo.get_commits()), 2
     ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
    def test_import_10(self):
        """Test that importing a 1.0 source format package works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR, 'dsc-1.0',
                                'hello-debhelper_%s.dsc' % version)

        dsc = _dsc('2.6-2')
        assert import_dsc(['arg0', dsc]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        self._check_repo_state(repo,
                               'master', ['master', 'upstream'],
                               tags=['upstream/2.6', 'debian/2.6-2'])
        assert len(repo.get_commits()) == 2
示例#20
0
 def test_upstream_branch_is_master(self):
     """Make sure we can import when upstream-branch == master (#750962)"""
     dsc = self._dsc30('2.6-2')
     assert import_dsc(['arg0',
                        '--verbose',
                        '--no-pristine-tar',
                        '--debian-branch=debian',
                        '--upstream-branch=master',
                        dsc]) == 0
     repo = ComponentTestGitRepository('hello-debhelper')
     self._check_repo_state(repo, 'debian', ['debian', 'master'])
     commits, expected = len(repo.get_commits()), 2
     ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))
    def test_import_debian_native(self):
        """Test that importing of debian native packages works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR, 'dsc-native',
                                'git-buildpackage_%s.dsc' % version)

        dsc = _dsc('0.4.14')
        assert import_dsc(['arg0', dsc]) == 0
        repo = ComponentTestGitRepository('git-buildpackage')
        self._check_repo_state(repo, 'master', ['master'])
        assert len(repo.get_commits()) == 1
        commitmsg = repo.get_commit_info('HEAD')['body']
        ok_("git-buildpackage (0.01) unstable; urgency=low" in commitmsg)
        ok_("git-buildpackage (0.4.14) unstable; urgency=low" in commitmsg)

        os.chdir('git-buildpackage')
        dsc = _dsc('0.4.15')
        assert import_dsc(['arg0', dsc]) == 0
        self._check_repo_state(repo, 'master', ['master'])
        assert len(repo.get_commits()) == 2
        commitmsg = repo.get_commit_info('HEAD')['body']
        ok_("git-buildpackage (0.4.14) unstable; urgency=low" not in commitmsg)
        ok_("git-buildpackage (0.4.15) unstable; urgency=low" in commitmsg)

        dsc = _dsc('0.4.16')
        assert import_dsc(['arg0', dsc]) == 0
        self._check_repo_state(repo, 'master', ['master'])
        assert len(repo.get_commits()) == 3
        commitmsg = repo.get_commit_info('HEAD')['body']
        ok_("git-buildpackage (0.4.14) unstable; urgency=low" not in commitmsg)
        ok_("git-buildpackage (0.4.15) unstable; urgency=low" not in commitmsg)
        ok_("git-buildpackage (0.4.16) unstable; urgency=low" in commitmsg)
示例#22
0
 def test_postunpack_env_vars(self):
     """
     Test that the expected environment variables are set during
     postunpack hook.
     """
     ComponentTestGitRepository.create(self.pkg)
     os.chdir(self.pkg)
     orig = self._orig('2.8')
     ok_(import_orig(['arg0',
                      '--postunpack=printenv > ../postunpack.out',
                      '--no-interactive', '--pristine-tar', orig]) == 0)
     self.check_hook_vars('../postunpack', ["GBP_GIT_DIR",
                                            "GBP_TMP_DIR",
                                            "GBP_SOURCES_DIR"])
    def test_pristine_tar_commit_on_origin(self, repo):
        """Test that we can create tarball from 'origin/pristine-tar'"""

        assert_true(repo.has_branch('pristine-tar'),
                    "Pristine-tar branch must exist in origin")
        dest = os.path.join(self._tmpdir, 'cloned_repo')
        clone(['arg0', repo.path, dest])
        cloned = ComponentTestGitRepository(dest)

        os.chdir(cloned.path)
        assert_false(cloned.has_branch('pristine-tar'),
                     "Pristine-tar branch must not exist in clone")
        ret = export_orig(['arg0', '--pristine-tar'])
        ok_(ret == 0, "Exporting tarballs must not fail")
示例#24
0
    def test_import_debian_native(self):
        """Test that importing of debian native packages works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR,
                                'dsc-native',
                                'git-buildpackage_%s.dsc' % version)

        dsc1 = _dsc('0.4.14')
        dsc2 = _dsc('0.4.15')
        assert import_dscs(['arg0', dsc1, dsc2]) == 0
        repo = ComponentTestGitRepository('git-buildpackage')
        self._check_repo_state(repo, 'master', ['master'])
        assert len(repo.get_commits()) == 2
        commitmsg = repo.get_commit_info('HEAD')['body']
        ok_("git-buildpackage (0.4.15) unstable; urgency=low" in commitmsg)
示例#25
0
    def test_git_archive_tree_non_existent(self):
        """Test that we're failing tarball generation when commits are missing"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')

        assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
        repo = ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        assert_false(repo.has_branch('pristine-tar'), "Pristine-tar branch not must exist")
        ret = export_orig(['arg0',
                           '--component=bar',  # non-existing component
                           '--no-pristine-tar'])
        ok_(ret == 1, "Exporting tarballs must fail")
        self._check_log(-1, "gbp:error: No tree for 'bar' found in "
                        "'upstream/2.8' to create additional tarball from")
示例#26
0
    def test_clone_with_attrs(self, repo):
        """Test that cloning a repo with harmful attrs disarms them"""
        with open('.gitattributes', 'w') as f:
            f.write('# not empty')
        repo.add_files('.gitattributes')
        repo.commit_files('.gitattributes', msg="add .gitattributes")

        dest = os.path.join(self._tmpdir, 'cloned_repo')
        clone(['arg0', repo.path, dest])
        cloned = ComponentTestGitRepository(dest)
        self._check_repo_state(cloned, 'master', ['master'])

        attrs_file = os.path.join(dest, '.git', 'info', 'attributes')
        ok_(os.path.exists(attrs_file), "%s is missing" % attrs_file)

        with open(attrs_file) as f:
            attrs = sorted(f.read().splitlines())

        expected_gitattrs = [
            '# Added by git-buildpackage to disable .gitattributes found in the upstream tree',
            '* -export-ignore',
            '* -export-subst',
            '* dgit-defuse-attrs',
            '[attr]dgit-defuse-attrs  -text -eol -crlf -ident -filter -working-tree-encoding',
        ]
        self.assertEquals(attrs, expected_gitattrs)
    def _test_buildpackage(self, pkg, dir, version):
        def _dsc(pkg, version):
            return os.path.join(DEB_TEST_DATA_DIR, dir,
                                '%s_%s.dsc' % (pkg, version))

        dsc = _dsc(pkg, version)
        assert import_dsc(['arg0', dsc]) == 0
        ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        ret = buildpackage([
            'arg0', '--git-prebuild=printenv > prebuild.out',
            '--git-postbuild=printenv > postbuild.out',
            '--git-builder=/bin/true', '--git-cleaner=/bin/true'
        ])
        ok_(ret == 0, "Building the package failed")
        eq_(os.path.exists('prebuild.out'), True)

        self.check_hook_vars(
            'prebuild',
            ["GBP_BUILD_DIR", "GBP_GIT_DIR", "GBP_GIT_DIR", "GBP_BUILD_DIR"])

        self.check_hook_vars('postbuild', [
            "GBP_CHANGES_FILE", "GBP_BUILD_DIR", "GBP_CHANGES_FILE",
            "GBP_BUILD_DIR"
        ])
示例#28
0
 def test_clone_github(self):
     """Test that cloning from github urls works"""
     dest = os.path.join(self._tmpdir, 'cloned_repo')
     ret = clone(['arg0', "github:agx/git-buildpackage", dest])
     self.assertEquals(ret, 0)
     cloned = ComponentTestGitRepository(dest)
     self._check_repo_state(cloned, 'master', ['master'])
    def test_tarball_dir_version_replacement(self):
        """Test that generating tarball from directory version substitution works"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
        tarballs = ["%s_2.8.orig-foo.tar.gz" % pkg, "%s_2.8.orig.tar.gz" % pkg]

        assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
        ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        for t in tarballs:
            self.assertFalse(os.path.exists(os.path.join('..', t)),
                             "Tarball %s must not exist" % t)

        tarball_dir = os.path.join(DEB_TEST_DATA_DIR, 'foo-%(version)s')
        ret = export_orig([
            'arg0',
            '--tarball-dir=%s' % tarball_dir, '--component=foo',
            '--no-pristine-tar'
        ])
        ok_(ret == 0, "Exporting tarballs failed")
        # tarballs should be found in existing --tarball-dir directory and thus
        # not get recreated by export-orig
        for t in tarballs:
            self.assertFalse(os.path.exists(os.path.join('..', t)),
                             "Tarball %s found" % t)
            self.assertTrue(
                os.path.exists(os.path.join(DEB_TEST_DATA_DIR, 'foo-2.8', t)),
                "Tarball %s not found" % t)
 def test_pristine_import_to_bare(self):
     """Test importing inside bare git repository"""
     repo = ComponentTestGitRepository.create('.', bare=True)
     orig = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')
     eq_(mock_import([orig]), 0)
     # No pristine-tar branch should be present
     self._check_repo_state(repo, 'master', ['master', 'upstream'])
 def test_pristine_import_to_bare(self):
     """Test importing inside bare git repository"""
     repo = ComponentTestGitRepository.create('.', bare=True)
     orig = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')
     eq_(mock_import([orig]), 0)
     # No pristine-tar branch should be present
     self._check_repo_state(repo, 'master', ['master', 'upstream'])
示例#32
0
    def test_setup_gitattrs_dgit34(self, repo):
        """Test that setting up Git attributes manually works even with a very old dgit"""
        dest = os.path.join(self._tmpdir, 'cloned_repo')
        clone(['arg0', repo.path, dest])
        cloned = ComponentTestGitRepository(dest)
        self._check_repo_state(cloned, 'master', ['master'])

        attrs_file = os.path.join(dest, '.git', 'info', 'attributes')

        # file shouldn’t exist at this point yet
        self.assertFalse(
            os.path.exists(attrs_file) and os.path.getsize(attrs_file),
            "%s is non-empty" % attrs_file)

        with open(attrs_file, 'w') as f:
            f.write('\n'.join(dgit34_attributes))

        os.chdir(cloned.path)
        setup_gitattributes(['arg0', '--verbose'])

        ok_(os.path.exists(attrs_file), "%s is missing" % attrs_file)

        with open(attrs_file) as f:
            attrs = sorted(f.read().splitlines())

        expected_gitattrs = sorted(sorted_gitattrs + [
            '# Old dgit macro disabled:',
            '# [attr]dgit-defuse-attrs\t-text -eol -crlf -ident -filter',
            '# ^ see dgit(7).  To undo, leave a definition of [attr]dgit-defuse-attrs',
        ])

        self.assertEquals(attrs, expected_gitattrs)
示例#33
0
 def test_with_auto_signaturefile(self):
     """
     Test that importing a new version with a signature file works
     when using auto mode.
     """
     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=auto', 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")])
示例#34
0
 def test_clone_vcsgit_ok(self):
     """Test that cloning from vcs-git urls works"""
     dest = os.path.join(self._tmpdir, 'cloned_repo')
     ret = clone(['arg0', "vcsgit:libvirt-glib", dest])
     self.assertEquals(ret, 0)
     cloned = ComponentTestGitRepository(dest)
     self._check_repo_state(cloned, 'debian/sid',
                            ['debian/sid', 'upstream/latest'])
示例#35
0
    def test_clone_nonempty(self):
        """Test that cloning into an existing dir fails"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR,
                                'dsc-native',
                                'git-buildpackage_%s.dsc' % version)

        # Build up somethng we can clone from
        dsc = _dsc('0.4.14')
        assert import_dsc(['arg0', dsc]) == 0
        repo = ComponentTestGitRepository('git-buildpackage')
        self._check_repo_state(repo, 'master', ['master'])
        assert len(repo.get_commits()) == 1

        ok_(clone(['arg0', repo.path]) == 1,
            "Cloning did no fail as expected")
        self._check_log(-2, "gbp:error: Git command failed: Error running git clone: fatal: destination path 'git-buildpackage' already exists and is not an empty directory.")
示例#36
0
 def test_pull_default_remote(self, repo):
     """Test that pulling of debian native packages works (default remote)"""
     dest = os.path.join(self._tmpdir, 'cloned_repo')
     clone(['arg0', repo.path, dest])
     cloned = ComponentTestGitRepository(dest)
     self._check_repo_state(cloned, 'master', ['master'])
     eq_(pull(['argv0']), 0)
     assert len(repo.get_commits()) == 1
 def test_target_dir(self):
     """Test that setting the target dir works"""
     dsc = self._dsc30('2.6-2')
     assert import_dsc(
         ['arg0', '--verbose', '--no-pristine-tar', dsc, 'targetdir']) == 0
     assert os.path.exists('targetdir')
     repo = ComponentTestGitRepository('targetdir')
     self._check_repo_state(repo, 'master', ['master', 'upstream'])
    def test_import_30_pristine_tar(self):
        dscfile = self._dsc30('2.6-1')
        assert import_dsc([
            'arg0', '--verbose', '--pristine-tar', '--debian-branch=master',
            '--upstream-branch=upstream', dscfile
        ]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        self._check_repo_state(repo, 'master',
                               ['master', 'pristine-tar', 'upstream'])
        commits, expected = len(repo.get_commits()), 2
        commitmsg = repo.get_commit_info('HEAD')['body']
        eq_("hello-debhelper (2.6-1) unstable; urgency=low",
            commitmsg.split('\n')[0])
        ok_(commits == expected,
            "Found %d commit instead of %d" % (commits, expected))

        os.chdir(repo.path)
        dscfile = self._dsc30('2.6-2')
        assert import_dsc([
            'arg0', '--verbose', '--pristine-tar', '--debian-branch=master',
            '--upstream-branch=upstream', dscfile
        ]) == 0
        commits, expected = len(repo.get_commits()), 3
        commitmsg = repo.get_commit_info('HEAD')['body']
        eq_("hello-debhelper (2.6-2) unstable; urgency=medium",
            commitmsg.split('\n')[0])
        ok_(commits == expected,
            "Found %d commit instead of %d" % (commits, expected))

        commits, expected = len(repo.get_commits(until='pristine-tar')), 1
        ok_(
            commits == expected,
            "Found %d pristine-tar commits instead of %d" %
            (commits, expected))
示例#39
0
    def test_pull_all(self, repo):
        """Test the '--all' commandline option"""
        # Create new branch in repo
        repo.create_branch('foob')

        # Clone and create new commits in origin
        dest = os.path.join(self._tmpdir, 'cloned_repo')
        clone(['arg0', '--all', repo.path, dest])
        cloned = ComponentTestGitRepository(dest)
        tmp_workdir = os.path.join(self._tmpdir, 'tmp_workdir')
        os.mkdir(tmp_workdir)
        with open(os.path.join(tmp_workdir, 'new_file'), 'w'):
            pass
        repo.commit_dir(tmp_workdir, 'New commit in master', branch='master')
        repo.commit_dir(tmp_workdir, 'New commit in foob', branch='foob')

        # Check that the branch is not updated when --all is not used
        eq_(pull(['argv0']), 0)
        eq_(len(cloned.get_commits(until='master')), 3)
        eq_(len(cloned.get_commits(until='upstream')), 1)
        eq_(len(cloned.get_commits(until='foob')), 2)

        # Check that --all updates all branches
        repo.commit_dir(tmp_workdir, 'New commit in upstream', branch='upstream')
        eq_(pull(['argv0', '--all']), 0)
        eq_(len(cloned.get_commits(until='foob')), 3)
        eq_(len(cloned.get_commits(until='upstream')), 2)
 def test_hook_error(self):
     """Test postimport hook failure"""
     repo = ComponentTestGitRepository.create('.')
     orig = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')
     eq_(mock_import(['--postimport=/bin/false', '--merge', '--no-rollback', orig]), 1)
     self._check_log(-2, "gbp:error: Postimport-hook '/bin/false' failed:")
     self._check_log(-1, 'gbp:error: Import of %s failed' % orig)
     # Other parts of the import should've succeeded
     self._check_repo_state(repo, 'master', ['master', 'upstream'])
 def test_hook_error(self):
     """Test postimport hook failure"""
     repo = ComponentTestGitRepository.create('.')
     orig = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')
     eq_(mock_import(['--postimport=/bin/false', '--merge', '--no-rollback', orig]), 1)
     self._check_log(-2, "gbp:error: Postimport-hook '/bin/false' failed:")
     self._check_log(-1, 'gbp:error: Import of %s failed' % orig)
     # Other parts of the import should've succeeded
     self._check_repo_state(repo, 'master', ['master', 'upstream'])
示例#42
0
    def test_component_generation(self):
        """Test that generating tarball and additional tarball works without pristine-tar"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
        tarballs = ["../%s_2.8.orig-foo.tar.gz" % pkg,
                    "../%s_2.8.orig.tar.gz" % pkg]

        assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
        repo = ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        assert_false(repo.has_branch('pristine-tar'), "Pristine-tar branch must not exist")
        for t in tarballs:
            self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
        ret = export_orig(['arg0',
                           '--component=foo',
                           '--no-pristine-tar'])
        ok_(ret == 0, "Exporting tarballs failed")
        for t in tarballs:
            self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)
示例#43
0
    def test_git_archive_tree_non_existent(self):
        """Test that we're failing tarball generation when commits are missing"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')

        assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
        repo = ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        assert_false(repo.has_branch('pristine-tar'),
                     "Pristine-tar branch not must exist")
        ret = export_orig([
            'arg0',
            '--component=bar',  # non-existing component
            '--no-pristine-tar'
        ])
        ok_(ret == 1, "Exporting tarballs must fail")
        self._check_log(
            -1, "gbp:error: No tree for 'bar' found in "
            "'upstream/2.8' to create additional tarball from")
 def test_import_zip(self):
     """Test importing of zip archive"""
     repo = ComponentTestGitRepository.create('.')
     # Import zip with, no master branch should be present
     orig = os.path.join(DATA_DIR, 'gbp-test-native-1.0.zip')
     files = ['.gbp.conf', 'packaging/gbp-test-native.spec',
              'dummy.sh', 'README', 'Makefile']
     eq_(mock_import([orig]), 0)
     self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
     eq_(repo.get_tags(), ['upstream/1.0'])
    def test_tag_only(self):
        """Test that only tagging a native debian package works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR, 'dsc-native',
                                'git-buildpackage_%s.dsc' % version)

        dsc = _dsc('0.4.14')
        assert import_dsc(['arg0', dsc]) == 0
        repo = ComponentTestGitRepository('git-buildpackage')
        os.chdir('git-buildpackage')
        repo.delete_tag('debian/0.4.14')  # make sure we can tag again
        ret = buildpackage([
            'arg0', '--git-tag-only', '--git-posttag=printenv > posttag.out',
            '--git-builder=touch builder-run.stamp', '--git-cleaner=/bin/true'
        ])
        ok_(ret == 0, "Building the package failed")
        eq_(os.path.exists('posttag.out'), True)
        eq_(os.path.exists('builder-run.stamp'), False)
        self.check_hook_vars('posttag', ["GBP_TAG", "GBP_BRANCH", "GBP_SHA1"])
 def test_import_zip(self):
     """Test importing of zip archive"""
     repo = ComponentTestGitRepository.create('.')
     # Import zip with, no master branch should be present
     orig = os.path.join(DATA_DIR, 'gbp-test-native-1.0.zip')
     files = ['.gbp.conf', 'packaging/gbp-test-native.spec',
              'dummy.sh', 'README', 'Makefile']
     eq_(mock_import([orig]), 0)
     self._check_repo_state(repo, 'master', ['master', 'upstream'], files)
     eq_(repo.get_tags(), ['upstream/1.0'])
 def test_branch_update(self):
     """Check that the working copy is kept in sync with branch HEAD"""
     repo = ComponentTestGitRepository.create('.')
     orig1 = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')
     orig2 = os.path.join(DATA_DIR, 'gbp-test-1.1.tar.bz2')
     eq_(mock_import(['--merge', orig1]), 0)
     repo.set_branch('upstream')
     eq_(mock_import([orig2]), 0)
     files = ['Makefile', 'README', 'dummy.sh']
     self._check_repo_state(repo, 'upstream', ['master', 'upstream'], files)
     eq_(len(repo.get_commits(until='upstream')), 2)
 def test_branch_update(self):
     """Check that the working copy is kept in sync with branch HEAD"""
     repo = ComponentTestGitRepository.create('.')
     orig1 = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')
     orig2 = os.path.join(DATA_DIR, 'gbp-test-1.1.tar.bz2')
     eq_(mock_import(['--merge', orig1]), 0)
     repo.set_branch('upstream')
     eq_(mock_import([orig2]), 0)
     files = ['Makefile', 'README', 'dummy.sh']
     self._check_repo_state(repo, 'upstream', ['master', 'upstream'], files)
     eq_(len(repo.get_commits(until='upstream')), 2)
示例#49
0
    def test_filter_with_component_tarballs(self):
        """
        Test that using a filter works even with component tarballs (#840602)
        """
        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'])

        # 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()
示例#50
0
    def test_component_generation(self):
        """Test that generating tarball and additional tarball works without pristine-tar"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
        tarballs = [
            "../%s_2.8.orig-foo.tar.gz" % pkg,
            "../%s_2.8.orig.tar.gz" % pkg
        ]

        assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
        repo = ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        assert_false(repo.has_branch('pristine-tar'),
                     "Pristine-tar branch must not exist")
        for t in tarballs:
            self.assertFalse(os.path.exists(t),
                             "Tarball %s must not exist" % t)
        ret = export_orig(['arg0', '--component=foo', '--no-pristine-tar'])
        ok_(ret == 0, "Exporting tarballs failed")
        for t in tarballs:
            self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)
示例#51
0
    def test_pristinetar_component_generation(self):
        """Test that generating tarball and additional tarball works with pristine-tar"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
        tarballs = ["../%s_2.8.orig-foo.tar.gz" % pkg,
                    "../%s_2.8.orig.tar.gz" % pkg]

        assert import_dsc(['arg0', '--pristine-tar', dsc]) == 0
        repo = ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        assert_true(repo.has_branch('pristine-tar'), "Pristine-tar branch must exist")
        for t in tarballs:
            self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
        #  Make sure the tree object for importing the main tarball is recreated
        repo.collect_garbage(prune='all', aggressive=True)
        ret = export_orig(['arg0',
                           '--component=foo',
                           '--pristine-tar'])
        ok_(ret == 0, "Exporting tarballs failed")
        for t in tarballs:
            self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)
    def test_import_hooks(self):
        """Basic test for postimport hook"""
        repo = ComponentTestGitRepository.create('.')
        orig = os.path.join(DATA_DIR, 'gbp-test-1.0.tar.bz2')

        script = ("echo -n branch: $GBP_BRANCH > ../hook.txt")
        eq_(mock_import(['--postimport', script, '--merge', orig]), 0)
        self._check_repo_state(repo, 'master', ['master', 'upstream'])
        eq_(repo.get_tags(), ['upstream/1.0'])
        with open('../hook.txt', 'r') as hookout:
            data = hookout.read()
        eq_(data, 'branch: master')
示例#53
0
    def test_import_30_pristine_tar(self):
        dscfile = self._dsc30('2.6-1')
        assert import_dsc(['arg0',
                           '--verbose',
                           '--pristine-tar',
                           '--debian-branch=master',
                           '--upstream-branch=upstream',
                           dscfile]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
        commits, expected = len(repo.get_commits()), 2
        commitmsg = repo.get_commit_info('HEAD')['body']
        eq_("hello-debhelper (2.6-1) unstable; urgency=low", commitmsg.split('\n')[0])
        ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))

        os.chdir(repo.path)
        dscfile = self._dsc30('2.6-2')
        assert import_dsc(['arg0',
                           '--verbose',
                           '--pristine-tar',
                           '--debian-branch=master',
                           '--upstream-branch=upstream',
                           dscfile]) == 0
        commits, expected = len(repo.get_commits()), 3
        commitmsg = repo.get_commit_info('HEAD')['body']
        eq_("hello-debhelper (2.6-2) unstable; urgency=medium", commitmsg.split('\n')[0])
        ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))

        commits, expected = len(repo.get_commits(until='pristine-tar')), 1
        ok_(commits == expected, "Found %d pristine-tar commits instead of %d" % (commits, expected))
    def test_import_multiple_pristine_tar(self):
        """Test if importing a multiple tarball package works"""

        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR, "dsc-3.0-additional-tarballs", "hello-debhelper_%s.dsc" % version)

        dscfile = _dsc("2.8-1")
        assert (
            import_dsc(
                ["arg0", "--verbose", "--pristine-tar", "--debian-branch=master", "--upstream-branch=upstream", dscfile]
            )
            == 0
        )
        repo = ComponentTestGitRepository("hello-debhelper")
        self._check_repo_state(repo, "master", ["master", "pristine-tar", "upstream"])
        commits, expected = len(repo.get_commits()), 2

        for file in ["foo/test1", "foo/test2"]:
            ok_(
                file in repo.ls_tree("HEAD"),
                "Could not find component tarball file %s in %s" % (file, repo.ls_tree("HEAD")),
            )

        ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))

        dsc = DscFile.parse(dscfile)
        # Check if we can rebuild the tarball and subtarball
        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, subtarball=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))
示例#55
0
    def test_debian_import(self):
        """Test that importing of debian native packages works"""

        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR, "dsc-native", "git-buildpackage_%s.dsc" % version)

        dsc = _dsc("0.4.14")
        assert import_dsc(["arg0", dsc]) == 0
        repo = ComponentTestGitRepository("git-buildpackage")
        self._check_repo_state(repo, "master", ["master"])
        assert len(repo.get_commits()) == 1

        os.chdir("git-buildpackage")
        dsc = _dsc("0.4.15")
        assert import_dsc(["arg0", dsc]) == 0
        self._check_repo_state(repo, "master", ["master"])
        assert len(repo.get_commits()) == 2

        dsc = _dsc("0.4.16")
        assert import_dsc(["arg0", dsc]) == 0
        self._check_repo_state(repo, "master", ["master"])
        assert len(repo.get_commits()) == 3
    def test_component_generation(self):
        """Test that generating tarball and additional tarball works without pristine-tar"""
        pkg = 'hello-debhelper'
        dsc = self._dsc_name(pkg, '2.8-1', 'dsc-3.0-additional-tarballs')
        tarballs = ["../%s_2.8.orig-foo.tar.gz" % pkg,
                    "../%s_2.8.orig.tar.gz" % pkg]

        assert import_dsc(['arg0', '--no-pristine-tar', dsc]) == 0
        repo = ComponentTestGitRepository(pkg)
        os.chdir(pkg)
        assert_false(repo.has_branch('pristine-tar'), "Pristine-tar branch must not exist")
        for t in tarballs:
            self.assertFalse(os.path.exists(t), "Tarball %s must not exist" % t)
        ret = buildpackage(['arg0',
                            '--git-component=foo',
                            '--git-no-pristine-tar',
                            '--git-posttag=printenv > posttag.out',
                            '--git-builder=touch builder-run.stamp',
                            '--git-cleaner=/bin/true'])
        ok_(ret == 0, "Building the package failed")
        for t in tarballs:
            self.assertTrue(os.path.exists(t), "Tarball %s not found" % t)
    def test_import_multiple_pristine_tar(self):
        """Test if importing a multiple tarball package works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR,
                                'dsc-3.0-additional-tarballs',
                                'hello-debhelper_%s.dsc' % version)

        dscfile = _dsc('2.8-1')
        assert import_dsc(['arg0',
                           '--verbose',
                           '--pristine-tar',
                           '--debian-branch=master',
                           '--upstream-branch=upstream',
                           dscfile]) == 0
        repo = ComponentTestGitRepository('hello-debhelper')
        self._check_repo_state(repo, 'master', ['master', 'pristine-tar', 'upstream'])
        commits, expected = len(repo.get_commits()), 2

        for file in ['foo/test1', 'foo/test2']:
            ok_(file in repo.ls_tree('HEAD'),
                "Could not find component tarball file %s in %s" % (file, repo.ls_tree('HEAD')))

        ok_(commits == expected, "Found %d commit instead of %d" % (commits, expected))

        dsc = DscFile.parse(dscfile)
        # Check if we can rebuild the tarball and component
        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)
            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))
示例#58
0
    def test_clone_environ(self):
        """Test that environment variables influence git configuration"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR,
                                'dsc-native',
                                'git-buildpackage_%s.dsc' % version)

        # Build up somethng we can clone from
        dsc = _dsc('0.4.14')
        os.environ['DEBFULLNAME'] = 'testing tester'
        os.environ['DEBEMAIL'] = '*****@*****.**'
        assert import_dsc(['arg0', dsc]) == 0
        repo = ComponentTestGitRepository('git-buildpackage')
        self._check_repo_state(repo, 'master', ['master'])
        assert len(repo.get_commits()) == 1

        got = repo.get_config("user.email")
        want = os.environ['DEBEMAIL']
        ok_(got == want, "unexpected git config user.email: got %s, want %s" % (got, want))

        got = repo.get_config("user.name")
        want = os.environ['DEBFULLNAME']
        ok_(got == want, "unexpected git config user.name: got %s, want %s" % (got, want))
    def test_tag_only(self):
        """Test that only tagging a native debian package works"""
        def _dsc(version):
            return os.path.join(DEB_TEST_DATA_DIR,
                                'dsc-native',
                                'git-buildpackage_%s.dsc' % version)

        dsc = _dsc('0.4.14')
        assert import_dsc(['arg0', dsc]) == 0
        repo = ComponentTestGitRepository('git-buildpackage')
        os.chdir('git-buildpackage')
        repo.delete_tag('debian/0.4.14')  # make sure we can tag again
        ret = buildpackage(['arg0',
                            '--git-tag-only',
                            '--git-posttag=printenv > posttag.out',
                            '--git-builder=touch builder-run.stamp',
                            '--git-cleaner=/bin/true'])
        ok_(ret == 0, "Building the package failed")
        eq_(os.path.exists('posttag.out'), True)
        eq_(os.path.exists('builder-run.stamp'), False)
        self.check_hook_vars('posttag', ["GBP_TAG",
                                         "GBP_BRANCH",
                                         "GBP_SHA1"])