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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
import argparse
import os
import sys
import subprocess
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
def check_not_in_venv():
if os.environ.get("VIRTUAL_ENV"):
sys.exit("You should not run this in a virtualenv!")
def clean():
cmd = ["git", "clean", "--force", "-d", "-x"]
subprocess.check_call(cmd, cwd=THIS_DIR)
def set_version(version):
pkgbuild = os.path.join(THIS_DIR, "PKGBUILD")
with open(pkgbuild, "r") as fp:
lines = fp.readlines()
new_lines = list()
for line in lines:
if line.startswith("pkgver"):
new_line = "pkgver='%s'\n" % version
new_lines.append(new_line)
else:
new_lines.append(line)
with open(pkgbuild, "w") as fp:
fp.writelines(new_lines)
def set_checksums():
cmd = ["/usr/bin/updpkgsums"]
subprocess.check_call(cmd, cwd=THIS_DIR)
def run_makepkg():
cmd = ["/usr/bin/extra-x86_64-build"]
subprocess.check_call(cmd, cwd=THIS_DIR)
def update_srcinfo():
cmd = ["mksrcinfo"]
subprocess.check_call(cmd, cwd=THIS_DIR)
def commit_all(version):
cmd = ["git", "add", "PKGBUILD", ".SRCINFO"]
subprocess.check_call(cmd)
cmd = ["git", "commit", "--message", "Update to %s" % version]
subprocess.check_call(cmd)
def push():
cmd = ["git", "--no-pager", "show", "HEAD"]
subprocess.check_call(cmd)
answer = input("OK to push (y/n)? ")
if answer == "y":
cmd = ["git", "push"]
subprocess.check_call(cmd)
def make_release(version):
clean()
set_version(version)
set_checksums()
run_makepkg()
update_srcinfo()
commit_all(version)
push()
def main():
parser = argparse.ArgumentParser()
parser.add_argument("version")
args = parser.parse_args()
check_not_in_venv()
version = args.version
make_release(version)
if __name__ == "__main__":
main()
|