<pre style='margin:0'>
Rainer Müller (raimue) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/693587cafc0f89c2ed9a1e4ac0b0240623f696a8">https://github.com/macports/macports-ports/commit/693587cafc0f89c2ed9a1e4ac0b0240623f696a8</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 693587cafc0f89c2ed9a1e4ac0b0240623f696a8
</span>Author: Rainer Müller <raimue@macports.org>
AuthorDate: Wed Apr 4 00:30:39 2018 +0200
<span style='display:block; white-space:pre;color:#404040;'> cargo group: Support additional crates from GitHub
</span>---
_resources/port1.0/group/cargo-1.0.tcl | 71 +++++++++++++++++++++++++++++++---
1 file changed, 66 insertions(+), 5 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/_resources/port1.0/group/cargo-1.0.tcl b/_resources/port1.0/group/cargo-1.0.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index b919fbe..7c899fa 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/_resources/port1.0/group/cargo-1.0.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/_resources/port1.0/group/cargo-1.0.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -47,8 +47,17 @@
</span> # updates of this list for new releases.
#
# https://github.com/macports/macports-contrib/tree/master/cargo2port/cargo2port.tcl
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# If Cargo.lock references pre-release versions, or in general references
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# crates not published on crates.io, but available from GitHub, also use the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# following:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# # download additional crates from github, not published on crates.io
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# cargo.crates_github \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# baz author/baz branch abcdef12345678...commit...abcdef12345678 fedcba654321...
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-options cargo.crates cargo.home
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+options cargo.home cargo.crates cargo.crates_github
</span>
default cargo.home {${workpath}/.home/.cargo}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -69,21 +78,61 @@ proc handle_cargo_crates {option action {value ""}} {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc cargo._import_crate {cname cversion chksum cratefile} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+option_proc cargo.crates_github handle_cargo_crates_github
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc handle_cargo_crates_github {option action {value ""}} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {${action} eq "set"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach {cname cgithub cbranch crevision chksum} ${value} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set cratefile ${cname}-${crevision}.tar.gz
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # The same crate name can appear with multiple versions. Use
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # a combination of crate name and checksum as unique identifier.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # As the :disttag cannot contain dots, the version number cannot be
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # used.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set cratetag crate-${cname}-${chksum}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ distfiles-append ${cratefile}:${cratetag}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ master_sites-append https://github.com/${cgithub}/archive/${crevision}.tar.gz?dummy=:${cratetag}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ checksums-append ${cratefile} sha256 ${chksum}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc cargo._extract_crate {cratefile} {
</span> global cargo.home distpath
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_debug "Adding ${cratefile} to cargo home"
</span> set tar [findBinary tar ${portutil::autoconf::tar_path}]
system -W "${cargo.home}/macports" "$tar -xf ${distpath}/${cratefile}"
<span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc cargo._write_cargo_checksum {cdirname chksum} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global cargo.home
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # although cargo will never see the .crate, it expects to find the sha256 checksum here
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set chkfile [open "${cargo.home}/macports/${cname}-${cversion}/.cargo-checksum.json" "w"]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set chkfile [open "${cargo.home}/macports/${cdirname}/.cargo-checksum.json" "w"]
</span> puts $chkfile "{"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts $chkfile " \"package\": \"${chksum}\","
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $chkfile " \"package\": ${chksum},"
</span> puts $chkfile " \"files\": {}"
puts $chkfile "}"
close $chkfile
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+proc cargo._import_crate {cname cversion chksum cratefile} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global cargo.home
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_info "Adding ${cratefile} to cargo home"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cargo._extract_crate ${cratefile}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cargo._write_cargo_checksum "${cname}-${cversion}" "\"${chksum}\""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc cargo._import_crate_github {cname cgithub crevision chksum cratefile} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global cargo.home
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set crepo [lindex [split ${cgithub} "/"] 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set cdirname "${crepo}-${crevision}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_info "Adding ${cratefile} from github to cargo home"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cargo._extract_crate ${cratefile}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cargo._write_cargo_checksum ${cdirname} "null"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # The distfiles of the main port will also be stored in this directory,
# but this is the only way to allow reusing the same crates across multiple ports.
dist_subdir cargo-crates
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -104,6 +153,14 @@ pre-build {
</span> puts $conf "\[source.crates-io\]"
puts $conf "replace-with = \"macports\""
puts $conf "local-registry = \"/var/empty\""
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength ${cargo.crates_github}] > 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach {cname cgithub cbranch crevision chksum} ${cargo.crates_github} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $conf "\[source.\"https://github.com/${cgithub}\"\]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $conf "git = \"https://github.com/${cgithub}\""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $conf "branch = \"${cbranch}\""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $conf "replace-with = \"macports\""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> close $conf
# import all crates
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -111,6 +168,10 @@ pre-build {
</span> set cratefile ${cname}-${cversion}.crate
cargo._import_crate ${cname} ${cversion} ${chksum} ${cratefile}
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach {cname cgithub cbranch crevision chksum} ${cargo.crates_github} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set cratefile ${cname}-${crevision}.tar.gz
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cargo._import_crate_github ${cname} ${cgithub} ${crevision} ${chksum} ${cratefile}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
use_configure no
</pre><pre style='margin:0'>
</pre>