From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OrBYO-0003yC-EE for mharc-grub-devel@gnu.org; Thu, 02 Sep 2010 11:18:16 -0400 Received: from [140.186.70.92] (port=51396 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OrBYE-0003up-LU for grub-devel@gnu.org; Thu, 02 Sep 2010 11:18:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OrBXp-0004rM-DT for grub-devel@gnu.org; Thu, 02 Sep 2010 11:17:43 -0400 Received: from mail-fx0-f41.google.com ([209.85.161.41]:62043) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OrBXp-0004r9-1d for grub-devel@gnu.org; Thu, 02 Sep 2010 11:17:41 -0400 Received: by fxm3 with SMTP id 3so346346fxm.0 for ; Thu, 02 Sep 2010 08:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:x-enigmail-version:content-type; bh=8xXW3SmFn8U1h/3TiMDZuv57VwVEZcizYbgJ6zKbTIM=; b=m8afaZofVMMLl6XeIjTjGKy1kEyMNXxJlQiwNPv+Tzmo6JmcHri+dJTrDQbZlmgxm5 1I3W5CW+Crl8fzzurWvRYSipFrP430Z/noMc7MFk+xj6/IYVTbQpc2NsQocVNK48CynK wN29eUuBVlHoQrTSWMwzJhUr6XEGHZqqVuplM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; b=Djwdj2ySGJ/n+t9+uxkED93l7X0N2YNc+SH82SUjdYYlqOQI04F6CFfy1S71rtjWdN 5NIH5DxNvxAiwALkA28KQ/iy8YwUfZub9JA1DGarqXRjop1GIb2Em3xfDCEEmGg+dUsV YZVNi/PJ0GOgVxZfqGfP458ApK7oPz097ndmM= Received: by 10.223.119.10 with SMTP id x10mr8735036faq.1.1283440659185; Thu, 02 Sep 2010 08:17:39 -0700 (PDT) Received: from debian.bg45.phnet (62-156.62-81.cust.bluewin.ch [81.62.156.62]) by mx.google.com with ESMTPS id c20sm246729fak.9.2010.09.02.08.17.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 02 Sep 2010 08:17:37 -0700 (PDT) Message-ID: <4C7FC00F.2020303@gmail.com> Date: Thu, 02 Sep 2010 17:17:35 +0200 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100805 Icedove/3.0.6 MIME-Version: 1.0 To: The development of GRUB 2 X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enigB430C86FD11910B339643879" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [PATCH] grub-mknetdir sciprt for convenience X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2010 15:18:12 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB430C86FD11910B339643879 Content-Type: multipart/mixed; boundary="------------040101060503060509090801" This is a multi-part message in MIME format. --------------040101060503060509090801 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable A small script for creating netboot directories. --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------040101060503060509090801 Content-Type: text/x-diff; name="mknetdir.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="mknetdir.diff" =3D=3D=3D added file 'ChangeLog.mknet' --- ChangeLog.mknet 1970-01-01 00:00:00 +0000 +++ ChangeLog.mknet 2010-09-02 15:15:53 +0000 @@ -0,0 +1,7 @@ +2010-09-02 Vladimir Serbinenko + + grub-mknetdir script. + + * Makefile.util.def (grub-mknetdir): New module. + * tests/util/grub-shell.in: Support boot=3Dnet + * util/grub-mknetdir.in: New file. =3D=3D=3D modified file 'Makefile.util.def' --- Makefile.util.def 2010-08-31 23:09:00 +0000 +++ Makefile.util.def 2010-09-02 15:15:53 +0000 @@ -361,6 +361,14 @@ }; =20 script =3D { + mansection =3D 8; + installdir =3D sbin; + name =3D grub-mknetdir; + + common =3D util/grub-mknetdir.in; +}; + +script =3D { name =3D grub-mkconfig; common =3D util/grub-mkconfig.in; mansection =3D 8; =3D=3D=3D modified file 'tests/util/grub-shell.in' --- tests/util/grub-shell.in 2010-08-25 14:59:11 +0000 +++ tests/util/grub-shell.in 2010-09-02 15:15:53 +0000 @@ -28,6 +28,7 @@ PACKAGE_TARNAME=3D@PACKAGE_TARNAME@ PACKAGE_VERSION=3D@PACKAGE_VERSION@ target_cpu=3D@target_cpu@ +platform=3D@platform@ =20 # Force build directory components PATH=3D${builddir}:$PATH @@ -42,7 +43,7 @@ =20 -h, --help print this message and exit -v, --version print the version information and exit - --boot=3D[fd|hd|cd] boot method for Qemu instance + --boot=3D[fd|hd|cd|net] boot method for Qemu instance --modules=3DMODULES pre-load specified modules MODULES --qemu=3DFILE Name of qemu binary --qemu-opts=3DOPTIONS extra options to pass to Qemu instance @@ -83,6 +84,7 @@ if [ "$dev" =3D "fd" ] ; then boot=3Dfd; elif [ "$dev" =3D "hd" ] ; then boot=3Dhd; elif [ "$dev" =3D "cd" ] ; then boot=3Dcd; + elif [ "$dev" =3D "net" ] ; then boot=3Dnet; elif [ "$dev" =3D "qemu" ] ; then boot=3Dqemu; elif [ "$dev" =3D "coreboot" ] ; then boot=3Dcoreboot; else @@ -134,10 +136,12 @@ EOF =20 isofile=3D`mktemp` -sh @builddir@/grub-mkrescue --grub-mkimage=3D${builddir}/grub-mkimage --= output=3D${isofile} --override-directory=3D${builddir}/grub-core \ - --rom-directory=3D"${rom_directory}" \ - /boot/grub/grub.cfg=3D${cfgfile} /boot/grub/testcase.cfg=3D${source}= \ - ${files} >/dev/null 2>&1 +if [ x$boot !=3D xnet ]; then + sh @builddir@/grub-mkrescue --grub-mkimage=3D${builddir}/grub-mkimag= e --output=3D${isofile} --override-directory=3D${builddir}/grub-core \ + --rom-directory=3D"${rom_directory}" \ + /boot/grub/grub.cfg=3D${cfgfile} /boot/grub/testcase.cfg=3D${source} \ + ${files} >/dev/null 2>&1 +fi if [ x$boot =3D xhd ]; then device=3Dhda bootdev=3D"-boot c" @@ -164,7 +168,15 @@ device=3Dcdrom fi =20 -${qemu} ${qemuopts} -nographic -serial file:/dev/stdout -monitor file:/d= ev/null -${device} ${isofile} ${bootdev} | cat | tr -d "\r" +if [ x$boot =3D xnet ]; then + netdir=3D`mktemp -d` + sh @builddir@/grub-mknetdir --grub-mkimage=3D${builddir}/grub-mkimag= e --override-directory=3D${builddir}/grub-core --net-directory=3D$netdir + cp ${cfgfile} $netdir/boot/grub/grub.cfg + cp ${source} $netdir/boot/grub/testcase.cfg + ${qemu} ${qemuopts} -nographic -serial file:/dev/stdout -monitor fil= e:/dev/null -boot n -net user,tftp=3D$netdir,bootfile=3D/boot/grub/$targe= t_cpu-$platform/core.0 -net nic | cat | tr -d "\r" +else + ${qemu} ${qemuopts} -nographic -serial file:/dev/stdout -monitor fil= e:/dev/null -${device} ${isofile} ${bootdev} | cat | tr -d "\r" +fi rm -f "${isofile}" "${imgfile}" rm -rf "${rom_directory}" if [ x$boot =3D xcoreboot ]; then =3D=3D=3D added file 'util/grub-mknetdir.in' --- util/grub-mknetdir.in 1970-01-01 00:00:00 +0000 +++ util/grub-mknetdir.in 2010-09-02 15:15:53 +0000 @@ -0,0 +1,230 @@ +#! /bin/sh + +# Install GRUB on your drive. +# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2= 010 Free Software Foundation, Inc. +# +# GRUB is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# GRUB is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GRUB. If not, see . + +# Initialize some variables. +transform=3D"@program_transform_name@" + +prefix=3D@prefix@ +exec_prefix=3D@exec_prefix@ +sbindir=3D@sbindir@ +bindir=3D@bindir@ +libdir=3D@libdir@ +PACKAGE_NAME=3D@PACKAGE_NAME@ +PACKAGE_TARNAME=3D@PACKAGE_TARNAME@ +PACKAGE_VERSION=3D@PACKAGE_VERSION@ +target_cpu=3D@target_cpu@ +platform=3D@platform@ +host_os=3D@host_os@ +pkglibdir=3D${libdir}/`echo ${PACKAGE_TARNAME}/${target_cpu}-${platform}= | sed ${transform}` +localedir=3D@datadir@/locale +native_platform=3D@platform@ +pkglib_DATA=3D"moddep.lst command.lst fs.lst partmap.lst parttool.lst ha= ndler.lst video.lst crypto.lst terminal.lst" + +self=3D`basename $0` + +grub_mkimage=3D${bindir}/`echo grub-mkimage | sed ${transform}` +rootdir=3D/srv/tftp +grub_prefix=3D`echo /boot/grub | sed ${transform}` +modules=3D + +install_device=3D +no_floppy=3D +recheck=3Dno +debug=3Dno +debug_image=3D +subdir=3D`echo /boot/grub | sed ${transform}` +pc_dir=3D${libdir}/$(echo ${PACKAGE_TARNAME} | sed ${transform})/i386-pc= + +# Usage: usage +# Print the usage. +usage () { + cat <. +EOF +} + +argument () { + opt=3D$1 + shift + + if test $# -eq 0; then + echo "$0: option requires an argument -- '$opt'" 1>&2 + exit 1 + fi + echo $1 +} + +# Check the arguments. +while test $# -gt 0 +do + option=3D$1 + shift + + case "$option" in + -h | --help) + usage + exit 0 ;; + -v | --version) + echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" + exit 0 ;; + + --modules) + modules=3D`argument $option "$@"`; shift;; + --modules=3D*) + modules=3D`echo "$option" | sed 's/--modules=3D//'` ;; + + --net-directory) + rootdir=3D`argument $option "$@"`; shift;; + --net-directory=3D*) + rootdir=3D`echo "$option" | sed 's/--net-directory=3D//'` ;; + + --subdir) + subdir=3D`argument $option "$@"`; shift;; + --subdir=3D*) + subdir=3D`echo "$option" | sed 's/--subdir=3D//'` ;; + + --grub-mkimage) + grub_mkimage=3D`argument $option "$@"`; shift;; + --grub-mkimage=3D*) + grub_mkimage=3D`echo "$option" | sed 's/--grub-mkimage=3D//'` ;; + + # This is an undocumented feature... + --debug) + debug=3Dyes ;; + --debug-image) + debug_image=3D`argument $option "$@"`; shift;; + --debug-image=3D*) + debug_image=3D`echo "$option" | sed 's/--debug-image=3D//'` ;; + + # Intentionally undocumented + --override-directory) + override_dir=3D`argument $option "$@"` + shift + PATH=3D${override_dir}:$PATH + export PATH + ;; + --override-directory=3D*) + override_dir=3D`echo "${option}/" | sed 's/--override-directory=3D//'` + PATH=3D${override_dir}:$PATH + export PATH + ;; + + -*) + echo "Unrecognized option \`$option'" 1>&2 + usage + exit 1 + ;; + *) + if test "x$install_device" !=3D x; then + echo "More than one install_devices?" 1>&2 + usage + exit 1 + fi + install_device=3D"${option}" ;; + esac +done + +set $grub_mkimage dummy +if test -f "$1"; then + : +else + echo "$1: Not found." 1>&2 + exit 1 +fi + +# Create the GRUB directory if it is not present. +mkdir -p "${rootdir}/${subdir}" || exit 1 + +process_input_dir () +{=20 + input_dir=3D"$1" + platform=3D"$2" + grubdir=3D"${rootdir}/${subdir}/${platform}" + config_opt=3D + mkdir -p "$grubdir" || exit 1 + + for file in ${grubdir}/*.mod ${grubdir}/*.lst ${grubdir}/*.img ${gru= bdir}/efiemu??.o; do + if test -f $file && [ "`basename $file`" !=3D menu.lst ]; then + rm -f $file || exit 1 + fi + done + for file in ${input_dir}/*.mod; do + if test -f "$file"; then + cp -f "$file" "$grubdir/" + fi + done + for file in ${pkglib_DATA}; do + if test -f "${input_dir}/${file}"; then + cp -f "${input_dir}/${file}" "$grubdir/" + fi + done + + mkdir -p "$grubdir/locale" + for file in ${input_dir}/po/*.mo; do + if test -f "$file"; then + cp -f "$file" "$grubdir/locale/" + fi + done + + rm -f ${grubdir}/load.cfg + + if [ "x${debug_image}" !=3D x ]; then + echo "set debug=3D'${debug_image}'" >> ${grubdir}/load.cfg + config_opt=3D"-c ${grubdir}/load.cfg " + fi + + case "${platform}" in + i386-pc) mkimage_target=3Di386-pc-pxe; + netmodules=3D"pxe"; + prefix=3D"(pxe)/${subdir}/${platform}"; + ext=3D0 ;; + *) echo Unsupported platform ${platform}; + exit 1;; + esac + + cat << EOF > ${grubdir}/grub.cfg +source ${subdir}/grub.cfg +EOF + + $grub_mkimage ${config_opt} -d "${input_dir}" -O ${mkimage_target} -= -output=3D${grubdir}/core.$ext --prefix=3D$prefix $modules $netmodules ||= exit 1 + echo "Netboot directory for ${platform} created. Configure your DHCP= server to point to ${subdir}/${platform}/core.$ext" +} + +if [ "${override_dir}" =3D "" ] ; then + if test -e "${pc_dir}" ; then + process_input_dir ${pc_dir} i386-pc + fi +else + process_input_dir ${override_dir} ${target_cpu}-${native_platform} +fi + + +# Bye. +exit 0 --------------040101060503060509090801-- --------------enigB430C86FD11910B339643879 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAkx/wA8ACgkQNak7dOguQgnPCQEAiQlLq+PZBe7HMtBjaU/VbZwr B11hBCN04270+1qgIuwA/RycrsjPOjOVdKsc39yzTjHS9WBcMPYIu9HDBfaXRr4D =6VxY -----END PGP SIGNATURE----- --------------enigB430C86FD11910B339643879--