diff --git a/Formula/bzip2.rb b/Formula/bzip2.rb new file mode 100644 index 0000000..9ba28c7 --- /dev/null +++ b/Formula/bzip2.rb @@ -0,0 +1,69 @@ +class Bzip2 < Formula + desc "Freely available high-quality data compressor" + homepage "https://sourceware.org/bzip2/" + url "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz" + sha256 "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269" + license "bzip2-1.0.6" + + livecheck do + url "https://sourceware.org/pub/bzip2/" + regex(/href=.*?bzip2[._-]v?(\d+(?:\.\d+)+)\.t/i) + end + + bottle do + rebuild 2 + sha256 cellar: :any_skip_relocation, arm64_sonoma: "f148a0cf9cec0d1711b5bd16c18047e0a9933acec37bfec30a182f29ae364577" + sha256 cellar: :any_skip_relocation, arm64_ventura: "52f70f97b2f8f2c6bc309e55970ed03ccd1b8110cf5f15fc16c2a930180a99f7" + sha256 cellar: :any_skip_relocation, arm64_monterey: "bcc8f2e728b154d43e76e8e81f77e934d905b8868b7be69e3b9b40b5868f7c34" + sha256 cellar: :any_skip_relocation, arm64_big_sur: "12f184d77bb72cc7d9278af9bd34fd74c610f7aa144559e2aa2d9f4a4b09bd76" + sha256 cellar: :any_skip_relocation, sonoma: "0aa9de4f40daf644d2c5745e35a20fac2babda8df0218e58bd471d0132ba8457" + sha256 cellar: :any_skip_relocation, ventura: "2cf2591f8865d9a806736a6f1b74f0905477b5520dd730f025aa12d4c5e0749b" + sha256 cellar: :any_skip_relocation, monterey: "fc4dd056738e20b1c850c6834405e27071a992f7671137306c1764c7c0eef350" + sha256 cellar: :any_skip_relocation, big_sur: "d222e089bf7b4ab714b150ad754cb76b88b548f57c4bdbbaa4857d6e0541a096" + sha256 cellar: :any_skip_relocation, x86_64_linux: "a731afa70daaafec28359b4f10f1c68455c1955ae66cdbb6b6d52eee277bbd3e" + end + + keg_only :provided_by_macos + + def install + inreplace "Makefile", "$(PREFIX)/man", "$(PREFIX)/share/man" + + system "make", "install", "PREFIX=#{prefix}" + return if OS.mac? + + # Install shared libraries + system "make", "-f", "Makefile-libbz2_so", "clean" + system "make", "-f", "Makefile-libbz2_so" + lib.install "libbz2.so.#{version}", "libbz2.so.#{version.major_minor}" + lib.install_symlink "libbz2.so.#{version}" => "libbz2.so.#{version.major}" + lib.install_symlink "libbz2.so.#{version}" => "libbz2.so" + + # Create pkgconfig file based on 1.1.x repository. + # https://gitlab.com/bzip2/bzip2/-/blob/master/bzip2.pc.in + (lib/"pkgconfig/bzip2.pc").write <<~EOS + prefix=#{opt_prefix} + exec_prefix=${prefix} + bindir=${exec_prefix}/bin + libdir=${exec_prefix}/lib + includedir=${prefix}/include + + Name: bzip2 + Description: Lossless, block-sorting data compression + Version: #{version} + Libs: -L${libdir} -lbz2 + Cflags: -I${includedir} + EOS + end + + test do + testfilepath = testpath + "sample_in.txt" + zipfilepath = testpath + "sample_in.txt.bz2" + + testfilepath.write "TEST CONTENT" + + system "#{bin}/bzip2", testfilepath + system "#{bin}/bunzip2", zipfilepath + + assert_equal "TEST CONTENT", testfilepath.read + end +end diff --git a/Formula/unzip.rb b/Formula/unzip.rb new file mode 100644 index 0000000..295781f --- /dev/null +++ b/Formula/unzip.rb @@ -0,0 +1,78 @@ +class Unzip < Formula + desc "Extraction utility for .zip compressed archives" + homepage "https://infozip.sourceforge.io/UnZip.html" + url "https://downloads.sourceforge.net/project/infozip/UnZip%206.x%20%28latest%29/UnZip%206.0/unzip60.tar.gz" + version "6.0" + sha256 "036d96991646d0449ed0aa952e4fbe21b476ce994abc276e49d30e686708bd37" + revision 4 + + bottle do + cellar :any_skip_relocation + sha256 "06aeb3114e2a030970f0d05424e9f2b2f845a2a5643065f173ba6a70e99970a3" => :mojave + sha256 "0e76c4b9f38e8de22409e666894400b95340271144e44bd408975a8d0100b942" => :high_sierra + sha256 "5445d1be98f82d7d4d4a01f930790d0745c845cdbf1a7ea23d07f7fc295d6f90" => :sierra + end + + keg_only :provided_by_macos + + # Upstream is unmaintained so we use the Debian patchset: + # https://packages.debian.org/sid/unzip + patch do + url "https://deb.debian.org/debian/pool/main/u/unzip/unzip_6.0-22.debian.tar.xz" + sha256 "f3c80c1e3917d59cb2fe72f0431159c919f2df7fc96f5b539c91cc96fc02ecfa" + apply %w[ + patches/01-manpages-in-section-1-not-in-section-1l.patch + patches/02-this-is-debian-unzip.patch + patches/03-include-unistd-for-kfreebsd.patch + patches/04-handle-pkware-verification-bit.patch + patches/05-fix-uid-gid-handling.patch + patches/06-initialize-the-symlink-flag.patch + patches/07-increase-size-of-cfactorstr.patch + patches/08-allow-greater-hostver-values.patch + patches/09-cve-2014-8139-crc-overflow.patch + patches/10-cve-2014-8140-test-compr-eb.patch + patches/11-cve-2014-8141-getzip64data.patch + patches/12-cve-2014-9636-test-compr-eb.patch + patches/13-remove-build-date.patch + patches/14-cve-2015-7696.patch + patches/15-cve-2015-7697.patch + patches/16-fix-integer-underflow-csiz-decrypted.patch + patches/17-restore-unix-timestamps-accurately.patch + patches/18-cve-2014-9913-unzip-buffer-overflow.patch + patches/19-cve-2016-9844-zipinfo-buffer-overflow.patch + patches/20-cve-2018-1000035-unzip-buffer-overflow.patch + ] + end + + def install + system "make", "-f", "unix/Makefile", + "CC=#{ENV.cc}", + "LOC=-DLARGE_FILE_SUPPORT", + "D_USE_BZ2=-DUSE_BZIP2", + "L_BZ2=-lbz2", + "macosx", + "LFLAGS1=-liconv" + system "make", "prefix=#{prefix}", "MANDIR=#{man1}", "install" + end + + test do + (testpath/"test1").write "Hello!" + (testpath/"test2").write "Bonjour!" + (testpath/"test3").write "Hej!" + + system "/usr/bin/zip", "test.zip", "test1", "test2", "test3" + %w[test1 test2 test3].each do |f| + rm f + refute_predicate testpath/f, :exist?, "Text files should have been removed!" + end + + system bin/"unzip", "test.zip" + %w[test1 test2 test3].each do |f| + assert_predicate testpath/f, :exist?, "Failure unzipping test.zip!" + end + + assert_match "Hello!", File.read(testpath/"test1") + assert_match "Bonjour!", File.read(testpath/"test2") + assert_match "Hej!", File.read(testpath/"test3") + end +end diff --git a/Formula/xz.rb b/Formula/xz.rb new file mode 100644 index 0000000..06b74ca --- /dev/null +++ b/Formula/xz.rb @@ -0,0 +1,63 @@ +# Upstream project has requested we use a mirror as the main URL +# https://github.com/Homebrew/legacy-homebrew/pull/21419 +class Xz < Formula + desc "General-purpose data compression with high compression ratio" + homepage "https://tukaani.org/xz/" + # The archive.org mirror below needs to be manually created at `archive.org`. + url "https://downloads.sourceforge.net/project/lzmautils/xz-5.4.4.tar.gz" + mirror "https://tukaani.org/xz/xz-5.4.4.tar.gz" + mirror "https://archive.org/download/xz-5.4.4/xz-5.4.4.tar.gz" + mirror "http://archive.org/download/xz-5.4.4/xz-5.4.4.tar.gz" + sha256 "aae39544e254cfd27e942d35a048d592959bd7a79f9a624afb0498bb5613bdf8" + license all_of: [ + :public_domain, + "LGPL-2.1-or-later", + "GPL-2.0-or-later", + "GPL-3.0-or-later", + ] + + bottle do + sha256 cellar: :any, arm64_sonoma: "2e78578e241975899342fa4ad4ca4315a4e74117696af09440cf2ce485febebb" + sha256 cellar: :any, arm64_ventura: "ba318d89eea54f33cc3613b1cb69ca4217a8f961e59026418e569e8421afbb8c" + sha256 cellar: :any, arm64_monterey: "c8a9e7812c258a3b5043c0207b8044ba099a0a4a97d3ab5314a0dbd171fff3f4" + sha256 cellar: :any, arm64_big_sur: "1857edbbd38cff88854e529670e708e6d87e9d01641e291efee79cafa82fe5b2" + sha256 cellar: :any, sonoma: "bc3b9885851178a5363c88917f7a439af880ec4ecdac24b0061608c5963b6bf6" + sha256 cellar: :any, ventura: "4c25f68798c0b4c9b869e78fdfbd9cd7f8f723c51ea56d643b5644456288d69e" + sha256 cellar: :any, monterey: "39a76706744e6f78f883c38e800d277bc6df71186313cc5fa362072d6c79f991" + sha256 cellar: :any, big_sur: "7bc66bbf17c331e226b65947a7b2c326a883bc70ccdd13127802612713ae1cc2" + sha256 x86_64_linux: "f68637417bc856ba59f1ec25f7fcb0ccba14a9d53557837dcf2ab0ddb652fb8b" + end + + def install + system "./configure", "--disable-debug", + "--disable-dependency-tracking", + "--disable-silent-rules", + "--prefix=#{prefix}" + system "make", "check" + system "make", "install" + end + + test do + path = testpath/"data.txt" + original_contents = "." * 1000 + path.write original_contents + + # compress: data.txt -> data.txt.xz + system bin/"xz", path + refute_predicate path, :exist? + + # decompress: data.txt.xz -> data.txt + system bin/"xz", "-d", "#{path}.xz" + assert_equal original_contents, path.read + + # Check that http mirror works + xz_tar = testpath/"xz.tar.gz" + stable.mirrors.each do |mirror| + next if mirror.start_with?("https") + + xz_tar.unlink if xz_tar.exist? + system "curl", "--location", mirror, "--output", xz_tar + assert_equal stable.checksum.hexdigest, xz_tar.sha256 + end + end +end