summaryrefslogtreecommitdiffstats
path: root/contrib/lgtm_container.py
blob: fbbb349bd8119fc3fa2d233fcdc531b35c1924a1 (plain)
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
#!/usr/bin/python3
"""Helper script to test LGTM config

$ contrib/lgtm_container.py > Dockerfile
$ docker build -t lgtm .
"""
import os
import yaml

LGTM_YML = os.path.join(os.path.dirname(__file__), '..', '.lgtm.yml')


def main():
    with open(LGTM_YML) as f:
        cfg = yaml.safe_load(f)

    python = cfg['extraction']['python']

    print("""\
    FROM ubuntu:bionic
    RUN apt-get update && \
        apt-get install -y {dpkg} python3-venv && \
        apt-get clean
    RUN python3 -m venv /venv
    RUN /venv/bin/pip install wheel
    RUN /venv/bin/pip install {pypkg}
    ADD . /freeipa
    RUN cd /freeipa && ./autogen.sh --with-ipaplatform=debian
    """.format(
        dpkg=' '.join(python['prepare']['packages']),
        pypkg=' '.join(python['python_setup']['requirements'])
    ))


if __name__ == '__main__':
    main()