Skip to content

Instantly share code, notes, and snippets.

@pat-s
Last active May 26, 2022 12:08
Show Gist options
  • Save pat-s/6430470cf817050e27d26c43c0e9be72 to your computer and use it in GitHub Desktop.
Save pat-s/6430470cf817050e27d26c43c0e9be72 to your computer and use it in GitHub Desktop.
# because base::file.rename() is a pain across OS
requireNamespace("fs", quietly = TRUE)
# download cluto zip file
temp = tempfile()
utils::download.file("http://glaros.dtc.umn.edu/gkhome/fetch/sw/cluto/cluto-2.1.2a.zip", temp, quiet = TRUE)
utils::unzip(temp, files = c("cluto-2.1.2/Linux-x86_64/vcluster", "cluto-2.1.2/MSWIN-x86_64/vcluster.exe"))
unlink(temp)
# check if mlr3spatiotempcv is installed
installed_packages = utils::installed.packages()[, "Package"]
if (!"mlr3spatiotempcv" %in% installed_packages) {
stop("Please install mlr3spatiotempcv first.")
}
# install CLUTO
switch(Sys.info()[["sysname"]],
"Windows" = {
message(sprintf("Installing the executable into '%s/vcluster.exe'.", system.file(package = "mlr3spatiotempcv")))
message("If the package is updated/reinstalled, this process needs to be repeated.")
fs::file_move("cluto-2.1.2/MSWIN-x86_64/vcluster.exe", sprintf("%s/vcluster.exe", system.file(package = "mlr3spatiotempcv")))
fs::file_chmod(system.file("vcluster.exe", package = "mlr3spatiotempcv"), "755")
},
"Darwin" = stop("macOS is not supported by CLUTO."),
"Linux" = {
message(sprintf("Installing the executable into '%s/vcluster'.", system.file(package = "mlr3spatiotempcv")))
message("If the package is updated/reinstalled, this process needs to be repeated.")
fs::file_move("cluto-2.1.2/Linux-x86_64/vcluster", sprintf("%s/vcluster", system.file(package = "mlr3spatiotempcv")))
fs::file_chmod(system.file("vcluster", package = "mlr3spatiotempcv"), "755")
}
)
unlink("cluto-2.1.2", recursive = TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment