2

My python code need to unpack a .pkg file, modify some file there and pack it again. Any mature python module to suggest? I saw there's pyxar (xarfile), which requires install xar on the machine first.

Any other options I could choose?

Finally decided to call xar from python directly, which actually could work. But another problem is that, the Scripts under payload.kg within the package is not unpacked. It suppose to be a directory, but remains as a file. Strange thing is that, the file Scripts shows as a gzip compressed data, from Unix. But I cannot use gzip to open it no matter on mac or linux. On mac, I can do tar -xf to open it, but on linux cannot. Any suggestion?

Thanks!

lucky_start_izumi
  • 1,967
  • 13
  • 37
  • 56
  • I've tried before and failed +1 – dsgdfg Aug 26 '15 at 18:32
  • then how did you solve it? @SDilmac – lucky_start_izumi Aug 26 '15 at 19:42
  • Failed ! can't solve ... – dsgdfg Aug 26 '15 at 19:43
  • Anyone has some ideas? – lucky_start_izumi Aug 27 '15 at 15:50
  • 1
    This might be useful if you haven't seen it yet: http://stackoverflow.com/questions/11298855/how-to-unpack-and-pack-pkg-file – ArtOfWarfare Aug 28 '15 at 21:07
  • @ArtOfWarfare thank you, that one is helpful :) But I need to have xar installed on my machine, wondering if there's a pure python approach I could use? – lucky_start_izumi Aug 28 '15 at 22:58
  • @XuanziHan - `xar` is already installed on my computer. I never intentionally installed it - it may have come with the command line tools that Xcode had me install. Anyways, I'll look into it to see if I can find the source code... might be feasible to port it to pure Python. – ArtOfWarfare Aug 29 '15 at 00:58
  • @XuanziHan - I appear to have found the source here. They have some documentation on how it works, and then you can use `svn` to download the source, it looks like: https://code.google.com/p/xar/ – ArtOfWarfare Aug 29 '15 at 01:06
  • @XuanziHan - It looks like all of the code you would need to port is in `xar/src/xar.c`. It has a lot of other C dependencies that it uses... I see xml readers and writers, getopt, regex... but there are equivalents for all of that in the Python standard library. It's about 900 lines of C code, so probably no more than ~300 lines of Python code if you want to port it. – ArtOfWarfare Aug 29 '15 at 01:19
  • @ArtOfWarfare, thanks so much :) Finally decided to call the command line from python directly. – lucky_start_izumi Aug 31 '15 at 22:04
  • Strange thing is that, the file Scripts shows as a gzip compressed data, from Unix. But I cannot use gzip to open it no matter on mac or linux. On mac, I can do tar -xf to open it, but on linux cannot. Any suggestion? – lucky_start_izumi Sep 01 '15 at 01:02

0 Answers0