Perry Myers
2008-Jul-02 18:17 UTC
[Ovirt-devel] [PATCH] Move building of PXE image into RPM build step
Old ovirt-host-image rpm used to store a copy of the ISO and the tftpboot directory. This is redundant. Source file for RPM is now just the ISO and build step uses livecd-tools to build the tftpboot directory from the ISO Signed-off-by: Perry Myers <pmyers at redhat.com> --- ovirt-host-creator/.gitignore | 1 + ovirt-host-creator/Makefile | 6 +++--- ovirt-host-creator/ovirt-cd.sh | 1 + ovirt-host-creator/ovirt-host-image.spec | 17 ++++++++++++----- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ovirt-host-creator/.gitignore b/ovirt-host-creator/.gitignore index 455b5f7..9adce7e 100644 --- a/ovirt-host-creator/.gitignore +++ b/ovirt-host-creator/.gitignore @@ -3,4 +3,5 @@ iso-file tftpboot rpm-build ovirt-pxe.log +ovirt-cd.log repos.ks diff --git a/ovirt-host-creator/Makefile b/ovirt-host-creator/Makefile index 6f862f3..c522851 100644 --- a/ovirt-host-creator/Makefile +++ b/ovirt-host-creator/Makefile @@ -4,7 +4,7 @@ all: rpms include ../common/release.mk clean: - rm -rf ovirt-host-image-* ovirt-pxe.log + rm -rf ovirt-host-image-* ovirt-pxe.log ovirt-cd.log distclean: clean rm -rf *.iso tftpboot repos.ks rpm-build iso-file @@ -14,12 +14,12 @@ repos.ks: repos.ks.in build: ovirt.ks common-install.ks common-pkgs.ks common-post.ks repos.ks rm -rf tftpboot/ - ./ovirt-pxe.sh > ovirt-pxe.log 2>&1 + ./ovirt-cd.sh > ovirt-cd.log 2>&1 tar: clean build mv $$(cat iso-file) ovirt.iso mkdir -p $(NV) - cp -a ovirt-host-image.spec ovirt.iso tftpboot/* $(NV) + cp -a ovirt-host-image.spec ovirt.iso $(NV) mkdir -p rpm-build tar zcvf rpm-build/$(NV).tar $(NV) cp version rpm-build/ diff --git a/ovirt-host-creator/ovirt-cd.sh b/ovirt-host-creator/ovirt-cd.sh index a4e4cff..0469e6a 100755 --- a/ovirt-host-creator/ovirt-cd.sh +++ b/ovirt-host-creator/ovirt-cd.sh @@ -29,3 +29,4 @@ else fi ISO=`create_iso $ISO` +echo $ISO > iso-file diff --git a/ovirt-host-creator/ovirt-host-image.spec b/ovirt-host-creator/ovirt-host-image.spec index 91ca6af..a4aacc2 100644 --- a/ovirt-host-creator/ovirt-host-image.spec +++ b/ovirt-host-creator/ovirt-host-image.spec @@ -22,15 +22,19 @@ At the moment, this RPM just packages prebuilt ISO. %package pxe Summary: oVirt Managed Node boot PXE image Group: Applications/System +BuildRequires: livecd-tools >= 017.1-1 %description pxe The PXE boot image for oVirt Managed Node network boot from oVirt Admin Node. -At the moment, this RPM just packages prebuilt tftpboot folder. %prep %setup -q %build +/usr/bin/livecd-iso-to-pxeboot ovirt.iso +# append BOOTIF with PXE MAC info +f=tftpboot/pxelinux.cfg/default +grep -q 'IPAPPEND 2' $f || sed -i '/KERNEL/a \\tIPAPPEND 2' $f %install %{__rm} -rf %{buildroot} @@ -38,10 +42,10 @@ mkdir %{buildroot} %{__install} -d -m0755 %{buildroot}%{tftpboot} %{__install} -d -m0755 %{buildroot}%{tftpboot}/pxelinux.cfg -%{__install} -p -m0644 pxelinux.cfg/default %{buildroot}%{tftpboot}/pxelinux.cfg/default -%{__install} -p -m0644 pxelinux.0 %{buildroot}%{tftpboot} -%{__install} -p -m0644 initrd0.img %{buildroot}%{tftpboot} -%{__install} -p -m0644 vmlinuz0 %{buildroot}%{tftpboot} +%{__install} -p -m0644 tftpboot/pxelinux.cfg/default %{buildroot}%{tftpboot}/pxelinux.cfg/default +%{__install} -p -m0644 tftpboot/pxelinux.0 %{buildroot}%{tftpboot} +%{__install} -p -m0644 tftpboot/initrd0.img %{buildroot}%{tftpboot} +%{__install} -p -m0644 tftpboot/vmlinuz0 %{buildroot}%{tftpboot} %{__install} -d -m0755 %{buildroot}%{app_root} %{__install} -p -m0644 ovirt.iso %{buildroot}%{app_root} @@ -60,5 +64,8 @@ mkdir %{buildroot} %{tftpboot}/vmlinuz0 %changelog +* Wed Jul 02 2008 Perry Myers <pmyers at redhat.com> 0.92-0 +- Only store ISO in SRPM, and generate PXE from that during build + * Tue Jun 03 2008 Alan Pevec <apevec at redhat.com> 0.0.5-1 - Initial build. -- 1.5.5.1
Perry Myers
2008-Jul-03 14:26 UTC
[Ovirt-devel] [PATCH] Move building of PXE image into RPM build step
Old ovirt-host-image rpm used to store a copy of the ISO and the tftpboot directory. This is redundant. Source file for RPM is now just the ISO and build step uses ovirt-pxe script to build the tftpboot directory from the ISO ovirt-pxe, ovirt-flash and ovirt-flash-static are now all part of the ISO RPM so that users can easily deploy the ISO image onto these media types. Signed-off-by: Perry Myers <pmyers at redhat.com> --- ovirt-host-creator/.gitignore | 2 +- ovirt-host-creator/Makefile | 9 ++--- ovirt-host-creator/{ovirt-cd.sh => ovirt-cd} | 16 ++++------ ovirt-host-creator/ovirt-common.sh | 16 ---------- ovirt-host-creator/{ovirt-flash.sh => ovirt-flash} | 23 +++++---------- .../{ovirt-flash-static.sh => ovirt-flash-static} | 26 ++++++---------- ovirt-host-creator/ovirt-host-image.spec | 30 +++++++++++++++---- ovirt-host-creator/{ovirt-pxe.sh => ovirt-pxe} | 20 ++++-------- 8 files changed, 59 insertions(+), 83 deletions(-) rename ovirt-host-creator/{ovirt-cd.sh => ovirt-cd} (82%) delete mode 100644 ovirt-host-creator/ovirt-common.sh rename ovirt-host-creator/{ovirt-flash.sh => ovirt-flash} (77%) rename ovirt-host-creator/{ovirt-flash-static.sh => ovirt-flash-static} (83%) rename ovirt-host-creator/{ovirt-pxe.sh => ovirt-pxe} (79%) diff --git a/ovirt-host-creator/.gitignore b/ovirt-host-creator/.gitignore index 455b5f7..dee1a01 100644 --- a/ovirt-host-creator/.gitignore +++ b/ovirt-host-creator/.gitignore @@ -2,5 +2,5 @@ iso-file *.iso tftpboot rpm-build -ovirt-pxe.log +ovirt-cd.log repos.ks diff --git a/ovirt-host-creator/Makefile b/ovirt-host-creator/Makefile index 6f862f3..6ebdfbd 100644 --- a/ovirt-host-creator/Makefile +++ b/ovirt-host-creator/Makefile @@ -4,22 +4,21 @@ all: rpms include ../common/release.mk clean: - rm -rf ovirt-host-image-* ovirt-pxe.log + rm -rf ovirt-host-image-* ovirt-cd.log distclean: clean - rm -rf *.iso tftpboot repos.ks rpm-build iso-file + rm -rf *.iso repos.ks rpm-build iso-file repos.ks: repos.ks.in sed "s/@@ARCH@@/$(ARCH)/" repos.ks.in > repos.ks build: ovirt.ks common-install.ks common-pkgs.ks common-post.ks repos.ks - rm -rf tftpboot/ - ./ovirt-pxe.sh > ovirt-pxe.log 2>&1 + ./ovirt-cd > ovirt-cd.log 2>&1 tar: clean build mv $$(cat iso-file) ovirt.iso mkdir -p $(NV) - cp -a ovirt-host-image.spec ovirt.iso tftpboot/* $(NV) + cp -a ovirt-host-image.spec ovirt-pxe ovirt-flash ovirt-flash-static ovirt.iso $(NV) mkdir -p rpm-build tar zcvf rpm-build/$(NV).tar $(NV) cp version rpm-build/ diff --git a/ovirt-host-creator/ovirt-cd.sh b/ovirt-host-creator/ovirt-cd similarity index 82% rename from ovirt-host-creator/ovirt-cd.sh rename to ovirt-host-creator/ovirt-cd index a4e4cff..5678f14 100755 --- a/ovirt-host-creator/ovirt-cd.sh +++ b/ovirt-host-creator/ovirt-cd @@ -17,15 +17,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -. ./ovirt-common.sh +PATH=/sbin:/bin:/usr/bin -if [ $# -eq 0 ]; then - ISO-elif [ $# -eq 1 ]; then - ISO=$1 -else - echo "Usage: ovirt-cd.sh [iso-image]" - exit 1 -fi +KICKSTART=ovirt.ks -ISO=`create_iso $ISO` +LABEL=ovirt-`date +%Y%m%d%H%M` +livecd-creator --skip-minimize -c $KICKSTART -f $LABEL 1>&2 && + +echo $LABEL.iso > iso-file diff --git a/ovirt-host-creator/ovirt-common.sh b/ovirt-host-creator/ovirt-common.sh deleted file mode 100644 index 62d2e93..0000000 --- a/ovirt-host-creator/ovirt-common.sh +++ /dev/null @@ -1,16 +0,0 @@ -PATH=/sbin:/bin:/usr/bin -export PATH - -create_iso() { - KICKSTART=ovirt.ks - if [ $# -eq 0 ]; then - LABEL=ovirt-`date +%Y%m%d%H%M` - livecd-creator --skip-minimize -c $KICKSTART -f $LABEL 1>&2 && - echo $LABEL.iso - elif [ $# -eq 1 ]; then - livecd-creator --skip-minimize -c $KICKSTART -b $1 1>&2 && - echo $1 - else - return 1 - fi -} diff --git a/ovirt-host-creator/ovirt-flash.sh b/ovirt-host-creator/ovirt-flash similarity index 77% rename from ovirt-host-creator/ovirt-flash.sh rename to ovirt-host-creator/ovirt-flash index 621972c..bb5b9be 100755 --- a/ovirt-host-creator/ovirt-flash.sh +++ b/ovirt-host-creator/ovirt-flash @@ -17,25 +17,18 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -. ./ovirt-common.sh +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } -if [ $# -eq 1 ]; then - ISO-elif [ $# -eq 2 ]; then - ISO=$2 -else - echo "Usage: ovirt-flash.sh <usbdevice> [iso-image]" - exit 1 -fi +test $# != 2 && die "Usage: $ME <usbdevice> <iso-image>" USBDEVICE=$1 +ISO=$2 -if [ ! -b "$USBDEVICE" ]; then - echo "USB device $USBDEVICE doesn't seem to exist" - exit 2 -fi - -ISO=`create_iso $ISO` || exit 1 +test ! -r $ISO && die "$ISO is not a readable file" +test ! -b $USBDEVICE && die "$USBDEVICE is not a valid block device" +test $( id -u ) -ne 0 && die "$ME must run as root" # clear out the old partition table dd if=/dev/zero of=$USBDEVICE bs=4096 count=1 diff --git a/ovirt-host-creator/ovirt-flash-static.sh b/ovirt-host-creator/ovirt-flash-static similarity index 83% rename from ovirt-host-creator/ovirt-flash-static.sh rename to ovirt-host-creator/ovirt-flash-static index 12e3d14..be9c7c9 100755 --- a/ovirt-host-creator/ovirt-flash-static.sh +++ b/ovirt-host-creator/ovirt-flash-static @@ -17,29 +17,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -. ./ovirt-common.sh +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } -if [ $# -eq 1 ]; then - ISO-elif [ $# -eq 2 ]; then - ISO=$2 -else - echo "Usage: ovirt-flash.sh <usbdevice> [iso-image]" - exit 1 -fi +test $# != 2 && die "Usage: $ME <usbdevice> <iso-image>" USBDEVICE=$1 +ISO=$2 + +test ! -r $ISO && die "$ISO is not a readable file" +test ! -b $USBDEVICE && die "$USBDEVICE is not a valid block device" +test $( id -u ) -ne 0 && die "$ME must run as root" + IMGTMP=/var/tmp/ovirt-$$ SQUASHTMP=/var/tmp/ovirt-squash-$$ USBTMP=/var/tmp/ovirt-usb-$$ -if [ ! -b "$USBDEVICE" ]; then - echo "USB device $USBDEVICE doesn't seem to exist" - exit 2 -fi - -ISO=`create_iso $ISO` || exit 1 - # do setup mkdir -p $IMGTMP $SQUASHTMP $USBTMP mount -o loop $ISO $IMGTMP diff --git a/ovirt-host-creator/ovirt-host-image.spec b/ovirt-host-creator/ovirt-host-image.spec index 91ca6af..0475cab 100644 --- a/ovirt-host-creator/ovirt-host-image.spec +++ b/ovirt-host-creator/ovirt-host-image.spec @@ -8,6 +8,8 @@ License: Fedora Group: Applications/System BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot URL: http://ovirt.org/ +Requires: livecd-tools >= 017 +Requires: syslinux %define app_root %{_datadir}/%{name} %define tftpboot %{_var}/lib/tftpboot @@ -22,15 +24,16 @@ At the moment, this RPM just packages prebuilt ISO. %package pxe Summary: oVirt Managed Node boot PXE image Group: Applications/System +BuildRequires: livecd-tools >= 017 %description pxe The PXE boot image for oVirt Managed Node network boot from oVirt Admin Node. -At the moment, this RPM just packages prebuilt tftpboot folder. %prep %setup -q %build +./ovirt-pxe ovirt.iso %install %{__rm} -rf %{buildroot} @@ -38,27 +41,40 @@ mkdir %{buildroot} %{__install} -d -m0755 %{buildroot}%{tftpboot} %{__install} -d -m0755 %{buildroot}%{tftpboot}/pxelinux.cfg -%{__install} -p -m0644 pxelinux.cfg/default %{buildroot}%{tftpboot}/pxelinux.cfg/default -%{__install} -p -m0644 pxelinux.0 %{buildroot}%{tftpboot} -%{__install} -p -m0644 initrd0.img %{buildroot}%{tftpboot} -%{__install} -p -m0644 vmlinuz0 %{buildroot}%{tftpboot} +%{__install} -p -m0644 tftpboot/pxelinux.cfg/default %{buildroot}%{tftpboot}/pxelinux.cfg/default +%{__install} -p -m0644 tftpboot/pxelinux.0 %{buildroot}%{tftpboot} +%{__install} -p -m0644 tftpboot/initrd0.img %{buildroot}%{tftpboot} +%{__install} -p -m0644 tftpboot/vmlinuz0 %{buildroot}%{tftpboot} %{__install} -d -m0755 %{buildroot}%{app_root} %{__install} -p -m0644 ovirt.iso %{buildroot}%{app_root} +%{__install} -d -m0755 %{buildroot}%{_sbindir} +%{__install} -p -m0755 ovirt-pxe %{buildroot}%{_sbindir} +%{__install} -p -m0755 ovirt-flash %{buildroot}%{_sbindir} +%{__install} -p -m0755 ovirt-flash-static %{buildroot}%{_sbindir} %clean %{__rm} -rf %{buildroot} %files -%defattr(-,root,root) +%defattr(-,root,root,0644) %{app_root}/ovirt.iso +%defattr(-,root,root,0755) +%{_sbindir}/ovirt-pxe +%{_sbindir}/ovirt-flash +%{_sbindir}/ovirt-flash-static %files pxe -%defattr(-,root,root) +%defattr(-,root,root,0644) %config(noreplace) %{tftpboot}/pxelinux.cfg/default %{tftpboot}/pxelinux.0 %{tftpboot}/initrd0.img %{tftpboot}/vmlinuz0 %changelog +* Thu Jul 03 2008 Perry Myers <pmyers at redhat.com> 0.92-0 +- Only store ISO in SRPM, and generate PXE from that during build + * Tue Jun 03 2008 Alan Pevec <apevec at redhat.com> 0.0.5-1 - Initial build. + + diff --git a/ovirt-host-creator/ovirt-pxe.sh b/ovirt-host-creator/ovirt-pxe similarity index 79% rename from ovirt-host-creator/ovirt-pxe.sh rename to ovirt-host-creator/ovirt-pxe index 624ac78..facca5b 100755 --- a/ovirt-host-creator/ovirt-pxe.sh +++ b/ovirt-host-creator/ovirt-pxe @@ -17,24 +17,18 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -. ./ovirt-common.sh +ME=$(basename "$0") +warn() { printf "$ME: $@\n" >&2; } +die() { warn "$@"; exit 1; } -if [ $# -eq 0 ]; then - ISO-elif [ $# -eq 1 ]; then - ISO=$1 -else - echo "Usage: ovirt-pxe.sh [iso-image]" - exit 1 -fi +test $# != 1 && die "Usage: $ME <iso-image>" -rm -f iso-file -ISO=`create_iso $ISO` || exit 1 +ISO=$1 +test ! -r $ISO && die "$ISO is not a readable file" +test $( id -u ) -ne 0 && die "$ME must run as root" livecd-iso-to-pxeboot $ISO # append BOOTIF with PXE MAC info f=tftpboot/pxelinux.cfg/default grep -q 'IPAPPEND 2' $f || sed -i '/KERNEL/a \\tIPAPPEND 2' $f - -echo $ISO > iso-file -- 1.5.5.1