|
13 | 13 | //! This module is responsible for installing the standard library,
|
14 | 14 | //! compiler, and documentation.
|
15 | 15 |
|
| 16 | +use std::fs; |
| 17 | +use std::path::Path; |
| 18 | +use std::process::Command; |
| 19 | + |
16 | 20 | use Build;
|
| 21 | +use dist::{package_vers, sanitize_sh, tmpdir}; |
17 | 22 |
|
18 | 23 | /// Installs everything.
|
19 |
| -pub fn install(_: &Build, stage: u32, host: &str) { |
20 |
| - println!("Install everything stage{} ({})", stage, host); |
21 |
| - println!("Note: install currently does nothing."); |
| 24 | +pub fn install(build: &Build, stage: u32, host: &str) { |
| 25 | + let prefix = build.config.prefix.as_ref().clone().map(|x| Path::new(x)) |
| 26 | + .unwrap_or(Path::new("/usr/local")); |
| 27 | + let empty_dir = build.out.join("tmp/empty_dir"); |
| 28 | + t!(fs::create_dir_all(&empty_dir)); |
| 29 | + if build.config.docs { |
| 30 | + install_sh(&build, "docs", "rust-docs", stage, host, prefix, &empty_dir); |
| 31 | + } |
| 32 | + install_sh(&build, "std", "rust-std", stage, host, prefix, &empty_dir); |
| 33 | + install_sh(&build, "rustc", "rustc", stage, host, prefix, &empty_dir); |
| 34 | + t!(fs::remove_dir_all(&empty_dir)); |
| 35 | +} |
| 36 | + |
| 37 | +fn install_sh(build: &Build, package: &str, name: &str, stage: u32, host: &str, |
| 38 | + prefix: &Path, empty_dir: &Path) { |
| 39 | + println!("Install {} stage{} ({})", package, stage, host); |
| 40 | + let package_name = format!("{}-{}-{}", name, package_vers(build), host); |
| 41 | + |
| 42 | + let mut cmd = Command::new("sh"); |
| 43 | + cmd.current_dir(empty_dir) |
| 44 | + .arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh"))) |
| 45 | + .arg(format!("--prefix={}", sanitize_sh(&prefix))) |
| 46 | + .arg("--disable-ldconfig"); |
| 47 | + build.run(&mut cmd); |
22 | 48 | }
|
0 commit comments