如何使用命令行提取xip存档? [英] How to extract xip archive using command line?

查看:152
本文介绍了如何使用命令行提取xip存档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找如何使用命令行来提取XIP存档的方法,所以我要把自己的解决方案作为bash函数留在这里.

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.

我找到了灵感这里.

推荐答案

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"
}

我们首先检查xip文件签名,然后使用xar提取其内容.然后,我们使用Jonathan Levin pbzx 正确地解包pbzx块并将输出通过管道传送到tar,跳过.,以避免覆盖当前的工作目录权限.

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.

这是在OS X El Capitan上解压缩Xcode8.xip档案的窍门.

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

这篇关于如何使用命令行提取xip存档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆