-
Notifications
You must be signed in to change notification settings - Fork 1
/
build
executable file
·85 lines (74 loc) · 3.54 KB
/
build
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
#!/usr/bin/env python3
import argparse
from subprocess import run
from distinfo import ReleaseInfo, distributions
REPO = 'ghcr.io/jbigot/pkg_builder/'
def run_docker(*args):
print("\n\n \033[34m===> docker " +
args[0] + " " + args[-1] + " <===\033[39m")
print('$ docker', *args, '\n')
return run(['docker'] + list(args)).returncode
def main():
parser = argparse.ArgumentParser(
description='Builds the required docker images.',
allow_abbrev=False)
parser.add_argument('-p', '--publish', action='store_true',
help='Publish the images')
args = parser.parse_args()
res = run_docker('build', '--force-rm', '-t',
REPO + 'rpm_tools', 'rpm_tools')
if res == 0 and args.publish:
run(['docker', 'push', REPO + 'rpm_tools']).returncode
for distrib in distributions():
for release in distrib.releases(eoled=False):
release_id = release.id
dist_id = distrib.id
builder = 'rpm_builder'
if 'debian' in distrib.id_like:
release_id = release.codename
builder = 'deb_builder'
docker_image = REPO + '' + distrib.id + '_builder:' + release_id
docker_release = release_id
if 'debian' == distrib.id and release.codename != 'experimental':
docker_release = docker_release + '-slim'
res = run_docker('build', '--force-rm', '-t', docker_image,
'--build-arg', 'DIST_ID=' + dist_id,
'--build-arg', 'DIST_RELEASE=' + docker_release,
'--build-arg', 'DIST_CODENAME=' +
str(release.codename),
builder)
if res == 0:
if args.publish:
run_docker('push', docker_image)
if (release.codename is not None
and release_id != release.codename):
res = run_docker('tag', docker_image,
REPO + '' + distrib.id + '_builder:'
+ str(release.codename))
if res == 0 and args.publish:
run_docker('push',
REPO + '' + distrib.id + '_builder:'
+ str(release.codename))
if release.suite is not None:
res = run_docker('tag', docker_image,
REPO + '' + distrib.id + '_builder:'
+ release.suite)
if res == 0 and args.publish:
run_docker('push',
REPO + '' + distrib.id + '_builder:'
+ release.suite)
if (release.supported() and
all([r <= release
for r in distrib.releases(supported=True)])):
res = run_docker('tag', docker_image,
REPO + distrib.id + '_builder:latest')
if res == 0 and args.publish:
run_docker('push',
REPO + distrib.id + '_builder:latest')
print("\n\n \033[32m===> DONE buidling " +
docker_image + "\033[39m")
else:
print("\n\n \033[33m===> SKIPPED buidling " +
docker_image + "\033[39m")
if __name__ == '__main__':
main()