From 445ef8bb92f802c50df2cd9cb26c1e206f993d2e Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Wed, 27 Jun 2018 18:34:16 -0500 Subject: [PATCH] [FIX] Armhf snap build (#11268) * Update snapcraft.yaml * Add node prep script * Make executable * Remove devDependency that caused arm failure. Also removed packaged binary for sharp for arm * dev/null tar stdout. Remove sharp vendor folder only for arm so it will download and build * add missing slash * fix arm check to catch armv7l also * remove /dev/null and verbose flag. * Move extract to new line --- .snapcraft/README.md | 61 -------------------------- .snapcraft/resources/prepareRocketChat | 14 ++++-- .snapcraft/resources/preparenode | 23 ++++++++++ .snapcraft/snapcraft.yaml | 2 +- 4 files changed, 35 insertions(+), 65 deletions(-) delete mode 100644 .snapcraft/README.md create mode 100755 .snapcraft/resources/preparenode diff --git a/.snapcraft/README.md b/.snapcraft/README.md deleted file mode 100644 index f0197f2dc65..00000000000 --- a/.snapcraft/README.md +++ /dev/null @@ -1,61 +0,0 @@ -![Rocket.Chat logo](https://rocket.chat/images/logo/logo-dark.svg?v3) - -# rocketchat-server snap for Ubuntu Core (all arch) - -Features: -* bundles ubuntu distribution specific and RC compatible mongodb version -* oplog tailing for mongo by default -* mongodb backup command -* mongodb restore command -* caddy reverse proxy built-in - capable of handling free lestencrypt ssl - -Note: - -Currently, this repository is mirrored on launchpad, and used to build latest ARMHF and i386 snaps. - -You can download recent builds here: -https://code.launchpad.net/~sing-li/+snap/rocketchat-server - -Due an issue with the existing installed base of amd64 users (existing snap always installed mongodb 3.2 [#issue](https://github.com/RocketChat/rocketchat-server-snap/issues/3)), this snap is not currently used for amd64 builds. - -### Test installation - -Download the latest snap file of the corresponding architecture to your Ubuntu Core 16 or 16.04LTS server. - -`sudo snap install ./rocketchat-server-xxxxxxxx.snap --dangerous` - - -### Development or compile your own snap - -Make sure you have `snapcraft` installed. - -``` -git clone https://github.com/RocketChat/rocketchat-server-snap -cd rocketchat-server-snap -snapcraft snap -``` - -### Regression tests (run for amd64, i386 and armhf): -- snapcraft runs properly -- snap installs properly -- all services start automatically -- rc service shows a 5-second restart delay while waiting for mongo - - to test manually, stop rc, stop mongo, start rc, wait 20s or so, start mongo -- rc can be successfully restarted via the "Restart the server" button under Admin > Settings > General -- rc service shows a 5-second delay when restarted via this button -- all commands execute successfully: - - initcaddy - - modify the Caddyfile to test: - - self-signed TLS certificate (use the "tls self_signed" caddy directive) - - changing ports (with and without TLS) - - using IP address (only works without TLS) - - successfully acquiring a Let's Encrypt certificate (requires a registered domain) - - backupdb - - should run only with sudo - - restoredb - - ideally, stop rc service prior to running this (mongo must be running) - - should run only with sudo - - use any file outside of $snap_common (should fail) - - use the file created with backupdb - - use a dummy .tgz file without actual data - - with and without a "parties" directory in the archive diff --git a/.snapcraft/resources/prepareRocketChat b/.snapcraft/resources/prepareRocketChat index 882998b9f82..2251551e6d0 100755 --- a/.snapcraft/resources/prepareRocketChat +++ b/.snapcraft/resources/prepareRocketChat @@ -2,11 +2,18 @@ curl -SLf "https://releases.rocket.chat/#{RC_VERSION}/download/" -o rocket.chat.tgz -tar xvf rocket.chat.tgz --strip 1 +tar xf rocket.chat.tgz --strip 1 cd programs/server +rm -rf npm/node_modules/meteor/emojione_emojione/node_modules/grunt-contrib-qunit -npm install +if [[ $(uname -m) == *armv6l* ]] || [[ $(uname -m) == *armv7l* ]] +then + rm -rf npm/node_modules/sharp/vendor +fi + +export NODE_ENV=production +npm i # Ideally this will go away. For some reason on install its installing node-v57-linux-x64-glibc but when actually running it is looking for node-v57-linux-x64-unknown if [[ $(uname -m) == "x86_64" ]] @@ -15,4 +22,5 @@ then fi # sharp needs execution stack removed - https://forum.snapcraft.io/t/snap-and-executable-stacks/1812 -execstack --clear-execstack npm/node_modules/sharp/vendor/lib/librsvg-2.so.2.42.0 +ls -l npm/node_modules/sharp/vendor +execstack --clear-execstack npm/node_modules/sharp/vendor/lib/librsvg-2.so* diff --git a/.snapcraft/resources/preparenode b/.snapcraft/resources/preparenode new file mode 100755 index 00000000000..f6e0c58d3cc --- /dev/null +++ b/.snapcraft/resources/preparenode @@ -0,0 +1,23 @@ +#!/bin/bash + +node_version="v8.11.3" + +unamem="$(uname -m)" +if [[ $unamem == *aarch64* ]]; then + node_arch="arm64" +elif [[ $unamem == *64* ]]; then + node_arch="x64" +elif [[ $unamem == *86* ]]; then + node_arch="x86" +elif [[ $unamem == *armv6l* ]]; then + node_arch="armv6l" +elif [[ $unamem == *armv7l* ]]; then + node_arch="armv7l" +else + echo "Aborted, unsupported or unknown architecture: $unamem" + return 2 +fi + + +wget https://nodejs.org/dist/$node_version/node-$node_version-linux-$node_arch.tar.xz +tar xf node-$node_version-linux-$node_arch.tar.xz --strip 1 diff --git a/.snapcraft/snapcraft.yaml b/.snapcraft/snapcraft.yaml index 48378873580..77bd479d66e 100644 --- a/.snapcraft/snapcraft.yaml +++ b/.snapcraft/snapcraft.yaml @@ -39,7 +39,7 @@ apps: parts: node: plugin: dump - prepare: wget https://nodejs.org/dist/v8.11.2/node-v8.11.2-linux-x64.tar.xz; tar xvf node-v8.11.2-linux-x64.tar.xz --strip 1; + prepare: ./resources/preparenode build-packages: # For fibers - python