git: c5e6ec09095e - main - net-im/signal-desktop: Update to 7.38.0

From: Mikael Urankar <mikael_at_FreeBSD.org>
Date: Mon, 20 Jan 2025 14:16:42 UTC
The branch main has been updated by mikael:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c5e6ec09095ed9d4eda7725541ca4a244f8bf806

commit c5e6ec09095ed9d4eda7725541ca4a244f8bf806
Author:     Mikael Urankar <mikael@FreeBSD.org>
AuthorDate: 2025-01-20 14:15:56 +0000
Commit:     Mikael Urankar <mikael@FreeBSD.org>
CommitDate: 2025-01-20 14:16:36 +0000

    net-im/signal-desktop: Update to 7.38.0
---
 net-im/signal-desktop/Makefile                     |  10 +-
 net-im/signal-desktop/distinfo                     |  10 +-
 .../files/app-builder-lib+24.13.3.patch            | 260 +++++++++++++++++++++
 .../signal-desktop/files/dmg-builder+24.13.3.patch |  13 ++
 net-im/signal-desktop/get_deps.sh                  |   2 +-
 5 files changed, 285 insertions(+), 10 deletions(-)

diff --git a/net-im/signal-desktop/Makefile b/net-im/signal-desktop/Makefile
index f1c58ec1d92d..313ba9fa3f36 100644
--- a/net-im/signal-desktop/Makefile
+++ b/net-im/signal-desktop/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	signal-desktop
 DISTVERSIONPREFIX=	v
-DISTVERSION=	7.36.1
+DISTVERSION=	7.38.0
 CATEGORIES=	net-im
 MASTER_SITES=	LOCAL/mikael/signal-desktop/:npm \
 		https://build-artifacts.signal.org/desktop/:sqlcipher
@@ -111,10 +111,14 @@ post-extract:
 	# Update node engine
 	${PREFIX}/bin/jq '.engines.node = ""' ${WRKSRC}/package.json > ${WRKSRC}/package.json.tmp.1
 	${PREFIX}/bin/jq '.devDependencies.esbuild = "${ESBUILD_VERSION}"' ${WRKSRC}/package.json.tmp.1 > ${WRKSRC}/package.json.tmp.2
-	${MV} ${WRKSRC}/package.json.tmp.2 ${WRKSRC}/package.json
+	${PREFIX}/bin/jq '.devDependencies."electron-builder"= "24.13.3"' ${WRKSRC}/package.json.tmp.2 > ${WRKSRC}/package.json.tmp.3
+	${MV} ${WRKSRC}/package.json.tmp.3 ${WRKSRC}/package.json
 	# remove mock-server as it doesn't build and is useless
 	${PREFIX}/bin/jq 'del(.devDependencies."@signalapp/mock-server")' ${WRKSRC}/package.json > ${WRKSRC}/package.json.tmp
 	${MV} ${WRKSRC}/package.json.tmp ${WRKSRC}/package.json
+	${RM} ${WRKSRC}/patches/app-builder-lib* ${WRKSRC}/patches/dmg-builder*
+	${CP} ${FILESDIR}/app-builder-lib+24.13.3.patch ${WRKSRC}/patches
+	${CP} ${FILESDIR}/dmg-builder+24.13.3.patch ${WRKSRC}/patches
 
 #	# for online build
 #	cd ${WRKSRC} && \
@@ -144,7 +148,6 @@ do-build:
 	${CP} ${DISTDIR}/${SQLCIPHER}.tar.gz \
 		${WRKSRC}/node_modules/@signalapp/better-sqlite3/deps/sqlcipher.tar.gz
 
-	# patch-package can't patch sqlite3 on aarch64, patch the yarn cache instead
 	cd ${WRKSRC} && ${PATCH} -s -N -i ${FILESDIR}/sqlite3.gyp.diff
 
 	@${RM} -r ${WRKSRC}/node_modules/fs-xattr
@@ -168,7 +171,6 @@ do-install:
 	cd ${WRKSRC} && \
 		${SETENV} ${MAKE_ENV} ${PACKAGE_ENV} npm run build:electron -- \
 			--linux --dir --config.npmRebuild=false \
-			--config.electronVersion=${ELECTRON_VER} \
 			--config.electronDist=${WRKDIR}/electron${ELECTRON_VER_MAJOR}
 
 	${MKDIR} ${STAGEDIR}${DATADIR}
diff --git a/net-im/signal-desktop/distinfo b/net-im/signal-desktop/distinfo
index f3613095c9ce..4595690056f5 100644
--- a/net-im/signal-desktop/distinfo
+++ b/net-im/signal-desktop/distinfo
@@ -1,7 +1,7 @@
-TIMESTAMP = 1736358055
-SHA256 (signal-desktop-7.36.1-npm-cache.tar.gz) = ed7fe7343d1a71daf28898fbe92a59ec2cbce3eff3ee520982ae0ee40577cc5a
-SIZE (signal-desktop-7.36.1-npm-cache.tar.gz) = 310220786
+TIMESTAMP = 1737282309
+SHA256 (signal-desktop-7.38.0-npm-cache.tar.gz) = b0b215a79a97c6859e3f94cd5eac4e239ae9647fd7882bd6f6e4a239ba51c8ed
+SIZE (signal-desktop-7.38.0-npm-cache.tar.gz) = 315293668
 SHA256 (sqlcipher-v2-4.6.1-signal-patch2--0.2.0-b0dbebe5b2d81879984bfa2318ba364fb4d436669ddc1668d2406eaaaee40b7e.tar.gz) = b0dbebe5b2d81879984bfa2318ba364fb4d436669ddc1668d2406eaaaee40b7e
 SIZE (sqlcipher-v2-4.6.1-signal-patch2--0.2.0-b0dbebe5b2d81879984bfa2318ba364fb4d436669ddc1668d2406eaaaee40b7e.tar.gz) = 9422094
-SHA256 (signalapp-Signal-Desktop-v7.36.1_GH0.tar.gz) = bdd40182eb729458fc6b8156e73a4b1023b82d90e067180666f1e3241cbfb97a
-SIZE (signalapp-Signal-Desktop-v7.36.1_GH0.tar.gz) = 43049940
+SHA256 (signalapp-Signal-Desktop-v7.38.0_GH0.tar.gz) = 673283a2eadaf5a68aa29f85826be910801a9af0c478d753a9cd35de52f45d65
+SIZE (signalapp-Signal-Desktop-v7.38.0_GH0.tar.gz) = 43074060
diff --git a/net-im/signal-desktop/files/app-builder-lib+24.13.3.patch b/net-im/signal-desktop/files/app-builder-lib+24.13.3.patch
new file mode 100644
index 000000000000..43a058815712
--- /dev/null
+++ b/net-im/signal-desktop/files/app-builder-lib+24.13.3.patch
@@ -0,0 +1,260 @@
+diff --git a/node_modules/app-builder-lib/out/asar/asarUtil.js b/node_modules/app-builder-lib/out/asar/asarUtil.js
+index 7f37444..1a85145 100644
+--- a/node_modules/app-builder-lib/out/asar/asarUtil.js
++++ b/node_modules/app-builder-lib/out/asar/asarUtil.js
+@@ -31,10 +31,16 @@ class AsarPackager {
+         }
+         await (0, promises_1.mkdir)(path.dirname(this.outFile), { recursive: true });
+         const unpackedFileIndexMap = new Map();
+-        for (const fileSet of fileSets) {
++        const orderedFileSets = [
++            // Write dependencies first to minimize offset changes to asar header
++            ...fileSets.slice(1),
++            // Finish with the app files that change most often
++            fileSets[0]
++        ].map(orderFileSet);
++        for (const fileSet of orderedFileSets) {
+             unpackedFileIndexMap.set(fileSet, await this.createPackageFromFiles(fileSet, packager.info));
+         }
+-        await this.writeAsarFile(fileSets, unpackedFileIndexMap);
++        await this.writeAsarFile(orderedFileSets, unpackedFileIndexMap);
+     }
+     async createPackageFromFiles(fileSet, packager) {
+         const metadata = fileSet.metadata;
+@@ -238,4 +244,47 @@ function copyFileOrData(fileCopier, data, source, destination, stats) {
+         return (0, promises_1.writeFile)(destination, data);
+     }
+ }
++function orderFileSet(fileSet) {
++    const filesAndIndices = Array.from(fileSet.files.entries());
++    filesAndIndices.sort(([, a], [, b]) => {
++        if (a === b) {
++            return 0;
++        }
++        // Place addons last because their signature change
++        const isAAddon = a.endsWith('.node');
++        const isBAddon = b.endsWith('.node');
++        if (isAAddon && !isBAddon) {
++            return 1;
++        }
++        if (isBAddon && !isAAddon) {
++            return -1;
++        }
++        // Otherwise order by name
++        return a < b ? -1 : 1;
++    });
++    let transformedFiles;
++    if (fileSet.transformedFiles) {
++        transformedFiles = new Map();
++        const indexMap = new Map();
++        for (const [newIndex, [oldIndex,]] of filesAndIndices.entries()) {
++            indexMap.set(oldIndex, newIndex);
++        }
++        for (const [oldIndex, value] of fileSet.transformedFiles) {
++            const newIndex = indexMap.get(oldIndex);
++            if (newIndex === undefined) {
++                const file = fileSet.files[oldIndex];
++                throw new Error(`Internal error: ${file} was lost while ordering asar`);
++            }
++            transformedFiles.set(newIndex, value);
++        }
++    }
++    const { src, destination, metadata, } = fileSet;
++    return {
++        src,
++        destination,
++        metadata,
++        files: filesAndIndices.map(([, file]) => file),
++        transformedFiles,
++    };
++}
+ //# sourceMappingURL=asarUtil.js.map
+\ No newline at end of file
+diff --git a/node_modules/app-builder-lib/out/electron/ElectronFramework.js b/node_modules/app-builder-lib/out/electron/ElectronFramework.js
+index 2b09620..739e296 100644
+--- a/node_modules/app-builder-lib/out/electron/ElectronFramework.js
++++ b/node_modules/app-builder-lib/out/electron/ElectronFramework.js
+@@ -9,6 +9,7 @@ const path = require("path");
+ const index_1 = require("../index");
+ const pathManager_1 = require("../util/pathManager");
+ const electronMac_1 = require("./electronMac");
++const electronWin_1 = require("./electronWin");
+ const electronVersion_1 = require("./electronVersion");
+ const fs = require("fs/promises");
+ const injectFFMPEG_1 = require("./injectFFMPEG");
+@@ -39,6 +40,9 @@ async function beforeCopyExtraFiles(options) {
+     else if (packager.platform === index_1.Platform.WINDOWS) {
+         const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`);
+         await (0, fs_extra_1.rename)(path.join(appOutDir, `${electronBranding.projectName}.exe`), executable);
++        if (options.asarIntegrity) {
++            await (0, electronWin_1.addWinAsarIntegrity)(executable, options.asarIntegrity);
++        }
+     }
+     else {
+         await (0, electronMac_1.createMacApp)(packager, appOutDir, options.asarIntegrity, options.platformName === "mas");
+diff --git a/node_modules/app-builder-lib/out/electron/electronWin.js b/node_modules/app-builder-lib/out/electron/electronWin.js
+new file mode 100644
+index 0000000..f198807
+--- /dev/null
++++ b/node_modules/app-builder-lib/out/electron/electronWin.js
+@@ -0,0 +1,39 @@
++"use strict";
++Object.defineProperty(exports, "__esModule", { value: true });
++exports.addWinAsarIntegrity = void 0;
++const promises_1 = require("fs/promises");
++const cjs_1 = require("resedit/cjs");
++const builder_util_1 = require("builder-util");
++/** @internal */
++async function addWinAsarIntegrity(executablePath, asarIntegrity) {
++    const resedit = await (0, cjs_1.load)();
++    const buffer = await (0, promises_1.readFile)(executablePath);
++    const executable = resedit.NtExecutable.from(buffer);
++    const resource = resedit.NtExecutableResource.from(executable);
++    const versionInfo = resedit.Resource.VersionInfo.fromEntries(resource.entries);
++    if (versionInfo.length !== 1) {
++        throw new Error(`Failed to parse version info in ${executablePath}`);
++    }
++    const languages = versionInfo[0].getAllLanguagesForStringValues();
++    if (languages.length !== 1) {
++        throw new Error(`Failed to locate languages in ${executablePath}`);
++    }
++    // See: https://github.com/electron/packager/blob/00d20b99cf4aa4621103dbbd09ff7de7d2f7f539/src/resedit.ts#L124
++    const integrityList = Array.from(Object.entries(asarIntegrity)).map(([file, { algorithm: alg, hash: value }]) => ({
++        file,
++        alg,
++        value,
++    }));
++    resource.entries.push({
++        type: "INTEGRITY",
++        id: "ELECTRONASAR",
++        bin: Buffer.from(JSON.stringify(integrityList)),
++        lang: languages[0].lang,
++        codepage: languages[0].codepage,
++    });
++    resource.outputResource(executable);
++    await (0, promises_1.writeFile)(executablePath, Buffer.from(executable.generate()));
++    builder_util_1.log.info({ executablePath }, "updating asar integrity executable resource");
++}
++exports.addWinAsarIntegrity = addWinAsarIntegrity;
++//# sourceMappingURL=electronWin.js.map
+diff --git a/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js b/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js
+index c3f1000..62bd27c 100644
+--- a/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js
++++ b/node_modules/app-builder-lib/out/targets/LinuxTargetHelper.js
+@@ -100,7 +100,7 @@ class LinuxTargetHelper {
+             // https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables
+             const execCodes = ["%f", "%u", "%F", "%U"];
+             if (executableArgs == null || executableArgs.findIndex(arg => execCodes.includes(arg)) === -1) {
+-                exec += " %U";
++                exec += " --no-sandbox %U";
+             }
+         }
+         const desktopMeta = {
+diff --git a/node_modules/app-builder-lib/templates/linux/after-install.tpl b/node_modules/app-builder-lib/templates/linux/after-install.tpl
+index 65e7326..29a8c44 100644
+--- a/node_modules/app-builder-lib/templates/linux/after-install.tpl
++++ b/node_modules/app-builder-lib/templates/linux/after-install.tpl
+@@ -10,9 +10,6 @@ else
+     ln -sf '/opt/${sanitizedProductName}/${executable}' '/usr/bin/${executable}'
+ fi
+ 
+-# SUID chrome-sandbox for Electron 5+
+-chmod 4755 '/opt/${sanitizedProductName}/chrome-sandbox' || true
+-
+ if hash update-mime-database 2>/dev/null; then
+     update-mime-database /usr/share/mime || true
+ fi
+diff --git a/node_modules/app-builder-lib/templates/nsis/include/allowOnlyOneInstallerInstance.nsh b/node_modules/app-builder-lib/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
+index fe5d45c..8bb2bf4 100644
+--- a/node_modules/app-builder-lib/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
++++ b/node_modules/app-builder-lib/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
+@@ -43,6 +43,7 @@
+   !else
+     # find process owned by current user
+     nsExec::Exec `%SYSTEMROOT%\System32\cmd.exe /c tasklist /FI "USERNAME eq %USERNAME%" /FI "IMAGENAME eq ${_FILE}" /FO csv | %SYSTEMROOT%\System32\find.exe "${_FILE}"`
++    nsExec::Exec `"$SYSDIR\cmd.exe" /c tasklist /FI "USERNAME eq %USERNAME%" /FI "IMAGENAME eq ${_FILE}" /FO csv | "$SYSDIR\find.exe" "${_FILE}"`
+     Pop ${_ERR}
+   !endif
+ !macroend
+@@ -73,7 +74,7 @@
+       !ifdef INSTALL_MODE_PER_ALL_USERS
+         nsExec::Exec `taskkill /im "${APP_EXECUTABLE_FILENAME}" /fi "PID ne $pid"`
+       !else
+-        nsExec::Exec `%SYSTEMROOT%\System32\cmd.exe /c taskkill /im "${APP_EXECUTABLE_FILENAME}" /fi "PID ne $pid" /fi "USERNAME eq %USERNAME%"`
++        nsExec::Exec `"$SYSDIR\cmd.exe" /c taskkill /im "${APP_EXECUTABLE_FILENAME}" /fi "PID ne $pid" /fi "USERNAME eq %USERNAME%"`
+       !endif
+       # to ensure that files are not "in-use"
+       Sleep 300
+@@ -91,7 +92,7 @@
+           !ifdef INSTALL_MODE_PER_ALL_USERS
+             nsExec::Exec `taskkill /f /im "${APP_EXECUTABLE_FILENAME}" /fi "PID ne $pid"`
+           !else
+-            nsExec::Exec `%SYSTEMROOT%\System32\cmd.exe /c taskkill /f /im "${APP_EXECUTABLE_FILENAME}" /fi "PID ne $pid" /fi "USERNAME eq %USERNAME%"`
++            nsExec::Exec `"$SYSDIR\cmd.exe" /c taskkill /f /im "${APP_EXECUTABLE_FILENAME}" /fi "PID ne $pid" /fi "USERNAME eq %USERNAME%"`
+           !endif
+           !insertmacro FIND_PROCESS "${APP_EXECUTABLE_FILENAME}" $R0
+           ${If} $R0 == 0
+diff --git a/node_modules/app-builder-lib/templates/nsis/include/installer.nsh b/node_modules/app-builder-lib/templates/nsis/include/installer.nsh
+index 34e91df..73bfffc 100644
+--- a/node_modules/app-builder-lib/templates/nsis/include/installer.nsh
++++ b/node_modules/app-builder-lib/templates/nsis/include/installer.nsh
+@@ -90,7 +90,13 @@
+       ${if} $installMode == "all"
+         SetShellVarContext current
+       ${endif}
+-      !insertmacro copyFile "$EXEPATH" "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}"
++      # SIGNAL CHANGE START
++      # This file is needed for electron-builder's native incremental updates,
++      # but we have our own system so no need to place it. Clean it up instead.
++      #
++      # !insertmacro copyFile "$EXEPATH" "$LOCALAPPDATA\${APP_INSTALLER_STORE_FILE}"
++      RMDir /r /REBOOTOK "$LOCALAPPDATA\signal-desktop-updater"
++      # SIGNAL CHANGE END
+       ${if} $installMode == "all"
+         SetShellVarContext all
+       ${endif}
+diff --git a/node_modules/app-builder-lib/templates/nsis/installSection.nsh b/node_modules/app-builder-lib/templates/nsis/installSection.nsh
+index 053772f..7981a4e 100644
+--- a/node_modules/app-builder-lib/templates/nsis/installSection.nsh
++++ b/node_modules/app-builder-lib/templates/nsis/installSection.nsh
+@@ -22,11 +22,38 @@ StrCpy $appExe "$INSTDIR\${APP_EXECUTABLE_FILENAME}"
+       SpiderBanner::Show /MODERN
+     !endif
+ 
++    # Set text (1000 is the id of text element of SpiderBanner)
+     FindWindow $0 "#32770" "" $hwndparent
+     FindWindow $0 "#32770" "" $hwndparent $0
+-    GetDlgItem $0 $0 1000
+-    SendMessage $0 ${WM_SETTEXT} 0 "STR:$(installing)"
+ 
++    GetDlgItem $1 $0 1000
++    SendMessage $1 ${WM_SETTEXT} 0 "STR:$(installing)"
++
++    # Set header image compatible with "ManifestDPIAware" mode.
++    !ifdef HEADER_ICO
++      # Convert 24 Dialog Units to pixels:
++      # See https://github.com/mozilla/gecko-dev/blob/8de0e699002872d969aebf1bc8407e5c839a4472/toolkit/mozapps/installer/windows/nsis/common.nsh#L8801
++
++      # rect = LPRect { .left = 0, .top = 0, .right = 24, .bottom = 0 }
++      # See https://nsis.sourceforge.io/Docs/System/System.html#faq
++      System::Call "*(i 0, i 0, i 24, i 0) p.r1"
++
++      # Call `MapDialogRect(window, &rect)`
++      System::Call `user32::MapDialogRect(p $0, p r1)`
++
++      # rect.right now contains the converted value (24du => ?px).
++      # Place `rect.right` into `r2`
++      System::Call "*$1(i, i, i.r2, i)"
++      System::Free $1
++
++      # Load image and pass `r2` as both width and height, get the image handle
++      # back to `r2` register.
++      System::Call `user32::LoadImage(i 0, t "$PLUGINSDIR\installerHeaderico.ico", i ${IMAGE_ICON}, i r2, i r2, i ${LR_LOADFROMFILE}) i.r2`
++
++      # 1025 is the id of the icon of SpiderBanner.
++      GetDlgItem $1 $0 1025
++      SendMessage $1 ${STM_SETIMAGE} ${IMAGE_ICON} $2
++    !endif
+     StrCpy $1 $hwndparent
+ 		System::Call 'user32::ShutdownBlockReasonCreate(${SYSTYPE_PTR}r1, w "$(installing)")'
+   ${endif}
diff --git a/net-im/signal-desktop/files/dmg-builder+24.13.3.patch b/net-im/signal-desktop/files/dmg-builder+24.13.3.patch
new file mode 100644
index 000000000000..b97312ce4c76
--- /dev/null
+++ b/net-im/signal-desktop/files/dmg-builder+24.13.3.patch
@@ -0,0 +1,13 @@
+diff --git a/node_modules/dmg-builder/out/dmgLicense.js b/node_modules/dmg-builder/out/dmgLicense.js
+index b91be7d..dad9ceb 100644
+--- a/node_modules/dmg-builder/out/dmgLicense.js
++++ b/node_modules/dmg-builder/out/dmgLicense.js
+@@ -6,7 +6,7 @@ const js_yaml_1 = require("js-yaml");
+ const license_1 = require("app-builder-lib/out/util/license");
+ const fs_extra_1 = require("fs-extra");
+ const licenseButtons_1 = require("./licenseButtons");
+-const dmg_license_1 = require("dmg-license");
++// SIGNAL: const dmg_license_1 = require("dmg-license");
+ async function addLicenseToDmg(packager, dmgPath) {
+     const licenseFiles = await (0, license_1.getLicenseFiles)(packager);
+     if (licenseFiles.length === 0) {
diff --git a/net-im/signal-desktop/get_deps.sh b/net-im/signal-desktop/get_deps.sh
index fad8fb129e57..ce0f8daf62d0 100644
--- a/net-im/signal-desktop/get_deps.sh
+++ b/net-im/signal-desktop/get_deps.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-SIGNAL_VERS=v7.36.0
+SIGNAL_VERS=v7.38.0
 
 fetch -qo /tmp/package.json https://raw.githubusercontent.com/signalapp/Signal-Desktop/${SIGNAL_VERS}/package.json
 node_version=$(awk /'"node":'/'{print $2}' /tmp/package.json | sed 's/"//g')