diff --git a/Makefile b/Makefile index 99f0cea..d846c70 100644 --- a/Makefile +++ b/Makefile @@ -2,14 +2,14 @@ CHANNEL=stable ENV=dev clean: - rm -rf *.img *.model *.manifest + rm -rf *.img *.model *.manifest snaps %.model: boards/%.yaml # sign a model file cat definition.yaml $< | python -c "import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=2)" | sed "s|TIMESTAMP|$(shell date -Iseconds --utc)|g" | snap sign -k default > $@ snaps/%: node build-tool.js --env $(ENV) --channel $(CHANNEL) --board $* %.img: %.model snaps/% # build an image - sudo ubuntu-image snap -o $@ -c $(CHANNEL) $< + sudo ubuntu-image snap -o $@ --cloud-init $(ENV).cloud-init.yaml -c $(CHANNEL) $< # VM stuff diff --git a/build-tool.js b/build-tool.js index 018be25..3a69152 100644 --- a/build-tool.js +++ b/build-tool.js @@ -18,6 +18,7 @@ const isDev = env === 'dev' const forceBuild = isDev const deps = yaml.safeLoad(read('deps/' + board + '.yaml')) +const common = yaml.safeLoad(read('deps/common.yaml')) const boardDef = yaml.safeLoad(read('boards/' + board + '.yaml')) const exec = (cmd, dir, ...args) => new Promise((resolve, reject) => { @@ -48,20 +49,23 @@ async function snapcraft (folder, outFile, targetArch) { async function pullOrClone (repo, dest, checkout) { let currentCommit = '' if (fs.existsSync(dest)) { - await exec('git', dest, 'remote', 'update', '--recurse-submodules=yes', '-p') + await exec('git', dest, 'remote', 'update', '-p') } else { await exec('git', process.cwd(), 'clone', '--recursive', repo, dest) currentCommit = String(execWithOutput('git', '-C', dest, 'rev-parse', '--verify', 'HEAD').stdout) } await exec('git', dest, 'checkout', checkout) + await exec('git', dest, 'submodule', 'init', '.') + await exec('git', dest, 'submodule', 'update') let newCommit = String(execWithOutput('git', '-C', dest, 'rev-parse', '--verify', 'HEAD').stdout) return currentCommit !== newCommit // returns bool if snap need recompilation } async function main () { - for (const snapName in deps.snaps) { // eslint-disable-line guard-for-in - const snap = deps.snaps[snapName] + const snaps = Object.assign(deps.snaps, common.snaps) + for (const snapName in snaps) { // eslint-disable-line guard-for-in + const snap = snaps[snapName] if (snap.mustBuild || forceBuild) { console.log('Building %s...', snapName) diff --git a/definition.yaml b/definition.yaml index 57f0881..5ce759e 100644 --- a/definition.yaml +++ b/definition.yaml @@ -5,6 +5,7 @@ model: ppl-hub # snaps to be preinstalled: required-snaps: - nextcloud # just for proof-of-concept + - snapweb # authority meta authority-id: 7xN2sMCILuFk10e6DxrTrQWprdmV0Vi9 brand-id: 7xN2sMCILuFk10e6DxrTrQWprdmV0Vi9 diff --git a/deps/common.yaml b/deps/common.yaml new file mode 100644 index 0000000..bbf6a94 --- /dev/null +++ b/deps/common.yaml @@ -0,0 +1 @@ +snaps: diff --git a/dev.cloud-init.yaml b/dev.cloud-init.yaml new file mode 100644 index 0000000..e69de29