| 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 subprocess |
| 18 | import argparse |
| 19 | from datetime import datetime |
| 20 | import gzip |
| 21 | import shutil |
| 22 | |
| 23 | |
| 24 | def compress(filename): |
| 25 | with open(filename, 'rb') as f_in: |
| 26 | with gzip.open('{}.gz'.format(filename), 'wb') as f_out: |
| 27 | shutil.copyfileobj(f_in, f_out) |
| 28 | |
| 29 | |
| 30 | packages = [ |
| 31 | 'autoconf', |
| 32 | 'automake', |
| 33 | 'bash-completion', |
| 34 | 'bison', |
| 35 | 'bsdtar', |
| 36 | 'build-essential', |
| 37 | 'chrpath', |
| 38 | 'clang', |
| 39 | 'cloc', |
| 40 | 'cppcheck', |
| 41 | 'curl', |
| 42 | 'elfutils', |
| 43 | 'flex', |
| 44 | 'gettext', |
| 45 | 'git', |
| 46 | 'htop', |
| 47 | 'jq', |
| 48 | 'libdw-dev', |
| 49 | 'libelf-dev', |
| 50 | 'libffi-dev', |
| 51 | 'libglib2.0-dev', |
| 52 | 'libmount-dev', |
| 53 | 'libnuma-dev', |
| 54 | 'libpfm4-dev', |
| 55 | 'libpopt-dev', |
| 56 | 'libtap-harness-archive-perl', |
| 57 | 'libtool', |
| 58 | 'libxml2', |
| 59 | 'libxml2-dev', |
| 60 | 'psmisc', |
| 61 | 'python-virtualenv', |
| 62 | 'python3', |
| 63 | 'python3-setuptools', |
| 64 | 'python3-dev', |
| 65 | 'python3-numpy', |
| 66 | 'python3-pandas', |
| 67 | 'python3-pip', |
| 68 | 'python3-sphinx', |
| 69 | 'stress', |
| 70 | 'swig', |
| 71 | 'texinfo', |
| 72 | 'tree', |
| 73 | 'uuid-dev', |
| 74 | 'vim', |
| 75 | 'wget', |
| 76 | ] |
| 77 | |
| 78 | |
| 79 | def main(): |
| 80 | parser = argparse.ArgumentParser(description='Generate lava lttng rootfs') |
| 81 | parser.add_argument("--arch", default='amd64') |
| 82 | parser.add_argument("--distribution", default='bionic') |
| 83 | parser.add_argument("--mirror", default='http://archive.ubuntu.com/ubuntu') |
| 84 | parser.add_argument( |
| 85 | "--component", default='universe,multiverse,main,restricted') |
| 86 | args = parser.parse_args() |
| 87 | |
| 88 | name = "rootfs_{}_{}_{}.tar".format(args.arch, args.distribution, |
| 89 | datetime.now().strftime("%Y-%m-%d")) |
| 90 | |
| 91 | hostname = "linaro-server" |
| 92 | user = "linaro/linaro" |
| 93 | root_password = "root" |
| 94 | print(name) |
| 95 | command = [ |
| 96 | "sudo", |
| 97 | "vmdebootstrap", |
| 98 | "--arch={}".format(args.arch), |
| 99 | "--distribution={}".format(args.distribution), |
| 100 | "--mirror={}".format(args.mirror), |
| 101 | "--debootstrapopts=components={}".format(args.component), |
| 102 | "--tarball={}".format(name), |
| 103 | "--package={}".format(",".join(packages)), |
| 104 | "--hostname={}".format(hostname), |
| 105 | "--user={}".format(user), |
| 106 | "--root-password={}".format(root_password), |
| 107 | "--no-kernel", |
| 108 | "--enable-dhcp", |
| 109 | "--verbose", |
| 110 | ] |
| 111 | |
| 112 | completed_command = subprocess.run(command, check=True) |
| 113 | |
| 114 | compress(name) |
| 115 | |
| 116 | |
| 117 | if __name__ == "__main__": |
| 118 | main() |