I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit a8e878f8 authored by kytv's avatar kytv
Browse files

SlackBuild: version extraction using awk (thanks 'ihavei2p') (ticket #1310)

parent 1f8f3eb4
No related branches found
No related tags found
No related merge requests found
...@@ -52,25 +52,10 @@ fi ...@@ -52,25 +52,10 @@ fi
# Extract version strings # Extract version strings
I2PBUILD=$(sed -e '/^.\+long\s\+BUILD/!d' -e 's/^.\+long\s\+BUILD\s\+=\s\+\([0-9]\+\);/\1/' $I2PSRC/router/java/src/net/i2p/router/RouterVersion.java) I2PBUILD=$(sed -e '/^.\+long\s\+BUILD/!d' -e 's/^.\+long\s\+BUILD\s\+=\s\+\([0-9]\+\);/\1/' $I2PSRC/router/java/src/net/i2p/router/RouterVersion.java)
CORE=$(awk -F'"' '/static\s+String\s+VERSION/{print $2}' $I2PSRC/core/java/src/net/i2p/CoreVersion.java) # Thanks to user "ihavei2p" for the second awk statement
# Temporarily change the field separator to '.' so the version string can be split up # If the version is x.y, it'll be set to x.y.0. Otherwise the version string will be unchanged
OLDIFS=$IFS CORE=$(awk -F'"' '/static\s+String\s+VERSION/{print $2}' $I2PSRC/core/java/src/net/i2p/CoreVersion.java | \
IFS="." awk -F. '{ if (NF > 3) { print; exit } else if ($3 == "") { $3=0; print $1"."$2"."$3 } else print }')
# split x.y.z into $1 $2 $3
set -- $CORE
# Restore the field separator to the previous value
IFS=$OLDIFS
# With an I2P version string like x.y.z, $1 = x, $2 = y, $3 = z.
# $3 won't be reachable if the version is of the form x.y, so we'll temporarily set +u to prevent aborting if this variable isn't set
set +u
if [ -z $3 ]; then
# If CORE is a value like 0.9, we'll set CORE equal to 0.9.0 to match the old behaviour
CORE=${CORE}.0
fi
# From this point forward, unset variables are *unacceptable*
set -o nounset
VERSION="${CORE}_${I2PBUILD}" VERSION="${CORE}_${I2PBUILD}"
[ -d $PKG ] && rm -rf $PKG [ -d $PKG ] && rm -rf $PKG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment