def _parser_add_plugin_args()

in antlir/nspawn_in_subvol/args.py [0:0]


def _parser_add_plugin_args(parser: argparse.ArgumentParser):
    "Keep in sync with `NspawnPluginArgs`"
    parser.add_argument(
        "--no-shadow-proxied-binaries",
        action="store_false",
        dest="shadow_proxied_binaries",
        help="By default, our container CLIs will attempt to shadow those "
        "binaries in the container, for which we have available proxies. "
        "For example, if the container has a default RPM snapshot "
        "installed for either `yum` or `dnf`, the corresponding binary "
        "will be shadowed with a proxy that uses the snapshot to install "
        'RPMs. The net effect is that the program appears to "just work". '
        "Pass this flag to turn off default behavior. In this case, you will "
        "want to manually pass `--serve-rpm-snapshot`, and either use the "
        "wrapper directly our of the snapshot, or use `--shadow-path` to "
        "shadow the container binary with the snapshot's proxy.",
    )
    parser.add_argument(
        "--serve-rpm-snapshot",
        action="append",
        dest="serve_rpm_snapshots",
        default=[],
        type=Path.from_argparse,
        help="Container-relative path to an RPM repo snapshot directory, "
        "normally located under `RPM_SNAPSHOT_BASE_DIR`. Your container "
        "will be provided with `repo-server`s listening on the ports "
        "specified in the `etc/{yum,dnf}/{yum,dnf}.conf` of the snapshot, "
        "so you can simply run `{yum,dnf} -c PATH_TO_CONF` to use them. "
        "This option may be repeated to serve multiple snapshots. See also: "
        "`--no-shadow-proxied-binaries`.",
    )
    parser.add_argument(
        "--shadow-path",
        action="append",
        dest="shadow_paths",
        nargs=2,
        metavar=("DEST_TO_SHADOW", "SRC"),
        default=[],
        type=Path.from_argparse,
        help="Read-only bind-mount container path `SRC` over container-"
        "absolute path `DEST`. If `DEST` is a filename, search container "
        "`PATH` for all copies of `DEST`, and shadow those. The original "
        "of any shadowed path is copied under "
        "`/__antlir__/shadowed/REAL/PATH/TO/DEST`. These originals can "
        "be read or mutated, and `yum-dnf-from-snapshot` implements a "
        " trick to allow RPM installers to upgrade packages containing "
        "shadowed files. See also: `--no-shadow-proxied-binaries`.",
    )
    parser.add_argument(
        "--snapshot-to-versionlock",
        action="append",
        dest="snapshots_and_versionlocks",
        nargs=2,
        metavar=("SNAPSHOT_PATH", "VERSIONLOCK_PATH"),
        default=[],
        type=Path.from_argparse,
        help="Restrict available versions for some of the snapshots specified "
        "via `--serve-rpm-snapshot`. Each version-lock file lists allowed "
        "RPM versions, one per line, in the following TAB-separated "
        "format: N\\tE\\tV\\tR\\tA. Snapshot is a container path, while "
        "versionlock is a host path.",
    )
    parser.add_argument(
        "--attach-antlir-dir-mode",
        choices=list(AttachAntlirDirMode),
        type=AttachAntlirDirMode,
        default=AttachAntlirDirMode.DEFAULT_ON,
        dest="attach_antlir_dir",
        help="Enabling this option will copy the `__antlir__` directory "
        "from the build_appliance used to build the layer into "
        "the volume created by nspawn_in_subvol. "
        "This includes an rpm snapshot and will allow dnf and yum "
        "to be run in non build appliance containers. For now this option "
        "only works for non-sendstream objects. The directory will be removed "
        "when the container exits. Enabling this requires that (a) the image "
        "does not contain `/__antlir__`, and (b) that the image's BA is "
        "discoverable (normally via the `flavor`). The option "
        '"explicit_on" throws an error if it cannot find the `__antlir__` '
        'directory in the build appliance while "default_on" fails '
        "silently.",
    )
    parser.add_argument(
        "--attach-antlir-dir",
        action="store_const",
        dest="--attach-antlir-dir-mode",
        const="explicit_on",
        help="Enabling this flag will force "
        "`--attach-antlir-dir-mode=explicit_on`. This is useful for "
        "debugging layers to figure out why the BA `__antlir__` "
        "directory cannot be attached to the layer.",
    )
    parser.add_argument(
        "--run-proxy-server",
        action="store_true",
        dest="run_proxy_server",
        help="Enabling this flag will start proxy server in the container.",
    )
    parser.add_argument(
        "--fbpkg-db-path",
        dest="fbpkg_db_path",
        help="Path to the Repo DB. Requiered parameter for proxy_server",
    )