Search code examples
sedyoctoopenembedded

Need to do sed to replace ${D} string in do_install()


I am doing a yocto recipe:

do_install () {
  install -d -m 755 ${D}/opt/intel
  sed -i 's/\/opt\/intel/\/TEST_PATH/' silent.cfg
}

This will work, but I want to replace TEST_PATH to ${D} in the recipe, the follows will bitbake fail:

do_install () {
  install -d -m 755 ${D}/opt/intel
  sed -i 's/\/opt\/intel/${D}/' silent.cfg
}

error:

sed: -e expression #1, char 17: unknown option to `s'

Solution

  • I dont know about the yocto aspect, which I am assuming replaces ${D} for you, but in sed the substitute command can use any delimiter, not just /. For example, if your variable ${D} doesn't contain a colon : you could use that:

    sed -i 's:/opt/intel:${D}:' silent.cfg