jlink: Add automatic updater
This commit is contained in:
parent
0fafc95119
commit
cbbe164e4a
26
externals/packages/jlink/default.nix
vendored
26
externals/packages/jlink/default.nix
vendored
|
@ -19,32 +19,14 @@
|
||||||
, libXrandr
|
, libXrandr
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
jlinkVersion = "756a";
|
conf = (lib.importJSON ./version.json).${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
|
||||||
|
|
||||||
architecture = {
|
|
||||||
x86_64-linux = "x86_64";
|
|
||||||
i686-linux = "i386";
|
|
||||||
armv7l-linux = "arm";
|
|
||||||
aarch64-linux = "arm64";
|
|
||||||
}.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
|
|
||||||
|
|
||||||
sha256 = {
|
|
||||||
x86_64-linux = "1bg038042byrfn575n3add9l83i1clbav7fzm7ga7svfd06k4lny";
|
|
||||||
i686-linux = "0a1prsb91rhpy55qklmnh3r1ac6325yvk3gjwhy0dcl34fd0wjqf";
|
|
||||||
armv7l-linux = "1vvxsfizvdsgqv0f71nxqj5kmj9glx09z1jsrqq8h3ld95f92xmp";
|
|
||||||
aarch64-linux = "0gw50jnd92g1p4391qiyvcwmn76akc3f1f5arkax6dqcwim443gg";
|
|
||||||
}.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
|
|
||||||
|
|
||||||
url = "https://www.segger.com/downloads/jlink/JLink_Linux_V${jlinkVersion}_${architecture}.tgz";
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "jlink";
|
pname = "jlink";
|
||||||
version = jlinkVersion;
|
version = conf.version;
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = url;
|
inherit (conf) url sha256 curlOpts;
|
||||||
sha256 = sha256;
|
|
||||||
curlOpts = "-d accept_license_agreement=accepted -d non_emb_ctr=confirmed";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dontConfigure = true;
|
dontConfigure = true;
|
||||||
|
@ -83,6 +65,8 @@ stdenv.mkDerivation rec {
|
||||||
patchelf --add-needed libudev.so.1 $out/JLink/libjlinkarm.so
|
patchelf --add-needed libudev.so.1 $out/JLink/libjlinkarm.so
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
passthru.updateScript = ./update.py;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "https://www.segger.com/downloads/jlink";
|
homepage = "https://www.segger.com/downloads/jlink";
|
||||||
description = "SEGGER J-Link";
|
description = "SEGGER J-Link";
|
||||||
|
|
43
externals/packages/jlink/update.py
vendored
Executable file
43
externals/packages/jlink/update.py
vendored
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ beautifulsoup4 requests ] )" nix-prefetch
|
||||||
|
import requests
|
||||||
|
import bs4
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
URL_FORMAT = 'https://www.segger.com/downloads/jlink/JLink_Linux_V{version}_{arch}.tgz'
|
||||||
|
CURL_OPTS = '-d accept_license_agreement=accepted -d submit=Download+software'
|
||||||
|
|
||||||
|
page = requests.get('https://www.segger.com/downloads/jlink').text
|
||||||
|
elem = bs4.BeautifulSoup(page, features='lxml').find(
|
||||||
|
'select', {'class': 'version'}).find('option')
|
||||||
|
version = elem.children.__next__().lstrip('V')
|
||||||
|
|
||||||
|
|
||||||
|
arches = [
|
||||||
|
('x86_64-linux', 'x86_64'),
|
||||||
|
('i686-linux', 'i686'),
|
||||||
|
('armv7l-linux', 'arm'),
|
||||||
|
('aarch64-linux', 'arm64')
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
out_obj = {}
|
||||||
|
for nix_arch, jlink_arch in arches:
|
||||||
|
url = URL_FORMAT.format(version=version.replace('.', ''), arch=jlink_arch)
|
||||||
|
out = subprocess.run(
|
||||||
|
['nix-prefetch', f'{{fetchurl}}: fetchurl {{ url = "{url}"; curlOpts = "{CURL_OPTS}"; }}'], stdout=subprocess.PIPE, check=True)
|
||||||
|
sha256 = out.stdout.decode('utf8').strip()
|
||||||
|
out_obj[nix_arch] = {
|
||||||
|
'url': url,
|
||||||
|
'version': version,
|
||||||
|
'curlOpts': CURL_OPTS,
|
||||||
|
'sha256': sha256
|
||||||
|
}
|
||||||
|
|
||||||
|
out_file = open(os.path.join(BASE_DIR, 'version.json'), 'w')
|
||||||
|
json.dump(out_obj, out_file)
|
||||||
|
out_file.close()
|
1
externals/packages/jlink/version.json
vendored
Normal file
1
externals/packages/jlink/version.json
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"x86_64-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V758b_x86_64.tgz", "version": "7.58b", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "sha256": "sha256-kr1zCzvGx4pmhPeWEoXlouOMnZY69V59/cF8hakv7ps="}, "i686-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V758b_i686.tgz", "version": "7.58b", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "sha256": "sha256-d8gVsn3hYU39m15Tu5VkqOnocPTXyuCKmvLZsRw6fNw="}, "armv7l-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V758b_arm.tgz", "version": "7.58b", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "sha256": "sha256-ze5EEjboQuT4UVxw/rU3w4Pgsk5yHoLARURQxonl26w="}, "aarch64-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V758b_arm64.tgz", "version": "7.58b", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "sha256": "sha256-NFzo2udZ2ZuHdwG4ZGftI139LZPIrdso5adiMG09uh0="}}
|
Loading…
Reference in a new issue