From 75dc7411abe2bcfa72f0228e90b278e4da4497fb Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 16 Aug 2022 12:13:06 +0200 Subject: [PATCH] sublime4.updateScript: Pass versionFile path through arguments That way, `maintainers/scripts/update.nix` will be able to turn the path to relative and be able to update it even with `--argstr commit true`. --- .../applications/editors/sublime/4/common.nix | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/pkgs/applications/editors/sublime/4/common.nix b/pkgs/applications/editors/sublime/4/common.nix index 0e510687a068..0f2afb432e4c 100644 --- a/pkgs/applications/editors/sublime/4/common.nix +++ b/pkgs/applications/editors/sublime/4/common.nix @@ -122,24 +122,28 @@ in stdenv.mkDerivation (rec { ''; passthru = { - updateScript = writeShellScript "${packageAttribute}-update-script" '' - set -o errexit - PATH=${lib.makeBinPath [ common-updater-scripts curl ]} + updateScript = + let + script = writeShellScript "${packageAttribute}-update-script" '' + set -o errexit + PATH=${lib.makeBinPath [ common-updater-scripts curl ]} - latestVersion=$(curl -s "${versionUrl}") + versionFile=$1 + latestVersion=$(curl -s "${versionUrl}") - if [[ "${buildVersion}" = "$latestVersion" ]]; then - echo "The new version same as the old version." - exit 0 - fi + if [[ "${buildVersion}" = "$latestVersion" ]]; then + echo "The new version same as the old version." + exit 0 + fi - for platform in ${lib.escapeShellArgs meta.platforms}; do - # The script will not perform an update when the version attribute is up to date from previous platform run - # We need to clear it before each run - update-source-version "${packageAttribute}.${primaryBinary}" 0 "${lib.fakeSha256}" --file=${versionFile} --version-key=buildVersion --source-key="sources.$platform" - update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file=${versionFile} --version-key=buildVersion --source-key="sources.$platform" - done - ''; + for platform in ${lib.escapeShellArgs meta.platforms}; do + # The script will not perform an update when the version attribute is up to date from previous platform run + # We need to clear it before each run + update-source-version "${packageAttribute}.${primaryBinary}" 0 "${lib.fakeSha256}" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform" + update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform" + done + ''; + in [ script versionFile ]; }; meta = with lib; {