Commit | Line | Data |
---|---|---|
11d1fd9c | 1 | #!/usr/bin/python3 |
888abe0b JR |
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 | ||
888abe0b | 17 | import argparse |
888abe0b | 18 | import gzip |
1e206006 | 19 | import os |
888abe0b | 20 | import shutil |
1e206006 JR |
21 | import subprocess |
22 | ||
23 | from datetime import datetime | |
888abe0b JR |
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) | |
1e206006 | 30 | os.remove(filename) |
888abe0b JR |
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 | 'cppcheck', | |
44 | 'curl', | |
45 | 'elfutils', | |
46 | 'flex', | |
47 | 'gettext', | |
48 | 'git', | |
49 | 'htop', | |
50 | 'jq', | |
51 | 'libdw-dev', | |
52 | 'libelf-dev', | |
53 | 'libffi-dev', | |
54 | 'libglib2.0-dev', | |
55 | 'libmount-dev', | |
56 | 'libnuma-dev', | |
57 | 'libpfm4-dev', | |
58 | 'libpopt-dev', | |
59 | 'libtap-harness-archive-perl', | |
60 | 'libtool', | |
61 | 'libxml2', | |
62 | 'libxml2-dev', | |
63 | 'psmisc', | |
64 | 'python-virtualenv', | |
65 | 'python3', | |
66 | 'python3-setuptools', | |
67 | 'python3-dev', | |
68 | 'python3-numpy', | |
69 | 'python3-pandas', | |
70 | 'python3-pip', | |
71 | 'python3-sphinx', | |
72 | 'stress', | |
73 | 'swig', | |
74 | 'texinfo', | |
75 | 'tree', | |
76 | 'uuid-dev', | |
77 | 'vim', | |
78 | 'wget', | |
79 | ] | |
80 | ||
81 | ||
82 | def main(): | |
83 | parser = argparse.ArgumentParser(description='Generate lava lttng rootfs') | |
84 | parser.add_argument("--arch", default='amd64') | |
85 | parser.add_argument("--distribution", default='bionic') | |
86 | parser.add_argument("--mirror", default='http://archive.ubuntu.com/ubuntu') | |
87 | parser.add_argument( | |
88 | "--component", default='universe,multiverse,main,restricted') | |
89 | args = parser.parse_args() | |
90 | ||
91 | name = "rootfs_{}_{}_{}.tar".format(args.arch, args.distribution, | |
92 | datetime.now().strftime("%Y-%m-%d")) | |
93 | ||
94 | hostname = "linaro-server" | |
95 | user = "linaro/linaro" | |
96 | root_password = "root" | |
97 | print(name) | |
98 | command = [ | |
99 | "sudo", | |
100 | "vmdebootstrap", | |
101 | "--arch={}".format(args.arch), | |
102 | "--distribution={}".format(args.distribution), | |
103 | "--mirror={}".format(args.mirror), | |
104 | "--debootstrapopts=components={}".format(args.component), | |
105 | "--tarball={}".format(name), | |
106 | "--package={}".format(",".join(packages)), | |
107 | "--hostname={}".format(hostname), | |
108 | "--user={}".format(user), | |
109 | "--root-password={}".format(root_password), | |
110 | "--no-kernel", | |
111 | "--enable-dhcp", | |
112 | "--verbose", | |
113 | ] | |
114 | ||
115 | completed_command = subprocess.run(command, check=True) | |
116 | ||
117 | compress(name) | |
118 | ||
119 | ||
120 | if __name__ == "__main__": | |
121 | main() |