diff --git a/package.json b/package.json index 948ca1b993..f0ac4c6629 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "prepare-adhoc-build": "node scripts/prepare_adhoc_build.js", "prepare-adhoc-version": "node scripts/prepare_tagged_version.js adhoc", "prepare-staging-build": "node scripts/prepare_staging_build.js", + "prepare-linux-build": "node scripts/prepare_linux_build.js", "test": "run-s test-node test-electron test-lint-intl test-eslint", "test-electron": "node ts/scripts/test-electron.js", "test-release": "node ts/scripts/test-release.js", diff --git a/reproducible-builds/build.sh b/reproducible-builds/build.sh index e4667aa1d9..40b802f9cc 100755 --- a/reproducible-builds/build.sh +++ b/reproducible-builds/build.sh @@ -3,7 +3,15 @@ # SPDX-License-Identifier: AGPL-3.0-only # Usage: -# ./build.sh [ dev (default) | public (prod and beta builds) | alpha | test | staging ] [ Build timestamp override. Defaults to latest git commit or 1. ] +# ./build.sh [ dev (default) | public (prod and beta builds) | alpha | test | staging ] +# Env vars: +# SOURCE_DATE_EPOCH: Build timestamp override. Defaults to latest git commit or 1. +# SKIP_DOCKER_BUILD: To support docker build cache during actions. +# BUILD_TARGETS: Override build targets. Empty default results in deb. + +# Examples: +# ./build.sh public +# SOURCE_DATE_EPOCH=123 ./build.sh test # First we prepare the docker container in which our build scripts will run. This container includes # all build dependencies at specific versions. @@ -19,9 +27,9 @@ cd .. # Prepare the timestamp of the actual build based on the latest git commit. source_date_epoch=1 -if [ "$2" != "" ]; then +if [ -n "${SOURCE_DATE_EPOCH}" ]; then echo "Using override timestamp for SOURCE_DATE_EPOCH." - source_date_epoch=$(($2)) + source_date_epoch="${SOURCE_DATE_EPOCH}" else git_timestamp=$(git log -1 --pretty=%ct) if [ "${git_timestamp}" != "" ]; then @@ -45,4 +53,5 @@ docker run --rm \ -e NPM_CONFIG_CACHE=/tmp/.npm-cache \ -e PNPM_HOME=/tmp/.pnpm-home \ -e SOURCE_DATE_EPOCH=$source_date_epoch \ + -e BUILD_TARGETS=$BUILD_TARGETS \ signal-desktop $1 diff --git a/reproducible-builds/docker-entrypoint.sh b/reproducible-builds/docker-entrypoint.sh index c9cfb14824..118ef910c5 100644 --- a/reproducible-builds/docker-entrypoint.sh +++ b/reproducible-builds/docker-entrypoint.sh @@ -66,4 +66,8 @@ else exit 1 fi +if [ "${BUILD_TARGETS}" != "" ]; then + pnpm run prepare-linux-build $BUILD_TARGETS +fi + pnpm run build-linux diff --git a/scripts/prepare_linux_build.js b/scripts/prepare_linux_build.js new file mode 100644 index 0000000000..c41bdde6a5 --- /dev/null +++ b/scripts/prepare_linux_build.js @@ -0,0 +1,30 @@ +// Copyright 2025 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +const fs = require('node:fs'); +const _ = require('lodash'); + +const TARGETS = new Set(['appimage', 'deb']); + +const targets = (process.argv[2] || '').split(','); +if ( + targets.length === 0 || + !targets.every(target => TARGETS.has(target.toLowerCase())) +) { + console.error( + `Invalid linux targets ${targets}. Valid options: ${[...TARGETS]}` + ); + process.exit(1); +} + +const { default: packageJson } = require('./packageJson.js'); + +console.log('prepare_linux_build: updating package.json'); + +// ------ + +_.set(packageJson, 'build.linux.target', targets); + +// ------- + +fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, ' '));