mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-19 03:52:17 +00:00
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
106 lines
3.3 KiB
Awk
106 lines
3.3 KiB
Awk
# MAINTAINER: rust@FreeBSD.org
|
|
|
|
BEGIN {
|
|
# No approval required to add a new gitlab instance here
|
|
gitlab_hosts["code.videolan.org"] = 1
|
|
gitlab_hosts["foss.heptapod.net"] = 1
|
|
gitlab_hosts["framagit.org"] = 1
|
|
gitlab_hosts["gitlab.com"] = 1
|
|
gitlab_hosts["gitlab.common-lisp.net"] = 1
|
|
gitlab_hosts["gitlab.cs.fau.de"] = 1
|
|
gitlab_hosts["gitlab.dune-project.org"] = 1
|
|
gitlab_hosts["gitlab.freedesktop.org"] = 1
|
|
gitlab_hosts["gitlab.gnome.org"] = 1
|
|
gitlab_hosts["gitlab.howett.net"] = 1
|
|
gitlab_hosts["gitlab.inria.fr"] = 1
|
|
gitlab_hosts["gitlab.isc.org"] = 1
|
|
gitlab_hosts["gitlab.linphone.org"] = 1
|
|
gitlab_hosts["gitlab.mathematik.uni-stuttgart.de"] = 1
|
|
gitlab_hosts["gitlab.mn.tu-dresden.de"] = 1
|
|
gitlab_hosts["gitlab.mpcdf.mpg.de"] = 1
|
|
gitlab_hosts["gitlab.redox-os.org"] = 1
|
|
gitlab_hosts["gitlab.torproject.org"] = 1
|
|
gitlab_hosts["gitlab.xfce.org"] = 1
|
|
gitlab_hosts["invent.kde.org"] = 1
|
|
gitlab_hosts["salsa.debian.org"] = 1
|
|
gitlab_hosts["source.puri.sm"] = 1
|
|
}
|
|
|
|
function warn(fmt, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) {
|
|
printf("WARNING: " fmt "\n", a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z) >"/dev/stderr"
|
|
}
|
|
|
|
function commit_from_git_url(url) {
|
|
if (url["query", "tag"]) {
|
|
return url["query", "tag"]
|
|
} else {
|
|
return url["fragment"]
|
|
}
|
|
}
|
|
|
|
function split_git_url(info, git_url, url, path, account, project, commit, i, dir_ver, host) {
|
|
delete info
|
|
split_url(url, git_url)
|
|
url["scheme"] = tolower(url["scheme"])
|
|
url["host"] = tolower(url["host"])
|
|
if (url["scheme"] ~ /^git(\+https?)?$/) {
|
|
if (url["host"] == "github.com") {
|
|
split(url["path"], path, "/")
|
|
account = path[2]
|
|
project = path[3]
|
|
sub(/\.[gG][iI][tT]$/, "", project)
|
|
commit = commit_from_git_url(url)
|
|
|
|
delete url
|
|
url["scheme"] = "https"
|
|
url["host"] = "codeload.github.com"
|
|
url["path"] = sprintf("/%s/%s/tar.gz/%s", account, project, commit)
|
|
url["query"] = "dummy"
|
|
url["query", "dummy"] = "/"
|
|
info["site"] = join_url(url)
|
|
|
|
info["filename"] = sprintf("%s-%s-%s_GH0.tar.gz", account, project, commit)
|
|
|
|
# Per bsd.sites.mk:
|
|
# "GitHub silently converts tags starting with v to not have v in the filename
|
|
# and extraction directory. It also replaces + with -."
|
|
dir_ver = commit
|
|
sub(/^[vV]/, "", dir_ver)
|
|
gsub(/\+/, "-", dir_ver)
|
|
gsub(/--/, "-", dir_ver)
|
|
info["dir"] = sprintf("%s-%s", project, dir_ver)
|
|
|
|
return 1
|
|
} else if (gitlab_hosts[url["host"]]) {
|
|
split(url["path"], path, "/")
|
|
account = path[2]
|
|
for (i = 3; i < length(path); i++) {
|
|
account = account "/" path[i]
|
|
}
|
|
project = path[i]
|
|
sub(/\.[gG][iI][tT]$/, "", project)
|
|
commit = commit_from_git_url(url)
|
|
|
|
host = url["host"]
|
|
delete url
|
|
url["scheme"] = "https"
|
|
url["host"] = host
|
|
url["path"] = sprintf("/%s/%s/-/archive/%s.tar.gz", account, project, commit)
|
|
url["query"] = "dummy"
|
|
url["query", "dummy"] = "/"
|
|
info["site"] = join_url(url)
|
|
|
|
gsub(/\//, "-", account)
|
|
info["filename"] = sprintf("%s-%s-%s_GL0.tar.gz", account, project, commit)
|
|
|
|
info["dir"] = sprintf("%s-%s", project, commit)
|
|
|
|
return 1
|
|
}
|
|
}
|
|
|
|
warn("Do not know how to handle %s", git_url)
|
|
warn("If it points to a GitLab instance try adding the hostname to gitlab_hosts[] at the top of cargo-crates-git-common.awk")
|
|
return 0
|
|
}
|