6 个版本
0.2.1 | 2021年1月10日 |
---|---|
0.2.0 | 2021年1月10日 |
0.1.0 | 2020年9月19日 |
0.0.5 | 2020年7月31日 |
0.0.4 | 2020年6月30日 |
#18 in #home-dir
92KB
2K SLoC
homebins
$HOME 的二进制文件。
Homebins 会将二进制文件和脚本直接从供应商处安装到您的 $HOME
目录中,无需 sudo 和 root 权限。
原因
Go 和 Rust 带来了一整套全新的优秀命令行工具,如 ripgrep、bat、exa 等。多亏了 Github Actions、Travis CI、Azure Pipelines 在构建容量上的慷慨赞助,甚至像 jq 或 pandoc 这样的成熟工具现在可以方便地将它们的发布版本作为二进制文件发布。
Homebins 帮助您将这些优秀工具的最新版本下载并安装到您的 $HOME 目录中,这样您就不再需要等待您的发行版提供它们,或安装编译器和构建依赖项,或访问数十个 Github 页面进行下载。
用例
- 在 Ubuntu LTS 上获取 bat 或 jq 的最新版本。
- 在没有 root 权限的服务器上安装 xsv 或 ripgrep。
- 发布您的工具,无需繁琐地将它们引入主流发行版的过程。
目标
- 获取像 bat 或 ripgrep 这样的命令行工具,预编译并直接从源头获取。
- 仅在特定的位置接触 $HOME。
- 支持 Linux,包括 x86_64 以及可能的其他架构。
非目标
- 软件包和依赖项管理。我们只处理二进制文件。
- 构建软件。维护者应该做这件事。
- 系统级安装。留给发行版处理。
- 32位系统。这些还存在吗?
- 支持 Windows 或 macOS。使用 scoop 或 Homebrew。
安装
- 确保已安装
git
、curl
、tar
和unzip
。 - 将
~/.local/bin
添加到您的$PATH
,并将~/.local/share/man
添加到您的manpath
(如果已设置$PATH
,Ubuntu 系统似乎会自动执行此操作)。 - 从最新发布版下载“homebins”工件。
chmod a+x./homebins
./homebins安装 homebins
rm./homebins
还有一个dotbot插件,位于dotbot-homebins。
用法
# List available binaries
$ homebins list
# Install bat and ripgrep
$ homebins install bat ripgrep
# List oudated binaries and update them
$ homebins outdated
$ homebins update
# Remove ripgrep again
$ homebins remove ripgrep
# Install a binary directly from a manifest file (see below)
$ homebins manifest-install my-tool.toml
查看homebins --help
获取更多信息。
清单
Homebins 依赖于以 TOML 编写的清单来描述从哪里获取二进制文件以及如何安装它。默认情况下,它使用位于 lunaryorn/homebin-manifests 的 Git 仓库中的清单;计划支持自定义清单仓库。它还可以使用 manifest-*
命令直接使用清单文件。
备注
Homebins 不保存已安装清单的数据库;它只是探测所有已知的清单并查询已安装二进制的版本。
编写自己的清单
清单是一个包含一些元数据和下载说明的简单 TOML 文件
[info]
# The name of the utility. Must match the filename (i.e. jq.toml)
name = "jq"
# The version of the tool
version = "1.6"
# The URL of the website or Github repo
url = "https://github.com/stedolan/jq"
# The license(s), as SPDX license expression (see below)
license = "MIT"
# How to check whether the this manifest is installed
[discover]
# The binary file to check for in ~/.local/bin
binary = "jq"
# The arguments to invoke the binary with to make it print its version
version_check.args = ["--version"]
# A regular expression to extract the version number from the output.
# Must have a single capturing group containing only the version number.
version_check.pattern = "jq-(\\d\\S+)"
# One or more installation instructions: This manifest requires two downloads
# to install.
[[install]]
# The URL to download
download = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64"
# A blake2 checksum to verify the download. We also support other checksums;
# prefer the one provided by the vendor, or blake2 if the vendor doesn't offer checksums.
checksums.b2 = "d08b0756d6a6c021c20610f184de2117827d4aeb28ce87a245a1fc6ee836ef42a3ffd3a31811ea4360361d4a63d6729baf328ac024a68545974de9f6b709733c"
# checksums.sha512 = ""
# checksums.sha256 = ""
# checksums.sha1 = ""
# Directly install the downloaded file as a binary named "jq".
# This copies the file to ~/.local/bin/jq.
# The "name" is optional; if missing it defaults to the filename of the URL.
name = "jq"
type = "bin"
# Another file to download; this time it's an archive.
[[install]]
download = "https://github.com/stedolan/jq/releases/download/jq-1.6/jq-1.6.tar.gz"
checksums.b2 = "c9be1314e9d027247de63492ee362e996ef85faf45a47ee421cad95ebde9188bff8d3fc7db64e717ab922e1052f3b1c1500f5589fc5b2199ab66effb000e442d"
# The file to install from the archive.
files = [
# Install the entry jq-1.6/jq.1.prebuilt as manpage in section 1, named jq.1
# This copies jq-1.6/jq.1.prebuilt from the archive to
# ~/.local/share/man/man1/jq.1
# Again "name" is optional and defaults to the filename of the "source".
{ source = "jq-1.6/jq.1.prebuilt", name = "jq.1", type = "man", section = 1 }
# Homebins also supports fish completions: The following would copy
# jq.fish to ~/.config/fish/completions/jq.fish but jq doesn't include fish
# completion.
# { source = "jq-1.6/jq.fish", type = "completion", shell = "fish" }
]
info.license
字段使用 SPDX 许可表达式。
查看lunaryorn/homebin-manifests获取更多示例。
许可
版权所有 (c) 2020 Sebastian Wiesner [email protected]
此源代码形式受 Mozilla 公共许可证第 2.0 版的条款约束。如果未随此文件分发 MPL 的副本,您可以从http://mozilla.org/MPL/2.0/获取。
依赖项
~11–22MB
~340K SLoC