run make cleanup-style

This commit is contained in:
Tony Theodore 2017-10-10 16:22:37 +11:00
parent 3b69d42716
commit e8fdb8f0f7
10 changed files with 413 additions and 413 deletions

View File

@ -6,11 +6,11 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
ddjvu_context_t *djvu_test; ddjvu_context_t *djvu_test;
(void)argc; (void)argc;
djvu_test = ddjvu_context_create(argv[0]); djvu_test = ddjvu_context_create(argv[0]);
ddjvu_context_release(djvu_test); ddjvu_context_release(djvu_test);
return 0; return 0;
} }

View File

@ -26,20 +26,20 @@ void *minst;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int code; int code;
(void)argc; (void)argc;
(void)argv; (void)argv;
code = gsapi_new_instance(&minst, 0); code = gsapi_new_instance(&minst, 0);
if (code < 0) if (code < 0)
return 1; return 1;
code = gsapi_exit(minst); code = gsapi_exit(minst);
if (code < 0) if (code < 0)
return 1; return 1;
gsapi_delete_instance(minst); gsapi_delete_instance(minst);
return 0; return 0;
} }

View File

@ -8,99 +8,99 @@
#include <hamlib/riglist.h> #include <hamlib/riglist.h>
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
RIG *my_rig; RIG *my_rig;
char *rig_file, *info_buf, *mm; char *rig_file, *info_buf, *mm;
freq_t freq; freq_t freq;
value_t rawstrength, power, strength; value_t rawstrength, power, strength;
float s_meter, rig_raw2val(); float s_meter, rig_raw2val();
int status, retcode, isz; int status, retcode, isz;
unsigned int mwpower; unsigned int mwpower;
rmode_t mode; rmode_t mode;
pbwidth_t width; pbwidth_t width;
rig_model_t myrig_model; rig_model_t myrig_model;
char portname[64]; char portname[64];
port_t myport; port_t myport;
strncpy(portname, argv[2], 63); strncpy(portname, argv[2], 63);
portname[63] = '\0'; portname[63] = '\0';
if ((strcmp(argv[2], "--help") == 0) || (argc < 2)) { if ((strcmp(argv[2], "--help") == 0) || (argc < 2)) {
printf("use like: ./%s <portname>\n", argv[0]); printf("use like: ./%s <portname>\n", argv[0]);
printf("example: ./%s /dev/ttyS0\n", argv[0]); printf("example: ./%s /dev/ttyS0\n", argv[0]);
return 0; return 0;
} }
/* Try to detect rig */ /* Try to detect rig */
/* may be overridden by backend probe */ /* may be overridden by backend probe */
myport.type.rig = RIG_PORT_SERIAL; myport.type.rig = RIG_PORT_SERIAL;
myport.parm.serial.rate = 9600; myport.parm.serial.rate = 9600;
myport.parm.serial.data_bits = 8; myport.parm.serial.data_bits = 8;
myport.parm.serial.stop_bits = 1; myport.parm.serial.stop_bits = 1;
myport.parm.serial.parity = RIG_PARITY_NONE; myport.parm.serial.parity = RIG_PARITY_NONE;
myport.parm.serial.handshake = RIG_HANDSHAKE_NONE; myport.parm.serial.handshake = RIG_HANDSHAKE_NONE;
strncpy(myport.pathname, portname, FILPATHLEN); strncpy(myport.pathname, portname, FILPATHLEN);
rig_load_all_backends(); rig_load_all_backends();
myrig_model = rig_probe(&myport); myrig_model = rig_probe(&myport);
/* Set verbosity level - errors only */ /* Set verbosity level - errors only */
rig_set_debug(RIG_DEBUG_ERR); rig_set_debug(RIG_DEBUG_ERR);
/* Instantiate a rig - your rig */ /* Instantiate a rig - your rig */
/* my_rig = rig_init(RIG_MODEL_TT565); */ /* my_rig = rig_init(RIG_MODEL_TT565); */
my_rig = rig_init(myrig_model); my_rig = rig_init(myrig_model);
/* Set up serial port, baud rate - serial device + baudrate */ /* Set up serial port, baud rate - serial device + baudrate */
rig_file = "/dev/ttyUSB0"; rig_file = "/dev/ttyUSB0";
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1); strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
my_rig->state.rigport.parm.serial.rate = 57600; my_rig->state.rigport.parm.serial.rate = 57600;
my_rig->state.rigport.parm.serial.rate = 9600; my_rig->state.rigport.parm.serial.rate = 9600;
/* Open my rig */ /* Open my rig */
retcode = rig_open(my_rig); retcode = rig_open(my_rig);
printf("retcode of rig_open = %d \n", retcode); printf("retcode of rig_open = %d \n", retcode);
/* Give me ID info, e.g., firmware version. */ /* Give me ID info, e.g., firmware version. */
info_buf = (char *)rig_get_info(my_rig); info_buf = (char *)rig_get_info(my_rig);
printf("Rig_info: '%s'\n", info_buf); printf("Rig_info: '%s'\n", info_buf);
/* Note: As a general practice, we should check to see if a given /* Note: As a general practice, we should check to see if a given
* function is within the rig's capabilities before calling it, but * function is within the rig's capabilities before calling it, but
* we are simplifying here. Also, we should check each call's returned * we are simplifying here. Also, we should check each call's returned
* status in case of error. (That's an inelegant way to catch an unsupported * status in case of error. (That's an inelegant way to catch an unsupported
* operation.) * operation.)
*/ */
/* Main VFO frequency */ /* Main VFO frequency */
status = rig_get_freq(my_rig, RIG_VFO_CURR, &freq); status = rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
printf("status of rig_get_freq = %d \n", status); printf("status of rig_get_freq = %d \n", status);
printf("VFO freq. = %.1f Hz\n", freq); printf("VFO freq. = %.1f Hz\n", freq);
/* Current mode */ /* Current mode */
status = rig_get_mode(my_rig, RIG_VFO_CURR, &mode, &width); status = rig_get_mode(my_rig, RIG_VFO_CURR, &mode, &width);
printf("status of rig_get_mode = %d \n", status); printf("status of rig_get_mode = %d \n", status);
switch(mode) { switch(mode) {
case RIG_MODE_USB: mm = "USB"; break; case RIG_MODE_USB: mm = "USB"; break;
case RIG_MODE_LSB: mm = "LSB"; break; case RIG_MODE_LSB: mm = "LSB"; break;
case RIG_MODE_CW: mm = "CW"; break; case RIG_MODE_CW: mm = "CW"; break;
case RIG_MODE_CWR: mm = "CWR"; break; case RIG_MODE_CWR: mm = "CWR"; break;
case RIG_MODE_AM: mm = "AM"; break; case RIG_MODE_AM: mm = "AM"; break;
case RIG_MODE_FM: mm = "FM"; break; case RIG_MODE_FM: mm = "FM"; break;
case RIG_MODE_WFM: mm = "WFM"; break; case RIG_MODE_WFM: mm = "WFM"; break;
case RIG_MODE_RTTY:mm = "RTTY"; break; case RIG_MODE_RTTY:mm = "RTTY"; break;
default: mm = "unrecognized"; break; /* there are more possibilities! */ default: mm = "unrecognized"; break; /* there are more possibilities! */
} }
printf("Current mode = 0x%X = %s, width = %d\n", mode, mm, (int) width); printf("Current mode = 0x%X = %s, width = %d\n", mode, mm, (int) width);
/* rig power output */ /* rig power output */
status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &power); status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RFPOWER, &power);
printf("RF Power relative setting = %.3f (0.0 - 1.0)\n", power.f); printf("RF Power relative setting = %.3f (0.0 - 1.0)\n", power.f);
/* Convert power reading to watts */ /* Convert power reading to watts */
status = rig_power2mW(my_rig, &mwpower, power.f, freq, mode); status = rig_power2mW(my_rig, &mwpower, power.f, freq, mode);
printf("RF Power calibrated = %.1f Watts\n", mwpower/1000.); printf("RF Power calibrated = %.1f Watts\n", mwpower/1000.);
/* Raw and calibrated S-meter values */ /* Raw and calibrated S-meter values */
status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RAWSTR, &rawstrength); status = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_RAWSTR, &rawstrength);
printf("Raw receive strength = %d\n", rawstrength.i); printf("Raw receive strength = %d\n", rawstrength.i);
isz = my_rig->caps->str_cal.size; isz = my_rig->caps->str_cal.size;
printf("isz = %d \n", isz); printf("isz = %d \n", isz);
s_meter = rig_raw2val(rawstrength.i, &my_rig->caps->str_cal); s_meter = rig_raw2val(rawstrength.i, &my_rig->caps->str_cal);
printf("S-meter value = %.2f dB relative to S9\n", s_meter); printf("S-meter value = %.2f dB relative to S9\n", s_meter);
/* now try using RIG_LEVEL_STRENGTH itself */ /* now try using RIG_LEVEL_STRENGTH itself */
status = rig_get_strength(my_rig, RIG_VFO_CURR, &strength); status = rig_get_strength(my_rig, RIG_VFO_CURR, &strength);
printf("status of rig_get_strength = %d \n", status); printf("status of rig_get_strength = %d \n", status);
printf("LEVEL_STRENGTH returns %d\n", strength.i); printf("LEVEL_STRENGTH returns %d\n", strength.i);
return 0; return 0;
} }

View File

@ -22,7 +22,7 @@ define $(PKG)_BUILD
cd '$(1)' && \ cd '$(1)' && \
ac_cv_func_malloc_0_nonnull=yes \ ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \ ac_cv_func_realloc_0_nonnull=yes \
./configure $(MXE_CONFIGURE_OPTS) \ ./configure $(MXE_CONFIGURE_OPTS) \
--enable-install-include --enable-install-include
$(MAKE) -C '$(1)' -j '$(JOBS)' $(MAKE) -C '$(1)' -j '$(JOBS)'

View File

@ -6,17 +6,17 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
SpectreDocument *document; SpectreDocument *document;
SpectreRenderContext *rc; SpectreRenderContext *rc;
(void)argc; (void)argc;
(void)argv; (void)argv;
document = spectre_document_new(); document = spectre_document_new();
rc = spectre_render_context_new(); rc = spectre_render_context_new();
spectre_document_free(document); spectre_document_free(document);
spectre_render_context_free(rc); spectre_render_context_free(rc);
return 0; return 0;
} }

View File

@ -8,10 +8,10 @@
int main() int main()
{ {
QWidget w; QWidget w;
qtsparkle::Updater* updater = new qtsparkle::Updater( qtsparkle::Updater* updater = new qtsparkle::Updater(
QUrl("http://www.example.com/sparkle.xml"), &w); QUrl("http://www.example.com/sparkle.xml"), &w);
updater->SetVersion("1.0"); updater->SetVersion("1.0");
return 0; return 0;
} }

View File

@ -8,10 +8,10 @@
int main() int main()
{ {
QWidget w; QWidget w;
qtsparkle::Updater* updater = new qtsparkle::Updater( qtsparkle::Updater* updater = new qtsparkle::Updater(
QUrl("http://www.example.com/sparkle.xml"), &w); QUrl("http://www.example.com/sparkle.xml"), &w);
updater->SetVersion("1.0"); updater->SetVersion("1.0");
return 0; return 0;
} }

View File

@ -6,12 +6,12 @@ It can be invoked on the command line like:
``` ```
/share/mxe/tools/copydlldeps.sh --infile /home/mxeuser/test/i686-w64-mingw32.shared/Application.exe \ /share/mxe/tools/copydlldeps.sh --infile /home/mxeuser/test/i686-w64-mingw32.shared/Application.exe \
--destdir /home/mxeuser/testdlls/ \ --destdir /home/mxeuser/testdlls/ \
--recursivesrcdir /home/mxeuser/mxe/usr/i686-w64-mingw32.shared/ \ --recursivesrcdir /home/mxeuser/mxe/usr/i686-w64-mingw32.shared/ \
--srcdir /home/mxeuser/test/ \ --srcdir /home/mxeuser/test/ \
--copy \ --copy \
--enforcedir /home/mxeuser/mxe/usr/i686-w64-mingw32.shared/qt5/plugins/platforms/ \ --enforcedir /home/mxeuser/mxe/usr/i686-w64-mingw32.shared/qt5/plugins/platforms/ \
--objdump /home/mxeuser/mxe/usr/bin/i686-w64-mingw32.shared-objdump --objdump /home/mxeuser/mxe/usr/bin/i686-w64-mingw32.shared-objdump
``` ```
It got embedded in a build script like: It got embedded in a build script like:
@ -22,26 +22,26 @@ compiler=i686-w64-mingw32.shared
orgDir=/path/to/my/nsis/dll # nsis is then copying all dlls in there to the place where the exe is located orgDir=/path/to/my/nsis/dll # nsis is then copying all dlls in there to the place where the exe is located
if [ ! $( echo $compiler | grep -q "shared" ) ]; then if [ ! $( echo $compiler | grep -q "shared" ) ]; then
echo "\$compiler=$compiler and contains the word 'shared'" | tee -a $CURLOG echo "\$compiler=$compiler and contains the word 'shared'" | tee -a $CURLOG
echo "+-----------------------------------------------+ " | tee -a $CURLOG echo "+-----------------------------------------------+ " | tee -a $CURLOG
echo "| Starting new MXE copydlldeps.sh by LHE DL5RCW | " | tee -a $CURLOG echo "| Starting new MXE copydlldeps.sh by LHE DL5RCW | " | tee -a $CURLOG
echo "+-----------------------------------------------+ " | tee -a $CURLOG echo "+-----------------------------------------------+ " | tee -a $CURLOG
echo "currently working in $( pwd ) " | tee -a $CURLOG echo "currently working in $( pwd ) " | tee -a $CURLOG
executable=$( find . -name "*.exe" | tail -n 1 ) executable=$( find . -name "*.exe" | tail -n 1 )
sharedLibsDir="${orgDir}/nsis/sharedLibs" sharedLibsDir="${orgDir}/nsis/sharedLibs"
echo "populating dir $sharedLibsDir with dll dependencies of $executable" | tee -a $CURLOG echo "populating dir $sharedLibsDir with dll dependencies of $executable" | tee -a $CURLOG
OBJDUMP=objdump OBJDUMP=objdump
if [ -e "$MXEPATH/usr/bin/$compiler-objdump" ]; then if [ -e "$MXEPATH/usr/bin/$compiler-objdump" ]; then
OBJDUMP="$MXEPATH/usr/bin/$compiler-objdump" OBJDUMP="$MXEPATH/usr/bin/$compiler-objdump"
fi fi
$MXEPATH/tools/copydlldeps.sh --infile $executable \ $MXEPATH/tools/copydlldeps.sh --infile $executable \
--destdir "$sharedLibsDir" \ --destdir "$sharedLibsDir" \
--recursivesrcdir "$MXEPATH/usr/$compiler/" \ --recursivesrcdir "$MXEPATH/usr/$compiler/" \
--enforcedir "$MXEPATH/usr/$compiler/qt5/plugins/platforms/" \ --enforcedir "$MXEPATH/usr/$compiler/qt5/plugins/platforms/" \
--copy \ --copy \
--objdump "$OBJDUMP" \ --objdump "$OBJDUMP" \
| tee -a $CURLOG | tee -a $CURLOG
fi fi
``` ```

View File

@ -1,10 +1,10 @@
#!/bin/bash #!/usr/bin/env bash
# #
# print version and license # print version and license
# is hereby part of the code and also displayed to the user # is hereby part of the code and also displayed to the user
version() { version() {
cat <<EOF >&2 cat <<EOF >&2
Welcome to $( basename $0)! Welcome to $( basename $0)!
Authors: Lars Holger Engelhard - DL5RCW (2016) Authors: Lars Holger Engelhard - DL5RCW (2016)
@ -51,7 +51,7 @@ tmp=$( mktemp -d )
# print an help menu # print an help menu
help() { help() {
cat <<EOF >&2 cat <<EOF >&2
Usage: $0 -c -d DEST -s SRC [-f FILE|-F DIR] Usage: $0 -c -d DEST -s SRC [-f FILE|-F DIR]
@ -73,16 +73,16 @@ Operating options:
-d, --destdir Destination directory - a single destination folder -d, --destdir Destination directory - a single destination folder
-f, --infile [ multiCall ] The input executable file or DLL. -f, --infile [ multiCall ] The input executable file or DLL.
-F, --infiles, --indir [ multiCall ] The input directory of executable files and/or DLLs. -F, --infiles, --indir [ multiCall ] The input directory of executable files and/or DLLs.
-s, --srcdir [ multiCall ] The directory with DLLs that can be copied. -s, --srcdir [ multiCall ] The directory with DLLs that can be copied.
-S, --srcdirs [ multiCall ] List of directories with DLLs that can be copied. Put "" around them, e.g. "/dir1 /root/dir2 /root/dir3" -S, --srcdirs [ multiCall ] List of directories with DLLs that can be copied. Put "" around them, e.g. "/dir1 /root/dir2 /root/dir3"
-R, --recursivesrcdir [ multiCall ] Target directory for recursive search of folders containing *dll files -R, --recursivesrcdir [ multiCall ] Target directory for recursive search of folders containing *dll files
-X, --excludepattern [ multiCall ] Exclude any path that contains such pattern, e.g. /(PREFIX)/(TARGET)/apps/ -X, --excludepattern [ multiCall ] Exclude any path that contains such pattern, e.g. /(PREFIX)/(TARGET)/apps/
Optional binary settings: Optional binary settings:
-o, --objdump Specify the path or name of your objdump application -o, --objdump Specify the path or name of your objdump application
-e, --enforcedir [ multiCall ] Enforce executable files and/or DLLs of a specific directory -e, --enforcedir [ multiCall ] Enforce executable files and/or DLLs of a specific directory
It will be entirely copied - flat, non recursive. assumes *.dll and *.exe in the top level directory It will be entirely copied - flat, non recursive. assumes *.dll and *.exe in the top level directory
It will copy those into a directory in DESTDIR! It will copy those into a directory in DESTDIR!
e.g. <path_to_mxe>/mxe/usr/<compiler>/qt5/plugins/platforms/ - for qwindows.dll becomes e.g. <path_to_mxe>/mxe/usr/<compiler>/qt5/plugins/platforms/ - for qwindows.dll becomes
DESTDIR/platforms/ containing qwindows.dll DESTDIR/platforms/ containing qwindows.dll
Other options: Other options:
@ -97,14 +97,14 @@ Authors: Lars Holger Engelhard - DL5RCW
EOF EOF
} }
# terminate the application # terminate the application
# print an error message # print an error message
# and clean the tmp directory # and clean the tmp directory
die() { die() {
echo $1 >&2 echo $1 >&2
rm -rf "$tmp" rm -rf "$tmp"
help help
exit 1 exit 1
} }
# find all directories containing dll files # find all directories containing dll files
@ -112,95 +112,95 @@ die() {
# and findAllSrcDirectories will hunt for dlls in each one recursively # and findAllSrcDirectories will hunt for dlls in each one recursively
# it will return a sorted list and duplicates are removed # it will return a sorted list and duplicates are removed
findAllSrcDirectories(){ findAllSrcDirectories(){
ar_recursiveDirList=${!1} ar_recursiveDirList=${!1}
string="" string=""
for curPath in "${ar_recursiveDirList[@]}"; do for curPath in "${ar_recursiveDirList[@]}"; do
for element in $(find $curPath $excludePattern -iname "*.dll"); do for element in $(find $curPath $excludePattern -iname "*.dll"); do
#ar_list+="$(dirname $element) " #ar_list+="$(dirname $element) "
string+="$(dirname $element) " string+="$(dirname $element) "
done done
done done
string=$(echo "$string" | tr -s ' ' | tr ' ' '\n' | nl | sort -u -k2 | sort -n | cut -f2-) string=$(echo "$string" | tr -s ' ' | tr ' ' '\n' | nl | sort -u -k2 | sort -n | cut -f2-)
echo $string #returns the string echo $string #returns the string
} }
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
key="$1" key="$1"
shift shift
case $key in case $key in
-f|--infile) -f|--infile)
infile+=" $1" infile+=" $1"
shift shift
;; ;;
-F|--indir|--infiles) -F|--indir|--infiles)
indir+=" $1" indir+=" $1"
shift shift
;; ;;
-s|--srcdir) -s|--srcdir)
srcdir+=" $1" srcdir+=" $1"
shift shift
;; ;;
-d|--destdir) -d|--destdir)
destdir="$1" destdir="$1"
shift shift
;; ;;
-S|--srcdirs) -S|--srcdirs)
srcdirs+=" $1" srcdirs+=" $1"
shift shift
;; ;;
-R|--recursivesrcdir) -R|--recursivesrcdir)
recursivesrcdir+=" $1" recursivesrcdir+=" $1"
shift shift
;; ;;
-X|--excludepattern) -X|--excludepattern)
excludepattern+=" $1" excludepattern+=" $1"
shift shift
;; ;;
-o|--objdump) -o|--objdump)
OBJDUMP="$1" OBJDUMP="$1"
shift shift
;; ;;
-e|--enforcedir) -e|--enforcedir)
enforcedir+=" $1" enforcedir+=" $1"
shift shift
;; ;;
-l|-L|--loglevel) -l|-L|--loglevel)
loglevel="$1" loglevel="$1"
shift shift
;; ;;
-p|--print) -p|--print)
opmode="print" opmode="print"
;; ;;
-c|--copy) -c|--copy)
opmode="copy" opmode="copy"
;; ;;
-h|-H|--help) -h|-H|--help)
help help
exit 0 exit 0
;; ;;
-v|-V|--version) -v|-V|--version)
version version
exit 0 exit 0
;; ;;
*) *)
echo "unknown option $key ignored" >&2 echo "unknown option $key ignored" >&2
;; ;;
esac esac
done done
# setting default values if no arguments were given # setting default values if no arguments were given
if ! [ "$loglevel" ]; then if ! [ "$loglevel" ]; then
loglevel=0 loglevel=0
fi fi
if ! [ "$opmode" ]; then if ! [ "$opmode" ]; then
opmode="copy" # used as default in productive opmode="copy" # used as default in productive
#opmode="print" # used as default in development #opmode="print" # used as default in development
fi fi
if ! [ "$destdir" ]; then if ! [ "$destdir" ]; then
die '--destdir is not specified.' die '--destdir is not specified.'
fi fi
if [ -n "$(ls -A $destdir 2>/dev/null)" ]; then if [ -n "$(ls -A $destdir 2>/dev/null)" ]; then
@ -211,41 +211,41 @@ else
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "filelist=$filelist" echo "filelist=$filelist"
echo "opmode=$opmode" echo "opmode=$opmode"
fi fi
excluePattern="" # building an exclude command consisting of patterns. We still contain the first hit of find excluePattern="" # building an exclude command consisting of patterns. We still contain the first hit of find
if [ ! -z "$excludepattern" ]; then if [ ! -z "$excludepattern" ]; then
for curString in $( echo "$excludepattern" | tr -s ' ' | tr ' ' '\n' ); do for curString in $( echo "$excludepattern" | tr -s ' ' | tr ' ' '\n' ); do
excludePattern+=" ! -path *$( echo "$curString" | tr -d ' ' )* " excludePattern+=" ! -path *$( echo "$curString" | tr -d ' ' )* "
done done
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "\$excluePattern: $excludePattern" echo "\$excluePattern: $excludePattern"
fi fi
str_inputFileList="" str_inputFileList=""
if [ "$indir" ]; then if [ "$indir" ]; then
for curPath in $( echo "${indir}" | tr -s ' ' | tr ' ' '\n' ); do for curPath in $( echo "${indir}" | tr -s ' ' | tr ' ' '\n' ); do
if [ `uname -s` == "Darwin" ]; then if [ `uname -s` == "Darwin" ]; then
curList=$( find $curPath -iname *.exe -or -iname *.dll | tr '\n' ' ' ) curList=$( find $curPath -iname *.exe -or -iname *.dll | tr '\n' ' ' )
else curList=$( find $curPath -iregex '.*\(dll\|exe\)' | tr '\n' ' ' ) else curList=$( find $curPath -iregex '.*\(dll\|exe\)' | tr '\n' ' ' )
fi fi
str_inputFileList+=" $curList" str_inputFileList+=" $curList"
done done
fi fi
if [ "$infile" ]; then if [ "$infile" ]; then
for curFile in $( echo "${infile}" | tr -s ' ' | tr ' ' '\n' ); do for curFile in $( echo "${infile}" | tr -s ' ' | tr ' ' '\n' ); do
if [ `uname -s` == "Darwin" ]; then if [ `uname -s` == "Darwin" ]; then
curString=$( find $curPath -iname *.exe -or -iname *.dll | tr '\n' ' ' ) curString=$( find $curPath -iname *.exe -or -iname *.dll | tr '\n' ' ' )
else curString=$( find $curPath -iregex '.*\(dll\|exe\)' | tr '\n' ' ' ) else curString=$( find $curPath -iregex '.*\(dll\|exe\)' | tr '\n' ' ' )
fi fi
str_inputFileList+=" $curString" str_inputFileList+=" $curString"
done done
fi fi
if [ -z "$str_inputFileList" ]; then if [ -z "$str_inputFileList" ]; then
die 'there was no input defined. use --indir and/or --infile in your command' die 'there was no input defined. use --indir and/or --infile in your command'
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "str_inputFileList=$str_inputFileList" echo "str_inputFileList=$str_inputFileList"
@ -254,32 +254,32 @@ fi
str_srcDirList="" str_srcDirList=""
if [ "$srcdir" ]; then if [ "$srcdir" ]; then
str_srcDirList+=" $srcdir" str_srcDirList+=" $srcdir"
fi fi
if [ "$srcdirs" ]; then if [ "$srcdirs" ]; then
str_srcDirList+=" $srcdirs" str_srcDirList+=" $srcdirs"
fi fi
if [ "$recursivesrcdir" ]; then if [ "$recursivesrcdir" ]; then
result="$( findAllSrcDirectories recursivesrcdir )" result="$( findAllSrcDirectories recursivesrcdir )"
str_srcDirList+=" $result" str_srcDirList+=" $result"
fi fi
if [ -z "$str_srcDirList" ]; then if [ -z "$str_srcDirList" ]; then
die 'there was no source directory defined. use --srcdirs or --srcdir or --recursivesrcdir in your command' die 'there was no source directory defined. use --srcdirs or --srcdir or --recursivesrcdir in your command'
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
#echo "infiles: filelist=$filelist" #echo "infiles: filelist=$filelist"
echo "infiles: str_inputFileList=$str_inputFileList" echo "infiles: str_inputFileList=$str_inputFileList"
echo " opmode: $opmode" echo " opmode: $opmode"
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "list for sources: str_srcDirList=${str_srcDirList}" echo "list for sources: str_srcDirList=${str_srcDirList}"
echo "using OBJDUMP=$OBJDUMP in Version $( $OBJDUMP -V)" echo "using OBJDUMP=$OBJDUMP in Version $( $OBJDUMP -V)"
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
## during development, I like to interrupt here to check the above output and skip the rest ## during development, I like to interrupt here to check the above output and skip the rest
echo "starting in 5 seconds" && sleep 5 echo "starting in 5 seconds" && sleep 5
fi fi
# introducing a whitelist of well known DLLs # introducing a whitelist of well known DLLs
@ -287,184 +287,184 @@ str_whiteListDlls="advapi32.dll kernel32.dll msvcrt.dll user32.dll ws2_32.dll gd
# function to append dependencies (recursively) # function to append dependencies (recursively)
append_deps() { append_deps() {
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "\$1=$1 + \$2=$2 " echo "\$1=$1 + \$2=$2 "
sleep 2 sleep 2
fi fi
local bn="$( basename $1 )" local bn="$( basename $1 )"
if [ -e "$tmp/$bn" ]; then if [ -e "$tmp/$bn" ]; then
return 0 return 0
fi fi
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then
path="$1" path="$1"
else else
path="" path=""
for curPath in $( echo "${str_srcDirList}" | tr -s ' ' | tr ' ' '\n' ); do for curPath in $( echo "${str_srcDirList}" | tr -s ' ' | tr ' ' '\n' ); do
counter=0 counter=0
result="" result=""
result=$(find $curPath $excludePattern -iname "$bn" -type f | tail -n 1) result=$(find $curPath $excludePattern -iname "$bn" -type f | tail -n 1)
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "complete find command in append_deps(): # find $curPath $excludePattern -iname $bn -type f | tail -n 1 # " echo "complete find command in append_deps(): # find $curPath $excludePattern -iname $bn -type f | tail -n 1 # "
fi fi
if [ ! -z "$result" ];then if [ ! -z "$result" ];then
path="$result" path="$result"
counter=$(expr $counter + 1) counter=$(expr $counter + 1)
fi fi
if [ $counter == 0 ]; then if [ $counter == 0 ]; then
#echo "ERROR: could not find \$path for dll $bn, \$counter=$counter: searched $curPath" #echo "ERROR: could not find \$path for dll $bn, \$counter=$counter: searched $curPath"
str_test="1" str_test="1"
else else
echo "OKAY: found path for dll $bn = $path, \$counter=$counter: searched $curPath" echo "OKAY: found path for dll $bn = $path, \$counter=$counter: searched $curPath"
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
if [ $counter == 0 ]; then if [ $counter == 0 ]; then
echo "could not find \$path for dll $bn, \$counter=$counter: searched $curPath" echo "could not find \$path for dll $bn, \$counter=$counter: searched $curPath"
else else
echo "found path for dll $bn = $path, \$counter=$counter: searched $curPath" echo "found path for dll $bn = $path, \$counter=$counter: searched $curPath"
fi fi
fi fi
done done
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "path for dll $bn now is $path" echo "path for dll $bn now is $path"
sleep 2 sleep 2
fi fi
fi fi
echo "Processing $1" >&2 echo "Processing $1" >&2
if ! [ -e "$path" ]; then if ! [ -e "$path" ]; then
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "path=$path| and we touch $tmp/$bn -> non existent in our src directories!" echo "path=$path| and we touch $tmp/$bn -> non existent in our src directories!"
sleep 4 sleep 4
fi fi
touch "$tmp/$bn" touch "$tmp/$bn"
return 0 return 0
fi fi
$OBJDUMP -p "$path" | grep 'DLL Name:' | cut -f3 -d' ' > "$tmp/$bn" $OBJDUMP -p "$path" | grep 'DLL Name:' | cut -f3 -d' ' > "$tmp/$bn"
echo "executing: $OBJDUMP -p "$path" | grep 'DLL Name:' | cut -f3 -d' ' > "$tmp/$bn"" echo "executing: $OBJDUMP -p "$path" | grep 'DLL Name:' | cut -f3 -d' ' > "$tmp/$bn""
for dll in $( cat "$tmp/$bn" | tr '\n' ' ' ); do for dll in $( cat "$tmp/$bn" | tr '\n' ' ' ); do
append_deps "$dll" append_deps "$dll"
done done
alldeps=$(printf "$alldeps\n%s" "$(cat $tmp/$bn)" | sort | uniq) alldeps=$(printf "$alldeps\n%s" "$(cat $tmp/$bn)" | sort | uniq)
} }
process_enforced_deps(){ process_enforced_deps(){
enforcedDirectory=$1 enforcedDirectory=$1
if [ ! -d $enforcedDirectory ]; then if [ ! -d $enforcedDirectory ]; then
echo "warning! \$enforcedDirectory=$enforcedDirectory is not valid" echo "warning! \$enforcedDirectory=$enforcedDirectory is not valid"
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
sleep 10 sleep 10
fi fi
fi fi
# first we append the path to enforced dir to our list of source directories # first we append the path to enforced dir to our list of source directories
# if we would do this file recursively, we should loop to find those and append them all to the list # if we would do this file recursively, we should loop to find those and append them all to the list
str_srcDirList+=" $enforcedDirectory" str_srcDirList+=" $enforcedDirectory"
# now we search for the dll and exe files to be included # now we search for the dll and exe files to be included
if [ `uname -s` == "Darwin" ]; then if [ `uname -s` == "Darwin" ]; then
string=$( find $enforcedDirectory -maxdepth 1 -iname *.exe -or -iname *.dll | tr '\n' ' ' ) string=$( find $enforcedDirectory -maxdepth 1 -iname *.exe -or -iname *.dll | tr '\n' ' ' )
else string=$( find $enforcedDirectory -maxdepth 1 -iregex '.*\(dll\|exe\)' | tr '\n' ' ' ) else string=$( find $enforcedDirectory -maxdepth 1 -iregex '.*\(dll\|exe\)' | tr '\n' ' ' )
fi fi
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "enforcedDirectory=$enforcedDirectory" echo "enforcedDirectory=$enforcedDirectory"
echo "we found dlls and exes:$string" echo "we found dlls and exes:$string"
sleep 4 sleep 4
fi fi
# we hard copy it to DEST # we hard copy it to DEST
if [ `uname -s` == "Darwin" ]; then if [ `uname -s` == "Darwin" ]; then
cp -av "${enforcedDirectory}" "$destdir" cp -av "${enforcedDirectory}" "$destdir"
else cp -dpRxv "${enforcedDirectory}" "$destdir" else cp -dpRxv "${enforcedDirectory}" "$destdir"
fi fi
} }
# beginning of the main function # beginning of the main function
# we start with the enforced dlls and exe # we start with the enforced dlls and exe
if [ ! -z "$enforcedir" ]; then if [ ! -z "$enforcedir" ]; then
for curFile in $( echo "${enforcedir}" | tr -s ' ' | tr ' ' '\n'); do for curFile in $( echo "${enforcedir}" | tr -s ' ' | tr ' ' '\n'); do
echo "startig for file $curFile in enforce section" echo "startig for file $curFile in enforce section"
append_deps "$curFile" rel append_deps "$curFile" rel
process_enforced_deps "$curFile" process_enforced_deps "$curFile"
done done
fi fi
# then we start with our indir or infile list # then we start with our indir or infile list
for file in $str_inputFileList; do for file in $str_inputFileList; do
echo "starting for file $file" echo "starting for file $file"
#sleep 4 #sleep 4
append_deps "$file" rel append_deps "$file" rel
done done
echo "I will now search for \$alldeps" echo "I will now search for \$alldeps"
for debugOut in $( echo $alldeps | tr -s ' ' | tr '\n' ' '); do for debugOut in $( echo $alldeps | tr -s ' ' | tr '\n' ' '); do
echo "debugOut: $debugOut" echo "debugOut: $debugOut"
done done
if [ "$loglevel" -eq 1 ]; then if [ "$loglevel" -eq 1 ]; then
echo "waiting 10 seconds until I proceed - so you can read my debugOut" echo "waiting 10 seconds until I proceed - so you can read my debugOut"
sleep 10 sleep 10
tmpStr=${str_srcDirList} tmpStr=${str_srcDirList}
echo "\$alldeps has ${#alldeps[@]} elements" echo "\$alldeps has ${#alldeps[@]} elements"
echo "and \$str_srcDirList has ${#str_srcDirList} elements" echo "and \$str_srcDirList has ${#str_srcDirList} elements"
fi fi
str_summary="Here is the summary:" str_summary="Here is the summary:"
str_summary="${str_summary} # ==== 8< ==== START ==== 8< ==== " str_summary="${str_summary} # ==== 8< ==== START ==== 8< ==== "
if [ $opmode == "copy" ]; then if [ $opmode == "copy" ]; then
echo "copying files from \${curFolder} to \$destdir:" echo "copying files from \${curFolder} to \$destdir:"
elif [ $opmode == "print" ]; then elif [ $opmode == "print" ]; then
echo "printing files:" echo "printing files:"
fi fi
for dll in $( echo $alldeps | tr '\n' ' ' ); do for dll in $( echo $alldeps | tr '\n' ' ' ); do
counter=0 counter=0
lowerDll=$( echo $dll | tr '[:upper:]' '[:lower:]' ) lowerDll=$( echo $dll | tr '[:upper:]' '[:lower:]' )
if [ $lowerDll == $dll ]; then if [ $lowerDll == $dll ]; then
lowerDll="" lowerDll=""
fi fi
for curFolder in $( echo "${str_srcDirList}" | tr -s ' ' | tr ' ' '\n'); do for curFolder in $( echo "${str_srcDirList}" | tr -s ' ' | tr ' ' '\n'); do
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "search for dll $dll in curFolder $curFolder" echo "search for dll $dll in curFolder $curFolder"
sleep 1 sleep 1
fi fi
for curDll in $dll $lowerDll; do for curDll in $dll $lowerDll; do
if [ -e "${curFolder}/${curDll}" ]; then if [ -e "${curFolder}/${curDll}" ]; then
counter=$( expr $counter + 1 ) counter=$( expr $counter + 1 )
if [ $opmode == "copy" ]; then if [ $opmode == "copy" ]; then
if [ `uname -s` == "Darwin" ]; then if [ `uname -s` == "Darwin" ]; then
cp -av "${curFolder}/${curDll}" "$destdir" cp -av "${curFolder}/${curDll}" "$destdir"
else cp -dpRxv "${curFolder}/${curDll}" "$destdir" else cp -dpRxv "${curFolder}/${curDll}" "$destdir"
fi fi
elif [ $opmode == "print" ]; then elif [ $opmode == "print" ]; then
echo "found $dll in: ${curFolder}/${curDll}" echo "found $dll in: ${curFolder}/${curDll}"
else else
echo "unknown opmode=$opmode" echo "unknown opmode=$opmode"
fi fi
fi fi
done done
done done
if [ $counter == 0 ]; then if [ $counter == 0 ]; then
lowerDll=$( echo $dll | tr '[:upper:]' '[:lower:]' ) lowerDll=$( echo $dll | tr '[:upper:]' '[:lower:]' )
str_whiteListDlls=$( echo ${str_whiteListDlls} | tr '[:upper:]' '[:lower:]' ) # make whiteListDlls lower case to ensure we find the match (case insensitive) str_whiteListDlls=$( echo ${str_whiteListDlls} | tr '[:upper:]' '[:lower:]' ) # make whiteListDlls lower case to ensure we find the match (case insensitive)
if [ -z "${str_whiteListDlls/*${lowerDll}*}" ]; then if [ -z "${str_whiteListDlls/*${lowerDll}*}" ]; then
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "Info: \"$dll\" not found - but it is white-listed. That means: it is well known by Windows - do not worry too much. " echo "Info: \"$dll\" not found - but it is white-listed. That means: it is well known by Windows - do not worry too much. "
fi fi
str_summary="${str_summary} # Info: \"$dll\" not found - but it is white-listed. That means: it is well known by Windows - do not worry too much. " str_summary="${str_summary} # Info: \"$dll\" not found - but it is white-listed. That means: it is well known by Windows - do not worry too much. "
else else
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "Warn: \"$dll\" NOT found. \$counter=$counter." echo "Warn: \"$dll\" NOT found. \$counter=$counter."
fi fi
str_summary="${str_summary} # Warn: \"$dll\" NOT found. \$counter=$counter." str_summary="${str_summary} # Warn: \"$dll\" NOT found. \$counter=$counter."
fi fi
else else
if [ "$loglevel" -gt 1 ]; then if [ "$loglevel" -gt 1 ]; then
echo "Good: \"$dll\" found in the list. \$counter=$counter" echo "Good: \"$dll\" found in the list. \$counter=$counter"
fi fi
str_summary="${str_summary} # Good: \"$dll\" Found in the list. \$counter=$counter" str_summary="${str_summary} # Good: \"$dll\" Found in the list. \$counter=$counter"
fi fi
done done
str_summary="${str_summary} # ==== 8< ==== END ==== 8< ==== " str_summary="${str_summary} # ==== 8< ==== END ==== 8< ==== "
echo "Job is done." echo "Job is done."
# print the summary now # print the summary now
for curLine in "$( echo "${str_summary}" | tr -s '#' | tr '#' '\n' )"; do # convert # to a linebreak - string ecomes an array that can be processed in for loop for curLine in "$( echo "${str_summary}" | tr -s '#' | tr '#' '\n' )"; do # convert # to a linebreak - string ecomes an array that can be processed in for loop
echo "$curLine" echo "$curLine"
done done
# clean up the temp directory stored in $tmp # clean up the temp directory stored in $tmp

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/usr/bin/env bash
set -xue set -xue