From 888abe0b8ea64c9c0d6cc38c321374352a4bf771 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 29 Nov 2018 16:12:53 -0500 Subject: [PATCH] LAVA: update rootfs generation script Use python. Remove dependency on linaro custom overlays. Use vanilla vmdeboostrap. Signed-off-by: Jonathan Rajotte --- lava/rootfs/vmdeboostrap/README.md | 16 --- lava/rootfs/vmdeboostrap/generate-root.py | 118 ++++++++++++++++++++ lava/rootfs/vmdeboostrap/lava-vmdebootstrap | 27 ----- lava/rootfs/vmdeboostrap/lttng-rootfs.sh | 45 -------- 4 files changed, 118 insertions(+), 88 deletions(-) delete mode 100644 lava/rootfs/vmdeboostrap/README.md create mode 100755 lava/rootfs/vmdeboostrap/generate-root.py delete mode 100755 lava/rootfs/vmdeboostrap/lava-vmdebootstrap delete mode 100755 lava/rootfs/vmdeboostrap/lttng-rootfs.sh diff --git a/lava/rootfs/vmdeboostrap/README.md b/lava/rootfs/vmdeboostrap/README.md deleted file mode 100644 index 04fc453..0000000 --- a/lava/rootfs/vmdeboostrap/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# How to - -For Ubuntu trusty amd64 -$ ARCH=amd64 DISTRIBUTION=trusty ./lttng-rootfs.sh - -For Ubuntu trusty armhf -$ ARCH=armhf DISTRIBUTION=trusty MIRROR=http://ports.ubuntu.com ./lttng-rootfs.sh --foreign=/usr/bin/qemu-arm-static - -Can be used for debian rootfs - -# Requirement - -* vmdeboostrap v1.3 - git://git.liw.fi/vmdebootstrap - Looks like v1.4 fail on dhcp configuration. -* cliapp - git://git.liw.fi/cliapp - diff --git a/lava/rootfs/vmdeboostrap/generate-root.py b/lava/rootfs/vmdeboostrap/generate-root.py new file mode 100755 index 0000000..fbc7b84 --- /dev/null +++ b/lava/rootfs/vmdeboostrap/generate-root.py @@ -0,0 +1,118 @@ +#!/usr/bin/python +# Copyright (C) 2018 - Jonathan Rajotte-Julien +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import subprocess +import argparse +from datetime import datetime +import gzip +import shutil + + +def compress(filename): + with open(filename, 'rb') as f_in: + with gzip.open('{}.gz'.format(filename), 'wb') as f_out: + shutil.copyfileobj(f_in, f_out) + + +packages = [ + 'autoconf', + 'automake', + 'bash-completion', + 'bison', + 'bsdtar', + 'build-essential', + 'chrpath', + 'clang', + 'cloc', + 'cppcheck', + 'curl', + 'elfutils', + 'flex', + 'gettext', + 'git', + 'htop', + 'jq', + 'libdw-dev', + 'libelf-dev', + 'libffi-dev', + 'libglib2.0-dev', + 'libmount-dev', + 'libnuma-dev', + 'libpfm4-dev', + 'libpopt-dev', + 'libtap-harness-archive-perl', + 'libtool', + 'libxml2', + 'libxml2-dev', + 'psmisc', + 'python-virtualenv', + 'python3', + 'python3-setuptools', + 'python3-dev', + 'python3-numpy', + 'python3-pandas', + 'python3-pip', + 'python3-sphinx', + 'stress', + 'swig', + 'texinfo', + 'tree', + 'uuid-dev', + 'vim', + 'wget', +] + + +def main(): + parser = argparse.ArgumentParser(description='Generate lava lttng rootfs') + parser.add_argument("--arch", default='amd64') + parser.add_argument("--distribution", default='bionic') + parser.add_argument("--mirror", default='http://archive.ubuntu.com/ubuntu') + parser.add_argument( + "--component", default='universe,multiverse,main,restricted') + args = parser.parse_args() + + name = "rootfs_{}_{}_{}.tar".format(args.arch, args.distribution, + datetime.now().strftime("%Y-%m-%d")) + + hostname = "linaro-server" + user = "linaro/linaro" + root_password = "root" + print(name) + command = [ + "sudo", + "vmdebootstrap", + "--arch={}".format(args.arch), + "--distribution={}".format(args.distribution), + "--mirror={}".format(args.mirror), + "--debootstrapopts=components={}".format(args.component), + "--tarball={}".format(name), + "--package={}".format(",".join(packages)), + "--hostname={}".format(hostname), + "--user={}".format(user), + "--root-password={}".format(root_password), + "--no-kernel", + "--enable-dhcp", + "--verbose", + ] + + completed_command = subprocess.run(command, check=True) + + compress(name) + + +if __name__ == "__main__": + main() diff --git a/lava/rootfs/vmdeboostrap/lava-vmdebootstrap b/lava/rootfs/vmdeboostrap/lava-vmdebootstrap deleted file mode 100755 index 76c746d..0000000 --- a/lava/rootfs/vmdeboostrap/lava-vmdebootstrap +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -set -e - -# temporary: download linaro-overlay packages, which provide -# auto-serial-console. Plans for the future include providing -# auto-serial-console in the Debian archive so we don't need this. -PREFIX=https://launchpad.net/~linaro-maintainers/+archive/overlay/+files -set -x -while read line; do - if ! echo "$line" | sha1sum --check --quiet - > /dev/null 2>&1; then - package=$(echo "$line" | awk '{ print($2) }') - echo "Downloading $package ..." - wget --quiet $PREFIX/$package - echo "$line" | sha1sum --check --quiet - fi -done < external-packages.sha1sum - -set -x -sudo vmdebootstrap \ - --custom-package='linaro-overlay_1112.2_all.deb' \ - --custom-package='linaro-overlay-minimal_1112.2_all.deb' \ - --enable-dhcp \ - --serial-console --serial-console-command='/bin/auto-serial-console' \ - --root-password='root' \ - --verbose \ - "$@" diff --git a/lava/rootfs/vmdeboostrap/lttng-rootfs.sh b/lava/rootfs/vmdeboostrap/lttng-rootfs.sh deleted file mode 100755 index 87ea305..0000000 --- a/lava/rootfs/vmdeboostrap/lttng-rootfs.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash -xue -# Copyright (C) 2016- Jonathan Rajotte-Julien -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -set -x - -# http://stackoverflow.com/questions/4609668/override-variable-in-bash-script-from-command-line -: ${ARCH:="amd64"} -: ${DISTRIBUTION:="trusty"} -: ${MIRROR:=http://archive.ubuntu.com/ubuntu} -: ${COMPONENTS:=universe,multiverse,main,restricted} - -date=`date +%Y-%m-%d-%H%M` -tarname="rootfs_${ARCH}_${DISTRIBUTION}_${date}.tar" - -./lava-vmdebootstrap \ - --arch=$ARCH \ - --distribution=$DISTRIBUTION \ - --tarball $tarname \ - --mirror=$MIRROR \ - --package=autoconf,automake,bash-completion,bison,bsdtar,build-essential,chrpath,clang,cloc,cppcheck,curl,flex,gettext,git,htop,jq,libglib2.0-dev,libpopt-dev,libtap-harness-archive-perl,libtool,libxml2-dev,python-virtualenv,python3,python3-dev,python3-sphinx,swig2.0,texinfo,tree,uuid-dev,vim,wget \ - --debootstrapopts=components=main,universe,multiverse\ - --hostname='linaro-server' \ - --user=linaro/linaro \ - --no-kernel \ - "$@" - -if [ $? -ne 0 ]; then - echo "An error occurred" - exit -else - gzip --best $tarname -fi -- 2.34.1