Merge pull request #167862 from AnatolyPopov/jetbrains-update-script-fixes

This commit is contained in:
Ben Siraphob 2022-05-02 10:18:28 -06:00 committed by GitHub
commit fa86dc7089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 28 deletions

View File

@ -687,6 +687,12 @@
github = "an-empty-string";
githubId = 681716;
};
AnatolyPopov = {
email = "aipopov@live.ru";
github = "AnatolyPopov";
githubId = 2312534;
name = "Anatolii Popov";
};
andehen = {
email = "git@andehen.net";
github = "andehen";

View File

@ -127,7 +127,7 @@ let
with JUnit, TestNG, popular SCMs, Ant & Maven. Also known
as IntelliJ.
'';
maintainers = with maintainers; [ edwtjo gytis-ivaskevicius steinybot ];
maintainers = with maintainers; [ edwtjo gytis-ivaskevicius steinybot AnatolyPopov ];
platforms = ideaPlatforms;
};
});
@ -263,7 +263,7 @@ in
sha256 = products.clion.sha256;
};
wmClass = "jetbrains-clion";
update-channel = "CLion RELEASE"; # channel's id as in http://www.jetbrains.com/updates/updates.xml
update-channel = products.clion.update-channel;
};
datagrip = buildDataGrip rec {
@ -276,7 +276,7 @@ in
sha256 = products.datagrip.sha256;
};
wmClass = "jetbrains-datagrip";
update-channel = "DataGrip RELEASE";
update-channel = products.datagrip.update-channel;
};
goland = buildGoland rec {
@ -289,7 +289,7 @@ in
sha256 = products.goland.sha256;
};
wmClass = "jetbrains-goland";
update-channel = "GoLand RELEASE";
update-channel = products.goland.update-channel;
};
idea-community = buildIdea rec {
@ -303,7 +303,7 @@ in
sha256 = products.idea-community.sha256;
};
wmClass = "jetbrains-idea-ce";
update-channel = "IntelliJ IDEA RELEASE";
update-channel = products.idea-community.update-channel;
};
idea-ultimate = buildIdea rec {
@ -317,12 +317,12 @@ in
sha256 = products.idea-ultimate.sha256;
};
wmClass = "jetbrains-idea";
update-channel = "IntelliJ IDEA RELEASE";
update-channel = products.idea-ultimate.update-channel;
};
mps = buildMps rec {
pname = "mps";
product = "MPS ${products.mps.version-major-minor}";
product = "MPS ${products.mps.version}";
version = products.mps.version;
description = "Create your own domain-specific language";
license = lib.licenses.asl20;
@ -331,7 +331,7 @@ in
sha256 = products.mps.sha256;
};
wmClass = "jetbrains-mps";
update-channel = "MPS RELEASE";
update-channel = products.mps.update-channel;
};
phpstorm = buildPhpStorm rec {
@ -344,7 +344,7 @@ in
sha256 = products.phpstorm.sha256;
};
wmClass = "jetbrains-phpstorm";
update-channel = "PhpStorm RELEASE";
update-channel = products.phpstorm.update-channel;
};
pycharm-community = buildPycharm rec {
@ -358,7 +358,7 @@ in
sha256 = products.pycharm-community.sha256;
};
wmClass = "jetbrains-pycharm-ce";
update-channel = "PyCharm RELEASE";
update-channel = products.pycharm-community.update-channel;
};
pycharm-professional = buildPycharm rec {
@ -372,7 +372,7 @@ in
sha256 = products.pycharm-professional.sha256;
};
wmClass = "jetbrains-pycharm";
update-channel = "PyCharm RELEASE";
update-channel = products.pycharm-professional.update-channel;
};
rider = buildRider rec {
@ -385,7 +385,7 @@ in
sha256 = products.rider.sha256;
};
wmClass = "jetbrains-rider";
update-channel = "Rider RELEASE";
update-channel = products.rider.update-channel;
};
ruby-mine = buildRubyMine rec {
@ -398,7 +398,7 @@ in
sha256 = products.ruby-mine.sha256;
};
wmClass = "jetbrains-rubymine";
update-channel = "RubyMine RELEASE";
update-channel = products.ruby-mine.update-channel;
};
webstorm = buildWebStorm rec {
@ -411,7 +411,7 @@ in
sha256 = products.webstorm.sha256;
};
wmClass = "jetbrains-webstorm";
update-channel = "WebStorm RELEASE";
update-channel = products.webstorm.update-channel;
};
}

View File

@ -1,6 +1,5 @@
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 python3.pkgs.packaging python3.pkgs.requests python3.pkgs.xmltodict
import hashlib
import json
import pathlib
import logging
@ -33,7 +32,8 @@ def download_channels():
def build_version(build):
return version.parse(build["@version"])
build_number = build["@fullNumber"] if "@fullNumber" in build else build["@number"]
return version.parse(build_number)
def latest_build(channel):
@ -43,11 +43,10 @@ def latest_build(channel):
def download_sha256(url):
url = f"{url}.sha256"
download_response = requests.get(url)
download_response.raise_for_status()
h = hashlib.sha256()
h.update(download_response.content)
return h.hexdigest()
return download_response.content.decode('UTF-8').split(' ')[0]
channels = download_channels()
@ -63,18 +62,22 @@ def update_product(name, product):
else:
try:
build = latest_build(channel)
version = build["@version"]
parsed_version = build_version(build)
version_major_minor = f"{parsed_version.major}.{parsed_version.minor}"
download_url = product["url-template"].format(version = version, versionMajorMinor = version_major_minor)
new_version = build["@version"]
new_build_number = build["@fullNumber"]
if "EAP" not in channel["@name"]:
version_or_build_number = new_version
else:
version_or_build_number = new_build_number
version_number = new_version.split(' ')[0]
download_url = product["url-template"].format(version=version_or_build_number, versionMajorMinor=version_number)
product["url"] = download_url
product["version-major-minor"] = version_major_minor
if "sha256" not in product or product.get("version") != version:
logging.info("Found a newer version %s.", version)
product["version"] = version
if "sha256" not in product or product.get("build_number") != new_build_number:
logging.info("Found a newer version %s with build number %s.", new_version, new_build_number)
product["version"] = new_version
product["build_number"] = new_build_number
product["sha256"] = download_sha256(download_url)
else:
logging.info("Already at the latest version %s.", version)
logging.info("Already at the latest version %s with build number %s.", new_version, new_build_number)
except Exception as e:
logging.exception("Update failed:", exc_info=e)
logging.warning("Skipping %s due to the above error.", name)