Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: use dmgs on macos #998

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,49 @@

let response_with_pb = pb.wrap_read(response);

let tar = GzDecoder::new(response_with_pb);
let archive = Archive::new(tar);
unpack_sans_parent(archive, target_path, levels_to_skip)
.with_context(|| format!("Failed to extract downloaded file from url `{}`.", url))?;
// if url is to a .dmg extract using macos native tools
if url.ends_with(".dmg") {
let mut archive = File::create(&target_path)?;

Check failure on line 90 in src/operations.rs

View workflow job for this annotation

GitHub Actions / test-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared type `File`

Check failure on line 90 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared type `File`

Check failure on line 90 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

failed to resolve: use of undeclared type `File`
copy(&mut response_with_pb, &mut archive)?;

Check failure on line 91 in src/operations.rs

View workflow job for this annotation

GitHub Actions / test-juliaup (x86_64-unknown-linux-gnu)

cannot find function `copy` in this scope

Check failure on line 91 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-unknown-linux-gnu)

cannot find function `copy` in this scope

Check failure on line 91 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

cannot find function `copy` in this scope

// Wait for the .dmg to mount
let mountpoint = wait_for_dmg_mount()?;

// Open the Julia root directory.
// TODO replace app name with actual name
let julia_root_path = mountpoint.join("Julia-1.12.app/Contents/Resources/julia");
let mut julia_root = File::open(&julia_root_path)?;

Check failure on line 99 in src/operations.rs

View workflow job for this annotation

GitHub Actions / test-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared type `File`

Check failure on line 99 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared type `File`

Check failure on line 99 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

failed to resolve: use of undeclared type `File`

// Copy Julia directory to target path
let mut target_file = File::create(&target_path)?;

Check failure on line 102 in src/operations.rs

View workflow job for this annotation

GitHub Actions / test-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared type `File`

Check failure on line 102 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared type `File`

Check failure on line 102 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

failed to resolve: use of undeclared type `File`
copy(&mut julia_root, &mut target_file)?;

Check failure on line 103 in src/operations.rs

View workflow job for this annotation

GitHub Actions / test-juliaup (x86_64-unknown-linux-gnu)

cannot find function `copy` in this scope

Check failure on line 103 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-unknown-linux-gnu)

cannot find function `copy` in this scope

Check failure on line 103 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

cannot find function `copy` in this scope

// Remove the mount point directory
fs::remove_dir_all(&mountpoint)?;

Check failure on line 106 in src/operations.rs

View workflow job for this annotation

GitHub Actions / test-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared crate or module `fs`

Check failure on line 106 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared crate or module `fs`

Check failure on line 106 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

failed to resolve: use of undeclared crate or module `fs`
} else {
let tar = GzDecoder::new(response_with_pb);
let archive = Archive::new(tar);
unpack_sans_parent(archive, target_path, levels_to_skip)
.with_context(|| format!("Failed to extract downloaded file from url `{}`.", url))?;
}

Ok(last_modified)
}

fn wait_for_dmg_mount() -> Result<std::path::PathBuf> {
// Loop until we find the mounted volume
loop {
if let Some(entry) = fs::read_dir("/Volumes")?.next() {

Check failure on line 120 in src/operations.rs

View workflow job for this annotation

GitHub Actions / test-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared crate or module `fs`

Check failure on line 120 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (x86_64-unknown-linux-gnu)

failed to resolve: use of undeclared crate or module `fs`

Check failure on line 120 in src/operations.rs

View workflow job for this annotation

GitHub Actions / check-juliaup (aarch64-apple-darwin)

failed to resolve: use of undeclared crate or module `fs`
let entry = entry?;
if entry.file_type()?.is_dir() {
return Ok(entry.path());
}
}
// Sleep for a short time before trying again
std::thread::sleep(std::time::Duration::from_secs(1));
}
}

#[cfg(windows)]
struct DataReaderWrap(windows::Storage::Streams::DataReader);

Expand Down Expand Up @@ -322,6 +357,10 @@
})?
.url_path;

if cfg!(target_os = "macos") {
download_url_path.trim_end_matches(".tar.gz").to_string() + ".dmg";
}

let download_url = juliaupserver_base
.join(download_url_path)
.with_context(|| {
Expand Down
Loading