#!/bin/sh

# Set our cnfg location for the script
if [ -z $EDBG_CNFG ]
then
  EDBG_CNFG="/var/lib/misc/edbg.yaml"
fi

# Add static parts of config
echo "version: 1" > $EDBG_CNFG
echo "vpd:" >> $EDBG_CNFG

# Look thru all the labels and find the one for system-vpd
# Missing is support for memvpd and procvpd that was in the
# previous python version of the script.  That also wasn't
# yet in use, so no detremental effects
for i in `ls /sys/bus/i2c/devices/*/of_node/label`
do 
  if [ `cat $i` = "system-vpd" ]
  then 
    echo "  - target: k0:n0:s0" >> $EDBG_CNFG
    echo "    system-vpd: "`dirname \`dirname $i\``"/eeprom" >> $EDBG_CNFG
  fi
done

echo Wrote config file to $EDBG_CNFG
