1 #! /usr/bin/env nix-shell
2 #! nix-shell -i python3 -p python3Packages.packaging python3Packages.python-debian common-updater-scripts
7 from urllib
import request
9 from collections
import OrderedDict
10 from debian
.deb822
import Packages
11 from debian
.debian_support
import Version
12 from os
.path
import abspath
, dirname
14 PIN_PATH
= dirname(abspath(__file__
)) + '/default.nix'
17 packages_url
= 'https://packages.microsoft.com/repos/edge/dists/stable/main/binary-amd64/Packages'
18 handle
= request
.urlopen(packages_url
)
22 def latest_packages(packages
: bytes
):
23 latest_packages
: OrderedDict
[str, Packages
] = {}
24 for package
in Packages
.iter_paragraphs(packages
, use_apt_pkg
=False):
25 name
: str = package
['Package']
26 if not name
.startswith('microsoft-edge-stable'):
28 channel
= name
.replace('microsoft-edge-', '')
29 if channel
not in latest_packages
:
30 latest_packages
[channel
] = package
32 old_package
= latest_packages
[channel
]
33 if old_package
.get_version() < package
.get_version(): # type: ignore
34 latest_packages
[channel
] = package
35 return OrderedDict(sorted(latest_packages
.items(), key
=lambda x
:x
[0]))
38 def write_expression():
39 latest
= latest_packages(packages())
40 version
= Version
.re_valid_version
.match(latest
['stable']['Version']).group('upstream_version')
41 os
.system(f
'update-source-version microsoft-edge "{version}"')