Example #1
0
    def test_make_tarball_with_orig(self):
        project_dir = self.datapath('packages/first')
        builder = build.Builder()
        builder.go_into_package_dir([project_dir])
        builder._set_package_format()

        with tempdir(False) as tmpdir:
            tgz1 = builder.make_orig_tarball(tmpdir)
            self.assertTrue(osp.exists(tgz1))

            project_dir = self.datapath('packages/next')
            builder = build.Builder()
            builder.go_into_package_dir([project_dir])
            builder._set_package_format()
            builder.config.orig_tarball = tgz1

            with tempdir(False) as tmpdir:
                tgz2 = builder.make_orig_tarball(tmpdir)
                self.assertFalse(os.system('diff -b %s %s' % (tgz1, tgz2)))
                self.assertEqual(osp.basename(tgz1), osp.basename(tgz2))
                tar1 = tarfile.open(tgz1, "r:gz")
                tar2 = tarfile.open(tgz2, "r:gz")

        self.assertSequenceEqual([(to.name, to.size)
                                  for to in tar1.getmembers()],
                                 [(to.name, to.size)
                                  for to in tar2.getmembers()])
    def test_tempdir_utility(self):
        with self.assertRaises(AssertionError):
            with utils.tempdir(False) as tmpdir:
                # force exception raising in with block
                assert False
        self.assertFalse(exists(tmpdir))

        with self.assertRaises(AssertionError):
            with utils.tempdir(True) as tmpdir:
                # force exception raising in with block
                assert False
        self.assertTrue(exists(tmpdir))
        os.rmdir(tmpdir)
Example #3
0
    def test_make_tarball_rev1(self):
        project_dir = self.datapath('packages/first')
        builder = build.Builder()
        builder.go_into_package_dir([project_dir])
        builder._set_package_format()

        with tempdir(False) as tmpdir:
            tgz = builder.make_orig_tarball(tmpdir)
            self.assertTrue(osp.exists(tgz))
            with tempdir(False) as tmpdir2:
                dscfile = builder.make_debian_source_package('sid',
                                                             tmpdir=tmpdir2)
                self.assertTrue(osp.exists(dscfile))
Example #4
0
 def run(self, args):
     Cleaner(config=self.config).run(args)
     os.umask(0o002)
     # create the upstream tarball if necessary and move it to result directory
     with tempdir(self.config.keep_tmpdir) as tmpdir:
         self.make_orig_tarball(tmpdir)
         try:
             for distrib in self.distributions:
                 self.logger.info('Attempting to build %s', distrib)
                 with tempdir(self.config.keep_tmpdir) as src_tmpdir:
                     if self.config.rpm or distrib.startswith(
                         ('fedora', 'epel')):
                         specfile = self.get_rpm_specfile()
                         if specfile is None:
                             # do not crash if a project does not (yet) provide a .spec file
                             continue
                         srpm = self.make_rpm_source_package(
                             specfile, distrib, src_tmpdir)
                         self.make_rpm_binary_package(distrib, srpm)
                         # move logs and rpms to distdir
                         rpms = glob(osp.join(src_tmpdir, '*.rpm'))
                         buildlog = glob(osp.join(src_tmpdir, '*.log'))
                         self.move_package_files(
                             rpms + buildlog, self.get_distrib_dir(distrib))
                         #
                         if self.config.post_treatments:
                             self.run_rpm_post_treatments(distrib)
                     else:
                         # create a debian source package
                         dscfile = self.make_debian_source_package(
                             distrib, src_tmpdir)
                         if self.make_debian_binary_package(
                                 distrib, dscfile):
                             # do post-treatments only for a successful binary build
                             if self.packages and self.config.post_treatments:
                                 self.run_deb_post_treatments(distrib)
             # report files to the console
             if self.packages:
                 self.logger.info("recent files from build:\n* %s" %
                                  '\n* '.join(sorted(set(self.packages))))
         except LGPException as exc:
             # XXX refactor ? if getattr(self.config, "verbose"):
             if hasattr(self, "config") and self.config.verbose:
                 import traceback
                 self.logger.critical(traceback.format_exc())
             raise exc
         finally:
             self.destroy_tmp_context()
         return self.build_status
Example #5
0
    def test_make_tarball_rev2(self):
        project_dir = self.datapath('packages/next')
        builder = build.Builder()
        builder.go_into_package_dir([project_dir])
        builder._set_package_format()

        with self.assertRaises(LGPCommandException):
            with tempdir(False) as tmpdir:
                builder.make_orig_tarball(tmpdir)