From 4f36610e9dc99c6f2c8a982d7e918f8e1ea5e57e Mon Sep 17 00:00:00 2001 From: Ismael Luceno Date: Sun, 26 Mar 2023 00:31:24 +0100 Subject: [PATCH] sightsee: Improve parsing Make so that the Watch line can come in any order; it was confusing before because it needed to happen after VERSION was defined. --- usr/lib/sorcery/cmd/sightsee | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/usr/lib/sorcery/cmd/sightsee b/usr/lib/sorcery/cmd/sightsee index a9314d7d..81e71f81 100755 --- a/usr/lib/sorcery/cmd/sightsee +++ b/usr/lib/sorcery/cmd/sightsee @@ -57,14 +57,9 @@ else fi find "${paths[@]}" -name DETAILS -exec awk ' - function check_missing() { - if (spell != "") - printf "E: %s: Upstream releases page not specified\n", \ - spell >"/dev/stderr" - } - END { check_missing() } + END { print_spell() } FNR==1 { - check_missing() + if (spell != "") print_spell() spell = FILENAME sub(/\/DETAILS$/, "", spell) sub(/.*\//, "", spell) @@ -72,16 +67,26 @@ find "${paths[@]}" -name DETAILS -exec awk ' /^ *VERSION=/ { version = $0 sub(/.*=/, "", version) + if (watch_url != "") nextfile } /^#Watch:/ { + watch_url = $2 + watch_regex = $3 # TODO check syntax - print spell, version, $2, $3 - spell = "" - nextfile + if (version != "") nextfile + } + function print_spell() { + if (watch_url == "") { + printf "E: %s: %s\n", spell, \ + "Upstream releases page not specified" \ + >"/dev/stderr" + } + print spell, version, watch_url, watch_regex + version = watch_url = spell = "" } ' {} + | while read spell cur_rel url regex; do - latest_rel=$(upstream_rel_get "$url" "$regex") && + latest_rel=$(upstream_rel_get "$url" "$regex") || continue if [ "x$latest_rel" != "x$cur_rel" ]; then echo "$spell $latest_rel" elif [ -n "$verbose" ]; then -- 2.38.5