Yuxiao Zhang | ed7346e | 2023-04-05 15:01:46 -0700 | [diff] [blame] | 1 | SUMMARY = "Rename the network device name" |
| 2 | PR = "r1" |
| 3 | LICENSE = "Apache-2.0" |
| 4 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" |
| 5 | |
| 6 | GBMC_ETHER_MAP ?= "" |
| 7 | |
| 8 | inherit systemd |
| 9 | |
| 10 | S = "${WORKDIR}" |
| 11 | |
| 12 | FILES:${PN} += "${systemd_unitdir}" |
| 13 | |
| 14 | do_install() { |
| 15 | netdir=${D}${systemd_unitdir}/network |
| 16 | install -d -m0755 $netdir |
| 17 | |
| 18 | # install dev renaming files if any |
| 19 | if [ -z "${GBMC_ETHER_MAP}"]; then |
| 20 | return |
| 21 | fi |
| 22 | devmap="${GBMC_ETHER_MAP}" |
| 23 | for str in $devmap |
| 24 | do |
| 25 | devaddr="$(echo "${str}" | cut -d'|' -f1)" |
| 26 | devname="$(echo "${str}" | cut -d'|' -f2)" |
| 27 | echo "[Match]" > ${WORKDIR}/30-netdev-${devname}.link |
| 28 | echo "Path=*-${devaddr}" >> ${WORKDIR}/30-netdev-${devname}.link |
| 29 | echo "[Link]" >> ${WORKDIR}/30-netdev-${devname}.link |
| 30 | echo "Name=${devname}" >> ${WORKDIR}/30-netdev-${devname}.link |
| 31 | install -m0644 ${WORKDIR}/30-netdev-${devname}.link ${netdir} |
| 32 | done |
| 33 | } |
| 34 | |