Separate bootstrapping from localPackageDirs in catalog initialization.

Previously, if localPackageDirs contained an app package that used a
troposphere package, the constraint solver would bomb out on that app
package. This commit separates out the checkout packages that we need for
bootstrapping catalog initialization from other local packages, which
are allowed to use troposphere packages.
This commit is contained in:
Emily Stark
2014-03-31 21:32:39 -07:00
parent 9c3d6e03f9
commit 1989702e07
2 changed files with 40 additions and 11 deletions

View File

@@ -75,27 +75,52 @@ _.extend(Catalog.prototype, {
// 'foo' that we find through the package server. Directories
// that don't exist (or paths that aren't directories) will be
// silently ignored.
// - bootstrapLocalPackageDirs: like 'localPackageDirs', but
// containing the packages that we can call 'unipackage.load' to
// load the packages that we need to talk to the server. Packages
// inside `bootstrapLocalPackageDirs` cannot use troposphere
// packages.
initialize: function (options) {
var self = this;
options = options || {};
// Trim down localPackageDirs to just those that actually exist
// (and that are actually directories)
self.localPackageDirs = _.filter(options.localPackageDirs || [],
isDirectory);
var trimPackageDirs = function (packageDirs) {
// Trim down local package dirs to just those that actually exist
// (and that are actually directories)
return _.filter(packageDirs || [], isDirectory);
};
var bootstrapPackageDirs = trimPackageDirs(
options.bootstrapLocalPackageDirs);
var localPackageDirs = trimPackageDirs(
options.localPackageDirs);
var allLocalPackageDirs = bootstrapPackageDirs.concat(localPackageDirs);
self.localPackageDirs = bootstrapPackageDirs;
self._recomputeEffectiveLocalPackages();
// First, initialize the catalog with just the local
// packages. This is just enough (at least if we're running from a
// checkout) that we're able to call unipackage.load to load the
// packages that we need to talk to the server.
// First, initialize the catalog with just the local packages for
// bootstrapping. This is just enough (at least if we're running
// from a checkout) that we're able to call unipackage.load to load
// the packages that we need to talk to the server.
self.packages = [];
self.versions = [];
self.builds = [];
console.log("XXX Loading local packages for bootstrapping");
self._addLocalPackageOverrides(true /* setInitialized */);
// Now we can include options.localPackageDirs. We do this
// separately from the bootstrapping packages because packages in
// options.localPackageDirs (app packages, for example) are allowed
// to use troposphere packages, so we have to be able to talk to the
// server before we load them.
self.localPackageDirs = allLocalPackageDirs;
self._recomputeEffectiveLocalPackages();
// We don't need to call _addLocalPackageOverrides here; that will
// be called as part of catalog initialization, which is the next
// step.
// OK, now initialize the catalog for real, with both local and
// package server packages.
console.log("XXX Loading catalog for real");

View File

@@ -678,10 +678,13 @@ Fiber(function () {
localPackageDirs = localPackageDirs.concat(
process.env.PACKAGE_DIRS.split(':'));
var bootstrapPackageDirs = [];
if (releaseName === null) {
// Running from a checkout, so use the Meteor core packages from
// the checkout.
localPackageDirs.push(path.join(files.getCurrentToolsDir(), 'packages'));
bootstrapPackageDirs.push(path.join(
files.getCurrentToolsDir(), 'packages'));
}
// Initialize the singleton Catalog. Only after this point is the
@@ -691,8 +694,9 @@ Fiber(function () {
// attempt to contact the server for more recent data. Otherwise, the catalog
// will attempt to synchronize with the remote package server.
catalog.initialize({
localPackageDirs: localPackageDirs,
offline: _.has(rawOptions, '--no-net')
bootstrapLocalPackageDirs: bootstrapPackageDirs,
localPackageDirs: localPackageDirs,
offline: _.has(rawOptions, '--no-net')
});
// We need to delete the option or we will throw an error.
// XXX: This seems like a hack?