首页 > 解决方案 > 有没有办法像 tar.gz 文件一样解压缩 dmg 文件?(使用 Mac 操作系统)

问题描述

我正在尝试使用使用 Linux 版本的其他程序的程序。我在 bash 中运行了这个:

c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
    echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
    mkdir -p "${SCRIPTPATH}/depends/c3d/"
    wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-Linux-x86_64.tar.gz && \
    tar -xzvf c3d-nightly-Linux-x86_64.tar.gz && mv c3d-1.1.0-Linux-x86_64/* "${SCRIPTPATH}/depends/c3d/" && \
    rm c3d-nightly-Linux-x86_64.tar.gz
    export PATH="${SCRIPTPATH}/depends/c3d/c3d-1.1.0-Linux-x86_64/bin/:$PATH"
fi

但它将程序文件的 linux 版本下载到我的目录中 - 产生错误:

{..omitted}/HippMapp3r/depends/c3d/bin/c3d: cannot execute binary file
Return Code: 126

我知道为了让它在我的计算机上运行,​​我需要使用 Mac OS 的版本,但是,我坚持如何“取消归档”包含在 .dmg 文件中的文件,以便我可以访问 bin 中的 c3d .

我对此进行了编辑,但我知道我不能在这种情况下使用 tar -xzvf 命令——是否有与 tar -xzvf 等效的“解包”dmg 文件?

c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
    echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
    mkdir -p "${SCRIPTPATH}/depends/c3d/"
    wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-MacOS-x86_64.dmg && \
    tar -xzvf c3d-nightly-MacOS-x86_64.dmg * "${SCRIPTPATH}/depends/c3d/" && \
    rm c3d-nightly-MacOS-x86_64.dmg
    export PATH="${SCRIPTPATH}/depends/c3d/c3d-nightly-MacOS-x86_64/bin/:$PATH"
fi

标签: bashmacosbinaryfiles

解决方案


首先,您必须安装 DMG 文件。命令:hdiutil mount test.dmg


推荐阅读