예제 #1
0
    def __init__(self, filename):
        super(BinaryPackage, self).__init__()
        self.filename = filename
        self.info = filename
        self.VerifyArchiveFormat()

        info = self.GetPkgInfo()
        self.ParseInfo(info)
        self.config = configuration.Configuration(self.BUILD_ARCH,
                                                  self.BUILD_TOOLCHAIN,
                                                  self.BUILD_CONFIG == 'debug')
예제 #2
0
  def __init__(self, pkg_root, config=None):
    super(SourcePackage, self).__init__()
    if config is None:
      config = configuration.Configuration()
    self.config = config

    self.root = os.path.abspath(pkg_root)
    info_file = os.path.join(self.root, 'pkg_info')
    if not os.path.isdir(self.root) or not os.path.exists(info_file):
      raise Error('Invalid package folder: %s' % pkg_root)

    super(SourcePackage, self).__init__(info_file)
    if self.NAME != os.path.basename(self.root):
      raise Error('%s: package NAME must match directory name' % self.info)
예제 #3
0
    def ParseIndex(self, index_data):
        if not index_data:
            return

        for info_files in index_data.split('\n\n'):
            info = pkg_info.ParsePkgInfo(info_files, self.filename,
                                         self.valid_keys, self.required_keys)
            debug = info['BUILD_CONFIG'] == 'debug'
            config = configuration.Configuration(info['BUILD_ARCH'],
                                                 info['BUILD_TOOLCHAIN'],
                                                 debug)
            key = (info['NAME'], config)
            if key in self.packages:
                error.Error('package index contains duplicate: %s' % str(key))
            self.packages[key] = info
예제 #4
0
파일: __main__.py 프로젝트: pvk84/naclports
def RunMain(args):
    base_commands = {
        'list': CmdList,
        'info': CmdInfo,
        'check': CmdCheck,
    }

    pkg_commands = {
        'download': CmdPkgDownload,
        'uscan': CmdPkgUscan,
        'check': CmdPkgCheck,
        'build': CmdPkgBuild,
        'install': CmdPkgInstall,
        'clean': CmdPkgClean,
        'uninstall': CmdPkgUninstall,
        'contents': CmdPkgContents,
        'depends': CmdPkgListDeps,
        'updatepatch': CmdPkgUpdatePatch,
        'extract': CmdPkgExtract,
        'patch': CmdPkgPatch
    }

    installed_pkg_commands = ['contents', 'uninstall']

    all_commands = dict(base_commands.items() + pkg_commands.items())

    epilog = "The following commands are available:\n"
    for name, function in all_commands.iteritems():
        epilog += '  %-12s - %s\n' % (name, function.__doc__)

    parser = argparse.ArgumentParser(
        prog='naclports',
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=epilog)
    parser.add_argument('-v',
                        '--verbose',
                        dest='verbosity',
                        action='count',
                        default=0,
                        help='Output extra information.')
    parser.add_argument('-V',
                        '--verbose-build',
                        action='store_true',
                        help='Make builds verbose (e.g. pass V=1 to make')
    parser.add_argument('--skip-sdk-version-check',
                        action='store_true',
                        help="Disable the NaCl SDK version check on startup.")
    parser.add_argument('--all',
                        action='store_true',
                        help='Perform action on all known ports.')
    parser.add_argument('--color',
                        choices=('always', 'never', 'auto'),
                        help='Enabled color terminal output',
                        default='auto')
    parser.add_argument('-f',
                        '--force',
                        action='store_const',
                        const='build',
                        help='Force building specified targets, '
                        'even if timestamps would otherwise skip it.')
    parser.add_argument(
        '--from-source',
        action='store_true',
        help='Always build from source rather than downloading '
        'prebuilt packages.')
    parser.add_argument(
        '-F',
        '--force-all',
        action='store_const',
        const='all',
        dest='force',
        help='Force building target and all '
        'dependencies, even if timestamps would otherwise skip '
        'them.')
    parser.add_argument('--no-deps',
                        dest='build_deps',
                        action='store_false',
                        default=True,
                        help='Disable automatic building of dependencies.')
    parser.add_argument(
        '--ignore-disabled',
        action='store_true',
        help='Ignore attempts to build disabled packages.\n'
        'Normally attempts to build such packages will result\n'
        'in an error being returned.')
    parser.add_argument(
        '-t',
        '--toolchain',
        help='Set toolchain to use when building (newlib, glibc, '
        'or pnacl)')
    # use store_const rather than store_true since we want to default for
    # debug to be None (which then falls back to checking the NACL_DEBUG
    # environment variable.
    parser.add_argument(
        '-d',
        '--debug',
        action='store_const',
        const=True,
        help='Build debug configuration (release is the default)')
    parser.add_argument('-a',
                        '--arch',
                        help='Set architecture to use when building (x86_64,'
                        ' x86_32, arm, pnacl)')
    parser.add_argument('command', help="sub-command to run")
    parser.add_argument('pkg', nargs='*', help="package name or directory")
    args = parser.parse_args(args)

    if not args.verbosity and os.environ.get('VERBOSE') == '1':
        args.verbosity = 1

    util.SetLogLevel(util.LOG_INFO + args.verbosity)

    if args.verbose_build:
        os.environ['VERBOSE'] = '1'
    else:
        if 'VERBOSE' in os.environ:
            del os.environ['VERBOSE']
        if 'V' in os.environ:
            del os.environ['V']

    if args.skip_sdk_version_check:
        util.MIN_SDK_VERSION = -1

    util.CheckSDKRoot()
    config = configuration.Configuration(args.arch, args.toolchain, args.debug)
    util.color_mode = args.color
    if args.color == 'never':
        util.Color.enabled = False
    elif args.color == 'always':
        util.Color.enabled = True

    if args.command in base_commands:
        base_commands[args.command](config, args, args.pkg)
        return 0

    if args.command not in pkg_commands:
        parser.error("Unknown subcommand: '%s'\n"
                     'See --help for available commands.' % args.command)

    if len(args.pkg) and args.all:
        parser.error('Package name(s) and --all cannot be specified together')

    if args.pkg:
        package_names = args.pkg
    else:
        package_names = [os.getcwd()]

    def DoCmd(package):
        try:
            pkg_commands[args.command](package, args)
        except error.DisabledError as e:
            if args.ignore_disabled:
                util.Log('naclports: %s' % e)
            else:
                raise e

    if args.all:
        args.ignore_disabled = True
        if args.command == 'clean':
            CleanAll(config)
        else:
            if args.command in installed_pkg_commands:
                package_iterator = installed_package.InstalledPackageIterator(
                    config)
            else:
                package_iterator = source_package.SourcePackageIterator()
            for p in package_iterator:
                DoCmd(p)
    else:
        for package_name in package_names:
            if args.command in installed_pkg_commands:
                p = installed_package.CreateInstalledPackage(
                    package_name, config)
            else:
                p = source_package.CreatePackage(package_name, config)
            DoCmd(p)
예제 #5
0
 def __init__(self, info_file):
     super(InstalledPackage, self).__init__(info_file)
     self.config = configuration.Configuration(self.BUILD_ARCH,
                                               self.BUILD_TOOLCHAIN,
                                               self.BUILD_CONFIG == 'debug')