-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathupdate-version
More file actions
executable file
·51 lines (39 loc) · 1.39 KB
/
update-version
File metadata and controls
executable file
·51 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
import os
import sys
def update_version(path, version, version_3, strict=False):
if not os.path.exists(path):
print(path, "does not exist, not updating version")
return
print("updating version number in", path)
with open(path, "r", encoding="ISO-8859-1", newline="") as f:
data = f.read()
version_upstream = version
if "--deb" in sys.argv:
version = version.replace("alpha", "~alpha")
version = version.replace("beta", "~beta")
version = version.replace("dev", "~dev")
data = data.replace("9.8.7dummy3", version_3)
data = data.replace("9.8.7dummy", version)
data = data.replace("9.8.7upstream", version_upstream)
data = data.replace("9.8.7", version_3 if strict else version)
with open(path, "w", encoding="ISO-8859-1", newline="") as f:
f.write(data)
def main():
with open("VERSION.FS", "r", encoding="ISO-8859-1", newline="") as f:
version = f.read().strip()
parts = version.split(".")
parts = parts[:3]
for i, part in enumerate(parts):
p = ""
for c in part:
if c in "0123456789":
p += c
else:
break
parts[i] = p
version_3 = ".".join(parts)
update_version(sys.argv[1], version, version_3,
strict=("--strict" in sys.argv))
if __name__ == "__main__":
main()