summaryrefslogtreecommitdiff
path: root/cli/tools/upgrade.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-01-19 03:40:22 +0100
committerGitHub <noreply@github.com>2021-01-19 03:40:22 +0100
commit9ff468df730e330370d90b33db5b2cfc0f508601 (patch)
tree2b41a41f1057143f0cf3bb472c6107f5c845f755 /cli/tools/upgrade.rs
parentb12afdb89a989e7d78389bd5289488d86202bb4e (diff)
feat: Standalone lite binaries and cross compilation (#9141)
This commit adds --target and --lite flags to deno compile subcommand. --target allows to cross-compile binary to different target architectures by fetching appropriate binary from remote server on first run. All downloaded binaries are stored in "$DENO_DIR/dl". --lite allows to use lite version of the runtime (ie. the one that doesn't contain built-in tooling like formatter or linter).
Diffstat (limited to 'cli/tools/upgrade.rs')
-rw-r--r--cli/tools/upgrade.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs
index 58c283ecd..ab49c06e9 100644
--- a/cli/tools/upgrade.rs
+++ b/cli/tools/upgrade.rs
@@ -111,7 +111,7 @@ pub async fn upgrade_command(
println!("Deno is upgrading to version {}", &install_version);
let old_exe_path = std::env::current_exe()?;
- let new_exe_path = unpack(archive_data)?;
+ let new_exe_path = unpack(archive_data, "deno")?;
let permissions = fs::metadata(&old_exe_path)?.permissions();
fs::set_permissions(&new_exe_path, permissions)?;
check_exe(&new_exe_path)?;
@@ -176,13 +176,17 @@ async fn download_package(
}
}
-fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, std::io::Error> {
+pub fn unpack(
+ archive_data: Vec<u8>,
+ exe_name: &str,
+) -> Result<PathBuf, std::io::Error> {
// We use into_path so that the tempdir is not automatically deleted. This is
// useful for debugging upgrade, but also so this function can return a path
// to the newly uncompressed file without fear of the tempdir being deleted.
let temp_dir = TempDir::new()?.into_path();
let exe_ext = if cfg!(windows) { "exe" } else { "" };
- let exe_path = temp_dir.join("deno").with_extension(exe_ext);
+ let archive_path = temp_dir.join(exe_name).with_extension(".zip");
+ let exe_path = temp_dir.join(exe_name).with_extension(exe_ext);
assert!(!exe_path.exists());
let archive_ext = Path::new(&*ARCHIVE_NAME)
@@ -191,7 +195,6 @@ fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, std::io::Error> {
.unwrap();
let unpack_status = match archive_ext {
"zip" if cfg!(windows) => {
- let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("powershell.exe")
.arg("-NoLogo")
@@ -217,7 +220,6 @@ fn unpack(archive_data: Vec<u8>) -> Result<PathBuf, std::io::Error> {
.wait()?
}
"zip" => {
- let archive_path = temp_dir.join("deno.zip");
fs::write(&archive_path, &archive_data)?;
Command::new("unzip")
.current_dir(&temp_dir)