summaryrefslogtreecommitdiff
path: root/meta-google/recipes-google/networking/gbmc-mac-config.bb
blob: 6ca4c798b32eb79640ca5e7b0393518393227f65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
SUMMARY = "Configures MAC addresses on a gBMC system"
PR = "r1"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

inherit systemd

SRC_URI += " \
  file://gbmc-mac-config.service \
  file://gbmc-mac-config.sh.in \
  "

S = "${WORKDIR}"

RDEPENDS_${PN} += " \
  bash \
  ipmi-fru-sh \
  "

FILES_${PN} += "${systemd_unitdir}"

SYSTEMD_SERVICE_${PN} += "gbmc-mac-config.service"

GBMC_MAC_EEPROM_OF_NAME ?= ""

# Maps the MAC address offset from the base address to an interface name
# in bash associative array syntax.
#   Ex. "[0]=eth0 [2]=eth2"
GBMC_MAC_IF_MAP ?= ""

do_install_append() {
  if [ -z '${GBMC_MAC_EEPROM_OF_NAME}' ]; then
    echo 'Missing GBMC_MAC_EEPROM_OF_NAME' >&2
    exit 1
  fi

  # Build time dictionary sanity check
  bash -c 'declare -A dict=(${GBMC_MAC_IF_MAP})'

  sed gbmc-mac-config.sh.in \
    -e 's#@EEPROM@#${GBMC_MAC_EEPROM_OF_NAME}#' \
    -e 's#@NUM_TO_IF@#${GBMC_MAC_IF_MAP}#' \
    >gbmc-mac-config.sh

  install -d -m0755 ${D}${libexecdir}
  install -m0755 gbmc-mac-config.sh ${D}${libexecdir}/

  install -d -m0755 ${D}${systemd_system_unitdir}
  install -m0644 gbmc-mac-config.service ${D}${systemd_system_unitdir}/
}