Changeset a8e878f


Ignore:
Timestamp:
Jun 14, 2014 12:08:49 AM (6 years ago)
Author:
kytv <kytv@…>
Branches:
master
Children:
89c07ac9
Parents:
1f8f3eb
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Slackware/i2p/i2p.SlackBuild

    r1f8f3eb ra8e878f  
    5353# Extract version strings
    5454I2PBUILD=$(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)
    55 CORE=$(awk -F'"' '/static\s+String\s+VERSION/{print $2}' $I2PSRC/core/java/src/net/i2p/CoreVersion.java)
    56 # Temporarily change the field separator to '.' so the version string can be split up
    57 OLDIFS=$IFS
    58 IFS="."
    59 # split x.y.z into $1 $2 $3
    60 set -- $CORE
    61 # Restore the field separator to the previous value
    62 IFS=$OLDIFS
    63 # With an I2P version string like x.y.z, $1 = x, $2 = y, $3 = z.
    64 # $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
    65 set +u
    66 if [ -z $3 ]; then
    67     # If CORE is a value like 0.9, we'll set CORE equal to 0.9.0 to match the old behaviour
    68     CORE=${CORE}.0
    69 fi
    70 
    71 # From this point forward, unset variables are *unacceptable*
    72 set -o nounset
    73 
     55# Thanks to user "ihavei2p" for the second awk statement
     56# If the version is x.y, it'll be set to x.y.0. Otherwise the version string will be unchanged
     57CORE=$(awk -F'"' '/static\s+String\s+VERSION/{print $2}' $I2PSRC/core/java/src/net/i2p/CoreVersion.java | \
     58        awk -F. '{ if (NF > 3) { print; exit } else if ($3 == "") { $3=0; print $1"."$2"."$3 } else print }')
    7459VERSION="${CORE}_${I2PBUILD}"
    7560
Note: See TracChangeset for help on using the changeset viewer.