about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub <jakub@jakub.cc>2013-09-08 22:59:51 +0000
committerJakub <jakub@jakub.cc>2013-09-12 23:31:45 +0000
commit3d14e82be752959fb010a786ef4c9ef417bd64db (patch)
treea95635d2f523df5316e14a99c12a80a84efe95ea
parent248765a746237e7292d30dce072799e076e4f9cf (diff)
downloadrust-3d14e82be752959fb010a786ef4c9ef417bd64db.tar.gz
rust-3d14e82be752959fb010a786ef4c9ef417bd64db.zip
Fix rustpkg install for git repositories
-rw-r--r--src/librustpkg/package_source.rs12
-rw-r--r--src/librustpkg/path_util.rs2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs
index 946707288c4..bba9d073b7d 100644
--- a/src/librustpkg/package_source.rs
+++ b/src/librustpkg/package_source.rs
@@ -18,7 +18,7 @@ use context::*;
 use crate::Crate;
 use messages::*;
 use source_control::{git_clone, git_clone_general};
-use path_util::{find_dir_using_rust_path_hack, default_workspace};
+use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_recursive};
 use util::compile_crate;
 use workspace::is_workspace;
 use workcache_support;
@@ -166,12 +166,14 @@ impl PkgSrc {
                   url, clone_target.to_str(), pkgid.version.to_str());
 
         if git_clone_general(url, &clone_target, &pkgid.version) {
-            // since the operation succeeded, move clone_target to local
-            if !os::rename_file(&clone_target, local) {
-                 None
+            // Since the operation succeeded, move clone_target to local.
+            // First, create all ancestor directories.
+            if make_dir_rwx_recursive(&local.pop())
+                && os::rename_file(&clone_target, local) {
+                 Some(local.clone())
             }
             else {
-                 Some(local.clone())
+                 None
             }
         }
         else {
diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs
index 1b732354f11..3cfa793e898 100644
--- a/src/librustpkg/path_util.rs
+++ b/src/librustpkg/path_util.rs
@@ -43,6 +43,8 @@ pub static U_RWX: i32 = (S_IRUSR | S_IWUSR | S_IXUSR) as i32;
 /// succeeded.
 pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) }
 
+pub fn make_dir_rwx_recursive(p: &Path) -> bool { os::mkdir_recursive(p, U_RWX) }
+
 // n.b. The next three functions ignore the package version right
 // now. Should fix that.