mwarning / openwrt-firmware-selector

OpenWrt firmware selector. With custom image builder support.
https://mwarning.github.io/openwrt-firmware-selector/www/
Creative Commons Zero v1.0 Universal
38 stars 23 forks source link

Change database to Names and IDs only #2

Closed aparcar closed 4 years ago

aparcar commented 4 years ago

I created a script that uses the tmp/.targetinfo file to generate a file called names.json looking like below. This could be used to load specific device information on demand instead of all together. Using target and id can be combined as { release }/{ target }/{ id }.json.

Would you be willing to change the current script to that?

{
  "FriendlyARM NanoPi NEO2": {
    "target": "sunxi/cortexa53",
    "id": "friendlyarm_nanopi-neo2"
  },
  "Pine64 Pine64+": {
    "target": "sunxi/cortexa53",
    "id": "pine64_pine64-plus"
  },
  "Pine64 SoPine": {
    "target": "sunxi/cortexa53",
    "id": "pine64_sopine-baseboard"
  },
  "Xunlong Orange Pi PC 2": {
    "target": "sunxi/cortexa53",
    "id": "xunlong_orangepi-pc2"
  },
  "Xunlong Orange Pi Zero Plus": {
    "target": "sunxi/cortexa53",
    "id": "xunlong_orangepi-zero-plus"
  },
  "CompuLab TrimSlice": {
    "target": "tegra",
    "id": "compulab_trimslice"
  },
  "Generic x86": {
    "target": "x86/generic",
    "id": ""
  },
  "Generic x86/legacy": {
    "target": "x86/legacy",
    "id": ""
  },
  "Geos": {
    "target": "x86/geode",
    "id": ""
  },
  "Generic x86/64": {
    "target": "x86/64",
    "id": ""
  },
  "Avnet ZedBoard": {
    "target": "zynq",
    "id": "avnet_zynq-zed"
  },
  "Digilent Zybo": {
    "target": "zynq",
    "id": "digilent_zynq-zybo"
  },
  "Digilent Zybo Z7": {
    "target": "zynq",
    "id": "digilent_zynq-zybo-z7"
  },
  "Xilinx ZC702": {
    "target": "zynq",
    "id": "xlnx_zynq-zc702"
  }
}
mwarning commented 4 years ago

Why use tmp/.targetinfo as another source when the json files are supposed to be available as well?

mwarning commented 4 years ago

As for splitting up the data in a quick to load json - that might be a good idea. But I like to keep things simple and the current size of the data does not seem to require this (the data.json is only <40KB compressed for three releases). Maybe we can make it possible to use both approaches without adding much complexity.

mwarning commented 4 years ago

Your proposed format is ok, but we would need to extend that to cover different releases. How about this then? And the data would be extracted from the json files instead.

{
   "19.07.1": {
      "commit": "r10911-c155900f66",
      "download_link": "https://downloads.openwrt.org/releases/%release/targets/%target/%file",
      "json_link": "https://downloads.openwrt.org/releases/%release/targets/%target/%id.json",
      "models": {
         "FriendlyARM NanoPi NEO2": {
            "target": "sunxi/cortexa53",
            "id": "friendlyarm_nanopi-neo2"
         },
         "Pine64 Pine64+": {
            "target": "sunxi/cortexa53",
            "id": "pine64_pine64-plus"
         }   
      }
   }
}

download_link is for the images to download. json_link would be for the json files. Also, as an alternative, all images data can be embedded into "models" instead of using the json_link.

aparcar commented 4 years ago

Why use tmp/.targetinfo as another source when the json files are supposed to be available as well?

Using targetinfo allows you to get all available models without building all. When you want to parse the online JSON files, then you also have to download about 1500 json files with details to get the model names.

However it has the disadvantage that we need to do this for every distro version we want to support. So run <script>.py for master, 19.07, etc ...

The JSON files would actually be called %distro-%version-%target-%profile.json, where %version is skipped on master builds and %target uses - instead of /.

EDIT: 19.07.x does not yet offer any JSON files, therefore it can't really be supported, what do you think?

mwarning commented 4 years ago

@aparcar I am more or less finished with the restructuring. But

mwarning commented 4 years ago

Hm, but when I would define something like %maintarget-$subtarget in the link, and $subtarget is empty, then the link would break, because the - would not supposed to be there.

mwarning commented 4 years ago

@aparcar I changed the json format to something yet simpler. Feel free to submit a PR to change it.. :-)