How to extract xip archive using command line?

筅森魡賤 提交于 2019-12-03 09:26:59

问题


I searched around how to extract XIP archive using command line with no luck so I am leaving my own solution, as a bash function, here.

I found my inspiration here.


回答1:


function unxip()
{
    [ -z "$1" ] && echo "usage: unxip /path/to/archive.xip" && return

    # http://newosxbook.com/src.jl?tree=listings&file=pbzx.c
    PBZX="/usr/local/src/pbzx/pbzx" && [ ! -x "$PBZX" ] && echo "$PBZX not found." && return

    [ ! -f "$1" ] && echo "$1 not found." && return

    [ -f "Content" ] || [ -f "Metadata" ] && echo "Content or Metadata already exists." && return

    pkgutil --check-signature "$1" && xar -xf "$1" && "$PBZX" Content | sudo tar x --strip-components=1

    rm "Content" "Metadata"
}

We first check for xip file signature then extract its contents using xar. We then use Jonathan Levin pbzx to properly unpack pbzx chunks and pipe the output to tar, skipping . to avoid overwriting current working directory permissions.

This does the trick to unpack Xcode8.xip archives on OS X El Capitan.




回答2:


You could try:

xip -x [path to .xip file]




回答3:


open -W archive.xip will work better since it will then block until the archive has finished opening.




回答4:


On macOS Mojave (not sure about other OS versions), navigate to the directory into which you’d like to expand the contents, then run xip --expand /path/to/xip.xip. For instance:

iMac:Applications jeff$ xip --expand /Users/jeff/Downloads/Xcode_11_Beta.xip



回答5:


Use unxip. You can install it with Homebrew:

brew install thii/unxip/unxip

To extract a .xip file:

unxip path/to/.xip



回答6:


You could just run:

open archive.xip


来源:https://stackoverflow.com/questions/40414645/how-to-extract-xip-archive-using-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!