homebrew-core/Formula/rpm.rb
ilovezfs ec749cc657 rpm: don't use Gpg.executable
Just assume gpg is HOMEBREW_PREFIX/"bin/gpg"
2017-12-30 13:35:39 -08:00

105 lines
3.2 KiB
Ruby

class Rpm < Formula
desc "Standard unix software packaging tool"
homepage "http://www.rpm.org/"
url "http://ftp.rpm.org/releases/rpm-4.14.x/rpm-4.14.0.tar.bz2"
sha256 "06a0ad54600d3c42e42e02701697a8857dc4b639f6476edefffa714d9f496314"
revision 1
version_scheme 1
bottle do
sha256 "3352d66eee4f6bb9f10b9003c1800e7caa9f82dc4fc341b5d66584bfc84db63f" => :high_sierra
sha256 "846ed9634a64472a13948e1f14d156f57f2b7aa0628733afdd38b403f66aea92" => :sierra
sha256 "685be758e9ccc3dcbd54d0a2a14c75d7d64529b7e36421a58189d0bab70f57f2" => :el_capitan
end
depends_on "pkg-config" => :run
depends_on "berkeley-db"
depends_on "gettext"
depends_on "libarchive"
depends_on "libmagic"
depends_on "lua@5.1"
depends_on "openssl@1.1"
depends_on "popt"
depends_on "xz"
depends_on "zstd"
def install
ENV.prepend_path "PKG_CONFIG_PATH", Formula["lua@5.1"].opt_libexec/"lib/pkgconfig"
# only rpm should go into HOMEBREW_CELLAR, not rpms built
inreplace ["macros.in", "platform.in"], "@prefix@", HOMEBREW_PREFIX
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}",
"--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=homebrew"
system "make", "install"
end
def post_install
(var/"lib/rpm").mkpath
# Attempt to fix expected location of GPG to a sane default.
inreplace lib/"rpm/macros", "/usr/bin/gpg2", HOMEBREW_PREFIX/"bin/gpg"
end
def test_spec
<<~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
%install
mkdir -p $RPM_BUILD_ROOT/tmp
touch $RPM_BUILD_ROOT/tmp/test
%files
/tmp/test
%changelog
EOS
end
def rpmdir(macro)
Pathname.new(`#{bin}/rpm --eval #{macro}`.chomp)
end
test do
(testpath/"rpmbuild").mkpath
(testpath/".rpmmacros").write <<~EOS
%_topdir #{testpath}/rpmbuild
%_tmppath %{_topdir}/tmp
EOS
system "#{bin}/rpm", "-vv", "-qa", "--dbpath=#{testpath}/var/lib/rpm"
assert_predicate testpath/"var/lib/rpm/Packages", :exist?,
"Failed to create 'Packages' file!"
rpmdir("%_builddir").mkpath
specfile = rpmdir("%_specdir")+"test.spec"
specfile.write(test_spec)
system "#{bin}/rpmbuild", "-ba", specfile
assert_predicate rpmdir("%_srcrpmdir")/"test-1.0-1.src.rpm", :exist?
assert_predicate rpmdir("%_rpmdir")/"noarch/test-1.0-1.noarch.rpm", :exist?
system "#{bin}/rpm", "-qpi", "--dbpath=#{testpath}/var/lib/rpm",
rpmdir("%_rpmdir")/"noarch/test-1.0-1.noarch.rpm"
end
end