def test_debian_buildpackage(self):
        """Test that building 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')
        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"])
示例#2
0
    def _test_buildpackage(self, pkg, dir, version, opts=[]):
        dsc = self._dsc_name(pkg, version, dir)
        assert import_dsc(['arg0', dsc]) == 0
        ComponentTestGitRepository(pkg)
        prebuild_out = os.path.join(os.path.abspath(pkg), 'prebuild.out')
        postbuild_out = os.path.join(os.path.abspath(pkg), 'postbuild.out')
        os.chdir(pkg)

        args = ['arg0',
                '--git-prebuild=printenv > %s' % prebuild_out,
                '--git-postbuild=printenv > %s' % postbuild_out,
                '--git-builder=/bin/true',
                '--git-cleaner=/bin/true'] + opts
        ret = buildpackage(args)
        ok_(ret == 0, "Building the package failed")
        eq_(os.path.exists(prebuild_out), True)
        eq_(os.path.exists(postbuild_out), True)

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

        self.check_hook_vars('postbuild', ["GBP_CHANGES_FILE",
                                           "GBP_BUILD_DIR",
                                           "GBP_CHANGES_FILE",
                                           "GBP_BUILD_DIR"])
    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"
        ])
示例#4
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_pristine_tar_commit(self, repo):
     """Test that committing to pristine-tar branch after building tarballs works"""
     assert_false(repo.has_branch('pristine-tar'), "Pristine-tar branch must not exist")
     ret = buildpackage(['arg0',
                         '--git-builder=/bin/true',
                         '--git-pristine-tar-commit'])
     ok_(ret == 0, "Building the package failed")
     assert_true(repo.has_branch('pristine-tar'), "Pristine-tar branch must exist")
     eq_(repo.ls_tree('pristine-tar'), {b'hello-debhelper_2.8.orig.tar.gz.id',
                                        b'hello-debhelper_2.8.orig.tar.gz.delta'})
 def test_pristine_tar_commit(self, repo):
     """Test that committing to pristine-tar branch after building tarballs works"""
     assert_false(repo.has_branch('pristine-tar'), "Pristine-tar branch must not exist")
     ret = buildpackage(['arg0',
                         '--git-builder=/bin/true',
                         '--git-pristine-tar-commit'])
     ok_(ret == 0, "Building the package failed")
     assert_true(repo.has_branch('pristine-tar'), "Pristine-tar branch must exist")
     eq_(repo.ls_tree('pristine-tar'), {b'hello-debhelper_2.8.orig.tar.gz.id',
                                        b'hello-debhelper_2.8.orig.tar.gz.delta'})
 def test_broken_upstream_version(self, repo):
     cl = ChangeLog(filename='debian/changelog')
     cl.add_section(["broken versionnumber"],
                    "unstable",
                    version={'version': "3.0"})
     ret = buildpackage(['argv0',
                         '--git-ignore-new',
                         '--git-builder=/bin/true',
                         '--git-tarball-dir=../tarballs'])
     eq_(ret, 1)
     self._check_log(-1, "gbp:error: Non-native package 'hello-debhelper' has invalid version '3.0'")
 def test_broken_upstream_version(self, repo):
     cl = ChangeLog(filename='debian/changelog')
     cl.add_section(["broken versionnumber"],
                    "unstable",
                    version={'version': "3.0"})
     ret = buildpackage(['argv0',
                         '--git-ignore-new',
                         '--git-builder=/bin/true',
                         '--git-tarball-dir=../tarballs'])
     eq_(ret, 1)
     self._check_log(-1, "gbp:error: Non-native package 'hello-debhelper' has invalid version '3.0'")
示例#9
0
 def test_argument_quoting(self, repo):
     """Test that we quote arguments to builder (#850869)"""
     with open('../arg with spaces', 'w'):
         pass
     # We use ls as builder to look for a file with spaces. This
     # will fail if build arguments are not properly quoted and
     # therefore split up
     ret = buildpackage([
         'arg0', '--git-builder=ls', '--git-cleaner=/bin/true',
         '../arg with spaces'
     ])
     ok_(ret == 0, "Building the package failed")
示例#10
0
 def test_tag_pq_branch(self, repo):
     ret = pq(['argv0', 'import'])
     eq_(repo.rev_parse('master'), repo.rev_parse('debian/2.8-1^{}'))
     eq_(ret, 0)
     eq_(repo.branch, 'patch-queue/master')
     self.add_file(repo, 'foo.txt')
     ret = buildpackage(
         ['argv0', '--git-tag-only', '--git-retag', '--git-ignore-branch'])
     eq_(ret, 0)
     eq_(repo.branch, 'patch-queue/master')
     eq_(repo.rev_parse('patch-queue/master^{}^'),
         repo.rev_parse('debian/2.8-1^{}'))
示例#11
0
 def test_tag_detached_head(self, repo):
     """
     Test that tagging works with an detached head (#863167)
     """
     eq_(repo.rev_parse('master^{}'), repo.rev_parse('debian/2.8-1^{}'))
     self.add_file(repo, 'debian/foo.txt')
     repo.checkout("HEAD~")
     ret = buildpackage(
         ['argv0', '--git-tag-only', '--git-retag', '--git-ignore-branch'])
     eq_(ret, 0)
     repo.checkout("master")
     eq_(repo.rev_parse('master~^{}'), repo.rev_parse('debian/2.8-1^{}'))
 def test_argument_quoting(self, repo):
     """Test that we quote arguments to builder (#850869)"""
     with open('../arg with spaces', 'w'):
         pass
     # We use ls as builder to look for a file with spaces. This
     # will fail if build arguments are not properly quoted and
     # therefore split up
     ret = buildpackage(['arg0',
                         '--git-builder=ls',
                         '--git-cleaner=/bin/true',
                         '../arg with spaces'])
     ok_(ret == 0, "Building the package failed")
示例#13
0
 def test_tag_only(self, repo):
     """Test that only tagging a native debian package works"""
     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", "debian/0.4.14"),
                                      ("GBP_BRANCH", "master"), "GBP_SHA1"])
示例#14
0
    def test_debian_buildpackage(self):
        """Test that building 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')
        ret = buildpackage(
            ['arg0', '--git-builder=/bin/true', '--git-cleaner=/bin/true'])
        ok_(ret == 0, "Building the package failed")
 def test_tag_pq_branch(self, repo):
     ret = pq(['argv0', 'import'])
     eq_(repo.rev_parse('master'), repo.rev_parse('debian/2.8-1^{}'))
     eq_(ret, 0)
     eq_(repo.branch, 'patch-queue/master')
     self.add_file(repo, 'foo.txt')
     ret = buildpackage(['argv0',
                         '--git-tag-only',
                         '--git-retag',
                         '--git-ignore-branch'])
     eq_(ret, 0)
     eq_(repo.branch, 'patch-queue/master')
     eq_(repo.rev_parse('patch-queue/master^{}^'), repo.rev_parse('debian/2.8-1^{}'))
 def test_tag_detached_head(self, repo):
     """
     Test that tagging works with an detached head (#863167)
     """
     eq_(repo.rev_parse('master^{}'), repo.rev_parse('debian/2.8-1^{}'))
     self.add_file(repo, 'debian/foo.txt')
     repo.checkout("HEAD~")
     ret = buildpackage(['argv0',
                         '--git-tag-only',
                         '--git-retag',
                         '--git-ignore-branch'])
     eq_(ret, 0)
     repo.checkout("master")
     eq_(repo.rev_parse('master~^{}'), repo.rev_parse('debian/2.8-1^{}'))
 def test_tag_only(self, repo):
     """Test that only tagging a native debian package works"""
     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", "debian/0.4.14"),
                                         ("GBP_BRANCH", "master"),
                                         "GBP_SHA1"])
示例#18
0
    def test_debian_buildpackage(self):
        """Test that building 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')
        ret = buildpackage(['arg0',
                            '--git-builder=/bin/true',
                            '--git-cleaner=/bin/true'])
        ok_(ret == 0, "Building the package failed")
示例#19
0
 def test_tarball_default_compression(self, repo):
     """Test that we use defaults for compression if not given (#820846)"""
     self._test_buildpackage(repo, ['--git-no-pristine-tar'])
     tarball = "../hello-debhelper_2.8.orig.tar.gz"
     out = subprocess.check_output(["file", tarball])
     ok_(b"max compression" not in out)
     m1 = hashlib.md5(open(tarball, 'rb').read()).hexdigest()
     os.unlink(tarball)
     eq_(
         buildpackage([
             'arg0', '--git-ignore-new', '--git-builder=/bin/true',
             '--git-cleaner=/bin/true', '../arg with spaces'
         ]), 0)
     m2 = hashlib.md5(open(tarball, 'rb').read()).hexdigest()
     eq_(m1, m2, "Regenerated tarball has different checksum")
 def test_tarball_default_compression(self, repo):
     """Test that we use defaults for compression if not given (#820846)"""
     self._test_buildpackage(repo, ['--git-no-pristine-tar'])
     tarball = "../hello-debhelper_2.8.orig.tar.gz"
     out = subprocess.check_output(["file", tarball])
     ok_(b"max compression" not in out)
     m1 = hashlib.md5(open(tarball, 'rb').read()).hexdigest()
     os.unlink(tarball)
     eq_(buildpackage(['arg0',
                       '--git-ignore-new',
                       '--git-builder=/bin/true',
                       '--git-cleaner=/bin/true',
                       '../arg with spaces']), 0)
     m2 = hashlib.md5(open(tarball, 'rb').read()).hexdigest()
     eq_(m1, m2, "Regenerated tarball has different checksum")
    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"])
示例#22
0
    def test_argument_quoting(self):
        """Test that we quote arguments to builder (#)"""
        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
        os.chdir('git-buildpackage')
        with open('../arg with spaces', 'w'):
            pass
        # We use ls as builder to look for a file with spaces. This
        # will fail if build arguments are not properly quoted and
        # therefore split up
        ret = buildpackage(['arg0',
                            '--git-builder=ls',
                            '--git-cleaner=/bin/true',
                            '../arg with spaces'])
        ok_(ret == 0, "Building the package failed")
示例#23
0
    def _test_buildpackage(self, repo, opts=[]):
        prebuild_out = os.path.join(repo.path, '..', 'prebuild.out')
        postbuild_out = os.path.join(repo.path, '..', 'postbuild.out')
        args = [
            'arg0',
            '--git-prebuild=printenv > %s' % prebuild_out,
            '--git-postbuild=printenv > %s' % postbuild_out,
            '--git-builder=/bin/true', '--git-cleaner=/bin/true'
        ] + opts
        os.chdir(repo.path)
        ret = buildpackage(args)
        ok_(ret == 0, "Building the package failed")
        eq_(os.path.exists(prebuild_out), True)
        eq_(os.path.exists(postbuild_out), True)

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

        self.check_hook_vars('../postbuild', [
            "GBP_CHANGES_FILE", "GBP_BUILD_DIR", "GBP_CHANGES_FILE",
            "GBP_BUILD_DIR"
        ])
    def _test_buildpackage(self, pkg, dir, version):
        dsc = self._dsc_name(pkg, version, dir)
        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"])
    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_buildpackage(self, repo, opts=[]):
        prebuild_out = os.path.join(repo.path, '..', 'prebuild.out')
        postbuild_out = os.path.join(repo.path, '..', 'postbuild.out')
        args = ['arg0',
                '--git-prebuild=printenv > %s' % prebuild_out,
                '--git-postbuild=printenv > %s' % postbuild_out,
                '--git-builder=/bin/true',
                '--git-cleaner=/bin/true'] + opts
        os.chdir(repo.path)
        ret = buildpackage(args)
        ok_(ret == 0, "Building the package failed")
        eq_(os.path.exists(prebuild_out), True)
        eq_(os.path.exists(postbuild_out), True)

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

        self.check_hook_vars('../postbuild', ["GBP_CHANGES_FILE",
                                              "GBP_BUILD_DIR",
                                              "GBP_CHANGES_FILE",
                                              "GBP_BUILD_DIR"])
    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"])
    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_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"])