Sunday, January 25, 2015

Unpack Mac Packages in Bash

alias unpkg='_(){ if [[ ! $# -eq 1 ]] || [[ ! -f "${1}" ]]; then echo "Usage: unpkg <~file~.pkg>"; else 7z x "${1}"; for a in *.pkg; do if [[ -d "$a" ]]; then cd "$a"; cat Payload | gunzip -dc |cpio -i; cd -; fi; done; fi; }; _'

This alias is not recursive, and will only process one level of pkg's if further pkg files exist you will have to re-run this alias on them as you find them, requires 7z (apt-get install p7zip-full).

Its also recommended to create a new directory and copy the pkg file into it before running, especially when you don't know what may be inside and it makes it easier to see what was extracted.

No comments:

Post a Comment