]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cdebugpack: add a utility to generate a debug package
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 5 Oct 2010 23:16:18 +0000 (16:16 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 5 Oct 2010 23:26:58 +0000 (16:26 -0700)
src/Makefile.am
src/cdebugpack.in [new file with mode: 0644]

index e20e9ce589bdb02a1f0b93e1bd68d00d7b84f547..715d3e1f6a2c1c9e02ba88305db07539225be648 100644 (file)
@@ -258,14 +258,14 @@ editpaths = sed \
        -e 's|@datadir[@]|$(pkgdatadir)|g' \
        -e 's|@prefix[@]|$(prefix)|g'
 
-init-ceph mkcephfs cclass: init-ceph.in mkcephfs.in cclass.in Makefile
+init-ceph mkcephfs cclass cdebugpack: init-ceph.in mkcephfs.in cclass.in Makefile cdebugpack.in
        rm -f $@ $@.tmp
        $(editpaths) '$(srcdir)/$@.in' >$@.tmp
        chmod +x $@.tmp
        chmod a-w $@.tmp
        mv $@.tmp $@
 
-BUILT_SOURCES += init-ceph mkcephfs cclass
+BUILT_SOURCES += init-ceph mkcephfs cclass cdebugpack
 
 ##
 LDADD =
diff --git a/src/cdebugpack.in b/src/cdebugpack.in
new file mode 100644 (file)
index 0000000..8f99325
--- /dev/null
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+
+
+# if we start up as ./init-ceph, assume everything else is in the
+# current directory too.
+if [ `dirname $0` = "." ] && [ $PWD != "/etc/init.d" ]; then
+    BINDIR=.
+    LIBDIR=.
+    ETCDIR=.
+else
+    BINDIR=@bindir@
+    LIBDIR=@libdir@/ceph
+    # i hate autoconf:
+    if [ "@sysconfdir@" = "/usr/etc" ]; then
+       ETCDIR=/etc/ceph
+    else
+       ETCDIR=@sysconfdir@/ceph
+    fi
+fi
+
+BINDBGDIR="/usr/lib/debug/usr/bin"
+
+usage_exit() {
+    echo "usage: $0 [-c ceph.conf] <filename>"
+    exit
+}
+
+
+. $LIBDIR/ceph_common.sh
+
+dest_tar=""
+
+while [ $# -ge 1 ]; do
+case $1 in
+    --conf | -c)
+           [ -z "$2" ] && usage_exit
+           shift
+           conf=$1
+           ;;
+    *)
+           if [ "$dest_tar" != "" ]; then
+               echo unrecognized option \'$1\'
+               usage_exit
+           fi
+           dest_tar=$1
+           ;;
+esac
+shift
+done
+
+[ "$dest_tar" == "" ] && usage_exit
+
+# get absolute path for dest_tar
+[ "${dest_tar::1}" != "/" ] && dest_tar="`pwd`/$dest_tar"
+
+bins="cmon cmds cosd"
+core_paths="/ $BINDIR $BINDBGDIR"
+[ "$conf" == "" ] && conf=$ETCDIR/ceph.conf
+log_path=`$CCONF -c $conf "log dir"`
+
+[ -z "$conf" ] && usage_exit
+
+
+tmp_path=`mktemp -d /tmp/cdebugpack.XXXXXXXXXX`
+tmp_path_bin=$tmp_path/bin
+tmp_path_bin_dbg=$tmp_path/bin.dbg
+tmp_path_log=$tmp_path/out
+tmp_path_core=$tmp_path/core
+
+echo tmp_path=$tmp_path
+
+mkdir -p $tmp_path_bin
+mkdir -p $tmp_path_bin_dbg
+mkdir -p $tmp_path_log
+mkdir -p $tmp_path_core
+
+
+#copy the binaries
+
+for name in $bins; do
+       [ -e $BINDIR/$name ] && cp $BINDIR/$name $tmp_path_bin
+       [ -e $BINDBGDIR/$name ] && cp $BINDBGDIR/$name $tmp_path_bin_dbg
+done
+
+
+# copy the logs
+cp -rp $log_path/* $tmp_path_log
+
+# copy cores (if exist)
+
+for path in $core_paths; do
+  files="`find $path -maxdepth 1 -name 'core*'`"
+  if [ "$files" != "" ]; then
+    for core_file in `ls $path/core*`; do
+      tmp_core=`mktemp $tmp_path_core/core.XXXX`
+      cp $core_file $tmp_core
+    done
+  fi
+done
+
+
+# now create a tarball
+
+cd $tmp_path
+tar cvfz $dest_tar -C $tmp_path *
+
+rm -fR $tmp_path
+