Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 1 | #!/bin/bash -e |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 2 | |
| 3 | script_full_path=$( cd "$(dirname "$0")" ; pwd -P ) |
| 4 | |
| 5 | source $script_full_path/utils/android |
| 6 | |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 7 | usage() { |
| 8 | echo "androdeb" |
| 9 | echo " prepare Prepare the device (when running for the first time)" |
| 10 | echo " shell Enter the androdeb shell environment and get to work!" |
| 11 | echo "" |
| 12 | echo " --tracers Enable tracing packages (perf and trace-cmd)" |
| 13 | echo " --compilers Enable compilers on the FS (gcc and clang)" |
| 14 | echo " --editors Enable vim, emacs and git packages" |
| 15 | echo " --scheduler scheduler testing tools (only rt-app for now)" |
| 16 | echo " --bcc Build and install BCC from source" |
| 17 | echo " --fullbuild Enable all of the above tools" |
| 18 | echo "" |
| 19 | echo " --kernelsrc path-to-kernel-sources (can be used for bcc)" |
| 20 | echo " --tempdir use a specific temporary directory" |
| 21 | echo " --distro Debian distro to base on (default is buster)" |
| 22 | exit 1 |
| 23 | } |
| 24 | |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 25 | # Set default vars |
| 26 | DISTRO=buster |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 27 | PACKAGES="" |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 28 | |
| 29 | # Parse command line parameters |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 30 | PKG=0; if [ $# -lt 1 ]; then usage; fi |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 31 | POSITIONAL=() |
| 32 | while [[ $# -gt 0 ]] |
| 33 | do |
| 34 | key="$1" |
| 35 | |
| 36 | case $key in |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 37 | prepare) |
| 38 | PREP=1; shift || true; ;; |
| 39 | shell) |
| 40 | SHELL=1; shift || true; ;; |
| 41 | --tracers) |
| 42 | TRACERS=1; PKG=1; shift || true; ;; |
| 43 | --compilers) |
| 44 | COMPILERS=1; PKG=1 shift || true; ;; |
| 45 | --editors) |
| 46 | EDITORS=1; PKG=1 shift || true; ;; |
| 47 | --scheduler) |
| 48 | SCHEDULER=1; PKG=1 shift || true; ;; |
| 49 | --fullbuild) |
| 50 | FULLBUILD=1; PKG=1 shift || true; ;; |
| 51 | --bcc) |
| 52 | BCC=1; PKG=1 shift || true; ;; |
| 53 | --kernelsrc) |
| 54 | KERNELSRC="$2"; shift || true; shift || true; ;; |
| 55 | --tempdir) |
| 56 | TMPDIR="$2"; shift || true; shift || true; ;; |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 57 | *) # unknown option |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 58 | echo "Unknown option ($1)"; usage |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 59 | ;; |
| 60 | esac |
| 61 | done |
| 62 | |
| 63 | set -- "${POSITIONAL[@]}" # restore positional parameters |
| 64 | |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 65 | if [[ ! -z ${PREP+x} ]] && [[ $PKG -eq 0 ]]; then; |
| 66 | echo "Need to specifify something to prepare"; usage; fi |
| 67 | |
| 68 | ########################################################## |
| 69 | # PREPARE |
| 70 | ########################################################## |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 71 | # Where do we want to store temporary files |
| 72 | if [[ -z ${TMPDIR+x} ]] || [[ ! -d "${TMPDIR}" ]]; then |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 73 | TMPDIR=`mktemp`; fi |
Joel Fernandes | 6c1ca31 | 2018-03-30 17:13:15 -0700 | [diff] [blame] | 74 | |
Joel Fernandes | 83676b1 | 2018-03-30 23:33:47 -0700 | [diff] [blame^] | 75 | echo $KERNELSRC |
| 76 | echo $BCC |
| 77 | echo $COMPILERS |
| 78 | echo $TRACERS |