2016-08-16 06:02:15 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
def get_full_version():
|
|
|
|
"""
|
|
|
|
Find full version of Pungi: if running from git, this will return cleaned
|
|
|
|
output of `git describe`, otherwise it will look for installed version.
|
|
|
|
"""
|
2020-02-03 03:50:06 +00:00
|
|
|
location = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
|
|
|
|
if os.path.isdir(os.path.join(location, ".git")):
|
2016-08-16 06:02:15 +00:00
|
|
|
import subprocess
|
2020-02-03 03:50:06 +00:00
|
|
|
|
|
|
|
proc = subprocess.Popen(
|
|
|
|
["git", "--git-dir=%s/.git" % location, "describe", "--tags"],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
universal_newlines=True,
|
|
|
|
)
|
2016-08-16 06:02:15 +00:00
|
|
|
output, _ = proc.communicate()
|
2020-02-03 03:50:06 +00:00
|
|
|
return re.sub(r"-1.fc\d\d?", "", output.strip().replace("pungi-", ""))
|
2016-08-16 06:02:15 +00:00
|
|
|
else:
|
2018-07-26 21:03:58 +00:00
|
|
|
import subprocess
|
2020-02-03 03:50:06 +00:00
|
|
|
|
2019-04-04 09:42:19 +00:00
|
|
|
proc = subprocess.Popen(
|
|
|
|
["rpm", "-q", "pungi"], stdout=subprocess.PIPE, universal_newlines=True
|
|
|
|
)
|
2018-07-26 21:03:58 +00:00
|
|
|
(output, err) = proc.communicate()
|
|
|
|
if not err:
|
|
|
|
return output.rstrip()
|
|
|
|
else:
|
2020-02-03 03:50:06 +00:00
|
|
|
return "unknown"
|