forked from univention/univention-corporate-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.build_unbuilt_packages
executable file
·72 lines (57 loc) · 2.18 KB
/
.build_unbuilt_packages
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/env python2.7
from univention.repong.repo_lib_pg import postgres
import os
import subprocess
import re
RE_BRANCH = re.compile(r'^(?P<major>[1-9][0-9]*)[.](?P<minor>[0-9]+)[-.](?P<subminor>[0-9]+)$')
def build_unbuilt_packages():
db = postgres()
changelog_filenames = subprocess.check_output(
['find', '.', '-mindepth', '4', '-maxdepth', '4', '-type', 'f', '-name', 'changelog', '-path', '*/debian/changelog']
).strip('\n').split('\n')
for changelog_filename in changelog_filenames:
with open(changelog_filename) as changelog_file:
first_changelog_line = changelog_file.readline()
changelog_fields = first_changelog_line.split()
package_name = changelog_fields[0]
package_name_long = "/".join(
changelog_filename.strip('./').split('/')[0:2]
)
package_version = changelog_fields[1][1:-1]
try:
db.get_srcrev(package_name, package_version)
except LookupError:
build_package(package_name, package_name_long)
def build_package(package_name, package_name_long):
branch = os.environ['CI_COMMIT_REF_NAME']
match = RE_BRANCH.match(branch)
if not match:
return
ucs_version_string = branch
ucs_version = match.groupdict()
release_yaml_filename = (
"/var/univention/buildsystem2/mirror/ftp/download/ucs-maintenance/{}.yaml"
).format(ucs_version_string)
repo_admin_command = [
"echo",
"repo_admin.py",
"-G", "[email protected]:univention/ucs.git",
"-b", ucs_version_string,
"-P", package_name_long,
"-p", package_name,
"-r", ucs_version_string[:3],
]
if os.path.isfile(release_yaml_filename):
scope = 'errata{major}.{minor}-{subminor}'.format(**ucs_version)
repo_admin_command += ["-s", scope]
build_command = ["echo", "b{major}{minor}-scope".format(**ucs_version), scope, package_name]
elif ucs_version['subminor'] > 0:
scope = 'ucs{major}.{minor}-{subminor}'.format(**ucs_version)
repo_admin_command += ["-s", scope]
build_command = ["echo", "b{major}{minor}-scope".format(**ucs_version), scope, package_name]
else:
build_command = ["echo", "b{major}{minor}".format(**ucs_version), package_name]
subprocess.check_call(repo_admin_command)
subprocess.check_call(build_command)
if __name__ == '__main__':
build_unbuilt_packages()