View Single Post
Old 05-16-2016, 12:44 PM   #1049
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
FWIW, to parse the /etc/version.txt file (mostly) correctly:

Code:
# Get the FW version
fw_build_maj="$(awk '/Version:/ { print $NF }' /etc/version.txt | awk -F- '{ print $NF }')"
fw_build_min="$(awk '/Version:/ { print $NF }' /etc/version.txt | awk -F- '{ print $1 }')"
# Legacy major versions used to have a leading zero, which is stripped from the complete build number. Except on really ancient builds, that (or an extra) 0 is always used as a separator between maj and min...
fw_build_maj_pp="${fw_build_maj#0}"
# That only leaves some weird diags build that handle this stuff in potentially even weirder ways to take care of...
if [ "${fw_build_maj}" -eq "${fw_build_min}" ] ; then
        # Weird diags builds... (5.0.0)
        fw_build="${fw_build_maj_pp}0???"
else
        # Most common instance... maj#6 + 0 + min#3 or maj#5 + 0 + min#3 (potentially with a leading 0 stripped from maj#5)
        if [ ${#fw_build_min} -eq 3 ] ; then
                fw_build="${fw_build_maj_pp}0${fw_build_min}"
        else
                # Truly ancient builds... For instance, 2.5.6, which is maj#5 + min#4 (with a leading 0 stripped from maj#5)
                fw_build="${fw_build_maj_pp}${fw_build_min}"
        fi
fi
(Snippet from the device_id script in the Helper extension).
NiLuJe is offline   Reply With Quote