Backport msi-conformant-version function

This commit is contained in:
twangboy 2017-04-12 12:00:57 -06:00
parent 0638418d22
commit 825832812b

View File

@ -712,5 +712,27 @@ def versions_report(include_salt_cloud=False):
yield line
def msi_conformant_version():
'''
A msi conformant version consists of up to 4 numbers, each smaller than 256,
except the 4th. Therefore, the year must be represented as 'short year'.
Examples (depend on git checkout):
develop 2016.11.0-742-g5ca4d20 16.11.0.742
2016.11 (branch) 2016.11.2-78-gce1f01f 16.11.2.78
v2016.11.2 (tag) 2016.11.2 16.11.2.0
Note that the commit count for tags is 0(zero)
'''
year2 = int(str(__saltstack_version__.major)[2:])
month = __saltstack_version__.minor
minor = __saltstack_version__.bugfix
commi = __saltstack_version__.noc
return '{0}.{1}.{2}.{3}'.format(year2, month, minor, commi)
if __name__ == '__main__':
print(__version__)
if len(sys.argv) == 2 and sys.argv[1] == 'msi':
# Building the msi requires an msi-conformant version
print(msi_conformant_version())
else:
print(__version__)