]> Creatis software - clitk.git/commitdiff
First version of gate_make_merge_release (for gatelab)
authorDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Fri, 26 Jul 2013 13:12:27 +0000 (15:12 +0200)
committerDavid Sarrut <david.sarrut@creatis.insa-lyon.fr>
Fri, 26 Jul 2013 13:12:27 +0000 (15:12 +0200)
cluster_tools/gate_make_merge_release.sh [new file with mode: 0755]

diff --git a/cluster_tools/gate_make_merge_release.sh b/cluster_tools/gate_make_merge_release.sh
new file mode 100755 (executable)
index 0000000..e506728
--- /dev/null
@@ -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"
+
+
+