#run-time #polkadot #docker-image #kusama #wasm #command-line-tool

app srtool-cli

srtool是一个cli工具,允许控制srtool docker镜像

3个版本 (破坏性更新)

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

#2 in #kusama

每月下载量 23

MIT许可证

32KB
369

srtool cli

srtool cli 512px

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

本项目是docker的cli接口,用于简化使用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大放异彩的功能需要耗时漫长。因此,目前该项目是从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。在投入过多精力之前,您可以先草拟一个PR。这样,如果您想在您将要进行的更改和如何进行更改方面获得我的意见,可以随时联系我(@chevdor)。

依赖项

~8–18MB
~259K SLoC