Changeset View
Standalone View
Mk/Scripts/cargo-crates.awk
- This file was added.
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
BEGIN { | |||||
gh_tuple_len = 0 | |||||
crates_len = 0 | |||||
package_name = "<unknown>" | |||||
} | |||||
/^"checksum .* .* \(registry\+.*\)" = ".*"/ { | |||||
# $2: crate | |||||
# $3: version | |||||
# $4: url | |||||
# $6: checksum | |||||
crates[crates_len++] = sprintf("%s-%s", $2, $3) | |||||
} | |||||
/^name = ".*"/ { | |||||
package_name = $3 | |||||
gsub("[^a-zA-Z_]", "", package_name) | |||||
} | |||||
mat: So, reading more, this is the one that cannot contain anything else than [^a-zA-Z_].
Those two… | |||||
/^source = "git\+(https|http|git):\/\/github.com\/.*#.*"/ { | |||||
split($3, url, "#") | |||||
gsub("^\"git\+", "", url[1]) | |||||
split(url[1], repourl, "/") | |||||
account = repourl[4] | |||||
project = repourl[5] | |||||
gsub("\.git$", "", project) | |||||
tag = url[2] | |||||
gsub("\"$", "", tag) | |||||
Done Inline ActionsNote that that bit of the url can contains many chars that are not allowed in our tags. Our tags end up being shell variables, so they must only contain [a-zA-Z0-9_] (as seen in the C locale, can't have accented characters and stuff). mat: Note that that bit of the url can contains many chars that are not allowed in our tags. Our… | |||||
gh_tuple[gh_tuple_len++] = sprintf(\ | |||||
Not Done Inline Actionsmmmm, I thought tag was the last part, not the commit id. Sorry about it. mat: mmmm, I thought tag was the last part, not the commit id. Sorry about it. | |||||
"%s:%s:%s:%s", account, project, tag, package_name) | |||||
} | |||||
function print_array(start, arr, arrlen) { | |||||
Done Inline ActionsThat is a bad idea, even for small repositories, collisions can come faster than you think. mat: That is a bad idea, even for small repositories, collisions can come faster than you think.
You… | |||||
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 { | |||||
if (gh_tuple_len > 0) { | |||||
use_github = ENVIRON["USE_GITHUB"] | |||||
if (use_github == "") { | |||||
use_github = "nodefault" | |||||
Not Done Inline ActionsMmmm, if the original software does not come from github, this will be a problem. I see two cases here.
mat: Mmmm, if the original software does not come from github, this will be a problem.
I see two… | |||||
} | |||||
printf "USE_GITHUB=\t%s\n", use_github | |||||
} | |||||
Not Done Inline ActionsI still think this should only be written in the USE_GITHUB=nodefault case. As it already exists otherwise. mat: I still think this should only be written in the USE_GITHUB=nodefault case. As it already… | |||||
print_array("GH_TUPLE=", gh_tuple, gh_tuple_len) | |||||
print_array("CARGO_CRATES=", crates, crates_len) | |||||
if (gh_tuple_len > 0) { | |||||
printf "CARGO_USE_GITHUB=\tyes\n" | |||||
} | |||||
} |
So, reading more, this is the one that cannot contain anything else than [^a-zA-Z_].
Those two lines should probably be folded into one: