Skip to content

Commit

Permalink
script/sepia_bt.sh: no need to pass version and sha1 anymore
Browse files Browse the repository at this point in the history
* try to figure out the working directory from the core dump's path
* add -C directory option, so user is able to specify the directory
  for the downloaded packages, and extracted files.

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Feb 13, 2017
1 parent 05f1a19 commit b2aeebe
Showing 1 changed file with 61 additions and 32 deletions.
93 changes: 61 additions & 32 deletions src/script/sepia_bt.sh
Expand Up @@ -6,28 +6,78 @@ function die() {
}

function usage() {
echo "bt: $0 -j job_name -c core_path -v version -d distro -s sha1"
echo "bt: $0 -c core_path [-d distro] [-C directory]"
exit 1
}

while getopts "j:c:v:d:s:" opt
do
case $opt in
j) run=$(dirname $OPTARG);
job=$(basename $OPTARG);;
c) core_path=$OPTARG;;
v) release=$OPTARG;;
s) sha1=$OPTARG;;
d) distro=$OPTARG;;
C) wd=$OPTARG;;
d) codename=$OPTARG;;
*) usage;;
esac
done

if [ -z $run ] || [ -z $core_path ] || [ -z $release ] || [ -z $distro ] || [ -z $sha1 ]; then
if [ -z $core_path ]; then
usage
fi

prog=`file $core_path | grep -oP "from '\K[^']+"`
sha1=$(strings $core_path | gawk 'BEGIN{ FS = "=" } /^CEPH_REF/{print $2}')

if [ -z $distro ]; then
machine=${core_path%/coredump/*}
machine=$(basename $machine)
teuthology_log=${core_path%/remote/*}/teuthology.log
if [ ! -r ${teuthology_log} ]; then
die "missing distro, and unable to read it from ${teuthology_log}"
fi
ld=$(grep -m1 -A1 "${machine}:Running.*linux_distribution" ${teuthology_log} | tail -n1 | grep -oP "\(\K[^\)]+")
distro=$(echo $ld | gawk -F ", " '{print $1}' | sed s/\'//g)
distro=$(echo $distro | tr '[:upper:]' '[:lower:]')
distro_ver=$(echo $ld | gawk -F ", " '{print $2}' | sed s/\'//g)
codename=$(echo $ld | gawk -F ", " '{print $3}' | sed s/\'//g)
else
case $codename in
xenial)
distro=ubuntu
distro_ver=16.04
;;
trusty)
distro=ubuntu
distro_ver=14.04
;;
centos7)
distro=centos
distro_ver=7
;;
*)
die "unknown distro: $distro"
;;
esac
fi

# try to figure out a name for working directory
if [ -z $wd ]; then
run=${core_path%/remote/*}
job_id=${run#/a/}
if [ $job_id != $core_path ]; then
# use the run/job for the working dir
wd=$job_id
fi
fi

if [ -z $wd ]; then
echo "unable to figure out the working directory, using core's basename"
wd=$(basename $core_path)
wd=${wd%.*}
fi

mkdir -p $wd
cd $wd

prog=$(file $core_path | grep -oP "from '\K[^']+")
case $prog in
ceph_test_*)
pkgs="ceph-test librados2"
Expand All @@ -40,6 +90,7 @@ case $prog in
;;
rados)
pkgs="ceph-common librados2 libradosstriper1"
;;
*)
die "unknown prog: $prog"
;;
Expand All @@ -48,26 +99,7 @@ esac
flavor=default
arch=x86_64

case $distro in
xenial)
codename=$distro
distro=ubuntu
distro_ver=16.04
;;
trusty)
codename=$distro
distro=ubuntu
distro_ver=14.04
;;
centos7)
distro=centos
distro_ver=7
;;
*)
die "unknown distro: $distro"
;;
esac

release=$(strings $core_path | grep -m1 -oP '/build/ceph-\K[^/]+')
case $distro in
ubuntu)
pkg_path=pool/main/c/ceph/%s_%s-1${codename}_amd64.deb
Expand All @@ -91,12 +123,9 @@ query_url="https://shaman.ceph.com/api/search?status=ready&project=ceph&flavor=$
repo_url=`curl -L -s "${query_url}" | jq -r '.[0] | .url'`
pkg_url=${repo_url}/${pkg_path}

mkdir -p $run/$job
cd $run/$job

for pkg in ${pkgs}; do
url=`printf $pkg_url $pkg $release`
wget $url
curl -O --insecure -L -C - $url
fname=`basename $url`
case $fname in
*.deb)
Expand Down

0 comments on commit b2aeebe

Please sign in to comment.