a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync<?php // -*- Mode: PHP; -*-
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Copyright (C) 2009 Marty Connor <mdc@etherboot.org>.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Copyright (C) 2009 Entity Cyber, Inc.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This program is free software; you can redistribute it and/or
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * modify it under the terms of the GNU General Public License as
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * published by the Free Software Foundation; either version 2 of the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * License, or any later version.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * This program is distributed in the hope that it will be useful, but
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * WITHOUT ANY WARRANTY; without even the implied warranty of
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * General Public License for more details.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * You should have received a copy of the GNU General Public License
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * along with this program; if not, write to the Free Software
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Get utility functions and set globals
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncrequire_once "utils.php";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Make sure at least $A (action) was supplied
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( ! isset ( $_POST['A"] ) ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // Present user with form to customize build options
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync require_once "customize-flags.php";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync exit ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// If user chose "Customize" option on form
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} else if ( $_POST['A"] == "Customize" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // Present user with form to customize build options
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync require_once "customize-flags.php";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync exit ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// The following conditional includes all other cases except "Get Image"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// particularly the explicit ($A == "Start Over") case
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} else if ( $_POST['A"] != "Get Image" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // Note that this method of redirections discards all the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // configuration flags, which is intentional in this case.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $dest = curDirURL ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync header ( "Location: $dest" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // This next "echo" should normally not be seen, because
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // the "header" statement above should cause immediate
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // redirection but just in case...
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo "Try this link: <a href=\"$dest\">$dest</a>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync exit ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// OK, we're going to try to use whatever options have been set
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// to build an image.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Make sure at least $nic was supplied
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( ! isset ( $_POST['nic"] ) ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync die ( "No NIC supplied!" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( isset ( $nics[$_POST['nic"]] ) ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $nic = $nics[$_POST['nic"]];
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} else {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync die ( "Invalid NIC \"${_POST['nic"]}\" supplied!" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Fetch flags
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$flags = get_flags ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Get requested format
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$ofmt = isset ( $_POST['ofmt"] ) ? $_POST['ofmt"] : "";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$fmt_extension = isset ( $ofmts[$ofmt] ) ? $ofmts[$ofmt] : 'dsk";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Handle some special cases
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$pci_vendor_code = "";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$pci_device_code = "";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( $nic == 'undionly" && $fmt_extension == "pxe" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // undionly.pxe can't work because it unloads the PXE stack
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // that it needs to communicate with, so we set the extension
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // to .kpxe, which has a chance of working. The extension
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // .kkpxe is another option.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $fmt_extension = "kpxe";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} else if ( $fmt_extension == "rom" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( ! isset ( $_POST['pci_vendor_code"] )
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync || ! isset ( $_POST['pci_device_code"] ) ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync die ( "rom output format selected but PCI code(s) missing!" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $pci_vendor_code = $_POST['pci_vendor_code"];
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $pci_device_code = $_POST['pci_device_code"];
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( $pci_vendor_code == ""
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync || $pci_device_code == "" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync die ( "rom output format selected but PCI code(s) missing!" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // Try to be forgiving of 0xAAAA format
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( strtolower ( substr ( $pci_vendor_code, 0, 2 ) ) == "0x"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync && strlen ( $pci_vendor_code ) == 6 ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $pci_vendor_code = substr ( $pci_vendor_code, 2, 4 );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( strtolower ( substr ( $pci_device_code, 0, 2 ) ) == "0x"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync && strlen ( $pci_device_code ) == 6 ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $pci_device_code = substr ( $pci_device_code, 2, 4 );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // concatenate the pci codes to get the $nic part of the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // Make target
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $pci_codes = strtolower ( $pci_vendor_code . $pci_device_code );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $nic = $pci_codes;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( ! isset ( $roms[$pci_codes] ) ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync die ( "Sorry, no network driver supports PCI codes<br>"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync . "${_POST['pci_vendor_code"]}:"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync . "${_POST['pci_device_code"]}" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync} else if ( $fmt_extension != "rom"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync && ( $pci_vendor_code != "" || $pci_device_code != "" ) ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync die ( "'$fmt_extension' format was selected but PCI IDs were"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync . " also entered.<br>Did you mean to select 'rom' output format"
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync . " instead?" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * remove temporary build directory
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * @return bool true if removal is successful, false otherwise
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncfunction rm_build_dir ()
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync{
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync global $build_dir;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync global $keep_build_dir;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( $keep_build_dir !== true ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync rm_file_or_dir ( $build_dir );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Arrange for the build directory to always be removed on exit.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$build_dir = "";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$keep_build_dir = false;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncregister_shutdown_function ( 'rm_build_dir" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Make temporary copy of src directory
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$build_dir = mktempcopy ( "$src_dir", "/tmp", "MDCROM" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$config_dir = $build_dir . "/config";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Write config files with supplied flags
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncwrite_ipxe_config_files ( $config_dir, $flags );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Handle a possible embedded script
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$emb_script_cmd = "";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$embedded_script = isset ( $_POST['embedded_script"] ) ? $_POST['embedded_script"] : "";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( $embedded_script != "" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $emb_script_path = "$build_dir" . "/script0.ipxe";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( substr ( $embedded_script, 0, 5 ) != "#!ipxe" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $embedded_script = "#!ipxe\n" . $embedded_script;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // iPXE 0.9.7 doesn't like '\r\n" in the shebang...
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $embedded_script = str_replace ( "\r\n", "\n", $embedded_script );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync write_file_from_string ( $emb_script_path, $embedded_script );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $emb_script_cmd = "EMBEDDED_IMAGE=${emb_script_path}";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Make the requested image. $status is set to 0 on success
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$make_target = "bin/${nic}.${fmt_extension}";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$make_cmd = "make -C '$build_dir' '$make_target' $emb_script_cmd 2>&1";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncexec ( $make_cmd, $maketxt, $status );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Uncomment the following section for debugging
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/**
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h2>build.php:</h2>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h3>Begin debugging output</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync//echo "<h3>\$_POST variables</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync//echo "<pre>"; var_dump ( $_POST ); echo "</pre>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h3>Build options:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<strong>Build directory is:</strong> $build_dir" . "<br><br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['ofmt'] = " . "\"${_POST['ofmt']}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['nic'] = " . "\"${_POST['nic']}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['pci_vendor_code'] = " . "\"${_POST['pci_vendor_code']}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['pci_device_code'] = " . "\"${_POST['pci_device_code']}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h3>Flags:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncshow_flags ( $flags );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( $embedded_script != "" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo "<h3>Embedded script:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo "<blockquote>"."<pre>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo $embedded_script;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo "</pre>"."</blockquote>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h3>Make output:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "Make command: " . $make_cmd . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "Build status = <? echo $status ?>" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<blockquote>"."<pre>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho htmlentities ( implode ("\n", $maketxt ) );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "</pre>"."</blockquote>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Uncomment the next line if you want to keep the
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// build directory around for inspection after building.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync$keep_build_dir = true;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncdie ( "<h3>End debugging output</h3>" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync**/ // End debugging section
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Send ROM to browser (with extreme prejudice)
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( $status == 0 ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $fp = fopen("${build_dir}/${make_target}", "rb" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( $fp > 0 ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $len = filesize ( "${build_dir}/${make_target}" );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync if ( $len > 0 ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $buf = fread ( $fp, $len );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync fclose ( $fp );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // Delete build directory as soon as it is not needed
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync rm_build_dir ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync $output_filename = "ipxe-${version}-${nic}.${fmt_extension}";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync // Try to force IE to handle downloading right.
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync Header ( "Cache-control: private");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync Header ( "Content-Type: application/x-octet-stream; " .
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync "name=$output_filename");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync Header ( "Content-Disposition: attachment; " .
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync "Filename=$output_filename");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync Header ( "Content-Location: $output_filename");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync Header ( "Content-Length: $len");
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo $buf;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync exit ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync }
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync/*
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * If we reach this point, the build has failed, and we provide
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync * debugging information for a potential bug report
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync *
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync */
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Remove build directory
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncrm_build_dir ();
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Announce failure if $status from make was non-zero
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h2>Build failed. Status = " . $status . "</h2>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h2>build.php:</h2>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h3>Build options:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<strong>Build directory is:</strong> $build_dir" . "<br><br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['ofmt'] = " . "\"${_POST['ofmt"]}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['nic'] = " . "\"${_POST['nic"]}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['pci_vendor_code'] = " . "\"${_POST['pci_vendor_code"]}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "\$_POST['pci_device_code'] = " . "\"${_POST['pci_device_code"]}\"" . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h3>Flags:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncshow_flags ( $flags );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncif ( $embedded_script != "" ) {
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo "<h3>Embedded script:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo "<blockquote>"."<pre>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo $embedded_script;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync echo "</pre>"."</blockquote>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync}
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<h3>Make output:</h3>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "Make command: " . $make_cmd . "<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "<blockquote>"."<pre>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho htmlentities ( implode ("\n", $maketxt ) );
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "</pre>"."</blockquote>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncecho "Please let us know that this happened, and paste the above output into your email message.<br>";
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsyncinclude_once $bottom_inc;
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// For emacs:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// Local variables:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// c-basic-offset: 4
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// c-indent-level: 4
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// tab-width: 4
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync// End:
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync
a734c64bff58bda2fa48c2795453e092167b0ff7vboxsync?>