Uniquely identifying a platform programmatically
Philip Prindeville
philipp_subx at redfish-solutions.com
Mon May 17 15:43:24 PDT 2021
Hi,
I was wondering what the best way to map a running box back to a candidate image would be.
It seems like the tuple ($CONFIG_TARGET_BOARD, $CONFIG_TARGET_SUBTARGET, $CONFIG_TARGET_PROFILE) would provide this, since you can mangle them into a bin/targets/$CONFIG_TARGET_BOARD/$CONFIG_TARGET_SUBTARGET/openwrt-*-$CONFIG_TARGET_BOARD-$CONFIG_TARGET_SUBTARGET-$CONFIG_TARGET_PROFILE-squashfs-sysupgrade.bin (or -factory.bin) image for provisioning...
Maybe also $CONFIG_VERSION_NUMBER if you're dealing with $CONFIG_IMAGEOPT.
/etc/os-release contains most of this information:
# cat /etc/os-release
NAME="OpenWrt"
VERSION="1.1"
ID="openwrt"
ID_LIKE="lede openwrt"
PRETTY_NAME="OpenWrt 1.1"
VERSION_ID="1.1"
HOME_URL="https://openwrt.org/"
BUG_URL="https://bugs.openwrt.org/"
SUPPORT_URL="https://forum.openwrt.org/"
BUILD_ID="r16585-182eaa4916"
OPENWRT_BOARD="ath79/generic"
OPENWRT_ARCH="mips_24kc"
OPENWRT_TAINTS="no-all"
OPENWRT_DEVICE_MANUFACTURER="OpenWrt"
OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/"
OPENWRT_DEVICE_PRODUCT="Generic"
OPENWRT_DEVICE_REVISION="v0"
OPENWRT_RELEASE="OpenWrt 1.1 r16585-182eaa4916"
Even if you have to split() OPENWRT_BOARD on the slash (trivial in sh)... But the target profile is sadly missing.
Any objections to adding it?
I understand that not all boards/architectures support this, so synthesizing the /etc/os-release file might become slightly more complicated...
I could grovel the target profile out of /etc/board.json, but then my scripting needs to support 'jq', etc.
# cat /etc/board.json
{
"model": {
"id": "tplink,archer-a7-v5",
"name": "TP-Link Archer A7 v5"
},
...
Any suggestions welcome.
Thanks.
-Philip
More information about the openwrt-devel
mailing list