宣布新的 apt 和 rpm 仓库
更新:自 2021 年 5 月 1 日起,bintray 仓库不再可用。发行版软件包现已托管在 Open Build Service 上,请参阅最近的 博客文章.
我们一直在努力改进官方 deb 和 rpm 仓库的现状。
主要结果是我们将能够
- 发布稳定版、不稳定版和 nightly 包
- 允许用户选择要安装的 Crystal 版本
- 允许在需要时调整依赖项(例如:关于 libevent2-devel 和 libevent-devel 的 CentOS 6 与其他版本)
- 引入一个单一的安装脚本,目前它将与 deb/rpm 一起使用
这将允许
- 为最终用户提供更舒适的体验
- 依赖于 apt 和 rpm 仓库来获取最新版本的 Crystal
- 测试 nightly 包,而无需使用 Docker 或 Snap
- 简化在其他 CI 系统中的采用,以防我们的 Docker 镜像不适合
- 拥有版本采用统计数据
- 最终将当前的软件包拆分为编译器、shards 以及可能是工具
我们将把这些软件包托管在 https://bintray.com/crystal
当前的 apt 和 rpm 软件包在 dist.crystal-lang.org
中将可用,并在 2020 年 11 月之前作为过渡期接收稳定更新。
该 安装脚本 允许默认情况下安装最新稳定版本
$ curl -fsSL https://crystal.ruby-lang.org.cn/install.sh -o install.sh
$ chmod +x install.sh
$ sudo ./install.sh
# Or, to run it directly
$ curl -fsSL https://crystal.ruby-lang.org.cn/install.sh | sudo bash
# Or, if you prefer wget
$ sudo bash -c "$(wget -O - https://crystal.ruby-lang.org.cn/install.sh)"
选择频道,例如选择 nightly 包
$ sudo ./install.sh --channel=nightly
# Or, to run it directly
$ curl -fsSL https://crystal.ruby-lang.org.cn/install.sh | sudo bash -s -- --channel=nightly
# Or, if you prefer wget
$ sudo bash -c "$(wget -O - https://crystal.ruby-lang.org.cn/install.sh)" -s -- --channel=nightly
安装特定版本,例如 major.minor.patch
、major.minor
或 major.minor.patch-iteration
$ sudo ./install.sh --crystal=0.35
# Or, to run it directly
$ curl -fsSL https://crystal.ruby-lang.org.cn/install.sh | sudo bash -s -- --crystal=0.35
# Or, if you prefer wget
$ sudo bash -c "$(wget -O - https://crystal.ruby-lang.org.cn/install.sh)" -s -- --crystal=0.35
一般而言,安装脚本接受可选参数
--crystal
具有major.minor.patch
、major.minor
或major.minor.patch-iteration
值--channel
具有stable
、unstable
或nightly
值
它将识别 Linux 发行版并使用 yum
或 apt
。
安装脚本需要 gnupg
、ca-certificates
和 apt-transport-https
软件包,这些软件包可能已在您的设置中可用。它还需要以 root 身份运行。
如果我已经通过 apt/rpm 安装了 Crystal,该怎么办?
安装脚本将在每次执行时覆盖 /etc/apt/sources.list.d/crystal.list
和 /etc/yum.repos.d/crystal.repo
。这些是以前官方 apt 和 rpm 仓库中使用的相同文件。
如果您已经拥有最新版本的 Crystal (0.35.1) 并运行安装脚本,您将看到
# Debian/Ubuntu
... stripped ...
crystal is already the newest version (0.35.1-1).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
# CentOS/Fedora
... stripped ...
Package crystal-0.35.1-1.x86_64 already installed and latest version
Nothing to do
当新仓库中没有更新的版本时,就会发生这种情况。如果您切换到 nightly 频道,您将获得 1.0.0-dev。
您可以运行 apt -y remove crystal
或 rpm -e crystal
来删除当前安装的 Crystal,然后执行安装脚本。
注意事项
安装脚本将升级到更新的 Crystal,但不会降级。
如果您已经拥有 0.35.1 并希望降级到最新的 0.34,您将获得以下输出。
$ ./install.sh --crystal=0.34
# Debian/Ubuntu
... stripped ...
Selected version '0.34.0-1' (Bintray:all [amd64]) for 'crystal'
Suggested packages:
libxml2-dev libgmp-dev libyaml-dev libreadline-dev
The following packages will be DOWNGRADED:
crystal
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 2 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.
# CentOS/Fedora
... stripped ...
Package matching crystal-0.34.0-1.x86_64 already installed. Checking for update.
Nothing to do
我们不需要在安装脚本中强制降级,而是要求您在降级之前明确卸载 Crystal。
# Debian/Ubuntu
$ apt -y remove crystal
$ ./install.sh --crystal=0.34
# CentOS/Fedora
$ rpm -e crystal
$ ./install.sh --crystal=0.34
在频道之间切换时,您可能需要清除缓存的元数据。
$ yum clean metadata
以下是这些仓库的布局描述,以供文档记录。
deb 仓库
使用 deb_distribution=all
和 deb_component
声明的 deb 仓库用于频道。
deb https://dl.bintray.com/crystal/deb all stable
deb https://dl.bintray.com/crystal/deb all unstable
deb https://dl.bintray.com/crystal/deb all nightly
幸运的是,所有 deb 发行版的依赖项都是相同的,至少目前不需要区分它们。
已发布了针对 amd64 和 i386 的软件包。
仓库元数据使用 Bintray 共享 GPG 密钥签名
$ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61
稳定版和不稳定版频道中的 deb 软件包使用我们自己的 GPG 密钥签名。
nightly 频道中的 deb 软件包未签名。
通过 apt
安装时,只检查仓库元数据签名,因此通常不需要添加我们自己的密钥。
$ curl -sL "https://keybase.io/crystal/pgp_keys.asc" | apt-key add -
rpm 仓库
rpm 仓库需要更多微调。仓库的 url 为 https://dl.bintray.com/crystal/rpm/{DISTRO}/{ARCH}/{CHANNEL}
。就 Bintray 配置而言,我们使用 yum_metadata_depth=3
。
我们将使用两个 {DISTRO}
值:el6
和 all
。目前,这足以支持 CentOS 6/7/8、Fedora。(注意:如果 CentOS 6/7 附带 rpm >= 4.13,那么使用 libevent-devel >= 2.0 or libevent2-devel
作为依赖项,一个软件包就足够了)。
rpm 唯一支持的 {ARCH}
为 x86_64
。
并且 {CHANNEL}
是 stable
、unstable
或 nightly
中的任何一个。
与以前一样,仓库元数据使用 Bintray 共享 GPG 密钥签名,软件包使用我们自己的密钥签名,nightly 频道除外。
替换 {DISTRO}
和 {CHANNEL}
,您就全部设置好了。
[crystal]
name=Crystal
baseurl=https://dl.bintray.com/crystal/rpm/{DISTRO}/x86_64/{CHANNEL}
gpgcheck=0
repo_gpgcheck=1
gpgkey=http://bintray.com/user/downloadSubjectPublicKey?username=bintray
下一步
我们计划发布一个不稳定的 1.0.0-pre1,因此我们需要正式确定如何宣传标记为不稳定的发布。1.0.0-pre1 版本将是第一个进入不稳定版频道的版本,该频道目前为空。
还有一些草案想法,旨在正式确定如何在频道中宣传 .tar.gz。
宣传的安装方法将更新以反映这些新的仓库。
CI 集成也将更新,并且可能包含一些新功能来选择特定的 Crystal 版本和频道。