Skip to content

Commit

Permalink
Merge pull request #1164 from sagiegurari/0.37.17
Browse files Browse the repository at this point in the history
0.37.17
  • Loading branch information
sagiegurari authored Sep 28, 2024
2 parents 43bce75 + ffe73f9 commit 97daaac
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## CHANGELOG

### v0.37.17

* Fix: support encrypted drives (shorten script file names) #1150
* Fix: setup musl failing on open ssl binary redirects

### v0.37.16 (2024-08-30)

* Enhancement: Expand condition_script_runner_args #1132 (thanks @wmmc88)
Expand Down
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ cliparser = "^0.1.2"
colored = "^2"
ctrlc = "^3"
dirs-next = "^2"
duckscript = "^0.8.0"
duckscriptsdk = { version = "^0.9.3", default-features = false }
duckscript = "^0.8.1"
duckscriptsdk = { version = "^0.9.4", default-features = false }
envmnt = "^0.10.4"
fern = "^0.6"
fsio = { version = "^0.4", features = ["temp-path"] }
Expand All @@ -63,6 +63,7 @@ indexmap = { version = "^2", features = ["serde"] }
itertools = "^0.13"
lenient_semver = "^0.4.2"
log = "^0.4"
md5 = "^0.7"
once_cell = "^1.20.0"
petgraph = "^0.6.5"
regex = "^1.10"
Expand All @@ -73,7 +74,6 @@ serde = "^1"
serde_derive = "^1"
serde_ignored = "^0.1"
serde_json = "^1"
sha2 = "^0.10"
shell2batch = "^0.4.5"
strip-ansi-escapes = "^0.2"
strum_macros = "0.26.4"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/descriptor/makefiles/rust.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ env.OPENSSL_DIR = "${HOME}/openssl-musl"
env.OPENSSL_PLATFORM = { source = "${CARGO_MAKE_BINARY_RELEASE_ENV_ARM_LINUX}", default_value = "x86_64", mapping = { "true" = "armv4" } }
script = '''
rustup target add "${CARGO_MAKE_RELEASE_FLOW_TARGET}"
curl ${CARGO_MAKE_OPENSSL_DOWNLOAD_URL} | tar xzf -
curl --location ${CARGO_MAKE_OPENSSL_DOWNLOAD_URL} | tar xzf -
cd openssl-${CARGO_MAKE_OPENSSL_VERSION}
CC=musl-gcc ./Configure --prefix="${OPENSSL_DIR}" no-dso no-ssl2 no-ssl3 linux-${OPENSSL_PLATFORM} -fPIC
make -j"$(nproc)"
Expand Down
50 changes: 35 additions & 15 deletions src/lib/scriptengine/script_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use crate::error::CargoMakeError;
use crate::io::create_text_file;
use fsio::file::write_text_file;
use fsio::path::as_path::AsPath;
use sha2::{Digest, Sha256};
use std::fmt::Write;
use md5;
use std::path::PathBuf;

pub(crate) fn create_script_file(
Expand All @@ -27,12 +26,26 @@ pub(crate) fn create_script_file(
pub(crate) fn create_persisted_script_file(
script_text: &Vec<String>,
extension: &str,
) -> Result<String, CargoMakeError> {
match create_persisted_script_file_with_options(script_text, extension, None) {
Ok(value) => Ok(value),
Err(_) => {
let limit = envmnt::get_usize("CARGO_MAKE_SCRIPT_FILE_PATH_MAX_LENGTH", 130);
create_persisted_script_file_with_options(script_text, extension, Some(limit))
}
}
}

fn create_persisted_script_file_with_options(
script_text: &Vec<String>,
extension: &str,
filename_limit: Option<usize>,
) -> Result<String, CargoMakeError> {
let text = script_text.join("\n");

let string_bytes = text.as_bytes();
let bytes = Sha256::digest(string_bytes);
let file_name = bytes_to_hex(&bytes[..])?;
let bytes = md5::compute(string_bytes);
let mut file_name = format!("{:x}", bytes);

let default_target_directory = envmnt::get_or("CARGO_MAKE_CRATE_TARGET_DIRECTORY", "target");
let directory = envmnt::get_or(
Expand All @@ -43,10 +56,26 @@ pub(crate) fn create_persisted_script_file(
file_path_buf.push(&directory);
file_path_buf.push("_cargo_make_temp");
file_path_buf.push("persisted_scripts");
file_path_buf.push(file_name);
file_path_buf.push(&file_name);
file_path_buf.set_extension(extension);
let mut file_path_string: String = file_path_buf.to_string_lossy().into_owned();

let file_path_string: String = file_path_buf.to_string_lossy().into_owned();
if let Some(limit) = filename_limit {
if file_path_string.len() > limit {
let reduce_size = file_path_string.len() - limit;
if reduce_size < file_name.len() {
file_name = file_name[0..file_name.len() - reduce_size].to_string();

file_path_buf = PathBuf::new();
file_path_buf.push(&directory);
file_path_buf.push("_cargo_make_temp");
file_path_buf.push("persisted_scripts");
file_path_buf.push(file_name);
file_path_buf.set_extension(extension);
file_path_string = file_path_buf.to_string_lossy().into_owned();
}
}
}

let file_path = file_path_string.as_path();
if file_path.exists() {
Expand All @@ -61,12 +90,3 @@ pub(crate) fn create_persisted_script_file(
}
}
}

fn bytes_to_hex(bytes: &[u8]) -> Result<String, CargoMakeError> {
let mut hex_string = String::with_capacity(2 * bytes.len());
for byte in bytes {
write!(hex_string, "{:02X}", byte)?;
}

Ok(hex_string)
}

0 comments on commit 97daaac

Please sign in to comment.