Skip to content

Commit 3f983ca

Browse files
z0w0brson
authored andcommitted
Fix cargo to install from archives correctly
1 parent ce2719a commit 3f983ca

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/cargo/cargo.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,10 @@ fn is_uuid(id: str) -> bool {
137137
// FIXME: implement URI/URL parsing so we don't have to resort to weak checks
138138

139139
fn is_archive_uri(uri: str) -> bool {
140-
let (_, ext) = path::splitext(uri);
141-
142-
alt ext {
143-
".tar" { ret true; }
144-
".tar.gz" { ret true; }
145-
".tar.xy" { ret true; }
146-
".tar.bz2" { ret true; }
147-
_ { ret false; }
148-
}
140+
str::ends_with(uri, ".tar")
141+
|| str::ends_with(uri, ".tar.gz")
142+
|| str::ends_with(uri, ".tar.xz")
143+
|| str::ends_with(uri, ".tar.bz2")
149144
}
150145

151146
fn is_archive_url(url: str) -> bool {
@@ -156,7 +151,7 @@ fn is_archive_url(url: str) -> bool {
156151
option::some(idx) {
157152
str::ends_with(url, ".tar")
158153
|| str::ends_with(url, ".tar.gz")
159-
|| str::ends_with(url, ".tar.xy")
154+
|| str::ends_with(url, ".tar.xz")
160155
|| str::ends_with(url, ".tar.bz2")
161156
}
162157
option::none { false }
@@ -641,7 +636,7 @@ fn install_curl(c: cargo, wd: str, url: str) {
641636
}
642637

643638
fn install_file(c: cargo, wd: str, path: str) {
644-
info("installing with file from " + path + "...");
639+
info("installing with tar from " + path + "...");
645640
run::run_program("tar", ["-x", "--strip-components=1",
646641
"-C", wd, "-f", path]);
647642
install_source(c, wd);
@@ -687,7 +682,9 @@ fn install_uuid(c: cargo, wd: str, uuid: str) {
687682
install_package(c, wd, p);
688683
ret;
689684
} else if vec::len(ps) == 0u {
690-
cargo_suggestion(c, false, { || error("no packages match uuid"); });
685+
cargo_suggestion(c, false, { ||
686+
error("can't find package: " + uuid);
687+
});
691688
ret;
692689
}
693690
error("found multiple packages:");
@@ -709,7 +706,9 @@ fn install_named(c: cargo, wd: str, name: str) {
709706
install_package(c, wd, p);
710707
ret;
711708
} else if vec::len(ps) == 0u {
712-
cargo_suggestion(c, false, { || error("no packages match name"); });
709+
cargo_suggestion(c, false, { ||
710+
error("can't find package: " + name);
711+
});
713712
ret;
714713
}
715714
error("found multiple packages:");
@@ -732,7 +731,7 @@ fn install_uuid_specific(c: cargo, wd: str, src: str, uuid: str) {
732731
}
733732
_ { }
734733
}
735-
error("can't find package " + src + "/" + uuid);
734+
error("can't find package: " + src + "/" + uuid);
736735
}
737736

738737
fn install_named_specific(c: cargo, wd: str, src: str, name: str) {
@@ -748,7 +747,7 @@ fn install_named_specific(c: cargo, wd: str, src: str, name: str) {
748747
}
749748
_ { }
750749
}
751-
error("can't find package " + src + "/" + name);
750+
error("can't find package: " + src + "/" + name);
752751
}
753752

754753
fn cmd_uninstall(c: cargo) {
@@ -1074,10 +1073,10 @@ Packages:
10741073
install [options] [source/]<uuid> Install a package by uuid
10751074
install [options] <url> Install a package via curl (HTTP,
10761075
FTP, etc.) from an
1077-
.tar[.gz|bz2|xy] file
1076+
.tar[.gz|bz2|xz] file
10781077
install [options] <url> [ref] Install a package via git
10791078
install [options] <file> Install a package directly from an
1080-
.tar[.gz|bz2|xy] file
1079+
.tar[.gz|bz2|xz] file
10811080
uninstall [options] <name> Remove a package by (meta) name
10821081
uninstall [options] <uuid> Remove a package by (meta) uuid
10831082

0 commit comments

Comments
 (0)