blob: 42c758186923c1120f25d55ec1fb6cdf234c28d5 [file] [log] [blame]
Andrew Jefferye4540252018-02-06 10:07:05 +10301#!/bin/bash
2#
3# SPDX-License-Identifier: Apache-2.0
4# Copyright (C) 2018 IBM Corp.
5
6set -eou pipefail
7
8if [ $# -lt 2 ]
9then
10 echo Usage: $0 [user@][host] [tarball]
11 exit 1
12fi
13
14TARGET="$1"
15DEBUGTOOLS_PATH="$2"
16DEBUGTOOLS="$(basename "${DEBUGTOOLS_PATH}")"
17
18scp "${DEBUGTOOLS_PATH}" libncurses.so.5.9 libncursesw.so.5.9 "${TARGET}":/tmp/
19ssh "${TARGET}" <<-EOF
20set -eou pipefail
21
22set -x
23
24on_exit() {
25 rm -f /tmp/'${DEBUGTOOLS}'
26 rm -f /tmp/libncurses.so.5.9 /tmp/libncursesw.so.5.9
27}
28
29trap on_exit EXIT
30
31# Deal with field mode
32if ! mountpoint /usr/local
33then
34 systemctl unmask usr-local.mount
35 systemctl start usr-local.mount
36fi
37
38# Untar debug tools tarball into /usr/local
39pushd /usr/local
40tar -xvJf /tmp/"${DEBUGTOOLS}"
41popd
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
47mkdir -p bin
48pushd /usr/local/bin
49# which expand isn't enough as expand might be a symlink to a busybox not built with CONFIG_EXPAND
50if ! echo "" | expand
51then
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
61fi
62
63# Fix the broken objdump link: https://github.com/openbmc/openbmc/issues/2878
64ln -sf arm-openbmc-linux-gnueabi-objdump objdump
65popd
66
67# perf-config(1) is terrible and won't write your configuration unless the
68# configuration file exists
69touch \${HOME}/.perfconfig
70
71# Disable writing junk to \${HOME}, otherwise we fill up the RW volume and
72# cause systemic failures.
73LD_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
77pushd /usr/local/lib
78if [ -f /tmp/libncurses.so.5.9 -o -f /tmp/libncursesw.so.5.9 ]
79then
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
85fi
86popd
87EOF
88
89echo
90echo Make sure to run the following in your shell:
91echo
92echo export LD_LIBRARY_PATH=/usr/local/lib PYTHONPATH=/usr/local/lib/python2.7
93echo