From 5324a3df400ea148185c3f42001ca6a1d441ee47 Mon Sep 17 00:00:00 2001 From: Benjamin Brittain Date: Sat, 15 Jul 2023 11:01:40 -0400 Subject: [PATCH] Release version 0.2.0 --- Cargo.toml | 2 +- src/main.rs | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d46b41b..88331df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "buckle" -version = "0.1.0" +version = "0.2.0" edition = "2021" description = "A lightweight launcher for buck2" license = "MIT" diff --git a/src/main.rs b/src/main.rs index a8f56cd..148722b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,19 @@ use anyhow::{anyhow, Error}; use serde::{Deserialize, Serialize}; +use std::io::Write; use std::{ env, fs::{self, File}, path::{Path, PathBuf}, process::{Command, Stdio}, }; -use std::{io::Write, time::SystemTime}; use tempfile::NamedTempFile; use url::Url; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; +#[cfg(unix)] +use std::time::SystemTime; const BASE_URL: &str = "https://github.com/facebook/buck2/releases/download"; const BUCK_RELEASE_URL: &str = "https://github.com/facebook/buck2/tags"; @@ -100,6 +102,8 @@ fn get_releases(path: &Path) -> Result, Error> { let mut releases_json_path = path.to_path_buf(); releases_json_path.push("releases.json"); + // TODO support last last_modification_time for windows users + #[cfg(unix)] if releases_json_path.exists() { use std::os::unix::fs::MetadataExt; let meta = fs::metadata(&releases_json_path)?; @@ -177,8 +181,11 @@ fn download_http(version: String, output_dir: &Path) -> Result { let resp = reqwest::blocking::get(format!("{BASE_URL}/{version}/buck2-{arch}.zst"))?; zstd::stream::copy_decode(resp, &tmp_buck2_bin).unwrap(); tmp_buck2_bin.flush()?; - let permissions = fs::Permissions::from_mode(0o755); - fs::set_permissions(&tmp_buck2_bin, permissions)?; + #[cfg(unix)] + { + let permissions = fs::Permissions::from_mode(0o755); + fs::set_permissions(&tmp_buck2_bin, permissions)?; + } fs::rename(tmp_buck2_bin.path(), &buck2_path)?; // Also fetch the prelude hash and store it