From 6873859d071b5bcdb650bfd42a0ee5cde6e93f09 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Fri, 26 Jul 2013 15:12:27 +0200 Subject: [PATCH] First version of gate_make_merge_release (for gatelab) --- cluster_tools/gate_make_merge_release.sh | 62 ++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 cluster_tools/gate_make_merge_release.sh diff --git a/cluster_tools/gate_make_merge_release.sh b/cluster_tools/gate_make_merge_release.sh new file mode 100755 index 0000000..e506728 --- /dev/null +++ b/cluster_tools/gate_make_merge_release.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +set -u +set -e + +function error { +echo "ERROR: $1" +echo "$(basename $0)" +exit 1 +} + +function get_deps { +targetbinary=${1} +targetdir=${2} +test -d ${targetdir} || error "${targetdir} isn't a directory" +ldd ${targetbinary} | while read library; do + libfile="$(echo ${library} | awk -F' ' '/=> \// {print $3}')" + test $libfile || continue # didn't macht regex + test -f "${targetdir}/$(basename ${libfile})" && continue # already exists + cp "${libfile}" "${targetdir}" + get_deps "${libfile}" "${targetdir}" +done +} + +function package_target { +targetname="${1}" +which "${targetname}" > /dev/null || error "cant locate ${targetname}" +targetbin="$(which ${targetname})" +echo "${targetname} executable is ${targetbin}" + +echo "Getting libraries" +targetdir="$(mktemp -d)" +get_deps "${targetbin}" "${targetdir}" + +echo "Removing unused libraries" +rm -f ${targetdir}/libdl.so* +rm -f ${targetdir}/libm.so* +rm -f ${targetdir}/libstdc++.so* +rm -f ${targetdir}/libgcc_s.so* +rm -f ${targetdir}/libpthread.so* +rm -f ${targetdir}/libc.so* + +echo "Copying binary" +cp "${targetbin}" . +for filename in $(find ${targetdir} -name '*.so*'); do cp ${filename} . ; done + +echo "Cleaning up" +rm -r "${targetdir}" +} + +filenames=("clitkImageArithm" "clitkMergeRootFiles" "clitkMergeAsciiDoseActor" "clitkImageUncertainty" "mergeStatFile.sh" "gate_power_merge.sh") + +for input in "${filenames[@]}"; do + package_target "${input}" || error "error while packaging ${input}" +done + +echo "Making release" +tar -czvf merge_release.tar.gz ** \ + || usage "can't create release zip" + + + -- 2.47.1