Why "SUPPORTED_DEVICES := $(subst _,$(comma),$(1))" in include/image.mk

Hi there,

I saw "SUPPORTED_DEVICES := $(subst _,$(comma),$(1))" in include/image.mk, why we should do this while generating image?

Thanks.

Why you think we should not?

Those replacements you do usually because:

  • Not all Linux utilities are able to handle all "special" characters.

  • Each OS supports its own set of characters allowed within filenames respectivley some are not allowed due to special meaning.

  • Each shell/cmd is different. You want to be as compatible as possible to different shells (like linux/bash vs macos/zsh). "common denominator"

So you usually strip/filter out special characters beforehand. Or you have to deal with regex during operation (for all different shells/utilities). E. g. you cannot just use "rm" to delete a file named "-myfile.txt". You would have to use rm -- "-myfile.txt". While _myfile.txt is O.K. for all shells.

For this case I just guess wild its done because the name is pharsed from some other file where names stored e. g. like zyxel,nbg7815. --> zyxel_nbg7815

As you said, underline is usually OK for all shells and any other program language. So I can't figure out that why we must replace underline with comma :joy:

And the replacement will cause invalid image check while upgrading, unless I add code like SUPPORTED_DEVICES += pogo_e02

Huh, I should clean my glasses. ;D Respectivley I would have expected the same substitiution.

But in general it would not be an error to convert in and out for certain purposes.

I have no clue where the include/image.mk Makefile is getting the "supported_devices". The underlying Makefile (target/linux/kirkwood/image/generik.mk) has:

define Device/cloudengines_pogoe02
  DEVICE_VENDOR := Cloud Engines
  DEVICE_MODEL := Pogoplug E02
  DEVICE_DTS := kirkwood-pogo_e02
  DEVICE_PACKAGES := kmod-rtc-mv
  SUPPORTED_DEVICES += pogo_e02
endef
TARGET_DEVICES += cloudengines_pogoe02
....
define Device/linksys_e4200-v2
  $(Device/linksys)
  DEVICE_MODEL := E4200
  DEVICE_VARIANT := v2
  SUPPORTED_DEVICES += linksys,viper linksys-viper
endef
TARGET_DEVICES += linksys_e4200-v2

Those lines looking strange anyway (no pattern). What would happen changing there pogo_e02 into pogoe02.

I can just guess here. I don't have really a clue about Makefiles.