Пример #1
0
 def test_simple(self):
     ipkg = InstalledPkgDescription(self.sections, self.meta, {})
     sections = ipkg.resolve_paths()
     res = sorted([(kind, source, target) for kind, source, target in iter_files(sections)])
     target_dir = ipkg.resolve_path(os.path.join("$prefix", "target"))
     ref = [("pythonfiles", os.path.join("source", "scripts", "bar.py"), os.path.join(target_dir, "scripts", "bar.py")),
            ("pythonfiles", os.path.join("source", "scripts", "foo.py"), os.path.join(target_dir, "scripts", "foo.py"))]
     self.assertEqual(res, ref)
Пример #2
0
    def store(self, filename, pkg):
        s = get_configured_state()
        scheme = dict([(k, s.paths[k]) for k in s.paths])

        meta = ipkg_meta_from_pkg(pkg)
        p = InstalledPkgDescription(self.sections, meta, scheme,
                                    pkg.executables)
        p.write(filename)
Пример #3
0
    def test_simple_roundtrip(self):
        # FIXME: we compare the loaded json to avoid dealing with encoding
        # differences when comparing objects, but this is kinda stupid
        r_ipkg = InstalledPkgDescription(self.sections, self.meta, {})
        f = StringIO()
        r_ipkg._write(f)
        r_s = f.getvalue()

        ipkg = InstalledPkgDescription.from_string(r_s)
        f = StringIO()
        ipkg._write(f)
        s = f.getvalue()

        self.assertEqual(json.loads(r_s), json.loads(s))
Пример #4
0
    def test_simple_roundtrip(self):
        # FIXME: we compare the loaded json to avoid dealing with encoding
        # differences when comparing objects, but this is kinda stupid
        r_ipkg = InstalledPkgDescription(self.sections, self.meta, {})
        f = StringIO()
        r_ipkg._write(f)
        r_s = f.getvalue()

        ipkg = InstalledPkgDescription.from_string(r_s)
        f = StringIO()
        ipkg._write(f)
        s = f.getvalue()
        
        self.assertEqual(json.loads(r_s), json.loads(s))
Пример #5
0
 def test_simple(self):
     ipkg = InstalledPkgDescription(self.sections, self.meta, {})
     sections = ipkg.resolve_paths(self.top_node)
     res = sorted([(kind, source.abspath(), target.abspath()) \
                   for kind, source, target in iter_files(sections)])
     target_dir = ipkg.resolve_path(os.path.join("$prefix", "target"))
     ref = [("pythonfiles",
             os.path.join(self.top_node.abspath(), "source", "scripts",
                          "bar.py"),
             os.path.join(target_dir, "scripts", "bar.py")),
            ("pythonfiles",
             os.path.join(self.top_node.abspath(), "source", "scripts",
                          "foo.py"),
             os.path.join(target_dir, "scripts", "foo.py"))]
     self.assertEqual(res, ref)
Пример #6
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        if o.dry_run:
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = ctx.get_paths_scheme()
        ipkg.update_paths(scheme)
        node_sections = ipkg.resolve_paths_with_destdir(ctx.build_node)

        if o.list_files:
            # XXX: this won't take into account action in post install scripts.
            # A better way would be to log install steps and display those, but
            # this will do for now.
            for kind, source, target in iter_files(node_sections):
                print(target.abspath())
            return

        if o.transaction:
            trans = TransactionLog("transaction.log")
            try:
                for kind, source, target in iter_files(node_sections):
                    trans.copy(source.abspath(), target.abspath(), kind)
            finally:
                trans.close()
        else:
            for kind, source, target in iter_files(node_sections):
                copy_installer(source.abspath(), target.abspath(), kind)
Пример #7
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = ctx.retrieve_configured_scheme()
        ipkg.update_paths(scheme)
        node_sections = ipkg.resolve_paths_with_destdir(ctx.build_node)

        if o.list_files:
            # XXX: this won't take into account action in post install scripts.
            # A better way would be to log install steps and display those, but
            # this will do for now.
            for kind, source, target in iter_files(node_sections):
                print(target.abspath())
            return

        if o.transaction:
            trans = TransactionLog("transaction.log")
            try:
                for kind, source, target in iter_files(node_sections):
                    trans.copy(source.abspath(), target.abspath(), kind)
            finally:
                trans.close()
        else:
            for kind, source, target in iter_files(node_sections):
                copy_installer(source.abspath(), target.abspath(), kind)
Пример #8
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        root = ctx.top_node
        while root.height() > 0:
            root = root.parent

        default_scheme = get_default_scheme(ctx.pkg.name)
        default_prefix = default_scheme["prefix"]
        default_sitedir = default_scheme["sitedir"]

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        name = ipkg.meta["name"]
        version = ipkg.meta["version"]
        py_short = ".".join([str(i) for i in sys.version_info[:2]])
        mpkg_name = "%s-%s-py%s.mpkg" % (name, version, py_short)

        categories = set()
        file_sections = ipkg.resolve_paths(ctx.build_node)
        for kind, source, target in iter_files(file_sections):
            categories.add(kind)

        # Mpkg metadata
        mpkg_root = os.path.join(os.getcwd(), "dist", mpkg_name)
        mpkg_cdir = os.path.join(mpkg_root, "Contents")
        if os.path.exists(mpkg_root):
            shutil.rmtree(mpkg_root)
        os.makedirs(mpkg_cdir)
        f = open(os.path.join(mpkg_cdir, "PkgInfo"), "w")
        try:
            f.write("pmkrpkg1")
        finally:
            f.close()
        mpkg_info = MetaPackageInfo.from_ipkg(ipkg)

        purelib_pkg = "%s-purelib-%s-py%s.pkg" % (name, version, py_short)
        scripts_pkg = "%s-scripts-%s-py%s.pkg" % (name, version, py_short)
        datafiles_pkg = "%s-datafiles-%s-py%s.pkg" % (name, version, py_short)
        mpkg_info.packages = [purelib_pkg, scripts_pkg, datafiles_pkg]
        make_mpkg_plist(mpkg_info, os.path.join(mpkg_cdir, "Info.plist"))

        mpkg_rdir = os.path.join(mpkg_root, "Contents", "Resources")
        os.makedirs(mpkg_rdir)
        make_mpkg_description(mpkg_info, os.path.join(mpkg_rdir, "Description.plist"))

        # Package the stuff which ends up into site-packages
        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", purelib_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["pythonfiles"], "Pure Python modules and packages")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", scripts_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["executables"], "Scripts and binaries")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", datafiles_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["bentofiles", "datafiles"], "Data files")
Пример #9
0
    def test_create_exe(self):
        # FIXME: do a real test here
        meta, sections, nodes = create_simple_ipkg_args(self.top_node)
        ipkg = InstalledPkgDescription(sections, meta, {})

        fid, arcname = tempfile.mkstemp(prefix="zip")
        try:
            create_exe(ipkg, arcname, "some-name.exe")
        finally:
            os.close(fid)
Пример #10
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        create_wininst(ipkg, src_root_node=ctx.build_node, build_node=ctx.build_node)
Пример #11
0
    def run(self, ctx):
        opts = ctx.cmd_opts
        o, a = self.parser.parse_args(opts)
        if o.help:
            self.parser.print_help()
            return

        if not os.path.exists(IPKG_PATH):
            raise UsageException("%s: error: %s subcommand require executed build" \
                    % (SCRIPT_NAME, "build_wininst"))

        ipkg = InstalledPkgDescription.from_file(IPKG_PATH)
        create_wininst(ipkg)
Пример #12
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        output_dir = o.output_dir
        output_file = o.output_file

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        build_egg(ipkg, ctx, ctx.build_node, output_dir, output_file)
Пример #13
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        output_dir = o.output_dir
        output_file = o.output_file

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        build_egg(ipkg, ctx, ctx.build_node, output_dir, output_file)
Пример #14
0
    def run(self):

        build = self.get_finalized_command("build")
        build.run()

        dist = build.distribution
        n = dist.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())

        build_node = self.distribution.build_node
        # FIXME: fix build_egg signature - we use a dummy context here to avoid
        # creating the whole command context stuff
        context = _FakeContext(build_node)
        build_egg(ipkg, context, build_node.abspath())
Пример #15
0
    def run(self):
        self.run_command("build")
        dist = self.distribution

        n = dist.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())

        egg_info = EggInfo.from_ipkg(ipkg, dist.build_node)

        egg_info_dir = op.join(self.egg_base, "%s.egg-info" % dist.pkg.name)
        try:
            os.makedirs(egg_info_dir)
        except OSError, e:
            if e.errno != 17:
                raise
Пример #16
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        create_wininst(ipkg,
                       src_root_node=ctx.build_node,
                       build_node=ctx.build_node,
                       wininst=o.output_file,
                       output_dir=o.output_dir)
Пример #17
0
    def run(self):
        self.run_command("build")
        dist = self.distribution

        n = dist.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())

        egg_info = EggInfo.from_ipkg(ipkg, dist.build_node)

        egg_info_dir = op.join(self.egg_base, "%s.egg-info" % dist.pkg.name)
        try:
            os.makedirs(egg_info_dir)
        except OSError, e:
            if e.errno != 17:
                raise
Пример #18
0
    def run(self, ctx):
        argv = ctx.get_command_arguments()
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return
        if o.output_dir is None:
            output_dir = None
        else:
            output_dir = o.output_dir

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        build_egg(ipkg, ctx, ctx.build_node, output_dir)
Пример #19
0
    def run(self, ctx):
        opts = ctx.cmd_opts
        o, a = self.parser.parse_args(opts)
        if o.help:
            self.parser.print_help()
            return

        if not os.path.exists(IPKG_PATH):
            msg = "%s file not found ! (Did you run build ?)" % IPKG_PATH
            raise UsageException(msg)

        ipkg = InstalledPkgDescription.from_file(IPKG_PATH)
        file_sections = ipkg.resolve_paths()

        for kind, source, target in iter_files(file_sections):
            copy_installer(source, target, kind)
Пример #20
0
    def write_record(self):
        dist = self.distribution

        options_context = dist.global_context.retrieve_options_context(self.cmd_name)
        cmd_context_klass = dist.global_context.retrieve_command_context(self.cmd_name)
        context = cmd_context_klass(dist.global_context, [], options_context, dist.pkg, dist.run_node)

        n = context.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = context.retrieve_configured_scheme()
        ipkg.update_paths(scheme)
        file_sections = ipkg.resolve_paths_with_destdir(src_root_node=context.build_node)

        def writer(fid):
            for kind, source, target in iter_files(file_sections):
                fid.write("%s\n" % target.abspath())
        bento.utils.io2.safe_write(self.record, writer, "w")
Пример #21
0
 def test_simple(self):
     """This just tests whether create_wininst runs at all and produces a zip-file."""
     ipackage = InstalledPkgDescription({}, {
         "name": "foo",
         "version": "1.0"
     }, {})
     create_wininst(ipackage,
                    self.build_node,
                    self.build_node,
                    wininst="foo.exe",
                    output_dir="dist")
     arcname = bento.commands.build_wininst.create_exe.call_args[0][1]
     fp = zipfile.ZipFile(arcname)
     try:
         fp.namelist()
     finally:
         fp.close()
Пример #22
0
    def write_record(self):
        dist = self.distribution

        install = InstallCommand()
        options_context = OptionsContext.from_command(install)
        context = CmdContext([], options_context, dist.pkg, dist.run_node)
        if self.record:
            n = context.build_node.make_node(IPKG_PATH)
            ipkg = InstalledPkgDescription.from_file(n.abspath())
            scheme = context.get_paths_scheme()
            ipkg.update_paths(scheme)
            file_sections = ipkg.resolve_paths(src_root_dir=context.build_node.abspath())

            fid = open(self.record, "w")
            try:
                for kind, source, target in iter_files(file_sections):
                    fid.write("%s\n" % target)
            finally:
                fid.close()
Пример #23
0
def extract_egg(egg, extract_dir):
    # Given a bento-produced egg, extract its content in the given directory,
    # and returned the corresponding ipkg info instance
    ipkg = InstalledPkgDescription.from_egg(egg)
    # egg scheme
    ipkg.update_paths({"prefix": ".", "eprefix": ".", "sitedir": "."})

    zid = zipfile.ZipFile(egg)
    try:
        for type, sections in ipkg.files.items():
            for name, section in sections.items():
                target_dir = ipkg.resolve_path(section.target_dir)
                section.source_dir = os.path.join(extract_dir, target_dir)
                for source, target in section.files:
                    g = os.path.join(target_dir, target)
                    g = os.path.normpath(g)
                    zid.extract(g, extract_dir)
    finally:
        zid.close()

    return ipkg
Пример #24
0
    def write_record(self):
        dist = self.distribution

        options_context = dist.global_context.retrieve_options_context(
            self.cmd_name)
        cmd_context_klass = dist.global_context.retrieve_command_context(
            self.cmd_name)
        context = cmd_context_klass(dist.global_context, [], options_context,
                                    dist.pkg, dist.run_node)

        n = context.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        scheme = context.retrieve_configured_scheme()
        ipkg.update_paths(scheme)
        file_sections = ipkg.resolve_paths_with_destdir(
            src_root_node=context.build_node)

        def writer(fid):
            for kind, source, target in iter_files(file_sections):
                fid.write("%s\n" % target.abspath())

        bento.utils.io2.safe_write(self.record, writer, "w")
Пример #25
0
 def test_simple_create(self):
     InstalledPkgDescription(self.sections, self.meta, {})
Пример #26
0
 def store(self, filename, pkg):
     meta = ipkg_meta_from_pkg(pkg)
     p = InstalledPkgDescription(self.sections, meta, pkg.executables)
     p.write(filename)
Пример #27
0
    def run(self, ctx):
        argv = ctx.command_argv
        p = ctx.options_context.parser
        o, a = p.parse_args(argv)
        if o.help:
            p.print_help()
            return

        root = ctx.top_node
        while root.height() > 0:
            root = root.parent

        default_scheme = get_default_scheme(ctx.pkg.name)
        default_prefix = default_scheme["prefix"]
        default_sitedir = default_scheme["sitedir"]

        n = ctx.build_node.make_node(IPKG_PATH)
        ipkg = InstalledPkgDescription.from_file(n.abspath())
        name = ipkg.meta["name"]
        version = ipkg.meta["version"]
        py_short = ".".join([str(i) for i in sys.version_info[:2]])
        if o.output_file is None:
            mpkg_name = "%s-%s-py%s.mpkg" % (name, version, py_short)
        else:
            mpkg_name = o.output_file

        categories = set()
        file_sections = ipkg.resolve_paths(ctx.build_node)
        for kind, source, target in iter_files(file_sections):
            categories.add(kind)

        # Mpkg metadata
        mpkg_root = os.path.join(os.getcwd(), o.output_dir, mpkg_name)
        mpkg_cdir = os.path.join(mpkg_root, "Contents")
        if os.path.exists(mpkg_root):
            shutil.rmtree(mpkg_root)
        os.makedirs(mpkg_cdir)
        f = open(os.path.join(mpkg_cdir, "PkgInfo"), "w")
        try:
            f.write("pmkrpkg1")
        finally:
            f.close()
        mpkg_info = MetaPackageInfo.from_ipkg(ipkg)

        purelib_pkg = "%s-purelib-%s-py%s.pkg" % (name, version, py_short)
        scripts_pkg = "%s-scripts-%s-py%s.pkg" % (name, version, py_short)
        datafiles_pkg = "%s-datafiles-%s-py%s.pkg" % (name, version, py_short)
        mpkg_info.packages = [purelib_pkg, scripts_pkg, datafiles_pkg]
        make_mpkg_plist(mpkg_info, os.path.join(mpkg_cdir, "Info.plist"))

        mpkg_rdir = os.path.join(mpkg_root, "Contents", "Resources")
        os.makedirs(mpkg_rdir)
        make_mpkg_description(mpkg_info,
                              os.path.join(mpkg_rdir, "Description.plist"))

        # Package the stuff which ends up into site-packages
        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", purelib_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["pythonfiles"],
                            "Pure Python modules and packages")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages", scripts_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/", ["executables"],
                            "Scripts and binaries")

        pkg_root = os.path.join(mpkg_root, "Contents", "Packages",
                                datafiles_pkg)
        build_pkg_from_temp(ctx, ipkg, pkg_root, root, "/",
                            ["bentofiles", "datafiles"], "Data files")
Пример #28
0
 def test_get_inidata_run(self):
     """Simply execute get_inidata."""
     # FIXME: do a real test here
     meta, sections, nodes = create_simple_ipkg_args(self.top_node)
     ipkg = InstalledPkgDescription(sections, meta, {})
     get_inidata(ipkg)
Пример #29
0
 def store(self, filename, pkg):
     meta = ipkg_meta_from_pkg(pkg)
     p = InstalledPkgDescription(self.sections, meta, pkg.executables)
     if not op.exists(op.dirname(filename)):
         os.makedirs(op.dirname(filename))
     p.write(filename)
Пример #30
0
    import \
        create_scripts

if __name__ == "__main__":
    import tempfile

    TMPDIR = tempfile.mkdtemp()
    try:
        EGG_PATH = sys.argv[1]

        zid = zipfile.ZipFile(EGG_PATH)
        try:
            zid.extractall(path=TMPDIR)
        finally:
            zid.close()
        ipkg = InstalledPkgDescription.from_egg(EGG_PATH)

        # Build executables
        bdir = os.path.join(TMPDIR, "SCRIPTS")
        os.makedirs(bdir)
        create_scripts(ipkg.executables, bdir)
        # XXX: use internal API
        for k in ipkg.files["executables"]:
            ipkg.files["executables"][k].source_dir = bdir

        meta = PackageMetadata.from_ipkg(ipkg)
        wininst = wininst_filename(meta.fullname)
        create_wininst(ipkg, src_root_dir=TMPDIR, wininst=wininst)
    finally:
        #shutil.rmtree(TMPDIR)
        pass
Пример #31
0
def read_ipkg(wininst):
    # See eof_cdir size in archive.h of bdist_wininst sources
    eof_cdir_n = 22
    eof_cdir_tag = 0x06054b50

    meta_n = 12

    stat_info = os.stat(WININST)
    inst_size = stat_info.st_size

    with open(WININST, "rb") as fid:
        fid.seek(-eof_cdir_n, 2)
        s = fid.read(4)
        tag = struct.unpack("<l", s)[0]
        if not tag == eof_cdir_tag:
            raise ValueError("Unexpected bits")
        fid.read(2 * 4)
        s = fid.read(4)
        nBytesCDir = struct.unpack("<l", s)[0]
        s = fid.read(4)
        ofsCDir = struct.unpack("<l", s)[0]

        arc_start = inst_size - eof_cdir_n - nBytesCDir - ofsCDir
        ofs = arc_start - meta_n
        fid.seek(ofs, 0)
        s = fid.read(4)
        tag = struct.unpack("<l", s)[0]
        if not tag == 0x1234567B:
            raise ValueError("Unexpected bits")

        s = fid.read(4)
        uncomp_size = struct.unpack("<l", s)[0]

        s = fid.read(4)
        bitmap_size = struct.unpack("<l", s)[0]
        pexe_size = ofs - uncomp_size - bitmap_size

        fid.seek(pexe_size, 0)
        data = fid.read(uncomp_size)

        from configparser import ConfigParser
        parser = ConfigParser()
        sdata = StringIO(data)

        def truncate_null(sdata):
            cur = sdata.tell()
            sdata.seek(0, 2)
            nbytes = sdata.tell()
            try:
                n = 10
                sdata.seek(-n, 2)
                null_ind = sdata.read().find("\0")
                sdata.truncate(nbytes - (n - null_ind))
            finally:
                sdata.seek(cur, 0)

        truncate_null(sdata)
        parser.readfp(sdata)
        raise ValueError("YO - fix wininst METADATA")
        ipkg_str = base64.b64decode(parser.get("IPKG_INFO", "value"))

        ipkg = InstalledPkgDescription.from_string(ipkg_str)
        return ipkg
Пример #32
0
def read_ipkg(wininst):
    # See eof_cdir size in archive.h of bdist_wininst sources
    eof_cdir_n = 22
    eof_cdir_tag = 0x06054b50

    meta_n = 12

    stat_info = os.stat(WININST)
    inst_size = stat_info.st_size

    with open(WININST, "rb") as fid:
        fid.seek(-eof_cdir_n, 2)
        s = fid.read(4)
        tag = struct.unpack("<l", s)[0]
        if not tag == eof_cdir_tag:
            raise ValueError("Unexpected bits")
        fid.read(2 * 4)
        s = fid.read(4)
        nBytesCDir = struct.unpack("<l", s)[0]
        s = fid.read(4)
        ofsCDir = struct.unpack("<l", s)[0]

        arc_start = inst_size - eof_cdir_n - nBytesCDir - ofsCDir
        ofs = arc_start - meta_n
        fid.seek(ofs, 0)
        s = fid.read(4)
        tag = struct.unpack("<l", s)[0]
        if not tag == 0x1234567B:
            raise ValueError("Unexpected bits")

        s = fid.read(4)
        uncomp_size = struct.unpack("<l", s)[0]

        s = fid.read(4)
        bitmap_size = struct.unpack("<l", s)[0]
        pexe_size = ofs - uncomp_size - bitmap_size

        fid.seek(pexe_size, 0)
        data = fid.read(uncomp_size)

        from ConfigParser import ConfigParser
        parser = ConfigParser()
        sdata = StringIO(data)

        def truncate_null(sdata):
            cur = sdata.tell()
            sdata.seek(0, 2)
            nbytes = sdata.tell()
            try:
                n = 10
                sdata.seek(-n, 2)
                null_ind = sdata.read().find("\0")
                sdata.truncate(nbytes - (n-null_ind))
            finally:
                sdata.seek(cur, 0)
        truncate_null(sdata)
        parser.readfp(sdata)
        raise ValueError("YO - fix wininst METADATA")
        ipkg_str = base64.b64decode(parser.get("IPKG_INFO", "value"))

        ipkg = InstalledPkgDescription.from_string(ipkg_str)
        return ipkg