-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-staging
executable file
·72 lines (52 loc) · 1.89 KB
/
update-staging
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
#!/usr/bin/python
# update-staging - script to write out staging results.
import sys
import os
import tarfile
import shutil
master_path = "/opt/buildbot/lsb-master"
staging_path = "/opt/buildbot/ftpdir/pub/lsb/staging"
src_arch = 'x86_64'
def parse_tarball_name(tarball):
fn_components = tarball.split('-')
arch = fn_components[-1].replace('.tar.gz', '')
area = fn_components[-2]
if fn_components[-3] == 'devel':
prj_index = -3
else:
prj_index = -2
prj = '-'.join(fn_components[:prj_index])
return (prj, area, arch)
def main():
if os.path.exists(staging_path):
shutil.rmtree(staging_path)
for tarball in os.listdir(master_path):
if tarball[-6:] != 'tar.gz':
continue
# Parse filename.
(prj, area, arch) = parse_tarball_name(tarball)
# Skip snapshot material and devchk.
if area == 'devel' or prj == 'devchk':
continue
# Make sure that the staging area is there.
prj_staging_path = os.path.join(staging_path, area, prj)
if not os.path.exists(prj_staging_path):
os.makedirs(prj_staging_path)
os.chdir(prj_staging_path)
# Unpack the tarball and move its contents into the staging area.
t = tarfile.open(os.path.join(master_path, tarball))
t.extractall()
# Move its contents out of the results directory. Skip
# source RPMs for all archs except one.
if prj == "lsb-sdk":
results_path = "sdk-results"
else:
results_path = "results"
for (dp, dn, fnlist) in os.walk(results_path):
for fn in fnlist:
if arch == src_arch or fn[-7:] != 'src.rpm':
shutil.move(os.path.join(dp, fn), os.path.join('.', fn))
# Clear out the results directory.
shutil.rmtree(results_path)
if __name__ == "__main__":
main()