summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorYuri Victorovich <yuri@FreeBSD.org>2023-07-12 12:14:57 -0700
committerYuri Victorovich <yuri@FreeBSD.org>2023-07-12 12:17:29 -0700
commit39a98a35c17a9b3721f215b4dd1acee3a41363a6 (patch)
tree6a048c2baef2e5238cf25dd730223ab5e6ae11aa /Tools
parentdevel/llvm13: arm and aarch64 improvements (diff)
Tools/scripts: Improve update-rust-port.sh
* use strict shell mode * check dependencies * update PORTREVISION Suggested by: mikael@ (use of portedit)
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/update-rust-port.sh22
1 files changed, 20 insertions, 2 deletions
diff --git a/Tools/scripts/update-rust-port.sh b/Tools/scripts/update-rust-port.sh
index 7e479f87822a..80edc8347f71 100755
--- a/Tools/scripts/update-rust-port.sh
+++ b/Tools/scripts/update-rust-port.sh
@@ -2,12 +2,25 @@
#
# MAINTAINER: yuri@FreeBSD.org
+# CAVEAT: ports with Makefile.crates are not yet supported
+
## args
VERSION="$1"
+## set strict mode
+
+STRICT="set -euo pipefail"
+$STRICT
+
## checks
+for dep in portedit rustc; do
+ if ! which -s $dep; then
+ echo "error: $dep dependency is missing, $0 requires lang/rust and ports-mgmt/portfmt to be installed" >&2
+ exit 1
+ fi
+done
if [ -z "$VERSION" ]; then
echo "Usage: $0 <new-version>"
exit 1
@@ -22,8 +35,13 @@ fi
# copy Makefile
cp Makefile Makefile.new
-# substitute version
-sed -i '' -E "s/(VERSION=[\t ]*)[0-9.]+/\1${VERSION}/" Makefile.new
+# substitute version tag PORTVERSION or DISTVERSION
+sed -i '' -E "s/^(PORT|DIST)(VERSION=[\t ]*)[0-9.-]+/\1\2${VERSION}/" Makefile.new
+
+# reset PORTREVISION if present
+if grep -q "PORTREVISION=" Makefile; then
+ echo PORTREVISION=0 | portedit merge -i Makefile.new
+fi
# replace CARGO_CRATES with a placeholder
/usr/bin/awk '