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'))
def get_metapackage_info(self): return dict( IFRequirementDicts=[plists.python_requirement(self.get_name())], IFPkgFlagComponentDirectory=tools.unicode_path( self.component_directory ), )
def get_scheme_description(self, scheme): description = self.scheme_descriptions.get(scheme) if description is None: return None files, common, prefix = self.get_scheme_root(scheme) if prefix is not None: description += u'\nInstalled to: ' + tools.unicode_path(prefix) return description
def path_requirement(SpecArgument, Level=u'requires', **kw): return dict( Level=Level, SpecType=u'file', SpecArgument=tools.unicode_path(SpecArgument), SpecProperty=u'NSFileType', TestOperator=u'eq', TestObject=u'NSFileTypeDirectory', **kw )
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'))
def python_requirement(pkgname, prefix=None, version=None, **kw): if prefix is None: prefix = sys.prefix if version is None: version = sys.version[:3] prefix = os.path.realpath(prefix) fmwkprefix = os.path.dirname(os.path.dirname(prefix)) is_framework = fmwkprefix.endswith('.framework') if is_framework: dprefix = os.path.dirname(fmwkprefix) else: dprefix = prefix dprefix = tools.unicode_path(dprefix) name = u'%s Python %s' % (FRIENDLY_PREFIX.get(dprefix, dprefix), version) kw.setdefault('LabelKey', name) title = u'%s requires %s to install.' % (pkgname, name,) kw.setdefault('TitleKey', title) kw.setdefault('MessageKey', title) return path_requirement(prefix, **kw)
def make_package(cmd, name, version, files, common, prefix, 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() mkpath(os.path.join(pkgdir, 'Contents', 'Resources')) if not dry_run: write_pkginfo(pkgdir) tools.mkbom(common, pkgdir) count = len(files) admin = tools.admin_writable(prefix) size = tools.reduce_size(files) compressed = tools.pax(common, pkgdir) if not dry_run: write_sizes(count, size, compressed, pkgdir) if admin: auth = u'AdminAuthorization' else: auth = u'RootAuthorization' ninfo = plists.pkg_info(name, version) ninfo.update(dict( IFPkgFlagAuthorizationAction=auth, IFPkgFlagDefaultLocation=tools.unicode_path(prefix), )) ninfo.update(dict(info)) if not dry_run: plists.write(ninfo, os.path.join(pkgdir, 'Contents', 'Info.plist')) desc = plists.common_description(name, version) if description is not None: 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) 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)