#!/usr/bin/env python3
from urllib.request import urlopen
import json
import os
import sys
from subprocess import run,DEVNULL,STDOUT
from autoupdater_helpers import *
os.chdir("/sources/base-pkgbuilds/firefox")
url = "https://product-details.mozilla.org/1.0/firefox_versions.json"
ctx = ssl_ctx()
with urlopen(url, context=ctx) as f:
versions = json.load(f)
ver = versions['LATEST_FIREFOX_VERSION']
prev_ver = pkgbuild_ver()
if ver == prev_ver:
print("Update not necessary")
sys.exit(0)
sums = "https://archive.mozilla.org/pub/firefox/releases/" + ver + "/SHA256SUMS"
for line in urlopen(sums, context=ctx):
line = line.decode().strip()
if "source/firefox-" in line:
(sha256sum,_) = line.split(" ",maxsplit=1)
break
pkgbuild_new_ver(ver, sha256sum)
os.chdir("../firefox-i18n")
pkgbuild_new_ver(ver)
os.chdir("..")
print(f"Updating {prev_ver} to {ver} (sum:{sha256sum})")
mpkg("firefox", ver)
mpkg("firefox-i18n", ver)