示例#1
0
    def _create_package(self, config, p, args):
        if args.type == 'native':
            pkg = Packager(config, p, self.store)
        else:
            pkg = DistArchive(config, p, self.store, args.type)

        m.action(_("Creating package for %s") % p.name)
        p.pre_package()
        paths = pkg.pack(os.path.abspath(args.output_dir), not args.no_devel,
                         args.force, args.keep_temp)
        if None in paths:
            paths.remove(None)
        if '' in paths:
            paths.remove('')

        paths = p.post_package(paths) or paths
        for p in paths:
            BUF_SIZE = 65536  # 64kb chunks
            sha1 = hashlib.sha1()
            with open(os.path.abspath(p), 'rb') as f:
                while True:
                    data = f.read(BUF_SIZE)
                    if not data:
                        break
                    sha1.update(data)
            sha1sum = sha1.hexdigest()

            m.action(_("Package successfully created in %s %s") % (os.path.abspath(p), sha1sum))
            # Generate the sha1sum file
            with open('%s.sha1' % p, 'w+') as sha1file:
                sha1file.write(sha1sum)
        return paths
示例#2
0
文件: package.py 项目: z-ming/cerbero
    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]))
示例#3
0
    def run(self, config, args):
        self.store = PackagesStore(config, offline=args.offline)
        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, args.offline,
                             args.dry_run)

        if args.only_build_deps or args.dry_run:
            return

        if args.xz:
            config.package_tarball_compression = 'xz'

        if p is None:
            raise PackageNotFoundError(args.package[0])
        p.pre_package()
        if args.tarball:
            if config.target_platform == Platform.ANDROID and \
               config.target_arch == Architecture.UNIVERSAL:
                pkg = AndroidPackager(config, p, self.store)
            else:
                pkg = DistTarball(config, p, self.store)
        else:
            pkg = Packager(config, p, self.store)
        m.action(_("Creating package for %s") % p.name)
        output_dir = os.path.abspath(args.output_dir)
        if args.tarball:
            paths = pkg.pack(output_dir,
                             args.no_devel,
                             args.force,
                             args.keep_temp,
                             split=not args.no_split,
                             strip_binaries=p.strip)
        else:
            paths = pkg.pack(output_dir, args.no_devel, args.force,
                             args.keep_temp)
        if None in paths:
            paths.remove(None)
        paths = p.post_package(paths, output_dir) or paths
        m.action(
            _("Package successfully created in %s") %
            ' '.join([os.path.abspath(x) for x in paths]))