From 0f136e17515d3a6431c08ffbfaa8f1da233f8160 Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 25 Apr 2024 22:08:22 +0100 Subject: [PATCH] Reapply "build-aux: rewrite version.sh in awk" This reverts commit 1c3e268776e8fd215264d2f39de8e86ce364adfe. --- .github/workflows/solaris.yml | 1 + build-aux/version.sh | 39 ++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/solaris.yml b/.github/workflows/solaris.yml index 96fcf83d7..6e1475a86 100644 --- a/.github/workflows/solaris.yml +++ b/.github/workflows/solaris.yml @@ -20,6 +20,7 @@ jobs: usesh: true prepare: | pkg install bash libtool automake gnu-m4 tree wget gcc autoconf + pkg install --accept developerstudio-125 run: | export LC_ALL=C LANG=C diff --git a/build-aux/version.sh b/build-aux/version.sh index bef1b33d9..b35292c61 100644 --- a/build-aux/version.sh +++ b/build-aux/version.sh @@ -9,14 +9,37 @@ ############################################################################# # # Author: Lasse Collin +# Kerin Millar # ############################################################################# -sed -n 's/LZMA_VERSION_STABILITY_ALPHA/alpha/ - s/LZMA_VERSION_STABILITY_BETA/beta/ - s/LZMA_VERSION_STABILITY_STABLE// - s/^#define LZMA_VERSION_[MPS][AIT][AJNT][A-Z]* //p' \ - src/liblzma/api/lzma/version.h \ - | tr '\n' '|' \ - | sed 's/|/./; s/|/./; s/|//g' \ - | tr -d '\r\n' +# Solaris provides a legacy awk implementation as /usr/bin/awk. It also provides +# /usr/bin/nawk, which is more or less POSIX-compliant. Be sure to use it. +if grep Solaris /etc/release >/dev/null 2>&1; then + awk=nawk +else + awk=awk +fi + +"$awk" -f - <<'EOF' + +BEGIN { + ARGV[1] = "src/liblzma/api/lzma/version.h" + ARGC = 2 + OFS = "." + ORS = "" +} + +/^#define LZMA_VERSION_(MAJOR|MINOR|PATCH|STABILITY) / { + sub(/.*_/, "", $2) + sub(/.*_/, "", $3) + if ($2 != "STABILITY" || $3 != "STABLE") { + ver[$2] = tolower($3) + } +} + +END { + print ver["MAJOR"], ver["MINOR"], ver["PATCH"] ver["STABILITY"] +} + +EOF