1 #!/usr/bin/env nix-shell
2 #!nix-shell -i python -p python3 python3Packages.looseversion common-updater-scripts nurl
8 from looseversion
import LooseVersion
9 from subprocess
import run
11 parser
= argparse
.ArgumentParser()
12 parser
.add_argument("--lts", action
="store_true")
13 parser
.add_argument("--regex")
14 args
= parser
.parse_args()
16 nixpkgs_path
= os
.environ
["PWD"]
19 file = f
"pkgs/by-name/in/incus/package.nix"
22 file = f
"pkgs/by-name/in/incus/lts.nix"
25 run(["list-git-tags", "--url=https://github.com/lxc/incus"], capture_output
=True)
26 .stdout
.decode("utf-8")
29 tags
= [t
.lstrip("v") for t
in tags
]
33 if args
.regex
!= None and not re
.match(args
.regex
, tag
):
36 if LooseVersion(tag
) > LooseVersion(latest_version
):
41 ["nix", "eval", "--raw", "-f", "default.nix", f
"{attr}.version"],
44 .stdout
.decode("utf-8")
48 if LooseVersion(latest_version
) <= LooseVersion(current_version
):
49 print("No update available")
52 print(f
"Found new version {latest_version} > {current_version}")
54 run(["update-source-version", attr
, latest_version
, f
"--file={file}"])
56 current_vendor_hash
= (
64 f
"{attr}.goModules.drvAttrs.outputHash",
69 .stdout
.decode("utf-8")
74 latest_vendor_hash
= (
76 ["nurl", "--expr", f
"(import {nixpkgs_path} {{}}).{attr}.goModules"],
79 .stdout
.decode("utf-8")
83 with
open(file, "r+") as f
:
84 file_content
= f
.read()
85 file_content
= re
.sub(current_vendor_hash
, latest_vendor_hash
, file_content
)