#!/bin/sh set -eu TOOL=$(basename "$0") HELP=$(cat <"${COREFILE}" if [ "${CMDNAME}" != 'tarantool' ]; then [ -t 1 ] && cat </dev/null; then [ -t 1 ] && cat </dev/null | \ grep -q 'tarantool_version in section .text' then # XXX: This is a very ugly hack to implement 'unless' # operator in bash for a long pipeline as a conditional. : else [ -t 1 ] && cat </dev/null || echo hostname) # Proceed with collecting and packing artefacts. TMPDIR=$(mktemp -d -p "${COREDIR}") TARLIST=${TMPDIR}/tarlist VERSION=${TMPDIR}/version ARCHIVENAME=${COREDIR}/tarantool-core-${PID:-N}-$(date +%Y%m%d%H%M -d @"${TIME}")-${HOSTNAME%%.*}.tar.gz # Dump the version to checkout the right commit later. ${BINARY} --version >"${VERSION}" # Collect the most important artefacts. { echo "${VERSION}" echo "${BINARY}" echo "${COREFILE}" } >>"${TARLIST}" SEPARATOR1="Shared Object Library" SEPARATOR2="Shared library is missing debugging information" # XXX: This is kinda "postmortem ldd": the command below dumps the # full list of the shared libraries the binary is linked against # or those loaded via dlopen at the platform runtime. # This is black voodoo magic. Do not touch. You are warned. if gdb -batch -n "${BINARY}" -c "${COREFILE}" -ex 'info shared' | \ sed -n "/${SEPARATOR1}/,/${SEPARATOR2}/p;/${SEPARATOR2}/q" | \ awk '{ print $NF }' | grep '^/' >>"${TARLIST}" then # XXX: This is a very ugly hack to implement 'unless' # operator in bash for a long pipeline as a conditional. : else [ -t 1 ] && cat < FINALIZE # Cleanup temporary files. [ -f "${TARLIST}" ] && rm -f "${TARLIST}" [ -f "${VERSION}" ] && rm -f "${VERSION}" [ -d "${TMPDIR}" ] && rmdir "${TMPDIR}"