@@ -157,27 +157,6 @@ impl<'self> PkgScript<'self> {
157
157
impl Ctx {
158
158
159
159
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
-
181
160
match cmd {
182
161
~"build" => {
183
162
if args.len() < 1 {
@@ -227,9 +206,7 @@ impl Ctx {
227
206
return usage::uninstall();
228
207
}
229
208
230
- let (name, vers) = sep_name_vers(copy args[0]);
231
-
232
- self.prefer(name.get(), vers);
209
+ self.prefer(args[0], None);
233
210
}
234
211
~"test" => {
235
212
self.test();
@@ -239,20 +216,16 @@ impl Ctx {
239
216
return usage::uninstall();
240
217
}
241
218
242
- let (name, vers) = sep_name_vers(copy args[0]);
243
-
244
- self.uninstall(name.get(), vers);
219
+ self.uninstall(args[0], None);
245
220
}
246
221
~"unprefer" => {
247
222
if args.len() < 1 {
248
223
return usage::uninstall();
249
224
}
250
225
251
- let (name, vers) = sep_name_vers(copy args[0]);
252
-
253
- self.unprefer(name.get(), vers);
226
+ self.unprefer(args[0], None);
254
227
}
255
- _ => fail!("reached an unhandled command" )
228
+ _ => fail!(fmt!("I don't know the command `%s`", cmd) )
256
229
}
257
230
}
258
231
@@ -267,7 +240,7 @@ impl Ctx {
267
240
debug!("Destination dir = %s", build_dir.to_str());
268
241
269
242
// Create the package source
270
- let mut src = PkgSrc::new(workspace, &build_dir, & pkgid);
243
+ let mut src = PkgSrc::new(workspace, &build_dir, pkgid);
271
244
debug!("Package src = %?", src);
272
245
273
246
// Is there custom build logic? If so, use it
@@ -305,7 +278,6 @@ impl Ctx {
305
278
// Build it!
306
279
src.build(&build_dir, cfgs, self.sysroot_opt);
307
280
}
308
-
309
281
}
310
282
311
283
fn clean(&self, workspace: &Path, id: &PkgId) {
@@ -317,7 +289,7 @@ impl Ctx {
317
289
util::note(fmt!("Cleaning package %s (removing directory %s)",
318
290
id.to_str(), dir.to_str()));
319
291
if os::path_exists(&dir) {
320
- util::remove_dir_r (&dir);
292
+ os::remove_dir_recursive (&dir);
321
293
util::note(fmt!("Removed directory %s", dir.to_str()));
322
294
}
323
295
@@ -353,19 +325,19 @@ impl Ctx {
353
325
debug!("Copying: %s -> %s", exec.to_str(), target_exec.to_str());
354
326
if !(os::mkdir_recursive(&target_exec.dir_path(), u_rwx) &&
355
327
os::copy_file(exec, &target_exec)) {
356
- cond.raise((*exec, target_exec));
328
+ cond.raise((copy *exec, copy target_exec));
357
329
}
358
330
}
359
331
for maybe_library.each |lib| {
360
332
debug!("Copying: %s -> %s", lib.to_str(), target_lib.to_str());
361
333
if !(os::mkdir_recursive(&target_lib.dir_path(), u_rwx) &&
362
334
os::copy_file(lib, &target_lib)) {
363
- cond.raise((*lib, target_lib));
335
+ cond.raise((copy *lib, copy target_lib));
364
336
}
365
337
}
366
338
}
367
339
368
- fn prefer(&self, _id: ~ str, _vers: Option<~str>) {
340
+ fn prefer(&self, _id: & str, _vers: Option<~str>) {
369
341
fail!(~"prefer not yet implemented");
370
342
}
371
343
@@ -374,15 +346,16 @@ impl Ctx {
374
346
fail!("test not yet implemented");
375
347
}
376
348
377
- fn uninstall(&self, _id: ~ str, _vers: Option<~str>) {
349
+ fn uninstall(&self, _id: & str, _vers: Option<~str>) {
378
350
fail!("uninstall not yet implemented");
379
351
}
380
352
381
- fn unprefer(&self, _id: ~ str, _vers: Option<~str>) {
353
+ fn unprefer(&self, _id: & str, _vers: Option<~str>) {
382
354
fail!("unprefer not yet implemented");
383
355
}
384
356
}
385
357
358
+
386
359
pub fn main() {
387
360
io::println("WARNING: The Rust package manager is experimental and may be unstable");
388
361
@@ -443,32 +416,6 @@ pub struct Crate {
443
416
cfgs: ~[~str]
444
417
}
445
418
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
-
472
419
pub impl Crate {
473
420
474
421
fn new(p: &Path) -> Crate {
@@ -527,10 +474,6 @@ pub fn src_dir() -> Path {
527
474
os::getcwd()
528
475
}
529
476
530
- condition! {
531
- bad_pkg_id: (super::Path, ~str) -> ::util::PkgId;
532
- }
533
-
534
477
// An enumeration of the unpacked source of a package workspace.
535
478
// This contains a list of files found in the source workspace.
536
479
pub struct PkgSrc {
@@ -576,7 +519,7 @@ impl PkgSrc {
576
519
577
520
if !os::path_exists(&dir) {
578
521
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 \
580
523
exist, and couldn't interpret it as a URL fragment"));
581
524
}
582
525
}
@@ -598,12 +541,12 @@ impl PkgSrc {
598
541
let mut local = self.root.push("src");
599
542
local = local.push(self.id.to_str());
600
543
// Git can't clone into a non-empty directory
601
- util::remove_dir_r (&local);
544
+ os::remove_dir_recursive (&local);
602
545
603
546
let url = fmt!("https://%s", self.id.remote_path.to_str());
604
547
util::note(fmt!("git clone %s %s", url, local.to_str()));
605
548
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 {
607
550
util::note(fmt!("fetching %s failed: can't clone repository", url));
608
551
return false;
609
552
}
@@ -733,3 +676,4 @@ impl PkgSrc {
733
676
self.build_crates(maybe_sysroot, dst_dir, &dir, self.benchs, cfgs, Bench);
734
677
}
735
678
}
679
+
0 commit comments