-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_bundle
executable file
·113 lines (89 loc) · 3.63 KB
/
update_bundle
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/python
import datetime
import time
import platform
import os
import sys
import glob
import shutil
def message(msg):
sys.stdout.write(msg + '\n')
sys.stdout.flush()
MAX_BUNDLE_DAYS = 30
arch = platform.machine()
if arch.endswith('86'):
arch = "x86"
arch_folder_name = "32bits"
else:
arch_folder_name = "64bits"
if len(sys.argv) < 2 or "release" not in sys.argv:
bundles_dir = "/mnt/bundles/daily/"
else:
bundles_dir = "/mnt/bundles/releases/"
archives_dir = os.path.join(bundles_dir, arch_folder_name, "archives")
def cleanup_bundles(to_archive):
for f in to_archive:
message("Archiving %s into %s" % (f, archives_dir))
shutil.move(f, os.path.join(archives_dir,
time.strftime("%Y%m%d-%H%M%S") + "-" + os.path.basename(f)))
# message("Cleaning up old bundles")
# now = time.time()
# for f in os.listdir(archives_dir):
# f = os.path.join(archives_dir, f)
# last_modification = os.path.getmtime(f)
# age = (now - last_modification) / 86400
# if age > MAX_BUNDLE_DAYS:
# message("Deleting file %s, it is %d days old" % (f, age))
# os.remove(f)
version = "0.95"
if len(sys.argv) == 2:
version_name = sys.argv[1]
else:
version_name = "latest"
path = os.environ["PATH"]
os.environ["PATH"] = "%s:%s" % (path, os.path.expanduser("~/bin"))
cerbero_folder = os.path.expanduser("~/devel/cerbero")
cerbero_default_branch = "pitivi/master"
tarball = "/tmp/" + "pitivi-" + version_name + "-" + arch + ".tar.xz"
tarball_name = bundles_dir + arch_folder_name + "/" + "pitivi-" + version_name + "-" + arch + ".tar.xz"
bundling_dir = os.path.expanduser("~/pitivi/bundling/")
os.system('mkdir -p %s' % bundling_dir)
open("/root/.cerbero/cerbero.cbc", 'w').write("""
home_dir='/root/cerbero'
use_ccache=True
variants = ['python3', 'gtk3']
""")
message("Using /root/.cerbero/cerbero.cbc:")
os.system("cat /root/.cerbero/cerbero.cbc")
commands = ["cd %s && git remote add pitivi https://github.com/pitivi/cerbero.git; git remote update && git reset --hard %s" % (cerbero_folder, cerbero_default_branch),
"echo $(git show --summary)",
"cerbero bootstrap --build-tools-only",
"cerbero fetch --reset-rdeps --full-reset pitivi",
"cerbero package pitivi --force --linux-bundle --output-dir %(bundling_dir)s --no-devel",
"mv pitivi-%(version)s-%(arch)s pitivi-%(version)s-%(arch)s-%(date)s",
"ln -s pitivi-%(version)s-%(arch)s-%(date)s pitivi-%(version)s-%(arch)s",
"tar -Jcf %(tarball)s pitivi-%(version)s-%(arch)s pitivi-%(version)s-%(arch)s.md5sum pitivi-%(version)s-%(arch)s-%(date)s",
"mv %(tarball)s %(tarball_name)s",
"rm -Rf %(bundling_dir)s/*"]
os.chdir(bundling_dir)
to_archive = glob.glob(os.path.join(bundles_dir, arch_folder_name) + "/pitivi-*.tar.*")
date = datetime.datetime.now().strftime("%Y-%m-%d_%H%M")
for command in commands:
command = command % {"arch": arch,
"version": version,
"version_name": version_name,
"arch_folder_name": arch_folder_name,
"bundles_dir": bundles_dir,
"bundling_dir": bundling_dir,
"archives_dir": archives_dir,
"tarball": tarball,
"tarball_name": tarball_name,
"date": date,
}
message("Launching %s" % command)
res = os.system(command)
if res != 0:
message("FAILLURE!")
exit(1)
cleanup_bundles(to_archive)
os.rename(tarball, tarball_name)