diff options
| author | Dongliang Mu <mudongliangabcd@gmail.com> | 2019-03-09 16:08:32 -0500 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-03-12 18:33:29 +0100 |
| commit | 2881fc25a8b874becd6b5c31668ebaeb7c6e9646 (patch) | |
| tree | b0e51e6bcb6233973ae051ded3fb0c4a737ead62 /tools/create-image.sh | |
| parent | a71bfb62b4fe7d9d02dd09752d8c52a21ccc1209 (diff) | |
tools/create-image.sh: fix two issues
allow user to provide ADD_PACKAGE and double check if KERNEL is set when perf is enabled
Diffstat (limited to 'tools/create-image.sh')
| -rwxr-xr-x | tools/create-image.sh | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tools/create-image.sh b/tools/create-image.sh index 77679615d..19c2019e3 100755 --- a/tools/create-image.sh +++ b/tools/create-image.sh @@ -8,13 +8,19 @@ set -eux # Create a minimal Debian distribution in a directory. DIR=chroot +PREINSTALL_PKGS=openssh-server,curl,tar,gcc,libc6-dev,time,strace,sudo,less,psmisc,selinux-utils,policycoreutils,checkpolicy,selinux-policy-default + +# If ADD_PACKAGE is not defined as an external environment variable, use our default packages +if [ -z ${ADD_PACKAGE+x} ]; then + ADD_PACKAGE="make,sysbench,git,vim,tmux,usbutils" +fi # Variables affected by options RELEASE=stretch FEATURE=minimal -ADD_PACKAGE="" PERF=false +# Display help function display_help() { echo "Usage: $0 [option...] " >&2 echo @@ -57,13 +63,20 @@ while true; do esac done +# Double check KERNEL when PERF is enabled +if [ $PERF = "true" ] && [ -z ${KERNEL+x} ]; then + echo "Please set KERNEL environment variable when PERF is enabled" + exit 1 +fi + +# If full feature is chosen, install more packages if [ $FEATURE = "full" ]; then - ADD_PACKAGE=",make,sysbench,git,vim,tmux,usbutils" + PREINSTALL_PKGS=$PREINSTALL_PKGS","$ADD_PACKAGE fi sudo rm -rf $DIR mkdir -p $DIR -sudo debootstrap --include=openssh-server,curl,tar,gcc,libc6-dev,time,strace,sudo,less,psmisc,selinux-utils,policycoreutils,checkpolicy,selinux-policy-default"$ADD_PACKAGE" $RELEASE $DIR +sudo debootstrap --include=$PREINSTALL_PKGS $RELEASE $DIR # Set some defaults and enable promtless ssh to the machine for root. sudo sed -i '/^root/ { s/:x:/::/ }' $DIR/etc/passwd @@ -90,7 +103,8 @@ ssh-keygen -f $RELEASE.id_rsa -t rsa -N '' sudo mkdir -p $DIR/root/.ssh/ cat $RELEASE.id_rsa.pub | sudo tee $DIR/root/.ssh/authorized_keys -if [ "$PERF" = true ]; then +# Add perf support +if [ $PERF = "true" ]; then cp -r $KERNEL $DIR/tmp/ sudo chroot $DIR /bin/bash -c "apt-get update; apt-get install -y flex bison python-dev libelf-dev libunwind8-dev libaudit-dev libslang2-dev libperl-dev binutils-dev liblzma-dev libnuma-dev" sudo chroot $DIR /bin/bash -c "cd /tmp/linux/tools/perf/; make" |
