]> Creatis software - clitk.git/blob - cluster_tools/gate_make_merge_release.sh
Debug RTStruct conversion with empty struc
[clitk.git] / cluster_tools / gate_make_merge_release.sh
1 #!/bin/bash
2
3 set -u
4 set -e
5
6 function error {
7 echo "ERROR: $1"
8 echo "$(basename $0)"
9 exit 1
10 }
11
12 function get_deps {
13 targetbinary=${1}
14 targetdir=${2}
15 test -d ${targetdir} || error "${targetdir} isn't a directory"
16 ldd ${targetbinary} | while read library; do
17         libfile="$(echo ${library} | awk -F' ' '/=> \// {print $3}')"
18         test $libfile || continue # didn't macht regex
19         test -f "${targetdir}/$(basename ${libfile})" && continue # already exists
20         cp "${libfile}" "${targetdir}"
21         get_deps "${libfile}" "${targetdir}"
22 done
23 }
24
25 function package_target {
26 targetname="${1}"
27 which "${targetname}" > /dev/null || error "cant locate ${targetname}"
28 targetbin="$(which ${targetname})"
29 echo "${targetname} executable is ${targetbin}"
30
31 echo "Getting libraries"
32 targetdir="$(mktemp -d)"
33 get_deps "${targetbin}" "${targetdir}"
34
35 echo "Removing unused libraries"
36 rm -f ${targetdir}/libdl.so*
37 rm -f ${targetdir}/libm.so*
38 rm -f ${targetdir}/libstdc++.so*
39 rm -f ${targetdir}/libgcc_s.so*
40 rm -f ${targetdir}/libpthread.so*
41 rm -f ${targetdir}/libc.so*
42
43 echo "Copying binary"
44 cp "${targetbin}" .
45 for filename in $(find ${targetdir} -name '*.so*'); do cp ${filename} . ; done
46
47 echo "Cleaning up"
48 rm -r "${targetdir}"
49 }
50
51 filenames=("clitkImageArithm" "clitkMergeRootFiles" "clitkMergeAsciiDoseActor" "clitkImageUncertainty" "mergeStatFile.sh" "gate_power_merge.sh")
52
53 for input in "${filenames[@]}"; do
54         package_target "${input}" || error "error while packaging ${input}"
55 done
56
57 echo "Making release"
58 tar -czvf merge_release.tar.gz ** \
59         || usage "can't create release zip"
60
61
62