From efe5ba0c4ffe03a100a3a1750983b7d9edbbba8d Mon Sep 17 00:00:00 2001 From: Anatolii Popov Date: Fri, 8 Apr 2022 14:53:32 +0300 Subject: [PATCH 1/2] jetbrains: update script fixes --- .../editors/jetbrains/default.nix | 26 ++++++++-------- pkgs/applications/editors/jetbrains/update.py | 31 ++++++++++--------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/pkgs/applications/editors/jetbrains/default.nix b/pkgs/applications/editors/jetbrains/default.nix index 86eb399dd44a..b534eaa3cf97 100644 --- a/pkgs/applications/editors/jetbrains/default.nix +++ b/pkgs/applications/editors/jetbrains/default.nix @@ -260,7 +260,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 { @@ -273,7 +273,7 @@ in sha256 = products.datagrip.sha256; }; wmClass = "jetbrains-datagrip"; - update-channel = "DataGrip RELEASE"; + update-channel = products.datagrip.update-channel; }; goland = buildGoland rec { @@ -286,7 +286,7 @@ in sha256 = products.goland.sha256; }; wmClass = "jetbrains-goland"; - update-channel = "GoLand RELEASE"; + update-channel = products.goland.update-channel; }; idea-community = buildIdea rec { @@ -300,7 +300,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 { @@ -314,12 +314,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; @@ -328,7 +328,7 @@ in sha256 = products.mps.sha256; }; wmClass = "jetbrains-mps"; - update-channel = "MPS RELEASE"; + update-channel = products.mps.update-channel; }; phpstorm = buildPhpStorm rec { @@ -341,7 +341,7 @@ in sha256 = products.phpstorm.sha256; }; wmClass = "jetbrains-phpstorm"; - update-channel = "PhpStorm RELEASE"; + update-channel = products.phpstorm.update-channel; }; pycharm-community = buildPycharm rec { @@ -355,7 +355,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 { @@ -369,7 +369,7 @@ in sha256 = products.pycharm-professional.sha256; }; wmClass = "jetbrains-pycharm"; - update-channel = "PyCharm RELEASE"; + update-channel = products.pycharm-professional.update-channel; }; rider = buildRider rec { @@ -382,7 +382,7 @@ in sha256 = products.rider.sha256; }; wmClass = "jetbrains-rider"; - update-channel = "Rider RELEASE"; + update-channel = products.rider.update-channel; }; ruby-mine = buildRubyMine rec { @@ -395,7 +395,7 @@ in sha256 = products.ruby-mine.sha256; }; wmClass = "jetbrains-rubymine"; - update-channel = "RubyMine RELEASE"; + update-channel = products.ruby-mine.update-channel; }; webstorm = buildWebStorm rec { @@ -408,7 +408,7 @@ in sha256 = products.webstorm.sha256; }; wmClass = "jetbrains-webstorm"; - update-channel = "WebStorm RELEASE"; + update-channel = products.webstorm.update-channel; }; } diff --git a/pkgs/applications/editors/jetbrains/update.py b/pkgs/applications/editors/jetbrains/update.py index 5301a85ba9a2..fe57f75c72e1 100755 --- a/pkgs/applications/editors/jetbrains/update.py +++ b/pkgs/applications/editors/jetbrains/update.py @@ -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) From 6abf6b46adfcb11be3dc0187ff07e4ddae8d3e2e Mon Sep 17 00:00:00 2001 From: Anatolii Popov Date: Fri, 8 Apr 2022 15:22:11 +0300 Subject: [PATCH 2/2] maintainers: adding AnatolyPopov --- maintainers/maintainer-list.nix | 6 ++++++ pkgs/applications/editors/jetbrains/default.nix | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index c2788a7193bb..49c71a4b581c 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -681,6 +681,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"; diff --git a/pkgs/applications/editors/jetbrains/default.nix b/pkgs/applications/editors/jetbrains/default.nix index b534eaa3cf97..407e5fea3db8 100644 --- a/pkgs/applications/editors/jetbrains/default.nix +++ b/pkgs/applications/editors/jetbrains/default.nix @@ -124,7 +124,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; }; });