1
0

pciids_gen 702 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. # Used for processing pci.ids into ipxe format
  3. # https://raw.githubusercontent.com/pciutils/pciids/master/pci.ids
  4. if [[ ! -n "$1" || ! -n "$2" ]]; then
  5. echo "Please set PCIIDS file location and PCIIDS output file location..."
  6. echo "pciids_gen pci.ids pciids.ipxe"
  7. exit 1
  8. fi
  9. PCIIDS_FILE=$1
  10. PCIIDS_IPXE=$2
  11. awk ' \
  12. BEGIN { \
  13. print "#!ipxe\ngoto ${vendor}${device} || goto ${vendor} || exit" \
  14. } \
  15. /^[0-9a-f]{4}/ { \
  16. vendor=substr($1,1,4); \
  17. printf ":%s\nset ven %s\nexit\n", vendor, substr($0,7) \
  18. } \
  19. /^\t[0-9a-f]{4}/ { \
  20. printf ":%s%s\nset dev %s\ngoto %s\n", \
  21. vendor, substr($0, 2, 4), substr($0, 8), vendor \
  22. } \
  23. ' ${PCIIDS_FILE} > ${PCIIDS_IPXE}