rasa/vmware-tools-patches

untar.sh picking wrong default tools version when multiple present

Closed this issue · 2 comments

When untar.sh isn't given a specific version to untar, it's trying to use the latest one present by default. To do this, it's using "sort -nr" on the file names and then using the first result. Unfortunately, this doesn't do a numeric sort if non-numeric characters appear first. For example:

$ ls VMwareTools* | sort -nr
VMwareTools-9.9.4-3193940.tar.gz
VMwareTools-9.9.3-2759765.tar.gz
VMwareTools-9.9.2-2496486.tar.gz
VMwareTools-9.9.0-2304977.tar.gz
VMwareTools-9.8.4-2202052.tar.gz
VMwareTools-9.8.3-2075148.tar.gz
VMwareTools-9.6.6-2649738.tar.gz
VMwareTools-9.6.2-1688356.tar.gz
VMwareTools-9.6.1-1378637.tar.gz
VMwareTools-9.6.0-1294478.tar.gz
VMwareTools-9.2.4-1398046.tar.gz
VMwareTools-10.0.5-3228253.tar.gz
VMwareTools-10.0.1-3160059.tar.gz
VMwareTools-10.0.0-2977863.tar.gz

With all of these versions present, untar.sh would pick 9.9.4.
If, however, you tell it where the specific numeric field is, things work:

$ ls VMwareTools* | sort -nr -t - -k 2
VMwareTools-10.0.5-3228253.tar.gz
VMwareTools-10.0.1-3160059.tar.gz
VMwareTools-10.0.0-2977863.tar.gz
VMwareTools-9.9.4-3193940.tar.gz
VMwareTools-9.9.3-2759765.tar.gz
VMwareTools-9.9.2-2496486.tar.gz
VMwareTools-9.9.0-2304977.tar.gz
VMwareTools-9.8.4-2202052.tar.gz
VMwareTools-9.8.3-2075148.tar.gz
VMwareTools-9.6.6-2649738.tar.gz
VMwareTools-9.6.2-1688356.tar.gz
VMwareTools-9.6.1-1378637.tar.gz
VMwareTools-9.6.0-1294478.tar.gz
VMwareTools-9.2.4-1398046.tar.gz

Adding the "-t - -k 2" options to sort would give us 10.0.5.

hurda commented

If you change the sort-command here

tool="$(find -type f -name 'VMwareTools-*.tar.gz' | sort -nr | head -n 1)"
to
tool="$(find -type f -name 'VMwareTools-*.tar.gz' | sort -nr -t - -k 2 | head -n 1)"
it's working for you?

That works for me (unpacks 10.0.5 with the update instead of 9.9.4 as with the current version with all of the tarballs present).