Remove cppcheck jobs
[lttng-ci.git] / lava / rootfs / vmdeboostrap / generate-root.py
1 #!/usr/bin/python3
2 # Copyright (C) 2018 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 import argparse
18 import gzip
19 import os
20 import shutil
21 import subprocess
22
23 from datetime import datetime
24
25
26 def compress(filename):
27 with open(filename, 'rb') as f_in:
28 with gzip.open('{}.gz'.format(filename), 'wb') as f_out:
29 shutil.copyfileobj(f_in, f_out)
30 os.remove(filename)
31
32
33 packages = [
34 'autoconf',
35 'automake',
36 'bash-completion',
37 'bison',
38 'bsdtar',
39 'build-essential',
40 'chrpath',
41 'clang',
42 'cloc',
43 'curl',
44 'elfutils',
45 'flex',
46 'gettext',
47 'git',
48 'htop',
49 'jq',
50 'libdw-dev',
51 'libelf-dev',
52 'libffi-dev',
53 'libglib2.0-dev',
54 'libmount-dev',
55 'libnuma-dev',
56 'libpfm4-dev',
57 'libpopt-dev',
58 'libtap-harness-archive-perl',
59 'libtool',
60 'libxml2',
61 'libxml2-dev',
62 'netcat-traditional',
63 'openssh-server',
64 'psmisc',
65 'python-virtualenv',
66 'python3',
67 'python3-dev',
68 'python3-numpy',
69 'python3-pandas',
70 'python3-pip',
71 'python3-setuptools',
72 'python3-sphinx',
73 'stress',
74 'swig',
75 'texinfo',
76 'tree',
77 'uuid-dev',
78 'vim',
79 'wget',
80 ]
81
82
83 def main():
84 parser = argparse.ArgumentParser(description='Generate lava lttng rootfs')
85 parser.add_argument("--arch", default='amd64')
86 # We are using xenial instead of bionic ++ since some syscall test depends
87 # on cat and the libc to use the open syscall. In recent libc openat is
88 # used. See these commit in lttng-tools that helps with the problem:
89 # c8e51d1559c48a12f18053997bbcff0c162691c4
90 # 192bd8fb712659b9204549f29d9a54dc2c57a9e
91 # These are only part of 2.11 and were not backported since they do not
92 # represent a *problem* per se.
93 parser.add_argument("--distribution", default='xenial')
94 parser.add_argument("--mirror", default='http://archive.ubuntu.com/ubuntu')
95 parser.add_argument(
96 "--component", default='universe,multiverse,main,restricted')
97 args = parser.parse_args()
98
99 name = "rootfs_{}_{}_{}.tar".format(args.arch, args.distribution,
100 datetime.now().strftime("%Y-%m-%d"))
101
102 hostname = "linaro-server"
103 user = "linaro/linaro"
104 root_password = "root"
105 print(name)
106 command = [
107 "sudo",
108 "vmdebootstrap",
109 "--arch={}".format(args.arch),
110 "--distribution={}".format(args.distribution),
111 "--mirror={}".format(args.mirror),
112 "--debootstrapopts=components={}".format(args.component),
113 "--tarball={}".format(name),
114 "--package={}".format(",".join(packages)),
115 "--hostname={}".format(hostname),
116 "--user={}".format(user),
117 "--root-password={}".format(root_password),
118 "--no-kernel",
119 "--verbose",
120 ]
121
122 completed_command = subprocess.run(command, check=True)
123
124 compress(name)
125
126
127 if __name__ == "__main__":
128 main()
This page took 0.032958 seconds and 4 git commands to generate.