【问题标题】:Homebrew: How to install an old version of a formula which uses a bottle?Homebrew:如何安装使用瓶子的旧版本的公式?
【发布时间】:2020-02-12 14:35:22
【问题描述】:

我想使用旧版本的poppler,它在某些程序中需要用于内联 PDF 显示。 由于与程序不兼容,我无法使用最新的。

我已经设法发现要安装带有选项--with-qtpoppler,我需要一个旧版本的poppler.rb 公式。我从 github homebrew-core tap 获得了这个版本,我认为它应该可以工作。到目前为止,一切都很好。现在,如果我尝试安装此公式--with-qt,我会收到 qt 已过时的消息,这是因为最新的自制 qt 无法再安装在我的操作系统上。

因此,我也需要安装旧版本的 qt。因此,我还从 github 获得了 qt-5.11.2 的旧公式,将公式修改为 qt@5112 而只是 qt 并尝试安装它,但我总是收到消息说这个 @5112formula 正在尝试下载一些来自

的瓶子
https://homebrew.bintray.com/bottles/qt@51122-5.11.2.el_capitan.bottle.tar.gz

它不存在,因为它只被称为https://homebrew.bintray.com/bottles/qt-5.11.2......。有谁知道如何解决这个问题?即:如何重命名一些瓶子?或者qt-5.11.2的公式从qtqt@5112

或者有没有更好的方法来破解这个酿造公式?

我真的很欣赏一些有用的输入。谢谢!


我正在尝试安装qt@5112.rb 公式(从here 修改为@5112):

# Patches for Qt must be at the very least submitted to Qt's Gerrit codereview
# rather than their bug-report Jira. The latter is rarely reviewed by Qt.
class QtAT5112 < Formula
  desc "Cross-platform application and UI framework"
  homepage "https://www.qt.io/"
  url "https://download.qt.io/official_releases/qt/5.11/5.11.2/single/qt-everywhere-src-5.11.2.tar.xz"
  mirror "https://qt.mirror.constant.com/archive/qt/5.11/5.11.2/single/qt-everywhere-src-5.11.2.tar.xz"
  mirror "https://ftp.osuosl.org/pub/blfs/conglomeration/qt5/qt-everywhere-src-5.11.2.tar.xz"
  sha256 "c6104b840b6caee596fa9a35bc5f57f67ed5a99d6a36497b6fe66f990a53ca81"
  head "https://code.qt.io/qt/qt5.git", :branch => "5.12", :shallow => false

  bottle do
    sha256 "8c77b5762267b127cc31346ac4da805bbfd59e0180d90e1e8b77fb463e929d60" => :mojave
    sha256 "096d8894b25b0fdec9b77150704491993872a7848397a04870627534fb95c9e3" => :high_sierra
    sha256 "0464be51d0eb0a45de4a1d1c6200e1d9768eec5e9737050755497a4f4de66a08" => :sierra
    sha256 "22e9abc0b47541bb03b2da7f6a19c5d7640ea2314322564551adc3d22305806e" => :el_capitan
  end

  keg_only "Qt 5 has CMake issues when linked"

  option "with-examples", "Build examples"
  option "without-proprietary-codecs", "Don't build with proprietary codecs (e.g. mp3)"

  deprecated_option "with-mysql" => "with-mysql-client"

  depends_on "pkg-config" => :build
  depends_on :xcode => :build
  depends_on "mysql-client" => :optional
  depends_on "postgresql" => :optional

  # Restore `.pc` files for framework-based build of Qt 5 on macOS, partially
  # reverting <https://codereview.qt-project.org/#/c/140954/>
  # Core formulae known to fail without this patch (as of 2016-10-15):
  #   * gnuplot (with `--with-qt` option)
  #   * mkvtoolnix (with `--with-qt` option, silent build failure)
  #   * poppler (with `--with-qt` option)
  patch do
    url "https://raw.githubusercontent.com/Homebrew/formula-patches/e8fe6567/qt5/restore-pc-files.patch"
    sha256 "48ff18be2f4050de7288bddbae7f47e949512ac4bcd126c2f504be2ac701158b"
  end

  # Chromium build failures with Xcode 10, fixed upstream:
  # https://bugs.chromium.org/p/chromium/issues/detail?id=840251
  # https://bugs.chromium.org/p/chromium/issues/detail?id=849689
  patch do
    url "https://raw.githubusercontent.com/Homebrew/formula-patches/962f0f/qt/xcode10.diff"
    sha256 "c064398411c69f2e1c516c0cd49fcd0755bc29bb19e65c5694c6d726c43389a6"
  end

  def install
    args = %W[
      -verbose
      -prefix #{prefix}
      -release
      -opensource -confirm-license
      -system-zlib
      -qt-libpng
      -qt-libjpeg
      -qt-freetype
      -qt-pcre
      -nomake tests
      -no-rpath
      -pkg-config
      -dbus-runtime
    ]

    args << "-nomake" << "examples" if build.without? "examples"

    if build.with? "mysql-client"
      args << "-plugin-sql-mysql"
      (buildpath/"brew_shim/mysql_config").write <<~EOS
        #!/bin/sh
        if [ x"$1" = x"--libs" ]; then
          mysql_config --libs | sed "s/-lssl -lcrypto//"
        else
          exec mysql_config "$@"
        fi
      EOS
      chmod 0755, "brew_shim/mysql_config"
      args << "-mysql_config" << buildpath/"brew_shim/mysql_config"
    end

    args << "-plugin-sql-psql" if build.with? "postgresql"
    args << "-proprietary-codecs" if build.with? "proprietary-codecs"

    system "./configure", *args
    system "make"
    ENV.deparallelize
    system "make", "install"

    # Some config scripts will only find Qt in a "Frameworks" folder
    frameworks.install_symlink Dir["#{lib}/*.framework"]

    # The pkg-config files installed suggest that headers can be found in the
    # `include` directory. Make this so by creating symlinks from `include` to
    # the Frameworks' Headers folders.
    Pathname.glob("#{lib}/*.framework/Headers") do |path|
      include.install_symlink path => path.parent.basename(".framework")
    end

    # Move `*.app` bundles into `libexec` to expose them to `brew linkapps` and
    # because we don't like having them in `bin`.
    # (Note: This move breaks invocation of Assistant via the Help menu
    # of both Designer and Linguist as that relies on Assistant being in `bin`.)
    libexec.mkpath
    Pathname.glob("#{bin}/*.app") { |app| mv app, libexec }
  end

  def caveats; <<~EOS
    We agreed to the Qt open source license for you.
    If this is unacceptable you should uninstall.
  EOS
  end

  test do
    (testpath/"hello.pro").write <<~EOS
      QT       += core
      QT       -= gui
      TARGET = hello
      CONFIG   += console
      CONFIG   -= app_bundle
      TEMPLATE = app
      SOURCES += main.cpp
    EOS

    (testpath/"main.cpp").write <<~EOS
      #include <QCoreApplication>
      #include <QDebug>

      int main(int argc, char *argv[])
      {
        QCoreApplication a(argc, argv);
        qDebug() << "Hello World!";
        return 0;
      }
    EOS

    system bin/"qmake", testpath/"hello.pro"
    system "make"
    assert_predicate testpath/"hello", :exist?
    assert_predicate testpath/"main.o", :exist?
    system "./hello"
  end
end

【问题讨论】:

    标签: macos qt terminal homebrew


    【解决方案1】:

    你误解了一件事。 qtqt@5112 是两个不同的名称。 Homebrew 将它们识别为两个不同的软件包。

    但是旧的propplerdepends_on "qt",而不是qt@5112。您必须将公式文件 qt@5112 重命名为 qt

    【讨论】:

    • 我知道旧的 poppler 默认情况下依赖于 qt 但我会将其更改为依赖于 qt@5112 所以它应该将旧的 qt 作为依赖项。改回使用 qt 作为依赖项根本不能解决我的问题。那是最初的问题,因为我不能使用最新的 qt,因此 poppler 没有使用正常公式安装。因此,我按照描述开始了解决方法:你知道如何处理瓶子命名吗?所以brew install qt@5112.rb 安装旧的但使用名称qt@5112
    • @avermaet poppler 依赖于qt,但它没有指定版本。因此,您可以使用旧版本安装 popplerqt。先安装qt 5.11.2,brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/360923286c0f1a6a1325ada578df030bf579009f/Formula/qt.rb。那么依赖就满足了,就可以安装老版本了popplerbrew install url/to/old/poppler.rb
    • 我理解你的想法并尝试这样做,但后来我遇到了问题,因为 qt 需要安装完整的 Xcode,而不仅仅是命令行工具。而且我的操作系统上不再提供必要的 Xcode 版本。如果我在 poppler 公式中删除对 Xcode 的要求,我将收到错误错误:子进程中发生异常:ArgumentError:/usr/local/Cellar/poppler/0.81.0/lib/libpoppler-qt5.dylib : 没有这样的文件,即使我有来自 bottle/brew 的有效但过时的 qt-5.11.2。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-28
    • 2021-06-17
    • 1970-01-01
    相关资源
    最近更新 更多