git » autoupdaters.git » main » tree

[main] / kicad.py

#!/usr/bin/env python3

from urllib.request import urlopen, Request
import os
import sys
import xml.etree.ElementTree as ET
from subprocess import run,DEVNULL,STDOUT
from autoupdater_helpers import *

os.chdir("/sources/base-pkgbuilds/kicad")

url = "https://www.kicad.org/blog/index.xml"
user_agent = "Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"
req = Request(url, headers={'User-Agent': user_agent})

with urlopen(req, context=ssl_ctx()) as f:
    blog_rss = ET.parse(f)

for title in blog_rss.getroot().findall('./channel/item/title'): 
    if title.text.startswith("KiCad ") and title.text.endswith(" Release"):
        (_,ver,_) = title.text.split()
        break

print("KiCad version:", ver)

prev_ver = pkgbuild_ver()

if ver == prev_ver:
    print("Update not necessary")
    sys.exit(0)

pkgbuild_new_ver(ver)

os.chdir("../kicad-library")

pkgbuild_new_ver(ver)

os.chdir("..")

print(f"Updating {prev_ver} to {ver}")
mpkg("kicad", ver)
mpkg("kicad-library", ver)