-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcreate_archives.py
executable file
·71 lines (50 loc) · 1.88 KB
/
create_archives.py
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
#!/usr/bin/env python
import os, sys
from os import path
import getopt
import re
def usage():
print '''Usage: package release-name
This script expects that the release folder is in the current directory with the specified name.
The output archives and checksums will be generated in the current directory.'''
#end usage()
def main():
if len(sys.argv) < 2:
usage()
sys.exit(1)
release_name = sys.argv[1]
mantis_path = './' + release_name
print "Packing from ", mantis_path
if not path.isfile(path.join(mantis_path, "core.php"))\
or not path.isdir(path.join(mantis_path, "core"))\
or not path.isfile(path.join(mantis_path, "core", "constant_inc.php")):
print "Error: mantis path does not appear to be a valid Mantis directory."
sys.exit(3)
# Create tarballs
print "Creating release tarballs..."
os.system("tar czf %s.tar.gz %s"%(release_name, release_name))
os.system("zip -rq %s.zip %s"%(release_name, release_name))
# Sign tarballs
print "Signing tarballs"
os.system("gpg -b -a %s.tar.gz"%(release_name))
os.system("gpg -b -a %s.zip"%(release_name))
# Generate checksums
print "Generating checksums..."
tar_md5 = os.popen("md5sum --binary %s.tar.gz"%(release_name)).read()
tar_sha1 = os.popen("sha1sum --binary %s.tar.gz"%(release_name)).read()
zip_md5 = os.popen("md5sum --binary %s.zip"%(release_name)).read()
zip_sha1 = os.popen("sha1sum --binary %s.zip"%(release_name)).read()
f = open("%s.tar.gz.digests"%release_name, 'w')
f.write("%s\n%s\n"%(tar_md5, tar_sha1))
f.close()
f = open("%s.zip.digests"%release_name, 'w')
f.write("%s\n%s\n"%(zip_md5, zip_sha1))
f.close()
print " " + tar_md5
print " " + tar_sha1
print " " + zip_md5
print " " + zip_sha1
print "Done!"
#end main()
if __name__ == "__main__":
main()