Skip to content

Commit

Permalink
Reapply "build-aux: rewrite version.sh in awk"
Browse files Browse the repository at this point in the history
This reverts commit 1c3e268.
  • Loading branch information
thesamesam committed May 2, 2024
1 parent 4139a96 commit 0f136e1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/solaris.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 31 additions & 8 deletions build-aux/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0f136e1

Please sign in to comment.