From e01f4dbf1393a789faaa2f38b53d2effad827e86 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Sat, 11 Jan 2020 13:08:29 +0200 Subject: [PATCH] Change Buffer to Buffer.alloc on Node v12. Try to fix Snap. --- fix-download-unicode/cfs_access-point.txt | 8 +++---- models/export.js | 2 +- models/wekanCreator.js | 2 +- packages/wekan-ldap/server/ldap.js | 4 ++-- packages/wekan-oidc/oidc_server.js | 6 ++--- rebuild-wekan.sh | 2 +- sandstorm.js | 2 +- snapcraft.yaml | 27 ++++++++++++++--------- 8 files changed, 29 insertions(+), 24 deletions(-) diff --git a/fix-download-unicode/cfs_access-point.txt b/fix-download-unicode/cfs_access-point.txt index 8e3359d05..145218dfd 100644 --- a/fix-download-unicode/cfs_access-point.txt +++ b/fix-download-unicode/cfs_access-point.txt @@ -451,14 +451,14 @@ FS.HTTP.Handlers.Get = function (ref) { if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('trident') >= 0 || userAgent.indexOf('chrome') >= 0) { ref.filename = encodeURIComponent(ref.filename); } else if(userAgent.indexOf('firefox') >= 0) { - ref.filename = new Buffer(ref.filename).toString('binary'); + ref.filename = new Buffer.alloc(ref.filename).toString('binary'); } else { /* safari*/ - ref.filename = new Buffer(ref.filename).toString('binary'); - } + ref.filename = new Buffer.alloc(ref.filename).toString('binary'); + } } catch (ex){ ref.filename = 'tempfix'; - } + } return originalHandler.call(this, ref); }; // 221 diff --git a/models/export.js b/models/export.js index cc979ce01..69aaf6198 100644 --- a/models/export.js +++ b/models/export.js @@ -138,7 +138,7 @@ export class Exporter { // [Old] for attachments we only export IDs and absolute url to original doc // [New] Encode attachment to base64 const getBase64Data = function(doc, callback) { - let buffer = new Buffer(0); + let buffer = new Buffer.alloc(0); // callback has the form function (err, res) {} const tmpFile = path.join( os.tmpdir(), diff --git a/models/wekanCreator.js b/models/wekanCreator.js index ec85d93f0..26d341705 100644 --- a/models/wekanCreator.js +++ b/models/wekanCreator.js @@ -441,7 +441,7 @@ export class WekanCreator { }); } else if (att.file) { file.attachData( - new Buffer(att.file, 'base64'), + new Buffer.alloc(att.file, 'base64'), { type: att.type, }, diff --git a/packages/wekan-ldap/server/ldap.js b/packages/wekan-ldap/server/ldap.js index bd2cd1fb4..9d9f7f9df 100644 --- a/packages/wekan-ldap/server/ldap.js +++ b/packages/wekan-ldap/server/ldap.js @@ -286,14 +286,14 @@ export default class LDAP { if (attribute) { filter = new this.ldapjs.filters.EqualityFilter({ attribute, - value: new Buffer(id, 'hex'), + value: new Buffer.alloc(id, 'hex'), }); } else { const filters = []; Unique_Identifier_Field.forEach((item) => { filters.push(new this.ldapjs.filters.EqualityFilter({ attribute: item, - value : new Buffer(id, 'hex'), + value : new Buffer.alloc(id, 'hex'), })); }); diff --git a/packages/wekan-oidc/oidc_server.js b/packages/wekan-oidc/oidc_server.js index 326238da6..5a0f82cd8 100644 --- a/packages/wekan-oidc/oidc_server.js +++ b/packages/wekan-oidc/oidc_server.js @@ -131,9 +131,9 @@ var getTokenContent = function (token) { if (token) { try { var parts = token.split('.'); - var header = JSON.parse(new Buffer(parts[0], 'base64').toString()); - content = JSON.parse(new Buffer(parts[1], 'base64').toString()); - var signature = new Buffer(parts[2], 'base64'); + var header = JSON.parse(new Buffer.alloc(parts[0], 'base64').toString()); + content = JSON.parse(new Buffer.alloc(parts[1], 'base64').toString()); + var signature = new Buffer.alloc(parts[2], 'base64'); var signed = parts[0] + '.' + parts[1]; } catch (err) { this.content = { diff --git a/rebuild-wekan.sh b/rebuild-wekan.sh index 7e61854e1..c80f17b83 100755 --- a/rebuild-wekan.sh +++ b/rebuild-wekan.sh @@ -111,7 +111,7 @@ do npm_call -g install node-gyp # Latest fibers for Meteor 1.8.x sudo mkdir -p /usr/local/lib/node_modules/fibers/.node-gyp - npm_call -g install fibers@4.0.1 + npm_call -g install fibers # Install Meteor, if it's not yet installed curl https://install.meteor.com | bash sudo chown -R $(id -u):$(id -g) $HOME/.npm $HOME/.meteor diff --git a/sandstorm.js b/sandstorm.js index 3cd84fc30..5bf3bbe04 100644 --- a/sandstorm.js +++ b/sandstorm.js @@ -55,7 +55,7 @@ if (isSandstorm && Meteor.isServer) { const parsedDescriptor = Capnp.parse( Powerbox.PowerboxDescriptor, - new Buffer(descriptor, 'base64'), + new Buffer.alloc(descriptor, 'base64'), { packed: true }, ); diff --git a/snapcraft.yaml b/snapcraft.yaml index ab93384b2..bb1cb05c9 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -1,5 +1,5 @@ name: wekan -version: 0 +version: '0' version-script: git describe --tags | cut -c 2- summary: The open-source kanban description: | @@ -12,6 +12,11 @@ description: | confinement: strict grade: stable +base: core18 + +environment: + npm_config_unsafe_perm: "true" + NODE_ENV: "production" architectures: - amd64 @@ -65,9 +70,9 @@ apps: parts: mongodb: - source: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-4.2.2.tgz + source: https://repo.mongodb.org/apt/ubuntu/dists/bionic/mongodb-org/4.2/multiverse/binary-amd64/mongodb-org-server_4.2.2_amd64.deb plugin: dump - stage-packages: [libssl1.0.0] + stage-packages: [libssl1.1] filesets: mongo: - usr @@ -81,21 +86,16 @@ parts: wekan: source: . plugin: nodejs - node-engine: 12.14.1 - node-packages: - - node-gyp - - node-pre-gyp - - fibers build-packages: - ca-certificates - apt-utils - build-essential - - python -# - python3 +# - python + - python3 - g++ - capnproto - curl - - libcurl3 + - libcurl4 - execstack - nodejs - npm @@ -106,6 +106,11 @@ parts: rm -rf ~/.meteor ~/.npm /usr/local/lib/node_modules # Create the OpenAPI specification rm -rf .build + npm -g install n + n 12.14.1 + npm install -g node-gyp + npm install -g node-pre-gyp + npm install -g fibers #mkdir -p .build/python #cd .build/python #git clone --depth 1 -b master https://github.com/Kronuz/esprima-python