Elaborate runtime machine identification in OE
RFC 1/1 Elaborate runtime machine identification in OE
Hello openembedded-devel,
Merry Christmas to everyone, and a good cleanup for holiday. ;-)
Some time ago, Michael Lauer added /etc/init.d/functions
(initscripts package), which is IMHO a great step for OE - without having and reusing common functionality in init/service scripts, we won't overcome the current situation of initscripts, which are more a random collection than a well-fitting and flexible facility.
/etc/init.d/functions in particular contains a function to detect
hardware model (i.e. machine) on which execution takes place. It's still used only by one other script/package in OE - gsm, but I'd like to extend its coverage, starting with psplash (to tackle at #3471). There're few issues with it, which would be nice to fix before going for general migration.
1. The function is called "cpuinfo_id" which doesn't correspond to what it really does. "machine_id" should be pretty clear and unambiguous. (A func to return CPU id worth adding too, there's use for it (e.g., irdautils uses that)).
2. We already had issues where what kernel had and what was written in script differed in case. Worth just settling on using one case, apparently lower. (This idea is from psplash init.)
3. It's worth having machine ids as proper identifiers, for example, to avoid unnecessary quoting, and for them to be usable as filenames directly (without excessive quoting, again). Using filenames to handle machine-specific features might come pretty handy - instead of long case statements, we would have just check for a filename, with fallback to default if needed. This doesn't have to be universal, but some cases just call for this, for example per-machine xmodmap configuration. Of course, in most cases there even won't be separate per-machine files, just symlinks to few common cases! (Btw, does mtn allows to store symlinks in repo?)
Here's how changes would look like:
============================================================
initscripts/initscripts-1.0/functions b93cf58a6991d27bc069277c77cad150e8dc7dbe renamed from initscripts/initscripts-1.0/functions cdb873e9c652d090c2e40fa96d5fd2db86db5413 +2 -2
@@ -1,11 +1,11 @@ # -*-Shell-script-*- # # functions This file contains functions to be used by most or all # shell scripts in the /etc/init.d directory. # -cpuinfo_id() { # return the Hardware module ID - awk 'BEGIN { FS=": " } /Hardware/ { print $2 } ' </proc/cpuinfo +machine_id() { # return the machine ID + awk 'BEGIN { FS=": " } /Hardware/ { gsub(" ", "_", $2); print tolower($2) } ' </proc/cpuinfo } killproc() { # kill the named process(es)
============================================================
gsm/files/default 2c9ff75946e58892430cb9cee5cb6e6a16739d7c renamed from gsm/files/default fff8f5a5e6aa3b4c82a98e13da7f097b7ee15b91 +7 -7
@@ -1,31 +1,31 @@ # gsmd This shell script configures for the gsmd init script. . /etc/init.d/functions -case `cpuinfo_id` in - "GTA01"|"GTA02") +case `machine_id` in + "gta01"|"gta02") GSMD_OPTS="-s 115200 -F" GSM_POW="/sys/bus/platform/devices/gta01-pm-gsm.0/power_on" GSM_RES="/sys/bus/platform/devices/gta01-pm-gsm.0/reset" GSM_DEV="/dev/ttySAC0" ;; - "HTC Apache"|"HTC Blueangel"|"HTC Universal") + "htc_apache"|"htc_blueangel"|"htc_universal") GSMD_OPTS="-s 115200 -F" GSM_DEV="/dev/ttyS0" ;; - "HTC Himalaya") + "htc_himalaya") GSMD_OPTS="-s 115200 -F" GSM_DEV="/dev/ttyS2" ;; - "HTC Magician") + "htc_magician") GSMD_OPTS="-s 115200 -F" GSM_DEV="/dev/ttyS1" ;; - "Palm Treo 650") + "palm_treo_650") GSMD_OPTS="-s 460800 -F -w 1" GSM_DEV="/dev/ttyS0" ;; - "Motorola Ezx Platform") + "motorola_ezx_platform") GSMD_OPTS="-s 115200 -F -v ti" GSM_DEV="/dev/mux0" ;;
Signature · 2 lines
Best regards, Paul mailto:[email protected]