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