diff --git a/contrib/generate-image-customization.py b/contrib/generate-image-customization.py new file mode 100755 index 0000000000..aba9c7e0d4 --- /dev/null +++ b/contrib/generate-image-customization.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 + +import requests +from pathlib import Path + +toh = requests.get("https://openwrt.org/toh.json").json() + +entries = toh["entries"] +captions = toh["captions"] +columns = toh["columns"] + + +def get_devices_from_gluon(): + devices = [] + for path in Path("../targets").glob("*"): + file = path.read_text() + for line in file.splitlines(): + if line.startswith("device('"): + devices.append(line.split("('")[1].split("',")[0]) + return devices + + +def create_caption_dict(columns, entries): + result = {} + for entry in entries: + result_entry = {} + for index, column in enumerate(columns): + result_entry[column] = entry[index] + device = result_entry["deviceid"].split(":")[1] + device = device.lower().replace("_", "-").replace(" ", "-").replace("!", "-") + result[device] = result_entry + return result + + +result = create_caption_dict(columns, entries) +devices = get_devices_from_gluon() +has_gluon = {k: v for k, v in result.items() if k in devices} + +has_lte = { + k: v for k, v in has_gluon.items() if v["modem"] and v["modem"].lower() == "lte" +} +is_outdoor = { + k: v for k, v in has_gluon.items() if v["outdoor"] and v["outdoor"].lower() == "yes" +} +has_usb = { + k: v for k, v in has_gluon.items() if v["usbports"] and v["usbports"] != ["-"] +} +no_wifi24 = { + k: v for k, v in has_gluon.items() if not v["wlan24ghz"] or v["wlan24ghz"][0] == "-" +} +no_wifi50 = { + k: v for k, v in has_gluon.items() if not v["wlan50ghz"] or v["wlan50ghz"][0] == "-" +} +atmost_64mb_ram = {k: v for k, v in has_gluon.items() if int(v["rammb"]) <= 64} + +with open("image-customization-helper.lua", "w") as f: + usb_devices = "',\n'".join([device for device in has_usb]) + lte_devices = "',\n'".join([device for device in has_lte]) + outdoor_devices = "',\n'".join([device for device in is_outdoor]) + no_wifi24_devices = "',\n'".join([device for device in no_wifi24]) + no_wifi50_devices = "',\n'".join([device for device in no_wifi50]) + atmost_64mb_ram_devices = "',\n'".join([device for device in atmost_64mb_ram]) + lines = f"""#!/usr/bin/lua +has_usb = false +if device('{usb_devices}') then + has_usb = true +end + +has_lte = false +if device('{lte_devices}') then + has_lte = true +end + +is_outdoor = false +if device('{outdoor_devices}') then + is_outdoor = true +end + +no_wifi24 = false +if device('{no_wifi24_devices}') then + no_wifi24 = true +end + +no_wifi50 = false +if device('{no_wifi50_devices}') then + no_wifi50 = true +end + +atmost_64mb_ram = false +if device('{atmost_64mb_ram_devices}') then + atmost_64mb_ram = true +end +""" + f.writelines(lines) diff --git a/contrib/image-customization-helper.lua b/contrib/image-customization-helper.lua new file mode 100644 index 0000000000..f9487f475c --- /dev/null +++ b/contrib/image-customization-helper.lua @@ -0,0 +1,225 @@ +#!/usr/bin/lua +has_usb = false +if device('cudy-wr1300-v1', +'ravpower-rp-wd009', +'enterasys-ws-ap3715i', +'d-link-dir-860l-b1', +'d-link-dir-882-a1', +'d-link-dir-505', +'gl.inet-gl-mt1300', +'gl.inet-gl-xe300', +'gl.inet-gl-usb150', +'gl.inet-gl-ar150', +'gl.inet-vixmini', +'gl.inet-gl-b1300', +'gl.inet-gl-ar750', +'gl.inet-gl-mt3000', +'gl.inet-gl-ar300m-lite', +'devolo-wifi-pro-1750e', +'onion-omega', +'asus-tuf-ax4200', +'asus-rt-ac51u', +'asus-tuf-ax6000', +'asus-rt-ax53u', +'linksys-wrt1200ac', +'aerohive-hiveap-330', +'netgear-wndr3800', +'netgear-wndrmac-v2', +'netgear-wndr3700-v2', +'netgear-wndr3700-v5', +'netgear-wndr3700-v4', +'netgear-r6260', +'netgear-r6120', +'netgear-dgn3500b', +'netgear-r6220', +'extreme-networks-ws-ap3825i', +'8devices-jalapeno', +'lemaker-banana-pro', +'ocedo-panda', +'aruba-ap-303h', +'aruba-ap-365', +'avm-fritz-box-7360-v2', +'avm-fritz-box-4040', +'avm-fritz-box-4020', +'avm-fritz-box-7530', +'xiaomi-mi-router-4c', +'tp-link-archer-c7-v5', +'tp-link-archer-d50-v1', +'tp-link-tl-wr1043nd-v3', +'tp-link-tl-wr842n-v3', +'tp-link-tl-wr902ac-v1', +'tp-link-tl-mr3420-v5', +'tp-link-archer-c50-v3', +'tp-link-archer-c7-v4', +'tp-link-tl-wr1043nd-v4', +'tp-link-tl-wr1043nd-v2', +'tp-link-tl-wr902ac-v3', +'tp-link-archer-a7-v5', +'tp-link-tl-wdr4900-v1', +'tp-link-td-w8980', +'tp-link-tl-mr3020-v3', +'tp-link-archer-c2600', +'tp-link-tl-wdr3600-v1', +'tp-link-archer-c59-v1', +'tp-link-tl-wdr3500-v1', +'zyxel-nbg6617', +'buffalo-wzr-600dhp', +'plasma-cloud-pa1200') then + has_usb = true +end + +has_lte = false +if device('zte-mf281', +'zte-mf289f', +'gl.inet-gl-xe300', +'wavlink-ws-wn572hp3-4g', +'tp-link-tl-mr6400-v5') then + has_lte = true +end + +is_outdoor = false +if device('devolo-wifi-pro-1750x', +'aruba-ap-365', +'wavlink-ws-wn572hp3-4g', +'tp-link-wbs210-v2', +'tp-link-cpe510-v3', +'tp-link-archer-c50-v4', +'tp-link-eap225-outdoor-v1', +'tp-link-archer-c50-v3', +'tp-link-wbs210-v1', +'tp-link-cpe510-v1', +'tp-link-cpe210-v1', +'tp-link-archer-c20-v5', +'tp-link-cpe220-v3', +'tp-link-cpe710-v1', +'tp-link-wbs510-v1', +'tp-link-cpe510-v2', +'tp-link-eap225-outdoor-v3', +'tp-link-cpe210-v3', +'tp-link-cpe210-v2', +'zyxel-nwa55axe', +'mikrotik-sxtsq-5-ac-rbsxtsqg-5acd', +'plasma-cloud-pa1200') then + is_outdoor = true +end + +no_wifi24 = false +if device('ubiquiti-edgerouter-x', +'ubiquiti-edgerouter-x-sfp', +'tp-link-cpe510-v3', +'tp-link-cpe510-v1', +'tp-link-cpe710-v1', +'tp-link-wbs510-v1', +'tp-link-cpe510-v2', +'mikrotik-sxtsq-5-ac-rbsxtsqg-5acd') then + no_wifi24 = true +end + +no_wifi50 = false +if device('sophos-ap15', +'d-link-dap-1365-a1', +'d-link-dap-1330-a1', +'d-link-dir-505', +'gl.inet-gl-xe300', +'gl.inet-gl-usb150', +'gl.inet-gl-ar150', +'gl.inet-vixmini', +'gl.inet-microuter-n300', +'gl.inet-gl-ar300m-lite', +'alfa-network-ap121f', +'onion-omega', +'netgear-dgn3500b', +'lemaker-banana-pro', +'ubiquiti-edgerouter-x', +'ubiquiti-unifi-ap', +'ubiquiti-edgerouter-x-sfp', +'avm-fritz-box-7360-v2', +'avm-fritz-box-7412', +'avm-fritz-box-7312', +'avm-fritz-wlan-repeater-450e', +'avm-fritz-box-4020', +'xiaomi-mi-router-4c', +'tp-link-wbs210-v2', +'tp-link-tl-wr1043nd-v3', +'tp-link-tl-wr842n-v3', +'tp-link-tl-mr3420-v5', +'tp-link-tl-wa801nd-v5', +'tp-link-tl-wr841n-v13', +'tp-link-wbs210-v1', +'tp-link-tl-wr1043nd-v4', +'tp-link-tl-wr1043nd-v2', +'tp-link-cpe210-v1', +'tp-link-cpe220-v3', +'tp-link-tl-wr1043n-v5', +'tp-link-tl-mr3020-v3', +'tp-link-cpe210-v3', +'tp-link-tl-mr6400-v5', +'tp-link-cpe210-v2', +'plasma-cloud-pa300', +'plasma-cloud-pa300e') then + no_wifi50 = true +end + +atmost_64mb_ram = false +if device('ravpower-rp-wd009', +'d-link-dap-1365-a1', +'d-link-dap-1330-a1', +'d-link-dir-505', +'gl.inet-gl-usb150', +'gl.inet-gl-ar150', +'gl.inet-vixmini', +'alfa-network-ap121f', +'onion-omega', +'asus-rt-ac51u', +'netgear-wndr3700-v2', +'netgear-ex6130', +'netgear-r6020', +'netgear-ex3700', +'netgear-ex6150', +'netgear-r6120', +'netgear-dgn3500b', +'ubiquiti-unifi-ap', +'avm-fritz-wlan-repeater-300e', +'avm-fritz-wlan-repeater-1750e', +'avm-fritz-box-7312', +'avm-fritz-wlan-repeater-450e', +'xiaomi-mi-router-4c', +'tp-link-archer-d50-v1', +'tp-link-wbs210-v2', +'tp-link-cpe510-v3', +'tp-link-archer-c50-v4', +'tp-link-re200-v2', +'tp-link-tl-wr1043nd-v3', +'tp-link-tl-wr842n-v3', +'tp-link-tl-wr902ac-v1', +'tp-link-tl-mr3420-v5', +'tp-link-re200-v3', +'tp-link-tl-wa801nd-v5', +'tp-link-tl-wr841n-v13', +'tp-link-archer-c50-v3', +'tp-link-archer-c50-v1', +'tp-link-archer-c60-v1', +'tp-link-archer-c2-v3', +'tp-link-wbs210-v1', +'tp-link-tl-wr1043nd-v4', +'tp-link-cpe510-v1', +'tp-link-re200-v4', +'tp-link-tl-wr1043nd-v2', +'tp-link-cpe210-v1', +'tp-link-archer-c20-v5', +'tp-link-tl-wr902ac-v3', +'tp-link-cpe220-v3', +'tp-link-wbs510-v1', +'tp-link-cpe510-v2', +'tp-link-tl-wr1043n-v5', +'tp-link-td-w8980', +'tp-link-tl-mr3020-v3', +'tp-link-cpe210-v3', +'tp-link-tl-mr6400-v5', +'tp-link-archer-c58-v1', +'tp-link-archer-c25-v1', +'tp-link-cpe210-v2', +'plasma-cloud-pa300', +'plasma-cloud-pa300e') then + atmost_64mb_ram = true +end