]> git.proxmox.com Git - ceph.git/blame - ceph/src/script/sepia_bt.sh
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / script / sepia_bt.sh
CommitLineData
11fdf7f2 1#!/usr/bin/env bash
7c673cae
FG
2
3function die() {
4 echo $@ >&2
5 exit 1
6}
7
8function usage() {
9 echo "bt: $0 -c core_path [-d distro] [-C directory] [-v]"
10 exit 1
11}
12
13function log() {
14 if [ -n "$verbose" ]; then
15 echo $*
16 fi
17}
18
19function get_machine() {
20 local core_path=$1
21 local machine=${core_path%/coredump/*}
22 echo $(basename $machine)
23}
24
25function get_t_dir() {
26 local core_path=$1
27 echo ${core_path%/remote/*}
28}
29
30while getopts "c:C:d:v" opt
31do
32 case $opt in
33 c) core_path=$OPTARG;;
34 C) wd=$OPTARG;;
35 d) codename=$OPTARG;;
36 v) verbose=1;;
37 *) usage;;
38 esac
39done
40
41if [ -z $core_path ]; then
42 usage
43fi
44
45sha1=$(strings $core_path | gawk 'BEGIN{ FS = "=" } /^CEPH_REF/{print $2}')
46if [ -z $sha1 ]; then
47 teuthology_log=$(get_t_dir $core_path)/teuthology.log
48 sha1=$(grep -m1 -A1 "Running command: sudo ceph --version" ${teuthology_log} | tail -n1 | grep -oP "ceph version [^ ]+ \(\K[^\) ]+")
49fi
50
51if [ -z $distro ]; then
52 machine=$(get_machine $core_path)
53 teuthology_log=$(get_t_dir $core_path)/teuthology.log
54 if [ ! -r ${teuthology_log} ]; then
55 die "missing distro, and unable to read it from ${teuthology_log}"
56 fi
57 ld=$(grep -m1 -A1 "${machine}:Running.*linux_distribution" ${teuthology_log} | tail -n1 | grep -oP "\(\K[^\)]+")
58 distro=$(echo $ld | gawk -F ", " '{print $1}' | sed s/\'//g)
59 distro=$(echo $distro | tr '[:upper:]' '[:lower:]')
60 distro_ver=$(echo $ld | gawk -F ", " '{print $2}' | sed s/\'//g)
61 codename=$(echo $ld | gawk -F ", " '{print $3}' | sed s/\'//g)
62 if [ "$distro" == "centos linux" ]; then
63 # there is chance that it's actually something different,
64 # but we take it as centos7 anyway.
65 distro=centos
66 distro_ver=7
67 fi
68else
69 case $codename in
70 xenial)
71 distro=ubuntu
72 distro_ver=16.04
73 ;;
74 trusty)
75 distro=ubuntu
76 distro_ver=14.04
77 ;;
78 centos7)
79 distro=centos
80 distro_ver=7
81 ;;
82 *)
83 die "unknown distro: $distro"
84 ;;
85 esac
86fi
87
88# try to figure out a name for working directory
89if [ -z $wd ]; then
90 run=${core_path%/remote/*}
91 job_id=${run#/a/}
92 if [ $job_id != $core_path ]; then
93 # use the run/job for the working dir
94 wd=$job_id
95 fi
96fi
97
98if [ -z $wd ]; then
99 wd=$(basename $core_path)
100 wd=${wd%.*}
101 echo "unable to figure out the working directory, using ${wd}"
102fi
103
104log "creating ${wd}"
105mkdir -p $wd
106cd $wd
107
108prog=$(file $core_path | grep -oP "from '\K[^']+" | cut -d' ' -f1)
109case $prog in
110 ceph_test_*)
111 pkgs="ceph-test librados2"
112 ;;
113 ceph-osd|ceph-mon)
114 pkgs=$prog
115 ;;
116 */python*)
117 prog=$(basename $prog)
118 pkgs=librados2
119 ;;
120 rados)
121 pkgs="ceph-common librados2 libradosstriper1"
122 ;;
123 *)
124 die "unknown prog: $prog"
125 ;;
126esac
127
128flavor=default
129arch=x86_64
130
131release=$(strings $core_path | grep -m1 -oP '/build/ceph-\K[^/]+')
132if [ -z $release ]; then
133 teuthology_log=$(get_t_dir $core_path)/teuthology.log
134 release=$(grep -m1 -A1 "Running command: sudo ceph --version" ${teuthology_log} | tail -n1 | grep -oP "ceph version \K[^ ]+")
135fi
136
137case $distro in
138 ubuntu)
139 pkg_path=pool/main/c/ceph/%s_%s-1${codename}_amd64.deb
140 for p in $pkgs; do
141 t="$t $p $p-dbg"
142 done
143 pkgs="$t"
144 ;;
145 centos)
146 pkg_path=${arch}/%s-%s.el7.x86_64.rpm
147 # 11.0.2-1022-g5b25cd3 => 11.0.2-1022.g5b25cd3
148 release=$(echo $release | sed s/-/./2)
149 pkgs="$pkgs ceph-debuginfo"
150 ;;
151 *)
152 die "unknown distro: $distro"
153 ;;
154esac
155
156query_url="https://shaman.ceph.com/api/search?status=ready&project=ceph&flavor=${flavor}&distros=${distro}%2F${distro_ver}%2F${arch}&sha1=${sha1}"
157repo_url=`curl -L -s "${query_url}" | jq -r '.[0] | .url'`
158pkg_url=${repo_url}/${pkg_path}
159log "repo url is ${repo_url}"
160
161for pkg in ${pkgs}; do
162 url=`printf $pkg_url $pkg $release`
163 log "downloading ${url}"
164 curl -O -L -C - --silent --fail --insecure $url
165 fname=`basename $url`
166 case $fname in
167 *.deb)
168 ar p `basename $fname` data.tar.xz | tar xJv;;
169 *.rpm)
170 rpm2cpio < $fname | cpio -id;;
171 *)
172 esac
173done
174
175cat > preclude.gdb <<EOF
176set sysroot .
177set debug-file-directory ./usr/lib/debug
178set solib-search-path ./usr/lib64
179file ./usr/bin/$prog
180core $core_path
181EOF
182gdb -x preclude.gdb