From 1989702e074b50dcd54e601c986bf4533dcda55b Mon Sep 17 00:00:00 2001 From: Emily Stark Date: Mon, 31 Mar 2014 21:32:39 -0700 Subject: [PATCH] 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. --- tools/catalog.js | 41 +++++++++++++++++++++++++++++++++-------- tools/main.js | 10 +++++++--- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/tools/catalog.js b/tools/catalog.js index 0eb2caf7b5..6521645563 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -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"); diff --git a/tools/main.js b/tools/main.js index 797465aaa8..fc0894beca 100644 --- a/tools/main.js +++ b/tools/main.js @@ -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?