2bad8d171a
Git sources from `Cargo.lock` are added to `CARGO_CRATES` through the normal mechanism of `make cargo-crates` by the porter. They are used to populate `MASTER_SITES`, `DISTFILES` with static git-archive(1) tarballs a la `USE_GITHUB`, `USE_GITLAB`. In the configure phase we generate `[patch]` sections in the config file which will cause `cargo update` to auto-update `Cargo.lock` to point to the appropriate extraction directories. Normally `cargo update` would connect to the network to update all Git sources but since rust-1.55.0 our cargo has been patched to skip this when `CARGO_FREEBSD_PORTS_SKIP_GIT_UPDATE` is set in the environment. This replaces the old `CARGO_USE_GITHUB`, `CARGO_USE_GITLAB` hacks where this was done by editing all `Cargo.toml` with sed(1) calls. Additionally, we try to automatically infer the individiual crate sub-directories inside the Git sources based on `package.name` in `Cargo.toml` to remove the need for `CARGO_GIT_SUBDIR`. USES=cargo also now sets `WRKSRC_crate_$name` for each crate to point to the crate extraction directories. PR: 256581 Reviewed by: jbeich
62 lines
1.2 KiB
Awk
62 lines
1.2 KiB
Awk
# MAINTAINER: rust@FreeBSD.org
|
|
|
|
BEGIN {
|
|
crates_len = 0
|
|
crate_name = "<unknown>"
|
|
crate_version = "<unknown>"
|
|
crate_source = "<unknown>"
|
|
}
|
|
|
|
/^name = ".*"/ {
|
|
crate_name = $3
|
|
gsub(/"/, "", crate_name)
|
|
}
|
|
|
|
/^version = ".*"/ {
|
|
crate_version = $3
|
|
gsub(/"/, "", crate_version)
|
|
}
|
|
|
|
/^source = ".*"/ {
|
|
crate_source = $3
|
|
gsub(/"/, "", crate_source)
|
|
}
|
|
|
|
/^\[\[package\]\]$/ {
|
|
add_crate()
|
|
}
|
|
|
|
function add_crate() {
|
|
if (crate_source ~ /^git\+/) {
|
|
gsub(/#/, "\\#", crate_source)
|
|
if (git_crates[crate_source]) {
|
|
git_crates[crate_source] = git_crates[crate_source] "," crate_name
|
|
} else {
|
|
git_crates[crate_source] = crate_name
|
|
}
|
|
} else if (crate_source == "registry+https://github.com/rust-lang/crates.io-index") {
|
|
crates[crates_len++] = sprintf("%s-%s", crate_name, crate_version)
|
|
}
|
|
crate_name = "<unknown>"
|
|
crate_version = "<unknown>"
|
|
crate_source = "<unknown>"
|
|
}
|
|
|
|
function print_array(start, arr, arrlen) {
|
|
end = " \\\n"
|
|
for (i = 0; i < arrlen; i++) {
|
|
if (i == arrlen - 1) {
|
|
end = "\n"
|
|
}
|
|
printf "%s\t%s%s", start, arr[i], end
|
|
start = "\t"
|
|
}
|
|
}
|
|
|
|
END {
|
|
add_crate()
|
|
for (crate_source in git_crates) {
|
|
crates[crates_len++] = git_crates[crate_source] "@" crate_source
|
|
}
|
|
print_array("CARGO_CRATES=", crates, crates_len)
|
|
}
|