<commit_before>require 'formula'

class IrcdIrc2 < Formula
  homepage 'http://www.irc.org/'
  url 'http://www.irc.org/ftp/irc/server/irc2.11.2p3.tgz'
  sha1 '1ab317daeac324cc3f10fe939588de04d52e47c5'
  version '2.11.2p3'

  def default_ircd_conf
    <<-EOS.undent
      # M-Line
      M:irc.localhost::Darwin ircd default configuration::000A

      # A-Line
      A:This is Darwin's default ircd configurations:Please edit your /usr/local/etc/ircd.conf file:Contact <root@localhost> for questions::ExampleNet

      # Y-Lines
      Y:fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b:512000:5.5:100.100
      Y:fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b:512000:5.5:250.250

      # I-Line
      I:*:::0:1
      I:127.0.0.1/32:::0:1

      # P-Line
      P::::6667:
    EOS
  end

  def install
    system "./configure", "--prefix=#{prefix}",
                          "--localstatedir=#{var}",
                          "--sysconfdir=#{etc}",
                          "--mandir=#{man}",
                          "CFLAGS=-DRLIMIT_FDMAX=0"

    # The directory is something like `i686-apple-darwin13.0.2'
    system "make", "install", "-C", `./support/config.guess`.chomp

    (etc/"ircd.conf").write default_ircd_conf
  end

  plist_options :manual => "ircd"

  def plist; <<-EOS.undent
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>KeepAlive</key>
      <false/>
      <key>Label</key>
      <string>#{plist_name}</string>
      <key>ProgramArguments</key>
      <array>
        <string>#{opt_prefix}/sbin/ircd</string>
        <string>-t</string>
      </array>
      <key>RunAtLoad</key><commit_msg>ircd-irc2: disable netsplit detection<commit_after>require 'formula'

class IrcdIrc2 < Formula
  homepage 'http://www.irc.org/'
  url 'http://www.irc.org/ftp/irc/server/irc2.11.2p3.tgz'
  sha1 '1ab317daeac324cc3f10fe939588de04d52e47c5'
  version '2.11.2p3'

  def default_ircd_conf
    <<-EOS.undent
      # M-Line
      M:irc.localhost::Darwin ircd default configuration::000A

      # A-Line
      A:This is Darwin's default ircd configurations:Please edit your /usr/local/etc/ircd.conf file:Contact <root<EMAIL>> for questions::ExampleNet

      # Y-Lines
      Y:fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b:512000:5.5:100.100
      Y:fd00:a516:7c1b:17cd:6d81:2137:bd2a:2c5b:512000:5.5:250.250

      # I-Line
      I:*:::0:1
      I:127.0.0.1/32:::0:1

      # P-Line
      P::::6667:
    EOS
  end

  def install
    system "./configure", "--prefix=#{prefix}",
                          "--localstatedir=#{var}",
                          "--sysconfdir=#{etc}",
                          "--mandir=#{man}",
                          "CFLAGS=-DRLIMIT_FDMAX=0"

    build_dir = `./support/config.guess`.chomp

    # Disable netsplit detection. In a netsplit, joins to new channels do not
    # give chanop status.
    inreplace "#{build_dir}/config.h", /#define DEFAULT_SPLIT_USERS\s+65000/,
      "#define DEFAULT_SPLIT_USERS 0"
    inreplace "#{build_dir}/config.h", /#define DEFAULT_SPLIT_SERVERS\s+80/,
      "#define DEFAULT_SPLIT_SERVERS 0"

    # The directory is something like `i686-apple-darwin13.0.2'
    system "make", "install", "-C", build_dir

    (etc/"ircd.conf").write default_ircd_conf
  end

  plist_options :manual => "ircd"

  def plist; <<-EOS.undent
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>KeepAlive</key>
      <false/>
      <key>Label</key>
      <string>#{plist_name}</string>
      <key>ProgramArguments</key>
      <array>
        <string>#{opt_prefix}/sbin/ircd</string>
        <string>-t</string>
      </array>
      <key>RunAtLoad</key>
{'fraction_non_alphanumeric': 0.16511627906976745, 'fraction_numerical': 0.07338501291989664, 'mean_word_length': 2.490532010820559, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 2, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 2}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2617040', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1467, 'n_words': 227}