def run(self, config, args): self.store = PackagesStore(config) p = self.store.get_package(args.package[0]) if args.skip_deps_build and args.only_build_deps: raise UsageError(_("Cannot use --skip-deps-build together with " "--only-build-deps")) if not args.skip_deps_build: self._build_deps(config, p, args.no_devel) if args.only_build_deps: return if p is None: raise PackageNotFoundError(args.package[0]) if args.tarball: pkg = DistTarball(config, p, self.store) else: pkg = Packager(config, p, self.store) m.action(_("Creating package for %s") % p.name) if args.tarball: paths = pkg.pack(os.path.abspath(args.output_dir), args.no_devel, args.force, args.keep_temp, split=not args.no_split) else: paths = pkg.pack(os.path.abspath(args.output_dir), args.no_devel, args.force, args.keep_temp) if None in paths: paths.remove(None) p.post_install(paths) m.action(_("Package successfully created in %s") % ' '.join([os.path.abspath(x) for x in paths]))
def pack(self, output_dir, devel=True, force=False, keep_temp=False, pack_deps=True, tmpdir=None): self.install_dir = self.package.get_install_dir() self.devel = devel self.force = force self._empty_packages = [] # Create a tmpdir for packages tmpdir, packagedir, srcdir = self.create_tree(tmpdir) # only build each package once if isinstance(self.package, App) and self.package.embed_deps: pass elif pack_deps: self.pack_deps(output_dir, tmpdir, force) if not isinstance(self.package, MetaPackage): # create a tarball with all the package's files tarball_packager = DistTarball(self.config, self.package, self.store) tarball = tarball_packager.pack( tmpdir, devel, True, split=False, package_prefix=self.full_package_name, strip_binaries=False)[0] tarname = self.setup_source(tarball, tmpdir, packagedir, srcdir) else: # metapackages only contains Requires dependencies with # other packages tarname = None m.action(_('Creating package for %s') % self.package.name) try: # do the preparations, fill spec file, write debian files, etc self.prepare(tarname, tmpdir, packagedir, srcdir) # and build the package paths = self.build(output_dir, tarname, tmpdir, packagedir, srcdir) stamp_path = os.path.join(tmpdir, self.package.name + '-stamp') open(stamp_path, 'w').close() finally: if not keep_temp: m.action(_('Removing temporary dir %s') % tmpdir) shutil.rmtree(tmpdir) return paths
class DistTarballTest(unittest.TestCase): def setUp(self): self.config = DummyConfig() self.tmp = tempfile.mkdtemp() self.config.prefix = self.tmp self.store = create_store(self.config) self.package = self.store.get_package('gstreamer-runtime') self.packager = DistTarball(self.config, self.package, self.store) add_files(self.tmp) def tearDown(self): shutil.rmtree(self.tmp) def testRuntimePackage(self): # Creates one package with the runtime files filenames = self.packager.pack(self.tmp, devel=False) self.assertEquals(len(filenames), 1) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEquals(tarfiles, self.package.files_list()) def testRuntimeAndDevelPackages(self): # Creates 2 packages, one with the runtime files a second one with the # devel files filenames = self.packager.pack(self.tmp, devel=True) self.assertEquals(len(filenames), 2) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEquals(tarfiles, self.package.files_list()) tar = tarfile.open(filenames[1], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEquals(tarfiles, self.package.devel_files_list()) def testRuntimeWithDevelPackage(self): # Creates 1 package, with the runtime files and the devel files filenames = self.packager.pack(self.tmp, devel=True, split=False) self.assertEquals(len(filenames), 1) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEquals(tarfiles, self.package.all_files_list())
class DistTarballTest(unittest.TestCase): def setUp(self): self.config = DummyConfig() self.tmp = tempfile.mkdtemp() self.config.prefix = self.tmp self.store = create_store(self.config) self.package = self.store.get_package('gstreamer-runtime') self.packager = DistTarball(self.config, self.package, self.store) add_files(self.tmp) def tearDown(self): shutil.rmtree(self.tmp) def testRuntimePackage(self): # Creates one package with the runtime files filenames = self.packager.pack(self.tmp, devel=False) self.assertEqual(len(filenames), 1) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEqual(tarfiles, self.package.files_list()) def testRuntimeAndDevelPackages(self): # Creates 2 packages, one with the runtime files a second one with the # devel files filenames = self.packager.pack(self.tmp, devel=True) self.assertEqual(len(filenames), 2) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEqual(tarfiles, self.package.files_list()) tar = tarfile.open(filenames[1], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEqual(tarfiles, self.package.devel_files_list()) def testRuntimeWithDevelPackage(self): # Creates 1 package, with the runtime files and the devel files filenames = self.packager.pack(self.tmp, devel=True, split=False) self.assertEqual(len(filenames), 1) tar = tarfile.open(filenames[0], "r:bz2") tarfiles = sorted([x.path for x in tar.getmembers()]) self.assertEqual(tarfiles, self.package.all_files_list())
def pack(self, output_dir, devel=True, force=False, keep_temp=False, pack_deps=True, tmpdir=None): self.install_dir = self.package.get_install_dir() self.devel = devel self.force = force self._empty_packages = [] # Create a tmpdir for packages tmpdir, packagedir, srcdir = self.create_tree(tmpdir) # only build each package once if isinstance(self.package, App) and self.package.embed_deps: pass elif pack_deps: self.pack_deps(output_dir, tmpdir, force) if not isinstance(self.package, MetaPackage): # create a tarball with all the package's files tarball_packager = DistTarball(self.config, self.package, self.store) tarball = tarball_packager.pack(tmpdir, devel, True, split=False, package_prefix=self.full_package_name)[0] tarname = self.setup_source(tarball, tmpdir, packagedir, srcdir) else: # metapackages only contains Requires dependencies with # other packages tarname = None m.action(_('Creating package for %s') % self.package.name) try: # do the preparations, fill spec file, write debian files, etc self.prepare(tarname, tmpdir, packagedir, srcdir) # and build the package paths = self.build(output_dir, tarname, tmpdir, packagedir, srcdir) stamp_path = os.path.join(tmpdir, self.package.name + '-stamp') open(stamp_path, 'w').close() finally: if not keep_temp: m.action(_('Removing temporary dir %s') % tmpdir) shutil.rmtree(tmpdir) return paths