FWIW, I found the code in the Sample Site to be unreliable. It’s entirely possible that I’m doing something wrong, but it works fine if the package doesn’t exist on the target site. If there is an older version there, however, it appears to install the newer version without updating the version number in the PM grid (and there are errors with installing the main component). The subpackage doesn’t uninstall properly. Worse yet, when I uninstall the main package, it appears to uninstall successfully, but none of the elements are removed, I ended up with quite a mess.
I settled for just copying the transport.zip files to core/packages with a file resolver and letting the user install them manually, since that method is completely bulletproof.
<?php
$root = dirname(dirname(__FILE__)) . '/';
$sources= array (
/* ... */
'packages'=> $root . 'core/packages',
);
if ($hasSubPackages) {
$modx->log(modX::LOG_LEVEL_INFO, 'Adding in subpackages.');
$vehicle->resolve('file',array(
'source' => $sources['packages'],
'target' => "return MODX_CORE_PATH;",
));
}