From 689225fecdbe2f766a811ade54a08ce8263dc454 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Mon, 25 Jun 2018 17:16:27 -0500 Subject: [PATCH 1/9] Update snapcraft.yaml --- .snapcraft/snapcraft.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.snapcraft/snapcraft.yaml b/.snapcraft/snapcraft.yaml index 48378873580ca..77bd479d66e9c 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 From bc8dfced58b7cbbd5ec01b16f9e9e447b7339347 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Mon, 25 Jun 2018 17:26:09 -0500 Subject: [PATCH 2/9] Add node prep script --- .snapcraft/resources/preparenode | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .snapcraft/resources/preparenode diff --git a/.snapcraft/resources/preparenode b/.snapcraft/resources/preparenode new file mode 100644 index 0000000000000..ece2324f0aa22 --- /dev/null +++ b/.snapcraft/resources/preparenode @@ -0,0 +1,22 @@ +#!/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 xvf node-$node_version-linux-$node_arch.tar.xz --strip 1; From cf416d3611d84b34a1fa148eb2d580c81ac6eee6 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Tue, 26 Jun 2018 16:17:58 -0500 Subject: [PATCH 3/9] Make executable --- .snapcraft/README.md | 61 -------------------------------- .snapcraft/resources/preparenode | 0 2 files changed, 61 deletions(-) delete mode 100644 .snapcraft/README.md mode change 100644 => 100755 .snapcraft/resources/preparenode diff --git a/.snapcraft/README.md b/.snapcraft/README.md deleted file mode 100644 index f0197f2dc65bf..0000000000000 --- 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/preparenode b/.snapcraft/resources/preparenode old mode 100644 new mode 100755 From 26111e279eed70dae78a9ecf458310be52216973 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Tue, 26 Jun 2018 19:58:17 -0500 Subject: [PATCH 4/9] Remove devDependency that caused arm failure. Also removed packaged binary for sharp for arm --- .snapcraft/resources/prepareRocketChat | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.snapcraft/resources/prepareRocketChat b/.snapcraft/resources/prepareRocketChat index 882998b9f82a8..02b82d0a6badd 100755 --- a/.snapcraft/resources/prepareRocketChat +++ b/.snapcraft/resources/prepareRocketChat @@ -1,12 +1,15 @@ #!/bin/bash -curl -SLf "https://releases.rocket.chat/#{RC_VERSION}/download/" -o rocket.chat.tgz +curl -SLf "https://releases.rocket.chat/0.65.2/download/" -o rocket.chat.tgz tar xvf rocket.chat.tgz --strip 1 cd programs/server +rm -rf npm/node_modules/meteor/emojione_emojione/node_modules/grunt-contrib-qunit +rm -rf npm/node_modules/sharp/vendor -npm install +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 +18,4 @@ 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 +execstack --clear-execstack npm/node_modules/sharp/vendor/lib/librsvg-2.so* From 7ad727265be4c42a15310f98f7a18a0d2511fc57 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Tue, 26 Jun 2018 22:11:45 -0500 Subject: [PATCH 5/9] dev/null tar stdout. Remove sharp vendor folder only for arm so it will download and build --- .snapcraft/resources/prepareRocketChat | 11 ++++++++--- .snapcraft/resources/preparenode | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.snapcraft/resources/prepareRocketChat b/.snapcraft/resources/prepareRocketChat index 02b82d0a6badd..08343b0815247 100755 --- a/.snapcraft/resources/prepareRocketChat +++ b/.snapcraft/resources/prepareRocketChat @@ -1,12 +1,16 @@ #!/bin/bash -curl -SLf "https://releases.rocket.chat/0.65.2/download/" -o rocket.chat.tgz +curl -SLf "https://releases.rocket.chat#{RC_VERSION}/download/" -o rocket.chat.tgz -tar xvf rocket.chat.tgz --strip 1 +tar xvf rocket.chat.tgz --strip 1 > /dev/null cd programs/server rm -rf npm/node_modules/meteor/emojione_emojione/node_modules/grunt-contrib-qunit -rm -rf npm/node_modules/sharp/vendor + +if [[ $(uname -m) == *armv6l* ]] +then + rm -rf npm/node_modules/sharp/vendor +fi export NODE_ENV=production npm i @@ -18,4 +22,5 @@ then fi # sharp needs execution stack removed - https://forum.snapcraft.io/t/snap-and-executable-stacks/1812 +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 index ece2324f0aa22..8011de5bff9c9 100755 --- a/.snapcraft/resources/preparenode +++ b/.snapcraft/resources/preparenode @@ -19,4 +19,4 @@ else fi -wget https://nodejs.org/dist/$node_version/node-$node_version-linux-$node_arch.tar.xz; tar xvf node-$node_version-linux-$node_arch.tar.xz --strip 1; +wget https://nodejs.org/dist/$node_version/node-$node_version-linux-$node_arch.tar.xz; tar xvf node-$node_version-linux-$node_arch.tar.xz --strip 1 > /dev/null; From 21d04dcb71a1d9efb75f16fa945279e94e208477 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Tue, 26 Jun 2018 22:13:47 -0500 Subject: [PATCH 6/9] add missing slash --- .snapcraft/resources/prepareRocketChat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.snapcraft/resources/prepareRocketChat b/.snapcraft/resources/prepareRocketChat index 08343b0815247..e8b4d1f6e9df5 100755 --- a/.snapcraft/resources/prepareRocketChat +++ b/.snapcraft/resources/prepareRocketChat @@ -1,6 +1,6 @@ #!/bin/bash -curl -SLf "https://releases.rocket.chat#{RC_VERSION}/download/" -o rocket.chat.tgz +curl -SLf "https://releases.rocket.chat/#{RC_VERSION}/download/" -o rocket.chat.tgz tar xvf rocket.chat.tgz --strip 1 > /dev/null From bb31951770822a99b3b98bb22d194c40d0b3d577 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Wed, 27 Jun 2018 12:21:18 -0500 Subject: [PATCH 7/9] fix arm check to catch armv7l also --- .snapcraft/resources/prepareRocketChat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.snapcraft/resources/prepareRocketChat b/.snapcraft/resources/prepareRocketChat index e8b4d1f6e9df5..a0738416ec005 100755 --- a/.snapcraft/resources/prepareRocketChat +++ b/.snapcraft/resources/prepareRocketChat @@ -7,7 +7,7 @@ tar xvf rocket.chat.tgz --strip 1 > /dev/null cd programs/server rm -rf npm/node_modules/meteor/emojione_emojione/node_modules/grunt-contrib-qunit -if [[ $(uname -m) == *armv6l* ]] +if [[ $(uname -m) == *armv6l* ]] || [[ $(uname -m) == *armv7l* ]] then rm -rf npm/node_modules/sharp/vendor fi From d2851aeb0fccb7b290f464d71c648d74ef8af9c6 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Wed, 27 Jun 2018 12:46:24 -0500 Subject: [PATCH 8/9] remove /dev/null and verbose flag. --- .snapcraft/resources/prepareRocketChat | 2 +- .snapcraft/resources/preparenode | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.snapcraft/resources/prepareRocketChat b/.snapcraft/resources/prepareRocketChat index a0738416ec005..2251551e6d0b7 100755 --- a/.snapcraft/resources/prepareRocketChat +++ b/.snapcraft/resources/prepareRocketChat @@ -2,7 +2,7 @@ curl -SLf "https://releases.rocket.chat/#{RC_VERSION}/download/" -o rocket.chat.tgz -tar xvf rocket.chat.tgz --strip 1 > /dev/null +tar xf rocket.chat.tgz --strip 1 cd programs/server rm -rf npm/node_modules/meteor/emojione_emojione/node_modules/grunt-contrib-qunit diff --git a/.snapcraft/resources/preparenode b/.snapcraft/resources/preparenode index 8011de5bff9c9..1d3eccc804e90 100755 --- a/.snapcraft/resources/preparenode +++ b/.snapcraft/resources/preparenode @@ -19,4 +19,4 @@ else fi -wget https://nodejs.org/dist/$node_version/node-$node_version-linux-$node_arch.tar.xz; tar xvf node-$node_version-linux-$node_arch.tar.xz --strip 1 > /dev/null; +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; From 5ea0f407a6efee2c839d332b619c1fd1c5027a37 Mon Sep 17 00:00:00 2001 From: Aaron Ogle Date: Wed, 27 Jun 2018 12:47:48 -0500 Subject: [PATCH 9/9] Move extract to new line --- .snapcraft/resources/preparenode | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.snapcraft/resources/preparenode b/.snapcraft/resources/preparenode index 1d3eccc804e90..f6e0c58d3cc54 100755 --- a/.snapcraft/resources/preparenode +++ b/.snapcraft/resources/preparenode @@ -19,4 +19,5 @@ else 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; +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