Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unpack and pack pkg file?

Tags:

macos

pkg-file

I have a pkg file created by Install Maker for Mac. I want to replace one file in pkg. But I must do this under Linux system, because this is a part of download process. When user starts to download file server must replace one file in pkg. I have a solution how unpack pkg and replace a file but I dont know how pack again to pkg. http://emresaglam.com/blog/1035 http://ilostmynotes.blogspot.com/2012/06/mac-os-x-pkg-bom-files-package.html

like image 594
dream2work Avatar asked Jul 02 '12 18:07

dream2work


People also ask

How do I unpack a .pkg file in Windows?

WinRAR comes with multiple threading features which enable you to extract or open multiple . pkg files simultaneously. Nevertheless, WinRAR is also lightweight and utilizes little computer resources. This software is compatible with all versions of the Windows OS, including Windows 10.

How do you open pkg files?

How to open a PKG file. Since PKG files are plain text files, you can open and edit them in any text editor, such as Microsoft Notepad (Windows) or Apple TextEdit (Mac).


1 Answers

Packages are just .xar archives with a different extension and a specified file hierarchy. Unfortunately, part of that file hierarchy is a cpio.gz archive of the actual installables, and usually that's what you want to edit. And there's also a Bom file that includes information on the files inside that cpio archive, and a PackageInfo file that includes summary information.

If you really do just need to edit one of the info files, that's simple:

mkdir Foo cd Foo xar -xf ../Foo.pkg # edit stuff xar -cf ../Foo-new.pkg * 

But if you need to edit the installable files:

mkdir Foo cd Foo xar -xf ../Foo.pkg cd foo.pkg cat Payload | gunzip -dc |cpio -i # edit Foo.app/* rm Payload find ./Foo.app | cpio -o | gzip -c > Payload mkbom Foo.app Bom # or edit Bom # edit PackageInfo rm -rf Foo.app cd .. xar -cf ../Foo-new.pkg 

I believe you can get mkbom (and lsbom) for most linux distros. (If you can get ditto, that makes things even easier, but I'm not sure if that's nearly as ubiquitously available.)

like image 90
abarnert Avatar answered Oct 03 '22 04:10

abarnert