sd-card-images/metascripts/rebuild-jekyll-boards

59 lines
2.0 KiB
Python
Executable File

#!/usr/bin/env python3
import csv, os, glob
for x in glob.glob("docs/_boards/*.md"):
os.remove(x)
for x in glob.glob("docs/_debians/*.md"):
os.remove(x)
chips = {}
isa_to_arch = {
"armv7": "armhf",
"armv8": "arm64",
"x86": "i386",
"x86-64": "amd64",
}
with open("chips.csv") as csvfile:
chipsf = csv.reader(csvfile)
next(chipsf)
for row in chipsf:
if not row:
continue
if row[0].strip().startswith("#"):
continue
chips[row[0]] = row
with open("boards.csv") as csvfile:
boardsf = csv.reader(csvfile)
next(boardsf)
for row in boardsf:
if not row:
continue
if row[0].strip().startswith("#"):
continue
with open("docs/_boards/%s.md" % row[0], "w") as boardf:
boardf.write("---\n")
boardf.write("layout: board\n")
boardf.write("title: %s SD card images\n" % (row[1]))
boardf.write("description: \"Minimal, pure and up-to-date vanilla Debian/Ubuntu %s SD card images for %s by %s, SoC: %s %s, CPU ISA: %s\"\n" % (isa_to_arch[chips[row[3]][4]], row[1], row[2], chips[row[3]][2], chips[row[3]][1], chips[row[3]][4]))
boardf.write("board_id: %s\n" % (row[0]))
boardf.write("board_dtb_name: %s\n" % (row[6]))
boardf.write("board_name: %s\n" % (row[1]))
boardf.write("board_maker_name: %s\n" % (row[2]))
boardf.write("board_soc_name: %s %s\n" % (chips[row[3]][2], chips[row[3]][1]))
boardf.write("board_cpu_name: %s (%s)\n" % (chips[row[3]][3], chips[row[3]][4]))
boardf.write("board_cpu_arch_isa: %s\n" % (chips[row[3]][4]))
boardf.write("board_cpu_arch_debian: %s\n" % (isa_to_arch[chips[row[3]][4]]))
boardf.write("---\n")
with open("debians-arm.csv") as csvfile:
debiansf = csv.reader(csvfile)
next(debiansf)
for row in debiansf:
if not row:
continue
if row[0].strip().startswith("#"):
continue
with open("docs/_debians/%s-%s-%s.md" % (row[0], row[1], row[2]), "w") as debiansf:
debiansf.write("---\n")
debiansf.write("os: %s\n" % (row[0], ))
debiansf.write("dist: %s\n" % (row[1], ))
debiansf.write("arch: %s\n" % (row[2], ))
debiansf.write("---\n")