def main():
    parser = OptionParser(usage=
                          'usage: %prog [options] <package_name> <mpkg_root>')
    parser.add_option("--component-directory",
                      action = 'store',
                      default = COMPONENT_DIRECTORY,
                      dest="comp_dir",
                      help="Subdirectory containing package directories; "
                      "defaults to " + COMPONENT_DIRECTORY)
    options, args = parser.parse_args()
    if len(args) != 2:
        parser.print_help()
        sys.exit(1)
    pkg_name, wd = args
    wd = abspath(wd)
    package_names = glob(pjoin(wd, COMPONENT_DIRECTORY, '*.pkg'))
    package_names = [psplit(pn)[1] for pn in package_names]
    n_pkgs = len(package_names)
    extra_plist = dict(
            IFRequirementDicts=[python_requirement(pkg_name)],
            IFPkgFlagComponentDirectory=tools.unicode_path(
                './' + COMPONENT_DIRECTORY))
    plist = mpkg_info(pkg_name, '1.7',
                      zip(package_names, ('selected',) * n_pkgs))
    plist.update(extra_plist)
    write(plist, pjoin(wd, 'Contents', 'Info.plist'))
Beispiel #2
0
def make_metapackage(cmd, name, version, packages, pkgdir,
        info=(), description=None):
    license = cmd.license
    readme = cmd.readme
    welcome = cmd.welcome
    background = cmd.background
    template = cmd.template
    dry_run = cmd.dry_run
    dist = cmd.distribution
    copy_tree = cmd.copy_tree
    copy_file = cmd.copy_file
    mkpath = cmd.mkpath

    if description is None:
        description = dist.get_description()
    if not description:
        description = u'%s %s' % (name, version)

    mkpath(os.path.join(pkgdir, 'Contents', 'Resources'))
    if not dry_run:
        write_pkginfo(pkgdir)

    ninfo = plists.mpkg_info(name, version, packages)
    ninfo.update(dict(info))
    if not dry_run:
        plists.write(ninfo, os.path.join(pkgdir, 'Contents', 'Info.plist'))

    desc = plists.common_description(name+' '+version, version)
    if description:
        desc['IFPkgDescriptionDescription'] = description
    if not dry_run:
        plists.write(
            desc,
            os.path.join(pkgdir, 'Contents', 'Resources', 'Description.plist')
        )

    template_dest = os.path.join(pkgdir, 'Contents', 'Resources')
    if not os.path.exists(template) and template in InstallationCheck:
        write_template(InstallationCheck[template], template_dest,
            mkpath=mkpath)
    else:
        copy_tree(template, template_dest)

    if readme is None:
        readme_text = dist.get_long_description()
        if readme_text:
            readme = StringIO(readme_text)

    def doc(path, name, exts=TEXT_EXTS):
        copy_doc(path, name, pkgdir, exts=exts, dry_run=dry_run,
            mkpath=mkpath, copy_tree=copy_tree, copy_file=copy_file,
        )

    doc(readme, 'ReadMe')
    doc(license, 'License')
    doc(welcome, 'Welcome')
    doc(background, 'Background', exts=IMAGE_EXTS)
def main():
    try:
        wd = sys.argv[1]
    except IndexError:
        wd = os.getcwd()
    wd = abspath(wd)
    package_names = glob(pjoin(wd, COMPONENT_DIRECTORY, '*.pkg'))
    package_names = [psplit(pn)[1] for pn in package_names]
    n_pkgs = len(package_names)
    extra_plist = dict(
            IFRequirementDicts=[python_requirement(PKG_NAME)],
            IFPkgFlagComponentDirectory=tools.unicode_path(
                './' + COMPONENT_DIRECTORY))
    plist = mpkg_info(PKG_NAME, '1.7',
                      zip(package_names, ('selected',) * n_pkgs))
    plist.update(extra_plist)
    write(plist, pjoin(wd, 'Contents', 'Info.plist'))