net-im/libsignal-node: Use pre-fetch target to download the yarn cache

Do the same as electron and use a pre-fetch target so that we don't
have to host a copy of the yarn cache on a website.

While here, pet portlint
This commit is contained in:
Mikael Urankar 2023-01-27 12:07:15 +01:00
parent 6a6b89a12f
commit b935549ad5
6 changed files with 2472 additions and 14 deletions

View File

@ -1,11 +1,12 @@
PORTNAME= libsignal
DISTVERSIONPREFIX= v
DISTVERSION= 0.21.1
PORTREVISION= 2
PORTREVISION= 1
CATEGORIES= net-im
MASTER_SITES= LOCAL/mikael/signal-desktop/:yarn
MASTER_SITES= https://nodejs.org/download/release/v${NODE_VERSION}/:node
PKGNAMESUFFIX= -node
DISTFILES= libsignal-node-${DISTVERSION}-yarn-cache.tar.gz:yarn
DISTFILES= libsignal-node-${DISTVERSION}-yarn-cache.tar.gz:prefetch \
node-v${NODE_VERSION}-headers.tar.gz:node
MAINTAINER= mikael@FreeBSD.org
COMMENT= Platform-agnostic APIs used by the official Signal clients and servers
@ -13,6 +14,8 @@ COMMENT= Platform-agnostic APIs used by the official Signal clients and servers
LICENSE= AGPLv3
LICENSE_FILE= ${WRKSRC}/LICENSE
FETCH_DEPENDS= yarn-node16>0:www/yarn-node16
EXTRACT_DEPENDS=yarn-node16>0:www/yarn-node16
BUILD_DEPENDS= llvm-config${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT} \
protoc:devel/protobuf \
yarn:www/yarn-node16
@ -23,6 +26,9 @@ GH_ACCOUNT= signalapp
GH_TUPLE= google:boringssl:f1c75347daa2ea81a941e953f2263e0a4d970c8d:boringssl \
google:boringssl:ae223d6138807a13006342edfeef32e813246b39:boringssl_fips
# keep NODE_VERSION in sync with www/node16 DISTVERSION
NODE_VERSION= 16.19.0
CARGO_CRATES= addr2line-0.17.0 \
adler-1.0.2 \
aead-0.4.3 \
@ -238,19 +244,39 @@ MAKE_ENV= ELECTRON_OVERRIDE_DIST_PATH=${LOCALBASE}/share/electron21 \
MAKE_ENV+= RUSTC_BOOTSTRAP=aes,polyval
USE_LDCONFIG= yes
USE_LDCONFIG= yes
PLIST_FILES= lib/libsignal_node.so
NODE_ARCH= ${ARCH:S/aarch64/arm64/:S/amd64/x64/:S/i386/ia32/:C/powerpc64.*/ppc64/}
RUST_ARCH= ${ARCH:S/amd64/x86_64/:S/i386/i686/}
YARN_TIMESTAMP= 1661146515
.include <bsd.port.options.mk>
.if ${ARCH:Mpowerpc64*}
EXTRA_PATCHES= ${FILESDIR}/${ARCH}-patch-node_binding.gyp
.endif
pre-fetch:
if [ ! -f ${DISTDIR}/libsignal-node-${DISTVERSION}-yarn-cache.tar.gz ]; \
then ${MKDIR} ${WRKDIR}; \
${ECHO_CMD} 'yarn-offline-mirror "./yarn-offline-cache"' >> \
${WRKDIR}/.yarnrc; \
${CP} ${FILESDIR}/node/package.json ${FILESDIR}/node/yarn.lock ${WRKDIR}; \
cd ${WRKDIR} && ${SETENV} HOME=${WRKDIR} XDG_CACHE_HOME=${WRKDIR}/.cache \
yarn --frozen-lockfile --ignore-scripts; \
${MTREE_CMD} -cbnSp yarn-offline-cache | ${MTREE_CMD} -C | ${SED} \
-e 's:time=[0-9.]*:time=${YARN_TIMESTAMP}.000000000:' \
-e 's:\([gu]id\)=[0-9]*:\1=0:g' \
-e 's:flags=.*:flags=none:' \
-e 's:^\.:./yarn-offline-cache:' > yarn-offline-cache.mtree; \
${TAR} cJf ${DISTDIR}/libsignal-node-${DISTVERSION}-yarn-cache.tar.gz \
@yarn-offline-cache.mtree; \
${RM} -r ${WRKDIR}; \
fi
post-patch:
${REINPLACE_CMD} "s#python3#${PYTHON_CMD}#" \
${WRKSRC}/node/binding.gyp
@ -260,8 +286,14 @@ post-extract:
${MV} ${WRKDIR}/boringssl-f1c75347daa2ea81a941e953f2263e0a4d970c8d/* ${WRKDIR}/boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl
${MV} ${WRKDIR}/boringssl-ae223d6138807a13006342edfeef32e813246b39/* ${WRKDIR}/boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl-fips
${MKDIR} ${WRKDIR}/.cache/node-gyp/${NODE_VERSION}
${MV} ${WRKDIR}/node-v${NODE_VERSION}/include ${WRKDIR}/.cache/node-gyp/${NODE_VERSION}
${ECHO_CMD} '9' > ${WRKDIR}/.cache/node-gyp/${NODE_VERSION}/installVersion
${CP} ${FILESDIR}/node/package.json ${WRKSRC}/node
do-build:
${ECHO_CMD} 'yarn-offline-mirror "../yarn-cache"' > ${WRKSRC}/.yarnrc
${ECHO_CMD} 'yarn-offline-mirror "../yarn-offline-cache"' > ${WRKSRC}/.yarnrc
cd ${WRKSRC}/node && \
${SETENV} ${MAKE_ENV} yarn install --frozen-lockfile --ignore-optional --offline
cd ${WRKSRC}/node && \

View File

@ -1,6 +1,8 @@
TIMESTAMP = 1671212150
SHA256 (libsignal-node-0.21.1-yarn-cache.tar.gz) = 9605939694c95debbacb7015e3d6a54d0618b39c9d5346f1525dc808f240a586
SIZE (libsignal-node-0.21.1-yarn-cache.tar.gz) = 67924654
TIMESTAMP = 1672674525
SHA256 (libsignal-node-0.21.1-yarn-cache.tar.gz) = 5888ccb3a4de59b34b1dce1bd34c0d2d19a34424a9e35adb8b624e19aec9d125
SIZE (libsignal-node-0.21.1-yarn-cache.tar.gz) = 21537796
SHA256 (node-v16.19.0-headers.tar.gz) = d0b02ce3d1198d41127daf64f204195252abff6a22da70830aaed846ba6ad864
SIZE (node-v16.19.0-headers.tar.gz) = 568145
SHA256 (rust/crates/addr2line-0.17.0.crate) = b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b
SIZE (rust/crates/addr2line-0.17.0.crate) = 32260
SHA256 (rust/crates/adler-1.0.2.crate) = f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe

View File

@ -0,0 +1,55 @@
{
"name": "@signalapp/libsignal-client",
"version": "0.21.1",
"license": "AGPL-3.0-only",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/*.js",
"dist/*.d.ts",
"dist/zkgroup/**/*.js",
"dist/zkgroup/**/*.d.ts",
"Native.js",
"Native.d.ts",
"zkgroup.js",
"zkgroup.d.ts",
"prebuilds/*/*.node"
],
"scripts": {
"install": "node-gyp-build",
"build": "node-gyp build",
"tsc": "tsc -b",
"clean": "rimraf dist build prebuilds",
"test": "mocha --recursive dist/test --require source-map-support/register",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"format": "p() { prettier ${@:- --write} '**/*.{css,js,json,md,scss,ts,tsx}'; }; p"
},
"dependencies": {
"node-gyp-build": "^4.2.3",
"uuid": "^8.3.0"
},
"devDependencies": {
"@types/bindings": "^1.3.0",
"@types/chai": "^4.3.1",
"@types/chai-as-promised": "^7.1.3",
"@types/mocha": "^5.2.7",
"@types/node": "*",
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-header": "^3.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-mocha": "^8.0.0",
"eslint-plugin-more": "^1.0.0",
"mocha": "^9",
"node-gyp": "^8.4.1",
"prettier": "^1.19.1",
"rimraf": "^3.0.1",
"source-map-support": "^0.5.19",
"typescript": "4.6.2"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
--- ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/CMakeLists.txt.orig 2022-08-16 17:41:13 UTC
+++ ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/CMakeLists.txt
--- ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/CMakeLists.txt.orig 2022-08-16 17:41:13.291238000 +0200
+++ ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/CMakeLists.txt 2022-08-16 17:41:48.826715000 +0200
@@ -264,6 +264,7 @@ add_library(
cipher_extra/tls_cbc.c
cmac/cmac.c
@ -8,8 +8,8 @@
cpu-aarch64-fuchsia.c
cpu-aarch64-linux.c
cpu-aarch64-win.c
--- ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/cpu-aarch64-freebsd.c.orig 2022-08-16 17:42:08 UTC
+++ ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/cpu-aarch64-freebsd.c
--- ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/cpu-aarch64-freebsd.c.orig 2022-08-16 17:42:08.418245000 +0200
+++ ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/src/crypto/cpu-aarch64-freebsd.c 2022-08-16 17:40:34.409448000 +0200
@@ -0,0 +1,62 @@
+/* Copyright (c) 2016, Google Inc.
+ *

View File

@ -14,8 +14,8 @@ Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51145
Reviewed-by: Adam Langley <agl@google.com>
--- ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/CMakeLists.txt.orig 2022-08-19 10:54:32 UTC
+++ ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/CMakeLists.txt
--- ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/CMakeLists.txt.orig 2022-08-19 10:54:32.212105000 +0200
+++ ../boring-b95cb545b97395cdf5da36814f7dfb6e3856a99c/boring-sys/deps/boringssl/CMakeLists.txt 2022-08-19 10:55:12.577991000 +0200
@@ -21,8 +21,11 @@ endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fno-common -std=c11")
endif()