首页 文章

Homebrew:如何列出已安装的瓶子及其操作系统版本?

提问于
浏览
2

我最近将Mac OS X升级到优胜美地,我想确保我目前安装的每个包都是Yosemite瓶 .

如何列出已安装的瓶子及其操作系统版本,以便最终卸载/安装它们?


EDIT Grepping字符串"bottled"赢了't work because it is there anyway if a bottle is available for the package, but you can still compile from source. For example I' ve刚从源构建yasm而 brew info yasm 返回:

yasm: stable 1.3.0 (bottled), HEAD
Modular BSD reimplementation of NASM
http://yasm.tortall.net/
/usr/local/Cellar/yasm/1.3.0 (44 files, 3.3M) *
  Built from source
[...]

1 回答

  • 1

    Updated Answer

    /usr/local/Cellar 中的每个 homebrew 包中似乎都有一个 INSTALL_RECEIPT.json ,例如这适用于OpenCV

    /usr/local/Cellar/opencv/2.4.12/INSTALL_RECEIPT.json
    

    它是标准的JSON,因此您可以像这样解析它而无需其他工具:

    python -mjson.tool /usr/local/Cellar/opencv/2.4.12/INSTALL_RECEIPT.json
    

    你得到这个 - 这可能有助于你的事业......也许吧 .

    {
        "HEAD": "d60f75135ecf1a667539700ad7916cefbcc98480",
        "built_as_bottle": false,
        "compiler": "clang",
        "poured_from_bottle": false,
        "source": {
            "path": "/usr/local/Library/Taps/homebrew/homebrew-science/opencv.rb",
            "spec": "stable",
            "tap": "homebrew/homebrew-science"
        },
        "stdlib": "libcxx",
        "time": 1444317226,
        "unused_options": [
            "--32-bit",
            "--with-java",
            "--with-qt",
            "--with-tbb",
            "--without-tests",
            "--without-opencl",
            "--with-cuda",
            "--with-quicktime",
            "--with-opengl",
            "--with-ximea",
            "--without-numpy",
            "--without-python",
            "--c++11",
            "--without-eigen",
            "--with-gstreamer",
            "--with-jasper",
            "--with-libdc1394",
            "--without-openexr",
            "--with-openni",
            "--with-ffmpeg"
        ],
        "used_options": []
    }
    

    您还可以以JSON格式获取 brew info 命令的输出,例如:

    brew info imagemagick --json=v1 | jq "."
    [
      {
        "name": "imagemagick",
        "full_name": "imagemagick",
        "desc": "Tools and libraries to manipulate images in many formats",
        "homepage": "http://www.imagemagick.org",
        "oldname": null,
        "versions": {
          "stable": "6.9.2-3",
          "bottle": true,
          "devel": null,
          "head": "HEAD"
        },
        "revision": 0,
        "installed": [
          {
            "version": "6.9.2-3",
            "used_options": [
              "--with-x11"
            ],
            "built_as_bottle": null,
            "poured_from_bottle": false
          }
        ],
        "linked_keg": "6.9.2-3",
        "keg_only": null,
        "dependencies": [
          "xz",
          "libtool",
          "pkg-config",
          "jpeg",
          "libpng",
          "libtiff",
          "freetype",
          "fontconfig",
          "little-cms",
          "little-cms2",
          "libwmf",
          "librsvg",
          "liblqr",
          "openexr",
          "ghostscript",
          "webp",
          "fftw",
          "pango"
        ],
        "conflicts_with": [],
        "caveats": null,
        "requirements": [
          {
            "name": "x11",
            "default_formula": null,
            "cask": "xquartz",
            "download": "https://xquartz.macosforge.org"
          }
        ],
        "options": [
          {
            "option": "--with-fftw",
            "description": "Compile with FFTW support"
          },
          {
            "option": "--with-hdri",
            "description": "Compile with HDRI support"
          },
          {
            "option": "--with-jp2",
            "description": "Compile with Jpeg2000 support"
          },
          {
            "option": "--with-openmp",
            "description": "Compile with OpenMP support"
          },
          {
            "option": "--with-perl",
            "description": "enable build/install of PerlMagick"
          },
          {
            "option": "--with-quantum-depth-8",
            "description": "Compile with a quantum depth of 8 bit"
          },
          {
            "option": "--with-quantum-depth-16",
            "description": "Compile with a quantum depth of 16 bit"
          },
          {
            "option": "--with-quantum-depth-32",
            "description": "Compile with a quantum depth of 32 bit"
          },
          {
            "option": "--without-opencl",
            "description": "Disable OpenCL"
          },
          {
            "option": "--without-magick-plus-plus",
            "description": "disable build/install of Magick++"
          },
          {
            "option": "--without-jpeg",
            "description": "Build without jpeg support"
          },
          {
            "option": "--without-libpng",
            "description": "Build without libpng support"
          },
          {
            "option": "--without-libtiff",
            "description": "Build without libtiff support"
          },
          {
            "option": "--without-freetype",
            "description": "Build without freetype support"
          },
          {
            "option": "--with-x11",
            "description": "Build with x11 support"
          },
          {
            "option": "--with-fontconfig",
            "description": "Build with fontconfig support"
          },
          {
            "option": "--with-little-cms",
            "description": "Build with little-cms support"
          },
          {
            "option": "--with-little-cms2",
            "description": "Build with little-cms2 support"
          },
          {
            "option": "--with-libwmf",
            "description": "Build with libwmf support"
          },
          {
            "option": "--with-librsvg",
            "description": "Build with librsvg support"
          },
          {
            "option": "--with-liblqr",
            "description": "Build with liblqr support"
          },
          {
            "option": "--with-openexr",
            "description": "Build with openexr support"
          },
          {
            "option": "--with-ghostscript",
            "description": "Build with ghostscript support"
          },
          {
            "option": "--with-webp",
            "description": "Build with webp support"
          },
          {
            "option": "--with-pango",
            "description": "Build with pango support"
          }
        ],
        "bottle": {
          "stable": {
            "revision": 0,
            "cellar": "/usr/local/Cellar",
            "prefix": "/usr/local",
            "root_url": "https://homebrew.bintray.com/bottles",
            "files": {
              "el_capitan": {
                "url": "https://homebrew.bintray.com/bottles/imagemagick-6.9.2-3.el_capitan.bottle.tar.gz",
                "sha256": "cd5edb53eae0271771df4a77a401a50e973b200ae875a04ef6a3f4d467ca2ef4"
              },
              "yosemite": {
                "url": "https://homebrew.bintray.com/bottles/imagemagick-6.9.2-3.yosemite.bottle.tar.gz",
                "sha256": "fbe139e4d7b540ce03fcde6a7735d9e79ed8652827cd7c877e551abcf804a494"
              },
              "mavericks": {
                "url": "https://homebrew.bintray.com/bottles/imagemagick-6.9.2-3.mavericks.bottle.tar.gz",
                "sha256": "99f2f95739d3ee11535fea62440f1608ce0ee1ef22bda2f878353360ab45e9cc"
              }
            }
          }
        }
      }
    ]
    

    Original Answer

    所以你想要的是不是从源头构建的瓶装包装 .

    # List all installed packages
    for p in $(brew list); do
       # Get info about this particular one...
       # ... if bottled and not from source, print first line
       brew info $p | awk '/bottled/{p=$0} /Built from source/{p=""} END{if(length(p))print p}'
    done
    

    如果您没有安装太多软件包,您可能会侥幸成功:

    brew info $(brew list) | awk ...
    

相关问题