Michelle
Michelle

Reputation: 21

Is there a way to unarchive a dmg file like a tar.gz file? (Using Mac OS)

I'm trying to use a program that uses Linux versions of other programs. I ran this in 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

But it downloads the linux version of the program files into my directory -- yielding the error:

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

I understand in order for this to work on my computer, I need to use the version for Mac OS, however, I stuck on how one might go about "unarchiving" the files contained within a .dmg file so I can access c3d in bin.

I edited it to this, but I understand I cannot use the tar -xzvf command in this context -- is there an equivalent to tar -xzvf to "unpack" dmg files?

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

Upvotes: 2

Views: 1930

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207465

Try using 7-zip. You can install it on a Mac with homebrew using:

brew install p7zip

Then run it with:

7z

Please see comment by @StefanSchmidt about a possible alternative package.

Upvotes: 2

Chris Hess
Chris Hess

Reputation: 207

First you have to mount the DMG file. command: hdiutil mount test.dmg

Upvotes: 0

Related Questions