3 个版本 (破坏性更新)

0.12.0 2023 年 5 月 17 日
0.11.0 2023 年 4 月 21 日
0.9.0 2023 年 3 月 7 日

#48#docker-image

每月 42 次下载
srtool-cli 中使用

自定义许可

5KB
93

srtool 命令行界面

srtool cli 512px

本项目并非实际用于构建 Substrate Wasm 运行的 srtool Docker 镜像。此实用工具需要安装并运行 Docker,并调用 srtool 镜像以帮助您构建 Substrate 运行时。

本项目是一个 Docker 的命令行界面,简化了使用 srtool Docker 镜像的过程。使用此可执行文件,您无需设置和维护一个长而复杂的别名,正如目前在 srtool 文档中所描述的那样。

安装

如果您之前已将 srtool 定义为别名,您首先需要将其删除。

清理

如果您过去使用过 srtool,您之前使用了一个 srtool 别名。您可以使用

type srtool

如果您看到一些提及 "srtool 是 docker run… 的别名" 的输出,您已设置了别名,我们需要将其删除

unalias srtool

这个别名很可能设置在您的 .bash_profile.zshrc 中,请确保也从那里删除此别名。

安装

cargo install --git https://github.com/chevdor/srtool-cli

用法

帮助

srtool is cli allowing to control the srtool docker image

Usage: srtool [OPTIONS] <COMMAND>

Commands:
  pull
          Simply pull the srtool image and do not run anything else
  build
          Start a new srtool container to build your runtime
  info
          Provide information about the srtool container and your repo
  version
          Show the versions of the srtool container. Use --version if you want the version of this executable
  help
          Print this message or the help of the given subcommand(s)

Options:
  -i, --image <IMAGE>
          Choose an alternative image. Beware to choose an image that is compatible with the original srtool image. Using a random image, you take the risk to NOT produce exactly the same deterministic result as srtool

          [default: docker.io/paritytech/srtool]

  -j, --json
          This option is DEPRECATED and has no effect

  -n, --no-cache
          Do not use the local cached tag value

  -e, --engine <ENGINE>
          By default, srtool-cli auto-detects whether you use Podman or Docker. You can force the engine if the detection does not meet your expectation. The default is auto and defaults to Podman.

          NOTE: Using Podman currently forces using --no-cache

          [default: auto]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

版本

Show the versions of the srtool container. Use --version if you want the version of this executable

Usage: srtool version [OPTIONS]

Options:
  -i, --image <IMAGE>
          Choose an alternative image. Beware to choose an image that is compatible with the original srtool image. Using a random image, you take the risk to NOT produce exactly the same deterministic result as srtool

          [default: docker.io/paritytech/srtool]

  -e, --engine <ENGINE>
          By default, srtool-cli auto-detects whether you use Podman or Docker. You can force the engine if the detection does not meet your expectation. The default is auto and defaults to Podman.

          NOTE: Using Podman currently forces using --no-cache

          [default: auto]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

信息

Provide information about the srtool container and your repo

Usage: srtool info [OPTIONS] --package <PACKAGE> [PATH]

Arguments:
  [PATH]
          By default, srtool will work in the current folder. If your project is located in another location, you can pass it here

          [default: .]

Options:
  -i, --image <IMAGE>
          Choose an alternative image. Beware to choose an image that is compatible with the original srtool image. Using a random image, you take the risk to NOT produce exactly the same deterministic result as srtool

          [default: docker.io/paritytech/srtool]

  -p, --package <PACKAGE>
          Provide the runtime such as kusama-runtime, polkadot-runtime, etc...

          [env: PACKAGE=]

  -r, --runtime-dir <RUNTIME_DIR>
          If your runtime is not in the standard location runtime/<chain_name> you can pass this args to help srtool find it

          [env: RUNTIME_DIR=]

  -e, --engine <ENGINE>
          By default, srtool-cli auto-detects whether you use Podman or Docker. You can force the engine if the detection does not meet your expectation. The default is auto and defaults to Podman.

          NOTE: Using Podman currently forces using --no-cache

          [default: auto]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

拉取

Simply pull the srtool image and do not run anything else

Usage: srtool pull [OPTIONS]

Options:
  -i, --image <IMAGE>
          Choose an alternative image. Beware to choose an image that is compatible with the original srtool image. Using a random image, you take the risk to NOT produce exactly the same deterministic result as srtool

          [default: docker.io/paritytech/srtool]

  -e, --engine <ENGINE>
          By default, srtool-cli auto-detects whether you use Podman or Docker. You can force the engine if the detection does not meet your expectation. The default is auto and defaults to Podman.

          NOTE: Using Podman currently forces using --no-cache

          [default: auto]

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

构建

Start a new srtool container to build your runtime

Usage: srtool build [OPTIONS] --package <PACKAGE> [PATH]

Arguments:
  [PATH]
          By default, srtool will work in the current folder. If your project is located in another location, you can pass it here

          [default: .]

Options:
  -i, --image <IMAGE>
          Choose an alternative image. Beware to choose an image that is compatible with the original srtool image. Using a random image, you take the risk to NOT produce exactly the same deterministic result as srtool

          [default: docker.io/paritytech/srtool]

  -p, --package <PACKAGE>
          Provide the runtime such as kusama-runtime, polkadot-runtime, etc...

          [env: PACKAGE=]

  -j, --json
          Enable json output, same than the global --json option

  -a, --app
          Enable the "app" mode which is a mix of json output and outputting progress during the build. This flag is recommended for CI. the json output will be provided as a single line at the end in compact mode

  -e, --engine <ENGINE>
          By default, srtool-cli auto-detects whether you use Podman or Docker. You can force the engine if the detection does not meet your expectation. The default is auto and defaults to Podman.

          NOTE: Using Podman currently forces using --no-cache

          [default: auto]

  -r, --runtime-dir <RUNTIME_DIR>
          If your runtime is not in the standard location runtime/<chain_name> you can pass this args to help srtool find it

          [env: RUNTIME_DIR=]

      --build-opts <BUILD_OPTS>
          You may pass options to cargo directly here. WARNING, if you pass this value, the automatic build options for Kusama and Polkadot will not be passed and you need to take care of them manually. In general, you should never use this option unless you HAVE to

          [env: BUILD_OPTS=]

      --default-features <DEFAULT_FEATURES>
          Passing this is less involved than passing BUILD_OPTS. It allows changing the list of default features while keeping the automatic features detection. This value is useless if BUILD_OPTS is set

          [env: DEFAULT_FEATURES=]

      --profile <PROFILE>
          The default profile to build runtimes is always `release`. You may override the default with this flag

          [env: PROFILE=]
          [default: release]

      --no-cache
          Passing this flag allows completely disabling caching. As a result, no cargo-home will be mounted to the srtool image. There is no known issue with having the cache ON, this is why it is the default

      --root
          Run container image as root, this helps on Linux based systems

      --verbose
          Run the build script using the verbose option

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

贡献

如果您来到这里,您可能想为此项目做出贡献。请允许我先感谢您。您有多种方式可以提供帮助。请从以下简要说明开始。

功能和问题

无论您是报告遇到的问题还是请求新功能,请在此处 打开一个问题

你知道怎么做:请尝试提供一些背景信息,您使用的版本,您的操作系统,如何重现。这将大大有助于更快地解决问题。

文档

本项目的文档主要使用 AsciiDoc 编写。不幸的是,GitHub 支持该功能需要 花费大量时间。因此,目前该项目使用 AsciiDoc 生成 markdown。简而言之,这意味着您不应该修改任何 .md 文件,而应更改 .adoc 文件,并运行 just md 来生成所有 markdown。

工具

本项目主要使用 Rust,因此您需要安装 Rust 编译器。请确保一切都能使用 Rust 的最新 稳定 版本正常工作。

您将在仓库根目录下找到一个 justfile。这是与 just 一起使用的,因此您可能还需要安装它。只需输入 just 😁 即可了解它如何帮助您。

在提交代码之前,请执行 cargo clippy 停止,以确保一切正常工作。如果您想与 CI 友好,请不要忘记 cargo fmt --all。当然,可以使用 cargo test 运行测试。

您可以使用 RUST_LOG=debug 等方式激活项目的 日志

拉取请求

欢迎 PR。在投入太多精力之前,您可以随时提交草稿。这样,如果您想让我(@chevdor)对您如何组合更改提出意见,可以随时联系我。

依赖关系

~2–2.8MB
~78K SLoC