<commit_before>class Squashfs < Formula
  desc "Compressed read-only file system for Linux"
  homepage "https://github.com/plougher/squashfs-tools"
  url "https://github.com/plougher/squashfs-tools/archive/4.5.tar.gz"
  sha256 "b9e16188e6dc1857fe312633920f7d71cc36b0162eb50f3ecb1f0040f02edddd"
  license "GPL-2.0"
  head "https://github.com/plougher/squashfs-tools.git", branch: "master"

  # Tags like `4.4-git.1` are not release versions and the regex omits these
  # (see: https://github.com/plougher/squashfs-tools/issues/96).
  livecheck do
    url :stable
    regex(/^v?(\d+(?:\.\d+)+)$/i)
  end

  bottle do
    sha256 cellar: :any,                 arm64_monterey: "d7f5df25aff892c871e31ac31117945ab98b7390eb1c0b05d0e355efeee05b56"
    sha256 cellar: :any,                 arm64_big_sur:  "55318dc9912602fe8452b595071511ebc10aec729429d101c4d87b0f11af23be"
    sha256 cellar: :any,                 monterey:       "896eccf7efeaa99831f7d1ebef0f81e379a2b8b139a7bf4f14fa2f394d168b16"
    sha256 cellar: :any,                 big_sur:        "6367ccf7c5ee95740026bf87f9c47b4cc430d03fe2c0bc4d4db78a029cd799b9"
    sha256 cellar: :any,                 catalina:       "1821a023342782230162c1fd3b2a1a760952b1a171bd97482b8aaf9d3e2a4e38"
    sha256 cellar: :any,                 mojave:         "0d78285daf5f932e2c8459242b340fd895a51195c2582c1e6ccc43f3f7f635c1"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "e5d319d1cafa8de74886f9e41623bcf1a1cb75307d9d62d143220f386d5b5206"
  end

  depends_on "lz4"
  depends_on "lzo"
  depends_on "xz"
  depends_on "zstd"

  uses_from_macos "zlib"

  # Patch necessary to emulate the sigtimedwait process otherwise we get build failures.
  # Also clang fixes, extra endianness knowledge and a bundle of other macOS fixes.
  # Original patchset: https://github.com/plougher/squashfs-tools/pull/69
  patch do
    url "https://raw.githubusercontent.com/Homebrew/formula-patches/d75d6958612eb590580872d1878f26af6d2deb83/squashfs/4.5.patch"
    sha256 "d90f3b167e016f44a87b84c2ccbb9bcfc47d28fc51b630857e7e27bd01b58084"
  end

  def install
    args = %W[
      EXTRA_CFLAGS=-std=gnu89
      LZ4_DIR=#{Formula["lz4"].opt_prefix}
      LZ4_SUPPORT=1
      LZO_DIR=#{Formula["lzo"].opt_prefix}
      LZO_SUPPORT=1
      XZ_DIR=#{Formula["xz"].opt_prefix}
      XZ_SUPPORT=1
      LZMA_XZ_SUPPORT=1
      ZSTD_DIR=#{Formula["zstd"].opt_prefix}
      ZSTD_SUPPORT=1
      XATTR_SUPPORT=1
    ]

    cd "squashfs-tools" do
      system "make", *args
      bin.install %w[mksquashfs unsquashfs]
    end

    doc.install %W[README-#{version.major_minor} RELEASE-READMEs USAGE COPYING]
  end

  test do
    # Check binaries execute
    assert_match version.to_s, shell_output("#{bin}/mksquashfs -version")
    assert_match version.to_s, shell_output("#{bin}/unsquashfs -v", 1)

    (testpath/"in/test1").write "G'day!"
    (testpath/"in/test2").write "Bonjour!"
    (testpath/"in/test3").write "Moien!"

    # Test mksquashfs can make a valid squashimg.
    #   (Also tests that `xz` support is properly linked.)
    system "#{bin}/mksquashfs", "in/test1", "in/test2", "in/test3", "test.xz.sqsh", "-quiet", "-comp", "xz"
    assert_predicate testpath/"test.xz.sqsh", :exist?
    assert_match "Found a valid SQUASHFS 4:0 superblock on test.xz.sqsh.",
      shell_output("#{bin}/unsquashfs -s test.xz.sqsh")

    # Test unsquashfs can extract files verbatim.
    system "#{bin}/unsquashfs", "-d", "out", "test.xz.sqsh"<commit_msg>squashfs 4.5.1<commit_after>class Squashfs < Formula
  desc "Compressed read-only file system for Linux"
  homepage "https://github.com/plougher/squashfs-tools"
  url "https://github.com/plougher/squashfs-tools/archive/4.5.1.tar.gz"
  sha256 "277b6e7f75a4a57f72191295ae62766a10d627a4f5e5f19eadfbc861378deea7"
  license "GPL-2.0-or-later"
  head "https://github.com/plougher/squashfs-tools.git", branch: "master"

  # Tags like `4.4-git.1` are not release versions and the regex omits these
  # (see: https://github.com/plougher/squashfs-tools/issues/96).
  livecheck do
    url :stable
    regex(/^v?(\d+(?:\.\d+)+)$/i)
  end

  bottle do
    sha256 cellar: :any,                 arm64_monterey: "d7f5df25aff892c871e31ac31117945ab98b7390eb1c0b05d0e355efeee05b56"
    sha256 cellar: :any,                 arm64_big_sur:  "55318dc9912602fe8452b595071511ebc10aec729429d101c4d87b0f11af23be"
    sha256 cellar: :any,                 monterey:       "896eccf7efeaa99831f7d1ebef0f81e379a2b8b139a7bf4f14fa2f394d168b16"
    sha256 cellar: :any,                 big_sur:        "6367ccf7c5ee95740026bf87f9c47b4cc430d03fe2c0bc4d4db78a029cd799b9"
    sha256 cellar: :any,                 catalina:       "1821a023342782230162c1fd3b2a1a760952b1a171bd97482b8aaf9d3e2a4e38"
    sha256 cellar: :any,                 mojave:         "0d78285daf5f932e2c8459242b340fd895a51195c2582c1e6ccc43f3f7f635c1"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "e5d319d1cafa8de74886f9e41623bcf1a1cb75307d9d62d143220f386d5b5206"
  end

  depends_on "gnu-sed" => :build
  depends_on "help2man" => :build

  depends_on "lz4"
  depends_on "lzo"
  depends_on "xz"
  depends_on "zstd"

  uses_from_macos "zlib"

  # Patch necessary to emulate the sigtimedwait process otherwise we get build failures.
  # Also clang fixes, extra endianness knowledge and a bundle of other macOS fixes.
  # Original patchset: https://github.com/plougher/squashfs-tools/pull/69
  patch do
    url "https://raw.githubusercontent.com/Homebrew/formula-patches/67d366d76a655dca08177bf05d812361c4175a10/squashfs/4.5.1.patch"
    sha256 "2cc6cfb75f1479cbc74e3a03b1c359ba63f1c1caa5bb65d6ffca0e95264552f1"
  end

  def install
    args = %W[
      EXTRA_CFLAGS=-std=gnu89
      LZ4_DIR=#{Formula["lz4"].opt_prefix}
      LZ4_SUPPORT=1
      LZO_DIR=#{Formula["lzo"].opt_prefix}
      LZO_SUPPORT=1
      XZ_DIR=#{Formula["xz"].opt_prefix}
      XZ_SUPPORT=1
      LZMA_XZ_SUPPORT=1
      ZSTD_DIR=#{Formula["zstd"].opt_prefix}
      ZSTD_SUPPORT=1
      XATTR_SUPPORT=1
    ]

    commands = %w[mksquashfs unsquashfs sqfscat sqfstar]

    cd "squashfs-tools" do
      system "make", *args
      bin.install commands
    end

    ENV.prepend_path "PATH", Formula["gnu-sed"].opt_libexec/"gnubin"
    mkdir_p man1
    cd "generate-manpages" do
      commands.each do |command|
        system "./#{command}-manpage.sh", bin, man1/"#{command}.1"
      end
    end

    doc.install %W[README-#{version} RELEASE-READMEs USAGE COPYING]
  end

  test do
    # Check binaries execute
    assert_match version.to_s, shell_output("#{bin}/mksquashfs -version")
    assert_match version.to_s, shell_output("#{bin}/unsquashfs -v", 1)

    (testpath/"in/test1").write "G'day!"
    (testpath/"in/test2").write "Bonjour!"
    (testpath/"in/test3").write "Moien!"

    # Test mksquashfs can make a valid squashimg.
    #   (Also tests that `xz` support is properly linked.)
    system "#{bin}/mksquashfs", "in/test1", "in/test2", "in/test3", "test.xz.sqsh", "-quiet", "-comp", "xz"
    assert_predicate testpath/"test.xz.sqsh", :exist?
    assert_match "Found a valid SQUASHFS 4:0 superblock on test.xz.sqsh.",
      shell_output("#{bin}/unsquashfs -s test.xz.sqsh")

    # Test unsquashfs can extract files verbatim.
    system "#{bin}/unsquashfs", "-d", "out", "test.xz.sqsh"
{'fraction_non_alphanumeric': 0.11456898925915726, 'fraction_numerical': 0.12737537868355825, 'mean_word_length': 3.5765595463137996, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3580732', 'n_tokens_mistral': 3467, 'n_tokens_neox': 2950, 'n_words': 479}