Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jul 2023 05:22:17 GMT
From:      Yuri Victorovich <yuri@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 7e866ceb0ef5 - main - Tools/scripts: Add update-rust-port.sh script to simplify Rust port updates
Message-ID:  <202307120522.36C5MHs9031145@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7e866ceb0ef53a7aeaed442890ca2fb1bab4e1e6

commit 7e866ceb0ef53a7aeaed442890ca2fb1bab4e1e6
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-07-12 05:18:21 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-07-12 05:18:21 +0000

    Tools/scripts: Add update-rust-port.sh script to simplify Rust port updates
    
    The command 'update-rust-port.sh <version>', when run in the Rust
    port directory, updates this port to the requested version.
    
    update-rust-port.sh should work in most cases.
---
 Tools/scripts/update-rust-port.sh | 69 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)

diff --git a/Tools/scripts/update-rust-port.sh b/Tools/scripts/update-rust-port.sh
new file mode 100755
index 000000000000..7e479f87822a
--- /dev/null
+++ b/Tools/scripts/update-rust-port.sh
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# MAINTAINER: yuri@FreeBSD.org
+
+## args
+
+VERSION="$1"
+
+## checks
+
+if [ -z "$VERSION" ]; then
+	echo "Usage: $0 <new-version>"
+	exit 1
+fi
+if ! [ -f Makefile ] || ! [ -f pkg-descr ] || ! grep -q "CARGO_CRATES=" Makefile; then
+	echo "$0 should be run in a Rust-based port directory"
+	exit 1
+fi
+
+## MAIN
+
+# copy Makefile
+cp Makefile Makefile.new
+
+# substitute version
+sed -i '' -E "s/(VERSION=[\t ]*)[0-9.]+/\1${VERSION}/" Makefile.new
+
+# replace CARGO_CRATES with a placeholder
+/usr/bin/awk '
+BEGIN {
+	in_cargo_crates = 0
+}
+/^CARGO_CRATES=.*/ {
+	in_cargo_crates = 1
+	print "#@@@PLACEHOLDER@@@"
+}
+/^\t.*/ {
+	if (in_cargo_crates) {
+		// skip line
+	} else {
+		print $0
+	}
+}
+!/^CARGO_CRATES=.*|^\t.*/ {
+	if (in_cargo_crates) {
+		in_cargo_crates = 0
+	}
+	print $0
+}' < Makefile.new > Makefile.new1 &&
+/bin/mv Makefile.new1 Makefile.new
+
+# update distinfo
+make -f Makefile.new makesum
+
+# replace the placeholder
+while IFS= read -r line; do
+	if [ "$line" = "#@@@PLACEHOLDER@@@" ]; then
+		make -f Makefile.new cargo-crates | grep -v '^='
+	else
+		echo "$line"
+	fi
+done < Makefile.new > Makefile.new1 &&
+mv Makefile.new1 Makefile.new
+
+# move Makefile.new
+mv Makefile.new Makefile
+
+# update distinfo
+make clean makesum


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202307120522.36C5MHs9031145>