diff --git a/apps/system/Makefile b/apps/system/Makefile index a4a5aecbe608..23993dd883c3 100644 --- a/apps/system/Makefile +++ b/apps/system/Makefile @@ -1,3 +1,13 @@ -.PHONY: remove-old-camera -remove-old-camera: +-include $(PWD)/build/common.mk + +BUILD_DIR=$(PWD)/build_stage/system + +.PHONY: all clean +all: clean + @echo Building system app to build_stage... + @mkdir -p $(BUILD_DIR) + @cp -r * $(BUILD_DIR) + @$(call run-app-js-command, build) +clean: @rm -rf ./camera + @rm -rf $(BUILD_DIR) diff --git a/apps/system/build/build.js b/apps/system/build/build.js new file mode 100644 index 000000000000..603b3c43b52e --- /dev/null +++ b/apps/system/build/build.js @@ -0,0 +1,87 @@ +'use strict'; + +/* global require, exports */ +var utils = require('utils'); + +var SystemAppBuilder = function() { +}; + +SystemAppBuilder.prototype.APP_DIR = 'apps/system'; +SystemAppBuilder.prototype.STAGE_DIR = 'build_stage/system'; +// set options +SystemAppBuilder.prototype.setOptions = function(options) { + var stageDirPath = [options.GAIA_DIR].concat(this.STAGE_DIR.split('/')); + this.stageDir = utils.getFile.apply(utils, stageDirPath); + + var appDirPath = [options.GAIA_DIR].concat(this.STAGE_DIR.split('/')); + this.appDir = utils.getFile.apply(utils, appDirPath); + + this.distDirPath = options.GAIA_DISTRIBUTION_DIR; +}; + +SystemAppBuilder.prototype.addCustomizeFiles = function() { + if (!utils.getFile(this.distDirPath, 'power').exists()) { + return; + } + var self = this; + var fileDir = utils.getFile(this.distDirPath, 'power'); + var files = utils.ls(fileDir); + files.forEach(function(file) { + utils.copyFileTo(file.path, + utils.joinPath(self.stageDir.path, 'resources', 'power'), + file.leafName, true); + }); +}; + +SystemAppBuilder.prototype.initConfigJsons = function() { + var iccDefault = { + 'defaultURL': 'http://www.mozilla.org/en-US/firefoxos/' + }; + var wapuaprofDefault = { + }; + var iccFile = utils.getFile(this.stageDir.path, 'js', 'icc.json'); + var wapFile = utils.getFile(this.stageDir.path, 'js', 'wapuaprof.json'); + + utils.writeContent(iccFile, + utils.getDistributionFileContent('icc', iccDefault, this.distDirPath)); + + utils.writeContent(wapFile, + utils.getDistributionFileContent('wapuaprof', + wapuaprofDefault, this.distDirPath)); + +}; + +SystemAppBuilder.prototype.generateManifest = function() { + var manifest = + utils.getJSON(utils.getFile(this.appDir.path, 'manifest.webapp')); + manifest.activities = manifest.activities || {}; + + manifest.activities.view = { + filters: { + type: 'url', + url: { + required: true, + pattern: 'https?:.{1,16384}', + patternFlags: 'i' + } + } + }; + // Write content to build_stage + utils.writeContent(utils.getFile(this.stageDir.path, 'manifest.webapp'), + JSON.stringify(manifest)); +}; + +SystemAppBuilder.prototype.execute = function(options) { + this.setOptions(options); + this.initConfigJsons(); + if (options.ROCKETBAR !== 'none') { + this.generateManifest(); + } + if (this.distDirPath) { + this.addCustomizeFiles(); + } +}; + +exports.execute = function(options) { + (new SystemAppBuilder()).execute(options); +}; diff --git a/apps/system/gaia_build.json b/apps/system/gaia_build.json new file mode 100644 index 000000000000..4b06b5a9caff --- /dev/null +++ b/apps/system/gaia_build.json @@ -0,0 +1,3 @@ +{ + "dir": "../../build_stage/system" +} diff --git a/build/applications-data.js b/build/applications-data.js index 2b64db5bc611..779069eef63a 100644 --- a/build/applications-data.js +++ b/build/applications-data.js @@ -329,24 +329,6 @@ function execute(options) { utils.writeContent(init, utils.getDistributionFileContent('support', content, distDir)); - // ICC / STK - init = utils.getFile(config.GAIA_DIR, - 'apps', 'system', 'resources', 'icc.json'); - content = { - 'defaultURL': 'http://www.mozilla.org/en-US/firefoxos/' - }; - - utils.writeContent(init, - utils.getDistributionFileContent('icc', content, distDir)); - - // WAP UA profile url - init = utils.getFile(config.GAIA_DIR, - 'apps', 'system', 'resources', 'wapuaprof.json'); - content = {}; - - utils.writeContent(init, - utils.getDistributionFileContent('wapuaprof.json', content, distDir)); - // Communications config init = utils.getFile(config.GAIA_DIR, 'apps', 'communications', 'contacts', 'config.json'); diff --git a/build/multilocale.js b/build/multilocale.js index 36f997a6415d..9b88bfc1e50d 100644 --- a/build/multilocale.js +++ b/build/multilocale.js @@ -3,7 +3,7 @@ const { Cc, Ci, Cr, Cu } = require('chrome'); Cu.import('resource://gre/modules/osfile.jsm'); -const utils = require('./utils'); +const utils = require('utils'); const webappZip = require('./webapp-zip'); const RE_SECTION_LINE = /\[(.*)\]/; const RE_IMPORT_LINE = /@import url\((.*)\)/; diff --git a/build/test/integration/build.test.js b/build/test/integration/build.test.js index 10cb0ed5cbb6..7ce230a09eeb 100644 --- a/build/test/integration/build.test.js +++ b/build/test/integration/build.test.js @@ -338,19 +338,49 @@ suite('Build Integration tests', function() { function(error, stdout, stderr) { helper.checkError(error, stdout, stderr); - var hsZip = new AdmZip(path.join(process.cwd(), 'profile', + var hsBroZip = new AdmZip(path.join(process.cwd(), 'profile', 'webapps', 'browser.gaiamobile.org', 'application.zip')); + var hsSysZip = new AdmZip(path.join(process.cwd(), 'profile', + 'webapps', 'system.gaiamobile.org', 'application.zip')); + var hsInit = - JSON.parse(hsZip.readAsText(hsZip.getEntry('js/init.json'))); - var hsManifest = - JSON.parse(hsZip.readAsText(hsZip.getEntry('manifest.webapp'))); + JSON.parse(hsBroZip.readAsText(hsBroZip.getEntry('js/init.json'))); + var hsBroManifest = + JSON.parse(hsBroZip.readAsText(hsBroZip.getEntry('manifest.webapp'))); var defaultJSONPath = path.join(process.cwd(), 'apps', 'browser', 'build', 'default.json'); - var expectedInitJson = JSON.parse(fs.readFileSync(defaultJSONPath)); + var hsIcc = + JSON.parse(hsSysZip.readAsText(hsSysZip.getEntry('js/icc.json'))); + var hsWapuaprof = + JSON.parse(hsSysZip.readAsText(hsSysZip.getEntry('js/wapuaprof.json'))); + var hsSysManifest = + JSON.parse(hsSysZip.readAsText(hsSysZip.getEntry('manifest.webapp'))); + var expectedInitJson = JSON.parse(fs.readFileSync(defaultJSONPath)); + var expectedIcc = { + 'defaultURL': 'http://www.mozilla.org/en-US/firefoxos/' + }; + var expectedWap = {}; + var expectedManifest = { + activities: { + view: { + filters: { + type: 'url', + url: { + required: true, + pattern: 'https?:.{1,16384}', + patternFlags: 'i' + } + } + } + } + }; helper.checkSettings(hsInit, expectedInitJson); - assert.equal(hsManifest.role, 'system'); - assert.equal(hsManifest.activities, null); + assert.equal(hsBroManifest.role, 'system'); + assert.equal(hsBroManifest.activities, null); + helper.checkSettings(hsIcc, expectedIcc); + helper.checkSettings(hsWapuaprof, expectedWap); + helper.checkSettings(hsSysManifest, expectedManifest); done(); } ); diff --git a/build/test/integration/distribution.test.js b/build/test/integration/distribution.test.js index 1b5813f7b0d4..c42ca15ff4e7 100644 --- a/build/test/integration/distribution.test.js +++ b/build/test/integration/distribution.test.js @@ -111,7 +111,29 @@ suite('Distribution mechanism', function() { var presetsContent = broZip.readAsText(broZip.getEntry('js/init.json')); assert.isNotNull(presetsContent, 'js/init.json should exist'); assert.deepEqual(JSON.parse(presetsContent), appConfig); + } + + function validateSystem() { + var icc = path.join(distDir, 'icc.json'); + var iccConfig = JSON.parse(fs.readFileSync(icc)); + var wapuaprof = path.join(distDir, 'wapuaprof.json'); + var wapuaprofConfig = JSON.parse(fs.readFileSync(wapuaprof)); + var power = path.join(distDir, 'power', 'fakePowerFile.json'); + var powerFile = JSON.parse(fs.readFileSync(power)); + var sysZip = new AdmZip(path.join(process.cwd(), 'profile', + 'webapps', 'system.gaiamobile.org', 'application.zip')); + + var realIcc = sysZip.readAsText(sysZip.getEntry('js/icc.json')); + var realWap = sysZip.readAsText(sysZip.getEntry('js/wapuaprof.json')); + var realPower = sysZip.readAsText(sysZip.getEntry( + 'resources/power/fakePowerFile.json')); + assert.isNotNull(realIcc, 'js/icc.json should exist'); + assert.deepEqual(JSON.parse(realIcc), iccConfig); + assert.isNotNull(realWap, 'js/wapuaprof.json should exist'); + assert.deepEqual(JSON.parse(realWap), wapuaprofConfig); + assert.isNotNull(realPower, 'resources/power/ should exist'); + assert.deepEqual(JSON.parse(realPower), powerFile); } test('build with GAIA_DISTRIBUTION_DIR', function(done) { @@ -125,6 +147,7 @@ suite('Distribution mechanism', function() { validateCalendar(); validateWappush(); validateBrowser(); + validateSystem(); done(); }); }); diff --git a/build/test/resources/distribution_test/icc.json b/build/test/resources/distribution_test/icc.json new file mode 100644 index 000000000000..fbb910f4a0b1 --- /dev/null +++ b/build/test/resources/distribution_test/icc.json @@ -0,0 +1,3 @@ +{ + "defaultURL": "testICClink" +} diff --git a/build/test/resources/distribution_test/power/fakePowerFile.json b/build/test/resources/distribution_test/power/fakePowerFile.json new file mode 100644 index 000000000000..d0ae716dbe4c --- /dev/null +++ b/build/test/resources/distribution_test/power/fakePowerFile.json @@ -0,0 +1,3 @@ +{ + "test": "test" +} diff --git a/build/test/resources/distribution_test/wapuaprof.json b/build/test/resources/distribution_test/wapuaprof.json new file mode 100644 index 000000000000..2c843a59dae8 --- /dev/null +++ b/build/test/resources/distribution_test/wapuaprof.json @@ -0,0 +1,3 @@ +{ + "wapprof": "testprof" +} diff --git a/build/webapp-manifests.js b/build/webapp-manifests.js index 132af423c456..b5c7d0c74fe1 100644 --- a/build/webapp-manifests.js +++ b/build/webapp-manifests.js @@ -200,8 +200,6 @@ function fillAppManifest(webapp) { if (webapp.url.indexOf('communications.' + config.GAIA_DOMAIN) !== -1) { fillCommsAppManifest(webapp, webappTargetDir); - } else if (config.ROCKETBAR !== 'none' && webapp.url.indexOf('system.' + config.GAIA_DOMAIN) !== -1) { - modifySystemForRocketbar(webapp, webappTargetDir); } manifestInterAppHostnames(webapp, webappTargetDir); diff --git a/build/webapp-zip.js b/build/webapp-zip.js index f905f9da756b..7766b2bab1fb 100644 --- a/build/webapp-zip.js +++ b/build/webapp-zip.js @@ -366,12 +366,6 @@ function execute(options) { } }); - if (webapp.sourceDirectoryName === 'system' && gaia.distributionDir) { - if (utils.getFile(gaia.distributionDir, 'power').exists()) { - customizeFiles(zip, 'power', 'resources/power/', webapp); - } - } - if (webapp.sourceDirectoryName === 'homescreen' && gaia.distributionDir) { let customization = utils.getFile(gaia.distributionDir, 'temp', 'apps', 'conf', 'singlevariantconf.json');