[Make a HTML5/Electron-based snap] - fail to update code when ran without snapcraft clean
Closed this issue · 1 comments
The provided build for the electron-part is the following:
override-build: |
case $SNAPCRAFT_ARCH_TRIPLET in
"i386-linux-gnu") ARCH="ia32";;
"x86_64-linux-gnu") ARCH="x64";;
"arm-linux-gnueabihf") ARCH="armv7l";;
"aarch64-linux-gnu") ARCH="arm64";;
*) echo "ERROR: electron does not support the '$SNAPCRAFT_ARCH_TRIPLET' architecture" && exit 1;;
esac
npm install electron-packager &&
./node_modules/.bin/electron-packager . --overwrite --platform=linux --arch=$ARCH --output=release-build --prune=true
cp -v -R ./electron-quick-start-linux-$ARCH $SNAPCRAFT_PART_INSTALL/electron-helloworld
The issue lies in this row: cp -v -R ./electron-quick-start-linux-$ARCH $SNAPCRAFT_PART_INSTALL/electron-helloworld
. This will work when the $SNAPCRAFT_PART_INSTALL/electron-helloworld
folder doesn't exist, but once it exists (next time you run snapcraft) those contents will remain and instead we copy a folder with name electron-quick-start-linux-$ARCH
inside of $SNAPCRAFT_PART_INSTALL/electron-helloworld
.
To get any new code working you have to run snapcraft clean every single time you build, which gets very very timeconsuming with all packages installed (especially when running in a virtual machine over a slow wifi this takes >30 minutes per build).
To solve this issue we can use the -T
option as well with cp
. Another maybe even better and elegant solution is to use rsync
like so: rsync -avh --delete ./electron-quick-start-linux-$ARCH/ $SNAPCRAFT_PART_INSTALL/electron-helloworld/
Thanks for submitting an issue for this tutorial. We have moved our tutorials to discourse. To contribute going forwards please go to https://discourse.ubuntu.com/c/tutorials.