Skip to content

Commit

Permalink
Merge pull request #227 from DilumAluthge/dpa/macos-tarball
Browse files Browse the repository at this point in the history
Install Julia from tarball on macOS
  • Loading branch information
ViralBShah authored Nov 7, 2024
2 parents c9fc09d + d2c3ba3 commit 5463b06
Showing 1 changed file with 3 additions and 41 deletions.
44 changes: 3 additions & 41 deletions R/installJulia.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ julia_url <- function(version){
} else if (sysname == "Darwin") {
os <- "mac"
slug <- ifelse(sysmachine == "arm64", "macaarch64", "mac64")
ext <- "dmg"
ext <- "tar.gz"
} else if (sysname == "Windows") {
os <- "winnt"
slug <- "win64"
Expand Down Expand Up @@ -111,7 +111,8 @@ install_julia <- function(version = "latest",
utils::untar(file, exdir=dest)
subfolder <- paste("julia-", version, sep="")
} else if (sysname == "Darwin") {
subfolder <- install_julia_dmg(file, dest)
utils::untar(file, exdir=dest)
subfolder <- paste("julia-", version, sep="")
} else if (sysname == "Windows") {
utils::unzip(file, exdir = dest)
subfolder <- paste("julia-", version, sep="")
Expand All @@ -124,42 +125,3 @@ install_julia <- function(version = "latest",

invisible(TRUE)
}


# Install Julia from DMG on macOS
install_julia_dmg <- function(dmg_path, install_dir) {
mount_root <- normalizePath(".")
mount_name <- tools::file_path_sans_ext(basename(dmg_path))
mount_point <- file.path(mount_root, mount_name)

umount(mount_point)

cmd <- paste(
'hdiutil attach "', dmg_path, '" -mountpoint "', mount_point,
'" -mount required -quiet',
sep = "")

tryCatch({
exitcode <- system(cmd)
stopifnot(exitcode == 0)

appname <- list.files(mount_point, pattern = "julia*", ignore.case = T)
src_path <- file.path(mount_point, appname)
if (!dir.exists(install_dir)) {
dir.create(install_dir, recursive = T)
}
file.copy(src_path, install_dir, recursive = T)
},
finally = {
umount(mount_point)
})

file.path(appname, "Contents", "Resources", "julia")
}
umount <- function(mount_point) {
if (dir.exists(mount_point)) {
system(paste('umount "', mount_point, '"', sep = ""))
} else {
0
}
}

0 comments on commit 5463b06

Please sign in to comment.