mono-test-install 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #!/usr/bin/env bash
  2. #
  3. # Does various checks for people that we can use to diagnose
  4. # an end user installation
  5. #
  6. temp_cs=temp$$.cs
  7. temp_exe=temp$$.exe
  8. if test -f $temp_cs; then
  9. echo Error: need a temporary file name, and $temp_cs already exists
  10. echo Run this program from a different directory, or delete the file and try again.
  11. exit 1
  12. fi
  13. set `echo $PATH | sed 's/:/ /g'`
  14. while test x$1 != x; do
  15. if test -x $1/mono; then
  16. if test x$monocmd = x; then
  17. monocmd=$1/mono
  18. else
  19. other_monos="$1/mono $other_monos"
  20. fi
  21. fi
  22. shift
  23. done
  24. echo Active Mono: $monocmd
  25. if test "x$other_monos" != x; then
  26. echo "Other Mono executables: $other_monos"
  27. fi
  28. #
  29. # Check that the pkg-config mono points to this mono
  30. #
  31. if pkg-config --modversion mono >& /dev/null; then
  32. pkg_config_mono=`(cd \`pkg-config --variable prefix mono\`/bin; pwd)`/mono
  33. if test $pkg_config_mono != $monocmd; then
  34. echo "Error: pkg-config Mono installation points to a different install"
  35. echo " than the Mono found:"
  36. echo " Mono on PATH: $monocmd"
  37. echo " Mono from pkg-config: $pkg_config_mono"
  38. fi
  39. else
  40. echo "Warning: pkg-config could not find mono installed on this system"
  41. fi
  42. ##########################################################################################
  43. #
  44. # Tests below this point require the dotnet install
  45. #
  46. #
  47. #
  48. # Check that -pkg:dotnet is available
  49. #
  50. if pkg-config --modversion dotnet >& /dev/null; then
  51. echo ""
  52. else
  53. echo "No dotnet pkgconfig found, Windows.Forms, System.Drawing and others will not work"
  54. exit 1
  55. fi
  56. case `uname` in
  57. Darwin)
  58. macos=true
  59. libgdiplus=libgdiplus.dylib
  60. LD_PATH=DYLD_LIBRARY_PATH
  61. ;;
  62. *)
  63. macos=false;
  64. libgdiplus=libgdiplus.so
  65. LD_PATH=LD_LIBRARY_PATH
  66. ;;
  67. esac
  68. search_libgdiplus_on_path()
  69. {
  70. libgdiplus_found=false
  71. if $macos; then
  72. set `echo $DYLD_LIBRARY_PATH | sed 's/:/ /g'`
  73. else
  74. set `echo $LD_LIBRARY_PATH | sed 's/:/ /g'`
  75. fi
  76. while test x$1 != x; do
  77. if test -e $1/$libgdiplus; then
  78. echo " The $libgdiplus is found on $libdir/$libgdiplus"
  79. libgdiplus_found=true
  80. libgdiplus_path=$1/$libgdiplus
  81. break
  82. fi
  83. shift
  84. done
  85. }
  86. #
  87. # Check GDI+ installation
  88. #
  89. cat > $temp_cs <<EOF
  90. using System;
  91. using System.Drawing;
  92. class X {
  93. static void Main ()
  94. {
  95. Bitmap b = new Bitmap (100, 100);
  96. }
  97. }
  98. EOF
  99. if mcs -pkg:dotnet $temp_cs >& /dev/null; then
  100. if mono $temp_exe >& /dev/null; then
  101. echo You have a working System.Drawing setup
  102. else
  103. echo Your system has a broken System.Drawing setup
  104. if mono $temp_exe 2>&1 | grep 'System.DllNotFoundException: gdiplus.dll' > /dev/null; then
  105. echo " your gdiplus.dll can not be loaded"
  106. libdir=`dirname $monocmd`/../lib
  107. if test -f $libdir/$libgdiplus; then
  108. echo " The $libgdiplus is found on $libdir/$libgdiplus"
  109. if test -e $libdir/$libgdiplus; then
  110. libgdiplus_path=$libdir/$libgdiplus
  111. libgdiplus_found=true
  112. else
  113. echo " but it seems to be a broken link"
  114. fi
  115. else
  116. search_libgdiplus_on_path
  117. fi
  118. if $libgdiplus_found; then
  119. echo ssss
  120. if which ldd >/dev/null; then
  121. LANG=C dirs=`ldd $libgdiplus_path | grep 'not found'`
  122. if echo $dirs | grep 'not found' >& /dev/null; then
  123. echo " libgdiplus is missing the following dependencies to run:"
  124. echo $dirs | sed 's/^/ /'
  125. fi
  126. fi
  127. else
  128. echo " No libgdiplus was found on your $LD_PATH"
  129. fi
  130. fi
  131. fi
  132. else
  133. echo Failed to compile sample System.Drawing program, your installation is broken
  134. exit 1
  135. fi
  136. cat > $temp_cs <<EOF
  137. using System;
  138. using System.Reflection;
  139. using System.IO;
  140. class Program {
  141. public static void Main()
  142. {
  143. object watcher = new FileSystemWatcher()
  144. .GetType ()
  145. .GetField ("watcher", BindingFlags.NonPublic | BindingFlags.Static)
  146. .GetValue (null);
  147. Console.WriteLine ("Your file system watcher is: {0}",
  148. watcher != null
  149. ? watcher.GetType ().FullName
  150. : "unknown");
  151. }
  152. }
  153. EOF
  154. if mcs $temp_cs >& /dev/null; then
  155. mono $temp_exe
  156. else
  157. echo Failed to compile sample test program, your installation is broken
  158. exit 1
  159. fi