From 3d8dd49eb4f0df2b61bdb0e65b8900e8bb017c11 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sat, 20 Jun 2015 19:37:00 +0100 Subject: [PATCH] Improving script --- functions/fn_deps_detect | 65 +++++++++++++++++++++++++++++++++++----- functions/fn_getopt | 12 ++++---- 2 files changed, 63 insertions(+), 14 deletions(-) diff --git a/functions/fn_deps_detect b/functions/fn_deps_detect index 0a0525336..e95840ff9 100644 --- a/functions/fn_deps_detect +++ b/functions/fn_deps_detect @@ -13,23 +13,72 @@ cd ${executabledir} readelf -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > ${rootdir}/.depdetect_readelf -echo "yum install " > ${rootdir}/.depdetect_centos -echo "apt-get install " > ${rootdir}/.depdetect_ubuntu -echo "apt-get install " > ${rootdir}/.depdetect_debian +echo "yum install " > ${rootdir}/.depdetect_centos_list_uniq +echo "apt-get install " > ${rootdir}/.depdetect_ubuntu_list_uniq +echo "apt-get install " > ${rootdir}/.depdetect_debian_list_uniq while read lib; do sharedlib=${lib} - if [ ${lib} == "libm.so.6" ]||[ ${lib} == "libc.so.6" ]||[ ${lib} == "libpthread.so.0" ]||[ ${lib} == "libdl.so.2" ]||[ ${lib} == "libnsl.so.1" ];then + if [ "${lib}" == "libm.so.6" ]||[ ${lib} == "libc.so.6" ]||[ ${lib} == "libpthread.so.0" ]||[ ${lib} == "libdl.so.2" ]||[ ${lib} == "libnsl.so.1" ];then echo "glibc.i386" >> ${rootdir}/.depdetect_centos_list echo "lib32gcc1" >> ${rootdir}/.depdetect_ubuntu_list echo "lib32gcc1" >> ${rootdir}/.depdetect_debian_list - elif [ ${lib} == "libstdc++.so.6" ];then + elif [ "${lib}" == "libstdc++.so.6" ];then echo "libstdc++.i686" >> ${rootdir}/.depdetect_centos_list echo "libstdc++6:i386" >> ${rootdir}/.depdetect_ubuntu_list echo "libstdc++6:i386" >> ${rootdir}/.depdetect_debian_list + elif [ "${lib}" == "libtier0.so" ];then + # Known shared libs what dont requires dependencies + : else + unknownlib=1 echo "${lib}" >> ${rootdir}/.depdetect_unknown fi done < ${rootdir}/.depdetect_readelf -uniq ${rootdir}/.depdetect_centos_list > ${rootdir}/.depdetect_centos_list_uniq -uniq ${rootdir}/.depdetect_ubuntu_list > ${rootdir}/.depdetect_ubuntu_list_uniq -uniq ${rootdir}/.depdetect_debian_list > ${rootdir}/.depdetect_debian_list_uniq \ No newline at end of file +sort ${rootdir}/.depdetect_centos_list | uniq >> ${rootdir}/.depdetect_centos_list_uniq +sort ${rootdir}/.depdetect_ubuntu_list | uniq >> ${rootdir}/.depdetect_ubuntu_list_uniq +sort ${rootdir}/.depdetect_debian_list | uniq >> ${rootdir}/.depdetect_debian_list_uniq +if [ "${unknownlib}" == "1" ];then + sort ${rootdir}/.depdetect_unknown | uniq >> ${rootdir}/.depdetect_unknown_uniq +fi + +awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_centos_list_uniq > ${rootdir}/.depdetect_centos_line +awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_ubuntu_list_uniq > ${rootdir}/.depdetect_ubuntu_line +awk -vORS=' ' '{ print $1, $2 }' ${rootdir}/.depdetect_debian_list_uniq > ${rootdir}/.depdetect_debian_line + +echo "" +echo "Required Dependencies" +echo "=================================" +echo "${executable}" +echo "" +echo "CentOS" +echo "=================================" +cat ${rootdir}/.depdetect_centos_line +echo "" +echo "" +echo "Ubuntu" +echo "=================================" +cat ${rootdir}/.depdetect_ubuntu_line +echo "" +echo "" +echo "Debian" +echo "=================================" +cat ${rootdir}/.depdetect_debian_line +echo "" +if [ "${unknownlib}" == "1" ];then + echo "Unknown shared Library" + echo "=================================" + cat ${rootdir}/.depdetect_debian_uniq +fi +echo -en "\n" + +rm -f ${rootdir}/.depdetect_centos_line +rm -f ${rootdir}/.depdetect_centos_list +rm -f ${rootdir}/.depdetect_centos_list +rm -f ${rootdir}/.depdetect_centos_list_uniq +rm -f ${rootdir}/.depdetect_debian_list +rm -f ${rootdir}/.depdetect_debian_list_uniq +rm -f ${rootdir}/.depdetect_readelf +rm -f ${rootdir}/.depdetect_ubuntu_list +rm -f ${rootdir}/.depdetect_ubuntu_list_uniq +rm -f ${rootdir}/.depdetect_unknown +rm -f ${rootdir}/.depdetect_unknown_uniq \ No newline at end of file diff --git a/functions/fn_getopt b/functions/fn_getopt index b459469de..1b9b281d4 100644 --- a/functions/fn_getopt +++ b/functions/fn_getopt @@ -42,7 +42,7 @@ case "$getopt" in fn_install;; auto-install) fn_autoinstall;; - depdetect) + depsdetect) fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update|force-update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install}" @@ -75,7 +75,7 @@ case "$getopt" in fn_install;; auto-install) fn_autoinstall;; - depdetect) + depsdetect) fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update|update-functions|monitor|email-test|details|backup|install|auto-install}" @@ -104,7 +104,7 @@ case "$getopt" in fn_console;; debug) fn_debug;; - depdetect) + depsdetect) fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|backup|console|debug}" @@ -139,7 +139,7 @@ case "$getopt" in fn_install;; map-compressor) fn_compress_ut99maps;; - depdetect) + depsdetect) fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}" @@ -187,7 +187,7 @@ case "$getopt" in fn_autoinstall;; map-compressor) fn_compress_unreal2maps;; - depdetect) + depsdetect) fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update|update-functions|validate|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}" @@ -223,7 +223,7 @@ case "$getopt" in fn_install;; map-compressor) fn_compress_unreal2maps;; - depdetect) + depsdetect) fn_deps_detect;; *) echo "Usage: $0 {start|stop|restart|update-functions|monitor|email-test|details|backup|console|debug|install|map-compressor}"