- 新增 update 模块:从 dl.shellrs.com 取已签名的更新清单(minisign,签名绑定通道和版本), 按大小和 SHA-256 校验安装包;下载可续传、可换镜像,走系统代理 - 按安装方式安装:macOS 整包交换并核对开发者签名,Windows 静默运行安装程序,Linux 覆盖 AppImage; 开发构建和无法自更新的安装只提示前往下载页 - 设置新增「关于」:版本信息、检查更新、下载进度和「自动检查并下载更新」开关; 新版本就绪后标题栏右上角提示,更新对话框写明重启会中断什么;退出时自动安装,新版本启动后提示已更新 - 数据库拒绝打开更新版本建的库,迁移已有的库之前先备份成 shellrs.db.v<旧版本>.bak - 新增 release workflow 和 packaging 脚本:universal macOS 包签名公证、Inno Setup 安装程序、 AppImage、上传 R2、生成并签名更新清单;新增 CHANGELOG.md - 应用图标放在 assets/logo;开发模式下 macOS Dock 显示 logo,Windows exe 嵌入图标 - 修正 AppImage 里 shellrs 命令链接到临时挂载点;启动时刷新已安装但过期的 Agent skill - 新增清单、验签、下载、各平台安装器和界面的单元测试与 UI 测试
66 lines
2.0 KiB
Rust
66 lines
2.0 KiB
Rust
//! Which package of a release fits this machine.
|
||
//!
|
||
//! The keys are part of the manifest format, so they never change. A
|
||
//! universal macOS build runs its native half, so an Apple Silicon Mac asks
|
||
//! for `macos-aarch64` even though both keys point at the same package; an
|
||
//! Intel-only build under Rosetta would ask for `macos-x86_64` and keep
|
||
//! getting Intel builds, which is why macOS ships universal.
|
||
|
||
/// The manifest's key for this build's platform.
|
||
pub fn platform_key() -> &'static str {
|
||
if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
|
||
"macos-aarch64"
|
||
} else if cfg!(all(target_os = "macos", target_arch = "x86_64")) {
|
||
"macos-x86_64"
|
||
} else if cfg!(all(windows, target_arch = "x86_64")) {
|
||
"windows-x86_64"
|
||
} else if cfg!(all(target_os = "linux", target_arch = "x86_64")) {
|
||
"linux-x86_64"
|
||
} else {
|
||
"unsupported"
|
||
}
|
||
}
|
||
|
||
/// The platform as 设置 › 关于 names it.
|
||
pub fn platform_label() -> &'static str {
|
||
match platform_key() {
|
||
"macos-aarch64" => "macOS · Apple Silicon",
|
||
"macos-x86_64" => "macOS · Intel",
|
||
"windows-x86_64" => "Windows · x64",
|
||
"linux-x86_64" => "Linux · x64",
|
||
_ => std::env::consts::OS,
|
||
}
|
||
}
|
||
|
||
/// `ShellRS/0.2.0 (macos; aarch64)`: all the update server learns about
|
||
/// the machine asking.
|
||
pub fn user_agent(version: &str) -> String {
|
||
format!(
|
||
"ShellRS/{version} ({}; {})",
|
||
std::env::consts::OS,
|
||
std::env::consts::ARCH
|
||
)
|
||
}
|
||
|
||
#[cfg(test)]
|
||
mod tests {
|
||
use super::*;
|
||
|
||
#[test]
|
||
fn the_user_agent_names_the_version_system_and_architecture() {
|
||
let agent = user_agent("1.2.3");
|
||
assert!(agent.starts_with("ShellRS/1.2.3 ("), "{agent}");
|
||
assert!(agent.contains(std::env::consts::OS), "{agent}");
|
||
assert!(
|
||
agent.ends_with(&format!("{})", std::env::consts::ARCH)),
|
||
"{agent}"
|
||
);
|
||
}
|
||
|
||
#[test]
|
||
fn this_machine_has_a_package() {
|
||
assert_ne!(platform_key(), "unsupported");
|
||
assert!(!platform_label().is_empty());
|
||
}
|
||
}
|