cygwin-copy.sh 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/env bash
  2. #####################################################################
  3. ## __ __ _ ___________ ##
  4. ## \ \ / /| |____ ____| ##
  5. ## \ \ / / | | | | ##
  6. ## \ \ /\ / / | | | | ##
  7. ## \ \/ \/ / | | | | ##
  8. ## \ /\ / | | | | ##
  9. ## \/ \/ |_| |_| ##
  10. ## ##
  11. ## Wiimms ISO Tools ##
  12. ## https://wit.wiimm.de/ ##
  13. ## ##
  14. #####################################################################
  15. ## ##
  16. ## This file is part of the WIT project. ##
  17. ## Visit https://wit.wiimm.de/ for project details and sources. ##
  18. ## ##
  19. ## Copyright (c) 2009-2021 by Dirk Clemens <wiimm@wiimm.de> ##
  20. ## ##
  21. #####################################################################
  22. ## ##
  23. ## This file copies the cygwin tools and DLLs into the binary ##
  24. ## directory to prepare the distribution. ##
  25. ## ##
  26. #####################################################################
  27. #------------------------------------------------------------------------------
  28. # setup
  29. CYGWIN_DIR="@@CYGWIN-DIR@@"
  30. CYGWIN_TOOLS="@@CYGWIN-TOOLS@@"
  31. BIN_FILES="@@BIN-FILES@@"
  32. DISTRIB_PATH="@@DISTRIB-PATH@@"
  33. BIN_PATH="$DISTRIB_PATH/bin"
  34. mkdir -p "$BIN_PATH" || exit 1
  35. #------------------------------------------------------------------------------
  36. # copy cygwin tools
  37. for tool in $CYGWIN_TOOLS
  38. do
  39. cp --preserve=time "$CYGWIN_DIR/$tool.exe" "$BIN_PATH" || exit 1
  40. done
  41. #------------------------------------------------------------------------------
  42. # copy wit tools
  43. for tool in $BIN_FILES
  44. do
  45. if [[ -s ./$tool.exe ]]
  46. then
  47. CYGWIN_TOOLS="$CYGWIN_TOOLS $tool"
  48. ln -f ./$tool.exe "$BIN_PATH" || exit 1
  49. fi
  50. done
  51. #------------------------------------------------------------------------------
  52. # copy needed cygwin dlls
  53. CYGCHECK="$( which cygcheck 2>/dev/null )"
  54. for tool in $CYGWIN_TOOLS
  55. do
  56. if [[ $CYGCHECK ]]
  57. then
  58. "$CYGCHECK" "$BIN_PATH/$tool.exe" \
  59. | grep -E 'cygwin.*\\bin\\.*\.dll' \
  60. | sed 's/.*\\//'
  61. else
  62. ldd "$BIN_PATH/$tool.exe" | grep -F "=> $CYGWIN_DIR/" | awk '{print $1}'
  63. fi
  64. done | sort | uniq | while read dll
  65. do
  66. cp --preserve=time "$CYGWIN_DIR/$dll" "$BIN_PATH" || exit 1
  67. done
  68. #------------------------------------------------------------------------------
  69. # done
  70. exit 0