Browse Source

fix: cleanbuild, now for real

master
Maciej Krüger 4 years ago
parent
commit
42f3161ca8
  1. 2
      Makefile
  2. 5
      build-tool.js
  3. 16
      conf-tool.sh
  4. 1
      package.json

2
Makefile

@ -24,7 +24,7 @@ clean:
presigned/%: %.model
cp $*.model presigned/$*
%.snaps:
node build-tool.js --build-backend $(SNAP_BUILD) --env $(ENV) --channel $(CHANNEL) --board $*
LC_ALL=C.UTF-8 LANGUAGE=C LANG=C.UTF-8 node build-tool.js --build-backend $(SNAP_BUILD) --env $(ENV) --channel $(CHANNEL) --board $*
.cloud-init.yaml: $(ENV).cloud-init.yaml
cat $(ENV).cloud-init.yaml | USER_EMAIL=$(USER_EMAIL) envsubst > .cloud-init.yaml
%.img: %.model %.snaps .cloud-init.yaml # build an image

5
build-tool.js

@ -13,6 +13,7 @@ const yaml = require('js-yaml')
const cp = require('child_process')
const JSON5 = require('json5')
const mkdir = require('mkdirp').sync
const glob = require('glob')
const isDev = env === 'dev'
const forceBuild = isDev
@ -49,7 +50,9 @@ async function snapcraft (folder, outFile, targetArch) {
await exec('snapcraft', folder, 'snap', '-o', outFile, '--target-arch=' + targetArch)
break
case 'cleanbuild':
await exec('snapcraft', folder, 'cleanbuild', '-o', outFile, '--target-arch=' + targetArch)
await exec('snapcraft', folder, 'cleanbuild', '--target-arch=' + targetArch)
const snapFile = glob.sync(path.join(folder, '*.snap'))[0]
fs.renameSync(snapFile, outFile)
break
default: {
throw new TypeError('Unsupported build backend: ' + buildBackend)

16
conf-tool.sh

@ -45,20 +45,29 @@ else
signing_key="-"
fi
echo
echo "Testing snap building support..."
tmp=$(mktemp -d)
pushd "$tmp"
o="$PWD"
cd "$tmp"
echo "$TEST_SNAP" | base64 -d | tar xz
OUT=$(snapcraft 2>&1 || /bin/true)
if [[ "$OUT" = "Native builds"* ]]; then
echo "$OUT" | tail -n 1
echo "No support for native backend. Testing cleanbuild..."
echo "Testing cleanbuild..."
OUT=$(snapcraft cleanbuild 2>&1 || /bin/true)
if [[ "$OUT" = "Failed to initialize container"* ]]; then
echo "$OUT" 1>&2
die "Quitting as neither native backend nor container backend works."
elif [[ "$OUT" = "Error: Get"* ]]; then
if [[ "$OUT" = *"connect: permission denied"* ]]; then
die "User not in lxd group. Run '$ sudo addgroup $(whoami) lxd', re-login and try again!"
else
echo "$OUT" 1>&2
die "LXD isn't properly configured!"
fi
else
echo "Using container building"
SNAP_BUILD=cleanbuild
@ -68,7 +77,8 @@ else
SNAP_BUILD=build
fi
popd
echo
cd "$o"
rm -rf "$tmp"
dev_user=$(echo "$user_email" | sed "s|@.*||g")

1
package.json

@ -20,6 +20,7 @@
"license": "MIT",
"dependencies": {
"colors": "^1.3.2",
"glob": "^7.1.3",
"js-yaml": "^3.12.0",
"json5": "^2.1.0",
"mkdirp": "^0.5.1",

Loading…
Cancel
Save