@@ -157,27 +157,6 @@ impl<'self> PkgScript<'self> {
157157impl Ctx {
158158
159159 fn run(&self, cmd: ~str, args: ~[~str]) {
160- let root = util::root();
161-
162- util::need_dir(&root);
163- util::need_dir(&root.push(~"work"));
164- util::need_dir(&root.push(~"lib"));
165- util::need_dir(&root.push(~"bin"));
166- util::need_dir(&root.push(~"tmp"));
167-
168- fn sep_name_vers(in: ~str) -> (Option<~str>, Option<~str>) {
169- let mut name = None;
170- let mut vers = None;
171-
172- for str::each_split_char(in, '@') |s| {
173- if name.is_none() { name = Some(s.to_owned()); }
174- else if vers.is_none() { vers = Some(s.to_owned()); }
175- else { break; }
176- }
177-
178- (name, vers)
179- }
180-
181160 match cmd {
182161 ~"build" => {
183162 if args.len() < 1 {
@@ -227,9 +206,7 @@ impl Ctx {
227206 return usage::uninstall();
228207 }
229208
230- let (name, vers) = sep_name_vers(copy args[0]);
231-
232- self.prefer(name.get(), vers);
209+ self.prefer(args[0], None);
233210 }
234211 ~"test" => {
235212 self.test();
@@ -239,20 +216,16 @@ impl Ctx {
239216 return usage::uninstall();
240217 }
241218
242- let (name, vers) = sep_name_vers(copy args[0]);
243-
244- self.uninstall(name.get(), vers);
219+ self.uninstall(args[0], None);
245220 }
246221 ~"unprefer" => {
247222 if args.len() < 1 {
248223 return usage::uninstall();
249224 }
250225
251- let (name, vers) = sep_name_vers(copy args[0]);
252-
253- self.unprefer(name.get(), vers);
226+ self.unprefer(args[0], None);
254227 }
255- _ => fail!("reached an unhandled command" )
228+ _ => fail!(fmt!("I don't know the command `%s`", cmd) )
256229 }
257230 }
258231
@@ -267,7 +240,7 @@ impl Ctx {
267240 debug!("Destination dir = %s", build_dir.to_str());
268241
269242 // Create the package source
270- let mut src = PkgSrc::new(workspace, &build_dir, & pkgid);
243+ let mut src = PkgSrc::new(workspace, &build_dir, pkgid);
271244 debug!("Package src = %?", src);
272245
273246 // Is there custom build logic? If so, use it
@@ -305,7 +278,6 @@ impl Ctx {
305278 // Build it!
306279 src.build(&build_dir, cfgs, self.sysroot_opt);
307280 }
308-
309281 }
310282
311283 fn clean(&self, workspace: &Path, id: &PkgId) {
@@ -317,7 +289,7 @@ impl Ctx {
317289 util::note(fmt!("Cleaning package %s (removing directory %s)",
318290 id.to_str(), dir.to_str()));
319291 if os::path_exists(&dir) {
320- util::remove_dir_r (&dir);
292+ os::remove_dir_recursive (&dir);
321293 util::note(fmt!("Removed directory %s", dir.to_str()));
322294 }
323295
@@ -353,19 +325,19 @@ impl Ctx {
353325 debug!("Copying: %s -> %s", exec.to_str(), target_exec.to_str());
354326 if !(os::mkdir_recursive(&target_exec.dir_path(), u_rwx) &&
355327 os::copy_file(exec, &target_exec)) {
356- cond.raise((*exec, target_exec));
328+ cond.raise((copy *exec, copy target_exec));
357329 }
358330 }
359331 for maybe_library.each |lib| {
360332 debug!("Copying: %s -> %s", lib.to_str(), target_lib.to_str());
361333 if !(os::mkdir_recursive(&target_lib.dir_path(), u_rwx) &&
362334 os::copy_file(lib, &target_lib)) {
363- cond.raise((*lib, target_lib));
335+ cond.raise((copy *lib, copy target_lib));
364336 }
365337 }
366338 }
367339
368- fn prefer(&self, _id: ~ str, _vers: Option<~str>) {
340+ fn prefer(&self, _id: & str, _vers: Option<~str>) {
369341 fail!(~"prefer not yet implemented");
370342 }
371343
@@ -374,15 +346,16 @@ impl Ctx {
374346 fail!("test not yet implemented");
375347 }
376348
377- fn uninstall(&self, _id: ~ str, _vers: Option<~str>) {
349+ fn uninstall(&self, _id: & str, _vers: Option<~str>) {
378350 fail!("uninstall not yet implemented");
379351 }
380352
381- fn unprefer(&self, _id: ~ str, _vers: Option<~str>) {
353+ fn unprefer(&self, _id: & str, _vers: Option<~str>) {
382354 fail!("unprefer not yet implemented");
383355 }
384356}
385357
358+
386359pub fn main() {
387360 io::println("WARNING: The Rust package manager is experimental and may be unstable");
388361
@@ -443,32 +416,6 @@ pub struct Crate {
443416 cfgs: ~[~str]
444417}
445418
446- pub struct Listener {
447- cmds: ~[~str],
448- cb: ~fn()
449- }
450-
451- pub fn run(listeners: ~[Listener]) {
452- let rcmd = copy os::args()[2];
453- let mut found = false;
454-
455- for listeners.each |listener| {
456- for listener.cmds.each |&cmd| {
457- if cmd == rcmd {
458- (listener.cb)();
459-
460- found = true;
461-
462- break;
463- }
464- }
465- }
466-
467- if !found {
468- os::set_exit_status(42);
469- }
470- }
471-
472419pub impl Crate {
473420
474421 fn new(p: &Path) -> Crate {
@@ -527,10 +474,6 @@ pub fn src_dir() -> Path {
527474 os::getcwd()
528475}
529476
530- condition! {
531- bad_pkg_id: (super::Path, ~str) -> ::util::PkgId;
532- }
533-
534477// An enumeration of the unpacked source of a package workspace.
535478// This contains a list of files found in the source workspace.
536479pub struct PkgSrc {
@@ -576,7 +519,7 @@ impl PkgSrc {
576519
577520 if !os::path_exists(&dir) {
578521 if !self.fetch_git() {
579- cond.raise((self.id, ~"supplied path for package dir does not \
522+ cond.raise((copy self.id, ~"supplied path for package dir does not \
580523 exist, and couldn't interpret it as a URL fragment"));
581524 }
582525 }
@@ -598,12 +541,12 @@ impl PkgSrc {
598541 let mut local = self.root.push("src");
599542 local = local.push(self.id.to_str());
600543 // Git can't clone into a non-empty directory
601- util::remove_dir_r (&local);
544+ os::remove_dir_recursive (&local);
602545
603546 let url = fmt!("https://%s", self.id.remote_path.to_str());
604547 util::note(fmt!("git clone %s %s", url, local.to_str()));
605548
606- if run::program_output(~"git", ~[~"clone", url, local.to_str()]).status != 0 {
549+ if run::program_output(~"git", ~[~"clone", copy url, local.to_str()]).status != 0 {
607550 util::note(fmt!("fetching %s failed: can't clone repository", url));
608551 return false;
609552 }
@@ -733,3 +676,4 @@ impl PkgSrc {
733676 self.build_crates(maybe_sysroot, dst_dir, &dir, self.benchs, cfgs, Bench);
734677 }
735678}
679+
0 commit comments