<commit_before>module Autoparts
  module Packages
    class MySQL < Package
      name 'mysql'
      version '5.6.13'
      source_url 'http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz/from/http://cdn.mysql.com/'
      source_sha1 '06e1d856cfb1f98844ef92af47d4f4f7036ef294'
      source_filetype 'tar.gz'
      binary_url 'http://nitrousio-autoparts-use1.s3.amazonaws.com/mysql-5.6.13-binary.tar.gz'
      binary_sha1 '7bf6ecd2138923043c6018f57af5307765e72b8c'

      def compile
        Dir.chdir('mysql-5.6.13') do
          args = [
            '.',
            "-DCMAKE_INSTALL_PREFIX=#{prefix_path}",
            "-DDEFAULT_CHARSET=utf8",
            "-DDEFAULT_COLLATION=utf8_general_ci",
            "-DINSTALL_MANDIR=#{man_path}",
            "-DINSTALL_DOCDIR=#{doc_path}",
            "-DINSTALL_INFODIR=#{info_path}",
            "-DINSTALL_MYSQLSHAREDIR=#{share_path.basename}/#{name}",
            "-DMYSQL_DATADIR=#{Path.var}/mysql",
            "-DSYSCONFDIR=#{Path.etc}",
            "-DWITH_READLINE=yes",
            "-DWITH_SSL=yes",
            "-DWITH_UNIT_TESTS=OFF"
          ]

          execute 'cmake', *args
          execute 'make'
        end
      end

      def install
        Dir.chdir('mysql-5.6.13') do
          execute 'make install'
          execute "ln -s #{prefix_path}/support-files/mysql.server #{bin_path}/"
          execute "rm -rf #{prefix_path}/data"
        end
      end

      def post_install
        args = [
          "--basedir=#{prefix_path}",
          "--datadir=#{Path.var}/mysql",
          "--tmpdir=/tmp",
          "--user=#{user}",
          '--verbose'
        ]
        execute "scripts/mysql_install_db", *args
      end

      def tips
        <<-STR.unindent
          To start the server:
            mysql.server start

          To stop the server:
            mysql.server stop

          To connect to the server:
            mysql -uroot<commit_msg>create mysql db only if it does not already exist<commit_after>module Autoparts
  module Packages
    class MySQL < Package
      name 'mysql'
      version '5.6.13'
      source_url 'http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz/from/http://cdn.mysql.com/'
      source_sha1 '06e1d856cfb1f98844ef92af47d4f4f7036ef294'
      source_filetype 'tar.gz'
      binary_url 'http://nitrousio-autoparts-use1.s3.amazonaws.com/mysql-5.6.13-binary.tar.gz'
      binary_sha1 '7bf6ecd2138923043c6018f57af5307765e72b8c'

      def compile
        Dir.chdir('mysql-5.6.13') do
          args = [
            '.',
            "-DCMAKE_INSTALL_PREFIX=#{prefix_path}",
            "-DDEFAULT_CHARSET=utf8",
            "-DDEFAULT_COLLATION=utf8_general_ci",
            "-DINSTALL_MANDIR=#{man_path}",
            "-DINSTALL_DOCDIR=#{doc_path}",
            "-DINSTALL_INFODIR=#{info_path}",
            "-DINSTALL_MYSQLSHAREDIR=#{share_path.basename}/#{name}",
            "-DMYSQL_DATADIR=#{Path.var}/mysql",
            "-DSYSCONFDIR=#{Path.etc}",
            "-DWITH_READLINE=yes",
            "-DWITH_SSL=yes",
            "-DWITH_UNIT_TESTS=OFF"
          ]

          execute 'cmake', *args
          execute 'make'
        end
      end

      def install
        Dir.chdir('mysql-5.6.13') do
          execute 'make install'
          execute "ln -s #{prefix_path}/support-files/mysql.server #{bin_path}/"
          execute "rm -rf #{prefix_path}/data"
        end
      end

      def post_install
        unless (Path.var + 'mysql' + 'mysql' + 'user.frm').exist?
          ENV['TMPDIR'] = nil
          args = [
            "--basedir=#{prefix_path}",
            "--datadir=#{Path.var}/mysql",
            "--tmpdir=/tmp",
            "--user=#{user}",
            '--verbose'
          ]
          execute "scripts/mysql_install_db", *args
        end
      end

      def tips
        <<-STR.unindent
          To start the server:
            mysql.server start

          To stop the server:
            mysql.server stop

          To connect to the server:
            mysql -uroot
{'fraction_non_alphanumeric': 0.13267326732673268, 'fraction_numerical': 0.0400990099009901, 'mean_word_length': 1.7583617747440272, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '102150', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1322, 'n_words': 210}