PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/Library/Formula/mysql.rb

https://github.com/wdeconinck/homebrew
Ruby | 194 lines | 141 code | 34 blank | 19 comment | 12 complexity | 1ffddcb84f552b03f8596f1a920e1597 MD5 | raw file
  1. require 'formula'
  2. class Mysql < Formula
  3. homepage 'http://dev.mysql.com/doc/refman/5.5/en/'
  4. url 'http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.25a.tar.gz/from/http://cdn.mysql.com/'
  5. version '5.5.25a'
  6. sha1 '85dfea413a7d5d2733a40f9dd79cf2320302979f'
  7. depends_on 'cmake' => :build
  8. depends_on 'readline'
  9. depends_on 'pidof'
  10. fails_with :llvm do
  11. build 2326
  12. cause "https://github.com/mxcl/homebrew/issues/issue/144"
  13. end
  14. skip_clean :all # So "INSTALL PLUGIN" can work.
  15. def options
  16. [
  17. ['--with-tests', "Build with unit tests."],
  18. ['--with-embedded', "Build the embedded server."],
  19. ['--with-libedit', "Compile with EditLine wrapper instead of readline"],
  20. ['--with-archive-storage-engine', "Compile with the ARCHIVE storage engine enabled"],
  21. ['--with-blackhole-storage-engine', "Compile with the BLACKHOLE storage engine enabled"],
  22. ['--universal', "Make mysql a universal binary"],
  23. ['--enable-local-infile', "Build with local infile loading support"]
  24. ]
  25. end
  26. # Remove optimization flags from `mysql_config --cflags`
  27. # This facilitates easy compilation of gems using a brewed mysql
  28. # Also fix compilation with Xcode and no CLT: http://bugs.mysql.com/bug.php?id=66001
  29. def patches; DATA; end
  30. def install
  31. # Make sure the var/mysql directory exists
  32. (var+"mysql").mkpath
  33. args = [".",
  34. "-DCMAKE_INSTALL_PREFIX=#{prefix}",
  35. "-DMYSQL_DATADIR=#{var}/mysql",
  36. "-DINSTALL_MANDIR=#{man}",
  37. "-DINSTALL_DOCDIR=#{doc}",
  38. "-DINSTALL_INFODIR=#{info}",
  39. # CMake prepends prefix, so use share.basename
  40. "-DINSTALL_MYSQLSHAREDIR=#{share.basename}/#{name}",
  41. "-DWITH_SSL=yes",
  42. "-DDEFAULT_CHARSET=utf8",
  43. "-DDEFAULT_COLLATION=utf8_general_ci",
  44. "-DSYSCONFDIR=#{etc}"]
  45. # To enable unit testing at build, we need to download the unit testing suite
  46. if ARGV.include? '--with-tests'
  47. args << "-DENABLE_DOWNLOADS=ON"
  48. else
  49. args << "-DWITH_UNIT_TESTS=OFF"
  50. end
  51. # Build the embedded server
  52. args << "-DWITH_EMBEDDED_SERVER=ON" if ARGV.include? '--with-embedded'
  53. # Compile with readline unless libedit is explicitly chosen
  54. args << "-DWITH_READLINE=yes" unless ARGV.include? '--with-libedit'
  55. # Compile with ARCHIVE engine enabled if chosen
  56. args << "-DWITH_ARCHIVE_STORAGE_ENGINE=1" if ARGV.include? '--with-archive-storage-engine'
  57. # Compile with BLACKHOLE engine enabled if chosen
  58. args << "-DWITH_BLACKHOLE_STORAGE_ENGINE=1" if ARGV.include? '--with-blackhole-storage-engine'
  59. # Make universal for binding to universal applications
  60. args << "-DCMAKE_OSX_ARCHITECTURES='i386;x86_64'" if ARGV.build_universal?
  61. # Build with local infile loading support
  62. args << "-DENABLED_LOCAL_INFILE=1" if ARGV.include? '--enable-local-infile'
  63. system "cmake", *args
  64. system "make"
  65. system "make install"
  66. plist_path.write startup_plist
  67. plist_path.chmod 0644
  68. # Don't create databases inside of the prefix!
  69. # See: https://github.com/mxcl/homebrew/issues/4975
  70. rm_rf prefix+'data'
  71. # Link the setup script into bin
  72. ln_s prefix+'scripts/mysql_install_db', bin+'mysql_install_db'
  73. # Fix up the control script and link into bin
  74. inreplace "#{prefix}/support-files/mysql.server" do |s|
  75. s.gsub!(/^(PATH=".*)(")/, "\\1:#{HOMEBREW_PREFIX}/bin\\2")
  76. end
  77. ln_s "#{prefix}/support-files/mysql.server", bin
  78. end
  79. def caveats; <<-EOS.undent
  80. Set up databases to run AS YOUR USER ACCOUNT with:
  81. unset TMPDIR
  82. mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=#{var}/mysql --tmpdir=/tmp
  83. To set up base tables in another folder, or use a different user to run
  84. mysqld, view the help for mysqld_install_db:
  85. mysql_install_db --help
  86. and view the MySQL documentation:
  87. * http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html
  88. * http://dev.mysql.com/doc/refman/5.5/en/default-privileges.html
  89. To run as, for instance, user "mysql", you may need to `sudo`:
  90. sudo mysql_install_db ...options...
  91. Start mysqld manually with:
  92. mysql.server start
  93. Note: if this fails, you probably forgot to run the first two steps up above
  94. A "/etc/my.cnf" from another install may interfere with a Homebrew-built
  95. server starting up correctly.
  96. To connect:
  97. mysql -uroot
  98. To launch on startup:
  99. * if this is your first install:
  100. mkdir -p ~/Library/LaunchAgents
  101. cp #{plist_path} ~/Library/LaunchAgents/
  102. launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
  103. * if this is an upgrade and you already have the #{plist_path.basename} loaded:
  104. launchctl unload -w ~/Library/LaunchAgents/#{plist_path.basename}
  105. cp #{plist_path} ~/Library/LaunchAgents/
  106. launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
  107. You may also need to edit the plist to use the correct "UserName".
  108. EOS
  109. end
  110. def startup_plist; <<-EOPLIST.undent
  111. <?xml version="1.0" encoding="UTF-8"?>
  112. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  113. <plist version="1.0">
  114. <dict>
  115. <key>KeepAlive</key>
  116. <true/>
  117. <key>Label</key>
  118. <string>#{plist_name}</string>
  119. <key>Program</key>
  120. <string>#{HOMEBREW_PREFIX}/bin/mysqld_safe</string>
  121. <key>RunAtLoad</key>
  122. <true/>
  123. <key>UserName</key>
  124. <string>#{`whoami`.chomp}</string>
  125. <key>WorkingDirectory</key>
  126. <string>#{var}</string>
  127. </dict>
  128. </plist>
  129. EOPLIST
  130. end
  131. end
  132. __END__
  133. diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh
  134. index 9296075..70c18db 100644
  135. --- a/scripts/mysql_config.sh
  136. +++ b/scripts/mysql_config.sh
  137. @@ -137,7 +137,9 @@ for remove in DDBUG_OFF DSAFE_MUTEX DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
  138. DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
  139. 'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
  140. Xa xstrconst "xc99=none" AC99 \
  141. - unroll2 ip mp restrict
  142. + unroll2 ip mp restrict \
  143. + mmmx 'msse[0-9.]*' 'mfpmath=sse' w pipe 'fomit-frame-pointer' 'mmacosx-version-min=10.[0-9]' \
  144. + aes Os
  145. do
  146. # The first option we might strip will always have a space before it because
  147. # we set -I$pkgincludedir as the first option
  148. diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake
  149. index 89a9de9..677c68d 100644
  150. --- a/cmake/libutils.cmake
  151. +++ b/cmake/libutils.cmake
  152. @@ -183,7 +183,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
  153. # binaries properly)
  154. ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
  155. COMMAND rm ${TARGET_LOCATION}
  156. - COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}
  157. + COMMAND libtool -static -o ${TARGET_LOCATION}
  158. ${STATIC_LIBS}
  159. )
  160. ELSE()