refresh-pxe-roms.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. # PXE ROM build script
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, see <http://www.gnu.org/licenses/>.
  16. #
  17. # Copyright (C) 2011 Red Hat, Inc.
  18. # Authors: Alex Williamson <alex.williamson@redhat.com>
  19. #
  20. # Usage: Run from root of qemu tree
  21. # ./scripts/refresh-pxe-roms.sh
  22. QEMU_DIR=$PWD
  23. ROM_DIR="pc-bios"
  24. BUILD_DIR="roms/ipxe"
  25. LOCAL_CONFIG="src/config/local/general.h"
  26. function cleanup ()
  27. {
  28. if [ -n "$SAVED_CONFIG" ]; then
  29. cp "$SAVED_CONFIG" "$BUILD_DIR"/"$LOCAL_CONFIG"
  30. rm "$SAVED_CONFIG"
  31. fi
  32. cd "$QEMU_DIR"
  33. }
  34. function make_rom ()
  35. {
  36. cd "$BUILD_DIR"/src
  37. BUILD_LOG=$(mktemp)
  38. echo Building "$2"...
  39. make bin/"$1".rom > "$BUILD_LOG" 2>&1
  40. if [ $? -ne 0 ]; then
  41. echo Build failed
  42. tail --lines=100 "$BUILD_LOG"
  43. rm "$BUILD_LOG"
  44. cleanup
  45. exit 1
  46. fi
  47. rm "$BUILD_LOG"
  48. cp bin/"$1".rom "$QEMU_DIR"/"$ROM_DIR"/"$2"
  49. cd "$QEMU_DIR"
  50. }
  51. if [ ! -d "$QEMU_DIR"/"$ROM_DIR" ]; then
  52. echo "error: can't find $ROM_DIR directory," \
  53. "run me from the root of the qemu tree"
  54. exit 1
  55. fi
  56. if [ ! -d "$BUILD_DIR"/src ]; then
  57. echo "error: $BUILD_DIR not populated, try:"
  58. echo " git submodule init $BUILD_DIR"
  59. echo " git submodule update $BUILD_DIR"
  60. exit 1
  61. fi
  62. if [ -e "$BUILD_DIR"/"$LOCAL_CONFIG" ]; then
  63. SAVED_CONFIG=$(mktemp)
  64. cp "$BUILD_DIR"/"$LOCAL_CONFIG" "$SAVED_CONFIG"
  65. fi
  66. echo "#undef BANNER_TIMEOUT" > "$BUILD_DIR"/"$LOCAL_CONFIG"
  67. echo "#define BANNER_TIMEOUT 0" >> "$BUILD_DIR"/"$LOCAL_CONFIG"
  68. IPXE_VERSION=$(cd "$BUILD_DIR" && git describe --tags)
  69. if [ -z "$IPXE_VERSION" ]; then
  70. echo "error: unable to retrieve git version"
  71. cleanup
  72. exit 1
  73. fi
  74. echo "#undef PRODUCT_NAME" >> "$BUILD_DIR"/"$LOCAL_CONFIG"
  75. echo "#define PRODUCT_NAME \"iPXE $IPXE_VERSION\"" >> "$BUILD_DIR"/"$LOCAL_CONFIG"
  76. make_rom 8086100e pxe-e1000.rom
  77. make_rom 80861209 pxe-eepro100.rom
  78. make_rom 10500940 pxe-ne2k_pci.rom
  79. make_rom 10222000 pxe-pcnet.rom
  80. make_rom 10ec8139 pxe-rtl8139.rom
  81. make_rom 1af41000 pxe-virtio.rom
  82. echo done
  83. cleanup