4

Does anyone know how to retrieve the version number of a .pkg file which isn't installed yet?

I'd like to use something like pkgutil --pkg-info, but that only works for installed packages.

I've also tried installer -pkginfo -verbose, but that doesn't show the version number.

Is there a built-in command to do this, or alternatively, could someone suggest a one-liner please?

Thanks.

3

The best I could come up with was this:

pkgutil --expand package.pkg /tmp/pkg; cat /tmp/pkg/PackageInfo | grep ./Applications | grep -m 1 .app\" | awk '{ print $3, $2 }'; rm -rf /tmp/pkg

Not the most elegant solution, so I'm still searching for a way to do this without having to extract the .pkg first.

  • Have you found any better solution yet ?? I do not see any effect to changing package version number when building the pkg file. The final package always seem to replace the existing files anyway, isnt it ? – Ahmed Aug 15 '16 at 22:32
1

Variation of @d3Xt3r answer:

tar xOvf PackageName.pkg output.pkg/PackageInfo 2>/dev/null | grep '<pkg-info' \
    | sed "s#.* version=\"\([0-9\.]*\)\".*#\1#"

Advantage is that this is only pipe processing.

Note my package had different structure, there is an extra directory output.pkg which contains file PackageInfo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .