Extract "Distribution" XML to get versions from downloaded packages using "xar" instead of "pkgutil --expand"#917
Conversation
…sing "xar" instead of "pkgutil --expand" All information about the why's and how's of extracting only the "Distribution" XML file from a package using "xar" have been written into the code comments. Basically, extracting ONLY the "Distribution" XML from the package can be a lot more efficient when dealing with large packages rather than extracting the entire package contents which could include large "Payload" files, etc. But, since "man xar" has a deprecation warning, this code checks if "xar" returned nothing in case of future removal or breakage and will fallback on extracting the entire package contents using "pkgutil --expand" like is currently being done. So, I think this is a win win since either the process is more efficient or the same as it currently is no matter what happens to "xar" in the future. If no version is detected either because the package is not a "distribution package" and therefore doesn't have a "Distribution" XML file or the XPath expression failed to retrieve a version for some reason, those errors will be logged by using new "appNewVersion" error values which would always just fail the "if [[ $appversion == $appNewVersion ]]; then" condition to always install the downloaded package when a version couldn't be detected for any reason.
|
I see that Installomator/fragments/functions.sh Line 664 in f07254c dev branch has an improved XPath expression to retrieve the version for the specific packageID.
I did not include this change since I was working off the |
Also exclude all digits and a few other common symbols in filenames to exclude that would never exist in the one and only "Distribution" filename that we want to extract.
|
I think the But I think it's not uncommon for folks to not include |
|
The reason we are expanding the entire archive is that the |
|
Just confirmed |
|
fyi, I had to update the xpath again to make it work for the Adobe Acrobat package: xpath patch |
All information about the why's and how's of extracting only the "Distribution" XML file from a package using "xar" have been written into the code comments. Basically, extracting ONLY the "Distribution" XML from the package can be a lot more efficient when dealing with large packages rather than extracting the entire package contents which could include large "Payload" files, etc.
But, since "man xar" has a deprecation warning, this code checks if "xar" returned nothing in case of future removal or breakage and will fallback on extracting the entire package contents using "pkgutil --expand" like is currently being done. So, I think this is a win win since either the process is more efficient or the same as it currently is no matter what happens to "xar" in the future.
If no version is detected either because the package is not a "distribution package" and therefore doesn't have a "Distribution" XML file or the XPath expression failed to retrieve a version for some reason, those errors will be logged by using new "appNewVersion" error values which would always just fail the "if [[ $appversion == $appNewVersion ]]; then" condition to always install the downloaded package when a version couldn't be detected for any reason.