#!/usr/bin/env bash # feed-check: cross-check DistroHopper's supported OSes against the # distro-feeds (https://github.com/oSoWoSo/distro-feeds) release feed. # # For every supported OS that appears in the feed, report whether # DistroHopper offers that exact ISO URL (OFFERED) and whether the ISO # is actually downloadable (AVAILABLE). # # Usage: feed-check [os] (no arg = all OSes present in the feed) set -u SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "${SCRIPT_DIR}" FEED_URL="https://raw.githubusercontent.com/oSoWoSo/distro-feeds/public/releases.xml" WANT_OS="${1:-}" # Parse the feed into TSV: dw_slug dh_os iso_url title TMP="$(mktemp)" trap 'rm -f "${TMP}"' EXIT python3 - "${WANT_OS}" "${TMP}" <<'PY' import urllib.request, xml.etree.ElementTree as ET, re, sys, subprocess want = sys.argv[1].strip().lower() if len(sys.argv) > 1 else "" out_path = sys.argv[2] def norm(s): s = s.lower().strip().replace("-", "") if s.endswith("linux"): s = s[:-5] return s os_list = subprocess.check_output(["./qget", "--list-os"]).decode().split() dh_map = {norm(o): o for o in os_list} data = urllib.request.urlopen( "https://raw.githubusercontent.com/oSoWoSo/distro-feeds/public/releases.xml").read() root = ET.fromstring(data) ns = {"a": "http://www.w3.org/2005/Atom"} lines = [] for e in root.findall("a:entry", ns): id_ = e.find("a:id", ns).text dw_slug = id_.rsplit("/", 1)[-1] title = e.find("a:title", ns).text or "" content = e.find("a:content", ns).text or "" m = re.search(r'href="([^"]+)"[^>]*>ISO', content) iso_url = m.group(1) if m else "" dh_os = dh_map.get(norm(dw_slug), "") if want and dh_os.lower() != want and dw_slug.lower() != want: continue lines.append(f"{dw_slug}|{dh_os}|{iso_url}|{title}") with open(out_path, "w") as f: f.write("\n".join(lines) + ("\n" if lines else "")) PY PASS=0; FAIL=0; SKIP=0 while IFS=$'|' read -r dw_slug dh_os iso_url title; do [ -z "${dw_slug}" ] && continue if [ -z "${dh_os}" ]; then echo "SKIP: ${dw_slug} (${title}) -- not supported by DistroHopper" SKIP=$((SKIP+1)) continue fi if [ -z "${iso_url}" ]; then echo "SKIP: ${dh_os} (${title}) -- no ISO in feed" SKIP=$((SKIP+1)) continue fi # HTTP availability of the feed's ISO http_code="$(curl --silent --output /dev/null --write-out '%{http_code}' \ --location --max-time 30 --connect-timeout 10 "${iso_url}" 2>/dev/null)" if [ "${http_code}" = "200" ]; then avail="AVAILABLE" else avail="BROKEN(${http_code})" fi # Is this ISO offered by DistroHopper? Compare by filename, since # mirrors/paths may differ between the feed and DistroHopper. offered="no" iso_name="${iso_url##*/}" if ./qget --check "${dh_os}" 2>/dev/null | grep -qF "${iso_name}"; then offered="yes" fi if [ "${offered}" = "yes" ] && [ "${avail}" = "AVAILABLE" ]; then echo "PASS: ${dh_os} offered=${offered} ${avail} ${iso_url}" PASS=$((PASS+1)) elif [ "${avail}" != "AVAILABLE" ]; then echo "FAIL: ${dh_os} offered=${offered} ${avail} ${iso_url}" FAIL=$((FAIL+1)) else echo "INFO: ${dh_os} offered=${offered} ${avail} ${iso_url} (latest from feed not offered by DistroHopper)" SKIP=$((SKIP+1)) fi done < "${TMP}" echo echo "Results: PASS=${PASS} FAIL=${FAIL} SKIP=${SKIP}" if [ "${FAIL}" -gt 0 ]; then exit 1 fi exit 0