Path: blob/main/Tools/scripts/update-rust-port.sh
18157 views
#!/bin/sh1#2# MAINTAINER: [email protected]34# CAVEAT: ports with Makefile.crates are not yet supported56## args78VERSION="$1"910## set strict mode1112STRICT="set -euo pipefail"13$STRICT1415## checks1617for dep in portedit rustc; do18if ! which -s $dep; then19echo "error: $dep dependency is missing, $0 requires lang/rust and ports-mgmt/portfmt to be installed" >&220exit 121fi22done23if [ -z "$VERSION" ]; then24echo "Usage: $0 <new-version>"25exit 126fi27if ! [ -f Makefile ] || ! [ -f pkg-descr ] || ! grep -q "CARGO_CRATES=" Makefile; then28echo "$0 should be run in a Rust-based port directory"29exit 130fi3132## MAIN3334# copy Makefile35cp Makefile Makefile.new3637# substitute version tag PORTVERSION or DISTVERSION38sed -i '' -E "s/^(PORT|DIST)(VERSION=[\t ]*)[0-9.-]+/\1\2${VERSION}/" Makefile.new3940# reset PORTREVISION if present41if grep -q "PORTREVISION=" Makefile; then42echo PORTREVISION=0 | portedit merge -i Makefile.new43fi4445# replace CARGO_CRATES with a placeholder46/usr/bin/awk '47BEGIN {48in_cargo_crates = 049}50/^CARGO_CRATES=.*/ {51in_cargo_crates = 152print "#@@@PLACEHOLDER@@@"53}54/^\t.*/ {55if (in_cargo_crates) {56// skip line57} else {58print $059}60}61!/^CARGO_CRATES=.*|^\t.*/ {62if (in_cargo_crates) {63in_cargo_crates = 064}65print $066}' < Makefile.new > Makefile6768# update distinfo69make makesum7071# replace the placeholder72while IFS= read -r line; do73if [ "$line" = "#@@@PLACEHOLDER@@@" ]; then74make cargo-crates | grep -v '^='75else76echo "$line"77fi78done < Makefile > Makefile.new &&79mv Makefile.new Makefile8081# clean82make clean8384# update distinfo85make makesum868788