build(hololake): add verified Windows x64 distribution path

This commit is contained in:
冰朔 2026-08-17 14:01:01 +08:00
commit 39fc36f35b
13 changed files with 275 additions and 33 deletions

View file

@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
use std::cmp::Reverse;
use std::fs::{self, OpenOptions};
use std::io::Write;
#[cfg(unix)]
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
use std::path::{Component, Path, PathBuf};
use std::process::Command;
@ -13,6 +14,18 @@ use tauri_plugin_dialog::DialogExt;
use url::Url;
use uuid::Uuid;
#[cfg(windows)]
trait OpenOptionsModeExt {
fn mode(&mut self, mode: u32) -> &mut Self;
}
#[cfg(windows)]
impl OpenOptionsModeExt for OpenOptions {
fn mode(&mut self, _mode: u32) -> &mut Self {
self
}
}
const SNAPSHOT_SCHEMA: &str = "hololake.code-channel/v1";
const REGISTRY_SCHEMA: &str = "hololake.code-channel-registry/v1";
const ALLOWED_HOSTS: &[&str] = &["guanghulab.com", "guanghubingshuo.com", "guanghu.chat"];
@ -207,6 +220,7 @@ pub(crate) fn register_managed_repository(
fn ensure_root(root: &Path) -> Result<(), String> {
fs::create_dir_all(root.join("repositories"))
.map_err(|error| format!("HOLOLAKE_CODE_CHANNEL_STORAGE_UNAVAILABLE: {error}"))?;
#[cfg(unix)]
fs::set_permissions(root, fs::Permissions::from_mode(0o700))
.map_err(|error| format!("HOLOLAKE_CODE_CHANNEL_PERMISSION_FAILED: {error}"))?;
Ok(())
@ -526,11 +540,15 @@ fn clone_at(root: &Path, input: CloneCodeChannelInput) -> Result<CodeChannelSnap
if destination.exists() {
return Err("HOLOLAKE_CODE_CHANNEL_DESTINATION_EXISTS".into());
}
let output = Command::new("/usr/bin/git")
let mut command = Command::new(git_executable());
command
.env("GIT_TERMINAL_PROMPT", "0")
.env("GIT_CONFIG_NOSYSTEM", "1");
#[cfg(unix)]
command
.env("GIT_ASKPASS", "/usr/bin/false")
.env("SSH_ASKPASS", "/usr/bin/false")
.env("GIT_CONFIG_NOSYSTEM", "1")
.env("SSH_ASKPASS", "/usr/bin/false");
let output = command
.args([
"-c",
"credential.helper=",
@ -761,7 +779,7 @@ fn write_registry(root: &Path, registry: &CodeChannelRegistry) -> Result<(), Str
}
fn git(root: &Path, args: &[&str], operation: &str) -> Result<String, String> {
let output = Command::new("/usr/bin/git")
let output = Command::new(git_executable())
.current_dir(root)
.env("GIT_TERMINAL_PROMPT", "0")
.args(args)
@ -778,7 +796,7 @@ fn git(root: &Path, args: &[&str], operation: &str) -> Result<String, String> {
}
fn git_optional(root: &Path, args: &[&str]) -> Option<String> {
let output = Command::new("/usr/bin/git")
let output = Command::new(git_executable())
.current_dir(root)
.env("GIT_TERMINAL_PROMPT", "0")
.args(args)
@ -790,6 +808,14 @@ fn git_optional(root: &Path, args: &[&str]) -> Option<String> {
.then(|| String::from_utf8_lossy(&output.stdout).into_owned())
}
fn git_executable() -> &'static str {
if cfg!(windows) {
"git"
} else {
"/usr/bin/git"
}
}
fn now_unix_ms() -> Result<u128, String> {
SystemTime::now()
.duration_since(UNIX_EPOCH)