Skip to content

Instantly share code, notes, and snippets.

@rmi1974
Last active November 20, 2023 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmi1974/a22123b39a4793b8476e9dee486f057b to your computer and use it in GitHub Desktop.
Save rmi1974/a22123b39a4793b8476e9dee486f057b to your computer and use it in GitHub Desktop.
How to unpack Wine MacOS packages (.pkg) on Linux #wine #macos #commandlinefu #debug

How to unpack Wine MacOS packages (.pkg) on Linux

Mentioned in Wine Bugzilla #48418. Download of package from WineHQ MacOS downloads.

$ sha1sum winehq-devel-5.0-rc4.pkg 
1abaaef7539226f19476ec70dad8741c26b3dbc2  winehq-devel-5.0-rc4.pkg

$ du -sh winehq-devel-5.0-rc4.pkg 
276M	winehq-devel-5.0-rc4.pkg

You need xar tool for extracting macOS .pkg files on Linux. See Open/Extract xar/pkg File with Freeware on Windows/Mac/Linux for overview.

xar (short for eXtensible ARchive) is an open source file archiver and the archiver's file format. It was created within the OpenDarwin project and is used in Mac OS X 10.5 for software installation routines, as well as browser extensions in Safari 5.0. Xar replaced the use of gzipped pax files.

pkg is just .xar archives with a different extension and a specified file hierarchy. pkg is an OS X Installer file. This file format is used by Apple Inc. on its Macintosh line of computers and on the iPhone. It is also used by Sony PlayStation 3 on downloadable content over PlayStation Network. The contents of a PKG file can be installed using the Apple Installer application.

Extract the .pkg file:

$ mkdir -p winehq-devel-5.0-rc4 && cd $_

$ xar -xf ../winehq-devel-5.0-rc4.pkg

$ ll
total 28
-rw-r--r--. 1 focht focht 2994 Jan  4 01:07 Distribution
drwxr-xr-x. 3 focht focht 4096 Jan  5 15:07 org.winehq.wine-devel32.pkg
drwxr-xr-x. 3 focht focht 4096 Jan  5 15:08 org.winehq.wine-devel64.pkg
drwxr-xr-x. 2 focht focht 4096 Jan  5 15:06 org.winehq.wine-devel-deps64.pkg
drwxr-xr-x. 2 focht focht 4096 Jan  5 15:06 org.winehq.wine-devel-deps.pkg
drwxr-xr-x. 3 focht focht 4096 Jan  5 15:10 org.winehq.wine-devel.pkg
drwxr-xr-x. 2 focht focht 4096 Jan  5 15:06 Resources

Extract resources:

$ cd org.winehq.wine-devel.pkg/

$ cat Payload | gunzip -dc |cpio -i
735228 blocks
$ file Contents/Resources/wine/lib/wine/write.exe
Contents/Resources/wine/lib/wine/write.exe: PE32 executable (GUI) Intel 80386, for MS Windows

Links

@camilasan
Copy link

For Archlinux: https://linux-packages.com/aur/package/xar-tpoechtrage-git

and then install pax (Portable Archive Interchange - the POSIX standard archive tool for cpio and tar formats):
pacman -S pax

So instead of:
$ cat Payload | gunzip -dc |cpio -i

run:
cat Payload | gunzip -dc | paxcpio -i

It should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment