feat: Cloud init - Update submodules

This commit is contained in:
Maciej Krüger 2018-08-10 17:39:10 +02:00
parent f4bb39e13c
commit 9949508cb3
No known key found for this signature in database
GPG Key ID: 0D948CE19CF49C5F
5 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

1
deps/common.yaml vendored Normal file
View File

@ -0,0 +1 @@
snaps:

0
dev.cloud-init.yaml Normal file
View File