mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-02 02:03:21 +00:00
sublime-merge.updateScript: sync with sublime4
See the parent commits.
This commit is contained in:
parent
75dc7411ab
commit
424802ffc5
@ -1,33 +1,28 @@
|
||||
{ buildVersion, sha256, dev ? false }:
|
||||
{ buildVersion, x64sha256, dev ? false }:
|
||||
|
||||
{ fetchurl, lib, stdenv, xorg, glib, libGL, glibcLocales, gtk3, cairo, pango, libredirect, makeWrapper, wrapGAppsHook
|
||||
, pkexecPath ? "/run/wrappers/bin/pkexec"
|
||||
, writeScript, common-updater-scripts, curl, gnugrep, coreutils
|
||||
, writeShellScript, common-updater-scripts, curl, gnugrep, coreutils
|
||||
}:
|
||||
|
||||
let
|
||||
pname = "sublime-merge";
|
||||
pnameBase = "sublime-merge";
|
||||
packageAttribute = "sublime-merge${lib.optionalString dev "-dev"}";
|
||||
binaries = [ "sublime_merge" "crash_reporter" "git-credential-sublime" "ssh-askpass-sublime" ];
|
||||
primaryBinary = "sublime_merge";
|
||||
primaryBinaryAliases = [ "smerge" ];
|
||||
downloadUrl = "https://download.sublimetext.com/sublime_merge_build_${buildVersion}_${arch}.tar.xz";
|
||||
downloadUrl = arch: "https://download.sublimetext.com/sublime_merge_build_${buildVersion}_${arch}.tar.xz";
|
||||
versionUrl = "https://www.sublimemerge.com/${if dev then "dev" else "download"}";
|
||||
versionFile = builtins.toString ./default.nix;
|
||||
archSha256 = sha256;
|
||||
arch = "x64";
|
||||
|
||||
libPath = lib.makeLibraryPath [ xorg.libX11 glib gtk3 cairo pango curl ];
|
||||
redirects = [ "/usr/bin/pkexec=${pkexecPath}" "/bin/true=${coreutils}/bin/true" ];
|
||||
in let
|
||||
binaryPackage = stdenv.mkDerivation {
|
||||
pname = "${pname}-bin";
|
||||
binaryPackage = stdenv.mkDerivation rec {
|
||||
pname = "${pnameBase}-bin";
|
||||
version = buildVersion;
|
||||
|
||||
src = fetchurl {
|
||||
url = downloadUrl;
|
||||
sha256 = archSha256;
|
||||
};
|
||||
src = passthru.sources.${stdenv.hostPlatform.system};
|
||||
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
@ -78,9 +73,18 @@ in let
|
||||
makeWrapper $out/.${primaryBinary}-wrapped $out/ssh-askpass-sublime \
|
||||
--argv0 "/ssh-askpass-sublime"
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
sources = {
|
||||
"x86_64-linux" = fetchurl {
|
||||
url = downloadUrl "x64";
|
||||
sha256 = x64sha256;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in stdenv.mkDerivation (rec {
|
||||
inherit pname;
|
||||
pname = pnameBase;
|
||||
version = buildVersion;
|
||||
|
||||
dontUnpack = true;
|
||||
@ -102,20 +106,30 @@ in stdenv.mkDerivation (rec {
|
||||
done
|
||||
'';
|
||||
|
||||
passthru.updateScript = writeScript "${pname}-update-script" ''
|
||||
#!${stdenv.shell}
|
||||
set -o errexit
|
||||
PATH=${lib.makeBinPath [ common-updater-scripts curl gnugrep ]}
|
||||
passthru = {
|
||||
updateScript =
|
||||
let
|
||||
script = writeShellScript "${pnameBase}-update-script" ''
|
||||
set -o errexit
|
||||
PATH=${lib.makeBinPath [ common-updater-scripts curl gnugrep ]}
|
||||
|
||||
latestVersion=$(curl -s ${versionUrl} | grep -Po '(?<=<p class="latest"><i>Version:</i> Build )([0-9]+)')
|
||||
versionFile=$1
|
||||
latestVersion=$(curl -s ${versionUrl} | grep -Po '(?<=<p class="latest"><i>Version:</i> Build )([0-9]+)')
|
||||
|
||||
for platform in ${lib.concatStringsSep " " 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 0000000000000000000000000000000000000000000000000000000000000000 --file=${versionFile} --version-key=buildVersion --system=$platform
|
||||
update-source-version ${packageAttribute}.${primaryBinary} $latestVersion --file=${versionFile} --version-key=buildVersion --system=$platform
|
||||
done
|
||||
'';
|
||||
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
|
||||
'';
|
||||
in [ script versionFile ];
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Git client from the makers of Sublime Text";
|
||||
|
@ -5,12 +5,12 @@ let
|
||||
in {
|
||||
sublime-merge = common {
|
||||
buildVersion = "2074";
|
||||
sha256 = "REo59Lpi0fmAOp0XJa4Iln3VKxR5kRiMpz2zfqz1MQs=";
|
||||
x64sha256 = "REo59Lpi0fmAOp0XJa4Iln3VKxR5kRiMpz2zfqz1MQs=";
|
||||
} {};
|
||||
|
||||
sublime-merge-dev = common {
|
||||
buildVersion = "2073";
|
||||
sha256 = "AQ0ESdi45LHndRNJnkYS+o9L+dlRJkw3nzBfJo8FYPc=";
|
||||
x64sha256 = "AQ0ESdi45LHndRNJnkYS+o9L+dlRJkw3nzBfJo8FYPc=";
|
||||
dev = true;
|
||||
} {};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user