@@ -39,11 +39,22 @@ source_url="https://github.com/rizinorg/rizin/archive/$rev.tar.gz"
3939echo " Prefetching Rizin source at $rev "
4040prefetch_json=$( nix store prefetch-file --json --unpack " $source_url " )
4141src_hash=$( printf ' %s\n' " $prefetch_json " | sed -n ' s/.*"hash"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' )
42+ source_path=$( printf ' %s\n' " $prefetch_json " | sed -n ' s/.*"storePath"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' )
4243
4344if [[ $src_hash != sha256-* ]]; then
4445 echo " Could not extract the Rizin source hash from: $prefetch_json " >&2
4546 exit 1
4647fi
48+ if [[ ! -d $source_path ]]; then
49+ echo " Could not extract the unpacked Rizin source path from: $prefetch_json " >&2
50+ exit 1
51+ fi
52+
53+ upstream_version=$( sed -n " s/^[[:space:]]*version: 'v\([^']*\)',/\1/p" " $source_path /meson.build" | head -n 1)
54+ if [[ ! $upstream_version =~ ^[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
55+ echo " Could not extract a three-part Rizin version from $source_path /meson.build" >&2
56+ exit 1
57+ fi
4758
4859backup=$( mktemp)
4960cp -- " $checksum_file " " $backup "
@@ -59,17 +70,18 @@ restore_on_error() {
5970trap restore_on_error EXIT
6071
6172write_checksums () {
62- target_rev=$1
63- target_src_hash=$2
64- target_deps_hash=$3
73+ target_version=$1
74+ target_rev=$2
75+ target_src_hash=$3
76+ target_deps_hash=$4
6577 tmp=$( mktemp " ${checksum_file} .tmp.XXXXXX" )
66- printf ' {\n "rev": "%s",\n "srcHash": "%s",\n "mesonDepsHash": "%s"\n}\n' \
67- " $target_rev " " $target_src_hash " " $target_deps_hash " > " $tmp "
78+ printf ' {\n "version": "%s",\n " rev": "%s",\n "srcHash": "%s",\n "mesonDepsHash": "%s"\n}\n' \
79+ " $target_version " " $ target_rev" " $target_src_hash " " $target_deps_hash " > " $tmp "
6880 mv -- " $tmp " " $checksum_file "
6981}
7082
7183fake_hash=" sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
72- write_checksums " $rev " " $src_hash " " $fake_hash "
84+ write_checksums " $upstream_version " " $ rev" " $src_hash " " $fake_hash "
7385
7486echo " Calculating the Meson dependency hash"
7587set +e
@@ -89,12 +101,13 @@ if [[ $meson_deps_hash != sha256-* ]]; then
89101 exit 1
90102fi
91103
92- write_checksums " $rev " " $src_hash " " $meson_deps_hash "
104+ write_checksums " $upstream_version " " $ rev" " $src_hash " " $meson_deps_hash "
93105echo " Validating Rizin and rizin-rs"
94106nix build .# rizin --no-link --print-build-logs
95107nix build .# rizin-rs --no-link --print-build-logs
96108
97109echo " Updated nix/rizin/checksum.json"
110+ echo " version: $upstream_version "
98111echo " rev: $rev "
99112echo " srcHash: $src_hash "
100113echo " mesonDepsHash: $meson_deps_hash "
0 commit comments