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