Separate RPM for virt-p2v. Use gettext for i18n.
[virt-p2v.git] / Makefile.in
index 68e1a9e..f5df4b4 100644 (file)
 #----------------------------------------------------------------------
 # General configuration
 
-PACKAGE  := @PACKAGE_NAME@
-VERSION  := @PACKAGE_VERSION@
+PACKAGE                := @PACKAGE_NAME@
+VERSION                := @PACKAGE_VERSION@
 
-HAVE_PERLDOC := @HAVE_PERLDOC@
-HAVE_QEMU := @HAVE_QEMU@
-HAVE_QEMU_KVM := @HAVE_QEMU_KVM@
-HAVE_LIVECD_CREATOR := @HAVE_LIVECD_CREATOR@
-
-# i386 images also work on x86-64, so best to stick with i386.
-ARCH     := i386
-
-# Base repository.
-BASE    := 8
-BASEURL         := http://download.fedora.redhat.com/pub/fedora/linux/releases/$(BASE)/Everything/$(ARCH)/os/
-
-LANG    := en_US.UTF-8
-KEYBOARD := us
-TIMEZONE := US/Eastern
+INSTALL                := @INSTALL@
 
-LABEL   := $(PACKAGE)-$(VERSION)
+HAVE_PERLDOC   := @HAVE_PERLDOC@
+HAVE_QEMU      := @HAVE_QEMU@
+HAVE_QEMU_KVM  := @HAVE_QEMU_KVM@
+HAVE_LIVECD_CREATOR := @HAVE_LIVECD_CREATOR@
+HAVE_LIVECD_ISO_TO_PXEBOOT := @HAVE_LIVECD_ISO_TO_PXEBOOT@
 
-ISO     := $(LABEL).iso
+LABEL          := $(PACKAGE)-$(VERSION)
+ISO            := $(LABEL).iso
+PXE_TAR                := $(PACKAGE)-$(VERSION)-pxeboot.tar
+VIRTP2V_RPM     := $(PACKAGE)-$(VERSION)-1.noarch.rpm
 
 #----------------------------------------------------------------------
 
 all:
+       @echo "make rpm       Build the virt-p2v RPM"
        @echo "make build     Build the live CD ISO"
        @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
        @echo "                 Boot built/named ISO (uses qemu)"
        @echo "make update    Update an existing live CD ISO with new"
        @echo "                 virt-p2v script, without doing full rebuild"
+       @echo "make pxe       Build a PXE image (in tftpboot/ subdirectory)"
        @echo "make man       Make man pages (needs POD)"
 
 # Build live CD.
 
 ifeq ($(HAVE_LIVECD_CREATOR),livecd-creator)
 
-build: checkroot checkscript livecd.ks
+build: checkroot checkrpm checkscript
        rm -f $(ISO)
-       livecd-creator --config=livecd.ks --fslabel=$(LABEL)
+       livecd-creator --config=p2v.ks --fslabel=$(LABEL)
        ls -lhtr *.iso
 
-livecd.ks: livecd.ks.in livecd-post.sh Makefile
-       rm -f $@
-       sed \
-         -e 's|@ARCH@|$(ARCH)|g' \
-         -e 's|@BASE@|$(BASE)|g' \
-         -e 's|@BASEURL@|$(BASEURL)|g' \
-         -e 's|@LANG@|$(LANG)|g' \
-         -e 's|@KEYBOARD@|$(KEYBOARD)|g' \
-         -e 's|@TIMEZONE@|$(TIMEZONE)|g' \
-         < $< | cat - livecd-post.sh > $@
-
-livecd-post.sh: livecd-post.sh.in virt-p2v virt-p2v-update-wrapper iso-attach inittab lvm.conf Makefile
-       rm -f $@
-       sed \
-         -e '/@VIRT-P2V@/ r virt-p2v' \
-         -e '/@VIRT-P2V@/ d' \
-         -e '/@VIRT-P2V-UPDATE-WRAPPER@/ r virt-p2v-update-wrapper' \
-         -e '/@VIRT-P2V-UPDATE-WRAPPER@/ d' \
-         -e '/@ISO-ATTACH@/ r iso-attach' \
-         -e '/@ISO-ATTACH@/ d' \
-         -e '/@INITTAB@/ r inittab' \
-         -e '/@INITTAB@/ d' \
-         -e '/@LVM.CONF@/ r lvm.conf' \
-         -e '/@LVM.CONF@/ d' \
-         < $< > $@
-
 endif
 
+# Build RPM of virt-p2v.
+
+rpm:   checknotroot rpmbuild/$(VIRTP2V_RPM)
+
+RPM_FLAGS := --define "_topdir       %(pwd)/rpmbuild" \
+            --define "_builddir     %{_topdir}" \
+            --define "_rpmdir       %{_topdir}" \
+            --define "_srcrpmdir    %{_topdir}" \
+            --define "_rpmfilename  $(VIRTP2V_RPM)" \
+            --define "_specdir      %{_topdir}" \
+            --define "_sourcedir    %(pwd)"
+
+rpmbuild/$(VIRTP2V_RPM): \
+               virt-p2v.spec \
+               virt-p2v virt-p2v-update-wrapper iso-attach \
+               inittab
+       mkdir -p rpmbuild
+       rpmbuild $(RPM_FLAGS) -ba $<
+       createrepo rpmbuild
+
+# Make the final script.
+
+virt-p2v: virt-p2v.ml0 virt-p2v.ml
+       cat $^ > $@
+       chmod 0555 $@
+
 # Run live CD under qemu.
 
 ifeq ($(HAVE_QEMU_KVM),qemu-kvm)
@@ -120,9 +115,18 @@ endif
 # Update an existing ISO.
 
 update: checkroot checkscript
-       -./iso-attach delete $(ISO)
+       -./iso-attach delete $(ISO) 2>/dev/null
        ./iso-attach add $(ISO) virt-p2v
 
+# PXE boot.
+
+ifeq ($(HAVE_LIVECD_ISO_TO_PXEBOOT),livecd-iso-to-pxeboot)
+
+pxe: checkroot checkscript
+       livecd-iso-to-pxeboot $(ISO)
+
+endif
+
 # Check that we are root.
 
 checkroot:
@@ -131,15 +135,36 @@ checkroot:
          exit 1; \
        fi
 
+# Check that we are not root.
+
+checknotroot:
+       @if [ `id -u` -eq 0 ]; then \
+         echo "You must not perform this step as root."; \
+         exit 1; \
+       fi
+
 # Check that the script compiles.
 
 checkscript:
+       test -x virt-p2v
        ./virt-p2v --test
 
+# Check that the RPM has been built.
+
+checkrpm:
+       test -f rpmbuild/$(VIRTP2V_RPM)
+
 # Clean.
 
 clean:
-       rm -f *~ core livecd.ks livecd-post.sh
+       rm -f *~ core virt-p2v pod2htm*
+
+distclean: clean
+       rm -rf autom4te.cache config.log config.status configure \
+         p2v.ks Makefile po/Makefile virt-p2v.spec
+
+reallyreallyclean: distclean
+       rm -f virt-p2v-*.tar.gz virt-p2v-*.iso
 
 # Manifest.
 
@@ -148,6 +173,7 @@ dist:
        rm -rf $(PACKAGE)-$(VERSION)
        mkdir $(PACKAGE)-$(VERSION)
        tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
+       $(INSTALL) -m 0755 configure $(PACKAGE)-$(VERSION)/
        tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
        rm -rf $(PACKAGE)-$(VERSION)
        ls -l $(PACKAGE)-$(VERSION).tar.gz
@@ -187,4 +213,20 @@ website: man dist
        cp virt-p2v.1.css $(WEBSITE_DIR)
        cp $(PACKAGE)-$(VERSION).tar.gz $(WEBSITE_DIR)
 
+# Upload everything.
+
+upload: upload_iso upload_pxe
+
+# Upload ISO.
+
+upload_iso:
+       scp -l 300 $(ISO) et.redhat.com:public_html/tmp/
+
+# Upload PXE image.
+
+upload_pxe:
+       tar cf $(PXE_TAR) tftpboot
+       scp -l 300 $(PXE_TAR) et.redhat.com:public_html/tmp/
+#      rm $(PXE_TAR)
+
 .PHONY:        build boot checkroot
\ No newline at end of file