Пример #1
0
def finaliseArgs(args, parser, star):

    # Nothing to finalise for version or analytics
    if args.action in ["version", "analytics", "architecture"]:
        return args

    # --architecture can be specified in both clean and build.
    if args.action in ["build", "clean"]:
        if not args.architecture:
            parser.error(
                format("Cannot determine architecture. "
                       "Please pass it explicitly.\n\n%s" %
                       ARCHITECTURE_TABLE[0]))
        if not args.forceUnknownArch and not matchValidArch(args.architecture):
            parser.error(
                format(
                    "Unknown / unsupported architecture: %(architecture)s.\n\n"
                    "%(table)s"
                    "Alternatively, you can use the `--force-unknown-architecture' option.",
                    table=ARCHITECTURE_TABLE[0],
                    architecture=args.architecture))

        args.disable = normalise_multiple_options(args.disable)

    if args.action in ["build", "clean", "init"]:
        args.referenceSources = format(args.referenceSources,
                                       workDir=args.workDir)

    if args.action == "build":
        args.configDir = format(args.configDir, prefix="")
        if args.remoteStore or args.writeStore:
            args.noSystem = True

        if "dockerImage" in args:
            args.docker = True

        if args.docker and args.architecture.startswith("osx"):
            parser.error("cannot use `-a %s` and --docker" % args.architecture)

        if args.docker and commands.getstatusoutput("which docker")[0]:
            parser.error(
                "cannot use --docker as docker executable is not found")

        # If specified, used the docker image requested, otherwise, if running
        # in docker the docker image is given by the first part of the
        # architecture we want to build for.
        if args.docker and not "dockerImage" in args:
            args.dockerImage = "alisw/%s-builder" % args.architecture.split(
                "_")[0]

        if args.remoteStore.endswith("::rw") and args.writeStore:
            parser.error(
                "cannot specify ::rw and --write-store at the same time")

        if args.remoteStore.endswith("::rw"):
            args.remoteStore = args.remoteStore[0:-4]
            args.writeStore = args.remoteStore

    if args.action in ["build", "init"]:
        if "develPrefix" in args and args.develPrefix == None:
            if "chdir" in args:
                args.develPrefix = basename(abspath(args.chdir))
            else:
                args.develPrefix = basename(dirname(abspath(args.configDir)))
        if "dockerImage" in args:
            args.develPrefix = "%s-%s" % (
                args.develPrefix, args.architecture
            ) if "develPrefix" in args else args.architecture

    if args.action == "init":
        args.configDir = format(args.configDir, prefix=args.develPrefix + "/")
    elif args.action == "build":
        pass
    elif args.action == "clean":
        pass
    else:
        pass
    return args
Пример #2
0
def finaliseArgs(args, parser, star):

  # Nothing to finalise for version or analytics
  if args.action in ["version", "analytics", "architecture"]:
    return args

  # --architecture can be specified in both clean and build.
  if args.action in  ["build", "clean"]:
    if not args.architecture:
      parser.error(format("Cannot determine architecture. "
                   "Please pass it explicitly.\n\n%s" % ARCHITECTURE_TABLE[0]))
    if not args.forceUnknownArch and not matchValidArch(args.architecture):
      parser.error(format("Unknown / unsupported architecture: %(architecture)s.\n\n"
                  "%(table)s"
                  "Alternatively, you can use the `--force-unknown-architecture' option.",
                  table=ARCHITECTURE_TABLE[0],
                  architecture=args.architecture))

    args.disable = normalise_multiple_options(args.disable)

  if args.action in ["build", "clean", "init"]:
    args.referenceSources = format(args.referenceSources, workDir=args.workDir)

  if args.action == "build":
    args.configDir = format(args.configDir, prefix="")
    if args.remoteStore or args.writeStore:
      args.noSystem = True

    if "dockerImage" in args:
      args.docker = True

    if args.docker and args.architecture.startswith("osx"):
      parser.error("cannot use `-a %s` and --docker" % args.architecture)

    if args.docker and commands.getstatusoutput("which docker")[0]:
      parser.error("cannot use --docker as docker executable is not found")

    # If specified, used the docker image requested, otherwise, if running
    # in docker the docker image is given by the first part of the
    # architecture we want to build for.
    if args.docker and not "dockerImage" in args:
      args.dockerImage = "alisw/%s-builder" % args.architecture.split("_")[0]

    if args.remoteStore.endswith("::rw") and args.writeStore:
      parser.error("cannot specify ::rw and --write-store at the same time")

    if args.remoteStore.endswith("::rw"):
      args.remoteStore = args.remoteStore[0:-4]
      args.writeStore = args.remoteStore

  if args.action in ["build", "init"]:
    if "develPrefix" in args and args.develPrefix == None:
      if "chdir" in args:
        args.develPrefix = basename(abspath(args.chdir))
      else:
        args.develPrefix = basename(dirname(abspath(args.configDir)))
    if "dockerImage" in args:
      args.develPrefix = "%s-%s" % (args.develPrefix, args.architecture) if "develPrefix" in args else args.architecture

  if args.action == "init":
    args.configDir = format(args.configDir, prefix=args.develPrefix+"/")
  elif args.action == "build":
    pass
  elif args.action == "clean":
    pass
  else:
    pass
  return args