nongnu: Update google-chrome-*
update google chrome. also I made this script to help with the update process:
#! /usr/bin/env -S guix shell python-wrapper -- python
"""This script automatically updates google-chrome."""
# Usage: ./chrome_update.py
# Most of this script is based on the update.py script from Nixpkgs:
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/browsers/chromium/update.py
import json
import re
import subprocess
from urllib.request import urlopen
RELEASES_URL = 'https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/all/versions/all/releases'
DEB_URL = 'https://dl.google.com/linux/chrome/deb/pool/main/g'
def guix_download(url):
"""Prefetches the content of the given URL and returns its hash."""
out = subprocess.check_output(['guix', 'download', url], stderr=subprocess.DEVNULL).decode().splitlines()[-1]
return out
with urlopen(RELEASES_URL) as resp:
releases = json.load(resp)['releases']
for release in releases:
if "endTime" in release["serving"]:
continue
channel_name = re.findall("chrome\/platforms\/linux\/channels\/(.*)\/versions\/", release['name'])[0]
channel = {'version': release['version']}
if channel_name == 'dev':
google_chrome_suffix = 'unstable'
elif channel_name == 'ungoogled-chromium':
google_chrome_suffix = 'stable'
else:
google_chrome_suffix = channel_name
channel['name'] = f"google-chrome-{google_chrome_suffix}"
try:
channel['hash'] = guix_download(
f'{DEB_URL}/{channel["name"]}/' +
f'{channel["name"]}_{release["version"]}-1_amd64.deb')
except subprocess.CalledProcessError:
# This release isn't actually available yet. Continue to
# the next one.
continue
print(f"====================================== {channel['name']} ===================================")
print(f"Version: {channel['version']}")
print(f"Hash: {channel['hash']}")
print("Commit message:\n\n")
print(f"nongnu: Update {channel['name']} to {channel['version']}. ")
print("")
print(f"* nongnu/packages/chrome.scm ({channel['name']}): Update to {channel['version']}.")
print("")
Is there some place we could put this? Maybe a scripts
directory in the root of the channel but then maybe guile module should be moved under a new directory modules
and .guix-channel
updated accordingly? What do you think?