amiaopensource / ltopers

Bash scripts to manage LTO cartridges with LTFS
https://github.com/amiaopensource/ltopers
MIT License
39 stars 8 forks source link

make version "dynamic" #79

Closed retokromer closed 7 years ago

retokromer commented 7 years ago

Thank you @privatezero for the idea!

retokromer commented 7 years ago

@dericed @privatezero If this PR and https://github.com/amiaopensource/ltopers/pull/78 are accepted, should we use the date-based versioning from the next releases on? In my feeling v2017-03-26 would be more informative than v0.1.13.

kieranjol commented 7 years ago

How does date versioning handle more than one update on the same day?

retokromer commented 7 years ago

It uses the release information, not the updates, therefore it would allow to know which release is used.

dericed commented 7 years ago

Would the results be wrong if the user uses brew switch to revert to an earlier version of ltopers. If they did, they would still see the highest numbered installed version number in their help documentation even when they switched to an earlier one.

I'd also suggest a fall back in case a user does not have a /usr/local/Cellar/ltopers dir.

retokromer commented 7 years ago

Good point!

(In our configuration older/newer versions are automatically removed, and only the last installed is there…)

retokromer commented 7 years ago

If we change to date-based versioning, then

VERSION=$(brew info ltopers | grep "/ltopers/" | grep -Eo "[0-9]{4}-[0-9]{2}-[0-9]{2}")

would give the actual active version.

retokromer commented 7 years ago

@dericed @kieranjol This

VERSION=$(TMP=$(brew info ltopers | grep -Eo "/ltopers/.* \(") ; echo ${TMP:9:(${#TMP}-11)})

should work with any installed version (including e.g. 0.00.007 alpha 2017-03-27 in the morning). BTW: it works also on Linux and Ubuntu on Windows.

dericed commented 7 years ago

This could also cause confusion when testing an uninstalled script while there is also an installed one, which may be most development scenarios. Could you also add a check to be sure that dirname $(which "${0}") is referencing the homebrew installation directory before using the homebrew version number.

retokromer commented 7 years ago

Do you mean something like

if [[ $(dirname $(which "${0}")) = "/usr/local/bin" ]]; then
  VERSION=$(TMP=$(brew info ltopers | grep -Eo "/ltopers/.* \(") ; echo ${TMP:9:(${#TMP}-11)})
else
  VERSION=""
fi

?

dericed commented 7 years ago

untested, but yes something like that, so that an uninstalled mountlto doesn't provide the version of the installed one

retokromer commented 7 years ago

Thank you again! I will amend again.