Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V7.1.0 #147

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/create-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ jobs:
run: |
/usr/local/bin/brew install --overwrite [email protected] || echo "Ignore errors on this 1"
/usr/local/bin/brew link --overwrite [email protected] || echo "Ignore errors on this 2"
/usr/local/bin/brew install --overwrite dpkg rpm upx zip make wget jq || echo "Ignore errors on this 3"
/usr/local/bin/brew install --overwrite dpkg upx zip make wget jq || echo "Ignore errors on this 3"
/usr/local/bin/brew link --overwrite [email protected] || echo "Ignore errors on this 4"
/usr/local/bin/brew install [email protected] || echo "Ignore errors on this 5"
/usr/local/bin/brew install [email protected] || echo "Ignore errors on this 6"
cd ~/work/aerolab/aerolab/Formula && /usr/local/bin/brew install ./rpm.rb
- name: "Install golang"
run: |
wget https://go.dev/dl/go1.21.0.darwin-amd64.pkg
Expand Down
154 changes: 154 additions & 0 deletions Formula/rpm.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
class Rpm < Formula
desc "Standard unix software packaging tool"
homepage "https://rpm.org/"
license "GPL-2.0-only"
version_scheme 1
head "https://github.com/rpm-software-management/rpm.git", branch: "master"

stable do
url "https://ftp.osuosl.org/pub/rpm/releases/rpm-4.18.x/rpm-4.18.1.tar.bz2"
sha256 "37f3b42c0966941e2ad3f10fde3639824a6591d07197ba8fd0869ca0779e1f56"

# Fix an "expected expression" error. Remove on next release.
patch do
url "https://github.com/rpm-software-management/rpm/commit/b960c0b43a080287a7c13533eeb2d9f288db1414.patch?full_index=1"
sha256 "28417a368e4d4a6c722944a8fe325212b3cea96b6d355437c6366606a7ca0d00"
end
end

# Upstream uses a 90+ patch to indicate prerelease versions (e.g., the
# tarball for "RPM 4.19 ALPHA" is `rpm-4.18.90.tar.bz2`).
livecheck do
url "https://rpm.org/download.html"
regex(/href=.*?rpm[._-]v?(\d+\.\d+(?:\.(?:\d|[1-8]\d+)(?:\.\d+)*))\.t/i)
end

bottle do
rebuild 1
sha256 arm64_ventura: "2d97d36743ae989839e7ef4c4d3f396c2f7cd5ab7ff87b429510a4bb9b047cf7"
sha256 ventura: "d5085f39aee9be16443d96ba081f46cfb80818dc6f0c3bb5367f6d79b62c51fd"
sha256 x86_64_linux: "f7021265bd0654607b2e50709a8e29f0be08e3da8ca407566b04109fa0d176e8"
end

depends_on "gettext"
depends_on "libarchive"
depends_on "libmagic"
depends_on "lua"
depends_on macos: :ventura
depends_on "openssl@3"
depends_on "pkg-config"
depends_on "popt"
depends_on "sqlite"
depends_on "xz"
depends_on "zstd"

uses_from_macos "bzip2"
uses_from_macos "zlib"

on_macos do
depends_on "libomp"
end

conflicts_with "rpm2cpio", because: "both install `rpm2cpio` binaries"

def install
ENV.append "LDFLAGS", "-lomp" if OS.mac?

# only rpm should go into HOMEBREW_CELLAR, not rpms built
inreplace ["macros.in", "platform.in"], "@prefix@", HOMEBREW_PREFIX

# ensure that pkg-config binary is found for dep generators
inreplace "scripts/pkgconfigdeps.sh",
"/usr/bin/pkg-config", Formula["pkg-config"].opt_bin/"pkg-config"

system "./configure", *std_configure_args,
"--disable-silent-rules",
"--localstatedir=#{var}",
"--sharedstatedir=#{var}/lib",
"--sysconfdir=#{etc}",
"--with-path-magic=#{HOMEBREW_PREFIX}/share/misc/magic",
"--enable-nls",
"--disable-plugins",
"--with-external-db",
"--with-crypto=openssl",
"--without-apidocs",
"--with-vendor=#{tap.user.downcase}",
# Don't allow superenv shims to be saved into lib/rpm/macros
"__MAKE=/usr/bin/make",
"__GIT=/usr/bin/git",
"__LD=/usr/bin/ld",
# GPG is not a strict dependency, so set stored GPG location to a decent default
"__GPG=#{Formula["gpg"].opt_bin}/gpg"

system "make", "install"

# NOTE: We need the trailing `/` to avoid leaving it behind.
inreplace lib/"rpm/macros", "#{Superenv.shims_path}/", ""
inreplace lib/"rpm/brp-remove-la-files", "--null", "-0"
end

def post_install
(var/"lib/rpm").mkpath
safe_system bin/"rpmdb", "--initdb" unless (var/"lib/rpm/rpmdb.sqlite").exist?
end

test do
ENV["HOST"] = "test"
(testpath/".rpmmacros").write <<~EOS
%_topdir %(echo $HOME)/rpmbuild
%_tmppath %_topdir/tmp
EOS

system bin/"rpmdb", "--initdb", "--root=#{testpath}"
system bin/"rpm", "-vv", "-qa", "--root=#{testpath}"
assert_predicate testpath/var/"lib/rpm/rpmdb.sqlite", :exist?,
"Failed to create 'rpmdb.sqlite' file"

%w[SPECS BUILD BUILDROOT].each do |dir|
(testpath/"rpmbuild/#{dir}").mkpath
end
specfile = testpath/"rpmbuild/SPECS/test.spec"
specfile.write <<~EOS
Summary: Test package
Name: test
Version: 1.0
Release: 1
License: Public Domain
Group: Development/Tools
BuildArch: noarch

%description
Trivial test package

%prep
%build
echo "hello brew" > test

%install
install -d $RPM_BUILD_ROOT/%_docdir
cp test $RPM_BUILD_ROOT/%_docdir/test

%files
%_docdir/test

%changelog

EOS
system bin/"rpmbuild", "-ba", specfile
assert_predicate testpath/"rpmbuild/SRPMS/test-1.0-1.src.rpm", :exist?
assert_predicate testpath/"rpmbuild/RPMS/noarch/test-1.0-1.noarch.rpm", :exist?

info = shell_output(bin/"rpm --query --package -i #{testpath}/rpmbuild/RPMS/noarch/test-1.0-1.noarch.rpm")
assert_match "Name : test", info
assert_match "Version : 1.0", info
assert_match "Release : 1", info
assert_match "Architecture: noarch", info
assert_match "Group : Development/Tools", info
assert_match "License : Public Domain", info
assert_match "Source RPM : test-1.0-1.src.rpm", info
assert_match "Trivial test package", info

files = shell_output(bin/"rpm --query --list --package #{testpath}/rpmbuild/RPMS/noarch/test-1.0-1.noarch.rpm")
assert_match (HOMEBREW_PREFIX/"share/doc/test").to_s, files
end
end
Loading