| Andrew Jeffery | e454025 | 2018-02-06 10:07:05 +1030 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 | # | 
|  | 3 | # SPDX-License-Identifier: Apache-2.0 | 
|  | 4 | # Copyright (C) 2018 IBM Corp. | 
|  | 5 |  | 
|  | 6 | set -eou pipefail | 
|  | 7 |  | 
|  | 8 | if [ $# -lt 2 ] | 
|  | 9 | then | 
|  | 10 | echo Usage: $0 [user@][host] [tarball] | 
|  | 11 | exit 1 | 
|  | 12 | fi | 
|  | 13 |  | 
|  | 14 | TARGET="$1" | 
|  | 15 | DEBUGTOOLS_PATH="$2" | 
|  | 16 | DEBUGTOOLS="$(basename "${DEBUGTOOLS_PATH}")" | 
|  | 17 |  | 
|  | 18 | scp "${DEBUGTOOLS_PATH}" libncurses.so.5.9 libncursesw.so.5.9 "${TARGET}":/tmp/ | 
|  | 19 | ssh "${TARGET}" <<-EOF | 
|  | 20 | set -eou pipefail | 
|  | 21 |  | 
|  | 22 | set -x | 
|  | 23 |  | 
|  | 24 | on_exit() { | 
|  | 25 | rm -f /tmp/'${DEBUGTOOLS}' | 
|  | 26 | rm -f /tmp/libncurses.so.5.9 /tmp/libncursesw.so.5.9 | 
|  | 27 | } | 
|  | 28 |  | 
|  | 29 | trap on_exit EXIT | 
|  | 30 |  | 
|  | 31 | # Deal with field mode | 
|  | 32 | if ! mountpoint /usr/local | 
|  | 33 | then | 
|  | 34 | systemctl unmask usr-local.mount | 
|  | 35 | systemctl start usr-local.mount | 
|  | 36 | fi | 
|  | 37 |  | 
|  | 38 | # Untar debug tools tarball into /usr/local | 
|  | 39 | pushd /usr/local | 
|  | 40 | tar -xvJf /tmp/"${DEBUGTOOLS}" | 
|  | 41 | popd | 
|  | 42 |  | 
|  | 43 | # Work around bugs preventing perf from working | 
|  | 44 | # Tracking issue: https://github.com/openbmc/openbmc/issues/2880 | 
|  | 45 |  | 
|  | 46 | # Fake expand(1): https://github.com/openbmc/openbmc/issues/2879 | 
|  | 47 | mkdir -p bin | 
|  | 48 | pushd /usr/local/bin | 
|  | 49 | # which expand isn't enough as expand might be a symlink to a busybox not built with CONFIG_EXPAND | 
|  | 50 | if ! echo "" | expand | 
|  | 51 | then | 
|  | 52 | # Remove what is likely a symlink to busybox before trying to overwrite | 
|  | 53 | # file because: | 
|  | 54 | # | 
|  | 55 | # 1) We get errors through trying to write to a read-only filesystem | 
|  | 56 | # 2) If the filesystem were read-write, we would overwrite the busybox binary | 
|  | 57 | [ -f expand ] && rm expand | 
|  | 58 | # Fake out expand(1) in the cheapest way possible | 
|  | 59 | echo -e "#!/bin/sh\ncat" > expand | 
|  | 60 | chmod +x expand | 
|  | 61 | fi | 
|  | 62 |  | 
|  | 63 | # Fix the broken objdump link: https://github.com/openbmc/openbmc/issues/2878 | 
|  | 64 | ln -sf arm-openbmc-linux-gnueabi-objdump objdump | 
|  | 65 | popd | 
|  | 66 |  | 
|  | 67 | # perf-config(1) is terrible and won't write your configuration unless the | 
|  | 68 | # configuration file exists | 
|  | 69 | touch \${HOME}/.perfconfig | 
|  | 70 |  | 
|  | 71 | # Disable writing junk to \${HOME}, otherwise we fill up the RW volume and | 
|  | 72 | # cause systemic failures. | 
|  | 73 | LD_LIBRARY_PATH=/usr/local/lib /usr/local/bin/perf config --user buildid.dir=/dev/null | 
|  | 74 |  | 
|  | 75 | # Deal with latencytop's missing shared object dependency on ncurses, tracked by | 
|  | 76 | # https://github.com/openbmc/openbmc/issues/2430 | 
|  | 77 | pushd /usr/local/lib | 
|  | 78 | if [ -f /tmp/libncurses.so.5.9 -o -f /tmp/libncursesw.so.5.9 ] | 
|  | 79 | then | 
|  | 80 | cp /tmp/libncurses.so.5.9 /tmp/libncursesw.so.5.9 . | 
|  | 81 | ln -sf libncurses.so.5.9 libncurses.so.5 | 
|  | 82 | ln -sf libncurses.so.5.9 libncurses.so | 
|  | 83 | ln -sf libncursesw.so.5.9 libncursesw.so.5 | 
|  | 84 | ln -sf libncursesw.so.5.9 libncursesw.so | 
|  | 85 | fi | 
|  | 86 | popd | 
|  | 87 | EOF | 
|  | 88 |  | 
|  | 89 | echo | 
|  | 90 | echo Make sure to run the following in your shell: | 
|  | 91 | echo | 
|  | 92 | echo export LD_LIBRARY_PATH=/usr/local/lib PYTHONPATH=/usr/local/lib/python2.7 | 
|  | 93 | echo |