Separate RPM for virt-p2v. Use gettext for i18n.
authorRichard W.M. Jones <rjones@redhat.com>
Sat, 22 Mar 2008 15:55:57 +0000 (15:55 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Sat, 22 Mar 2008 15:55:57 +0000 (15:55 +0000)
13 files changed:
.hgignore
MANIFEST
Makefile.in
README
configure.ac
p2v.ks.in
po/LINGUAS [new file with mode: 0644]
po/Makefile.in [new file with mode: 0644]
po/POTFILES [new file with mode: 0644]
po/virt-p2v.pot [new file with mode: 0644]
virt-p2v.ml [moved from virt-p2v with 88% similarity, mode: 0644]
virt-p2v.ml0 [new file with mode: 0644]
virt-p2v.spec.in [new file with mode: 0644]

index 92e2919..855f5c4 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -15,4 +15,8 @@
 ^Makefile$
 ^p2v\.ks$
 ^tftpboot/
-^localrepo/
\ No newline at end of file
+^localrepo/
+^rpmbuild/
+^virt-p2v.spec$
+^virt-p2v$
+^po/Makefile$
\ No newline at end of file
index 8d36af6..409e71c 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -42,10 +42,11 @@ p2v.ks.in
 README
 README.developers
 TODO
-virt-p2v
 virt-p2v.1
 virt-p2v.1.css
 virt-p2v.1.html
 virt-p2v.1.txt
+virt-p2v.ml0
+virt-p2v.ml
 virt-p2v.pod
 virt-p2v-update-wrapper
index f2a437b..f5df4b4 100644 (file)
@@ -34,10 +34,13 @@ HAVE_LIVECD_ISO_TO_PXEBOOT := @HAVE_LIVECD_ISO_TO_PXEBOOT@
 
 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)"
@@ -50,13 +53,39 @@ all:
 
 ifeq ($(HAVE_LIVECD_CREATOR),livecd-creator)
 
-build: p2v.ks checkroot checkscript
+build: checkroot checkrpm checkscript
        rm -f $(ISO)
-       livecd-creator --config=$< --fslabel=$(LABEL)
+       livecd-creator --config=p2v.ks --fslabel=$(LABEL)
        ls -lhtr *.iso
 
 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)
@@ -106,18 +135,33 @@ 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 p2v.ks pod2htm*
+       rm -f *~ core virt-p2v pod2htm*
 
 distclean: clean
-       rm -rf autom4te.cache config.log config.status configure
+       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
@@ -180,8 +224,6 @@ upload_iso:
 
 # Upload PXE image.
 
-PXE_TAR := $(PACKAGE)-$(VERSION)-pxeboot.tar
-
 upload_pxe:
        tar cf $(PXE_TAR) tftpboot
        scp -l 300 $(PXE_TAR) et.redhat.com:public_html/tmp/
diff --git a/README b/README
index 19962d1..521cfb4 100644 (file)
--- a/README
+++ b/README
@@ -41,8 +41,10 @@ Building
 Requirements:
 
  * livecd-creator (in Fedora the package is called 'livecd-tools')
- * ocaml, ocaml-extlib-devel, ocaml-pcre-devel, ocaml-xml-light-devel,
-   ocaml-newt-devel, ocaml-libvirt-devel (all in Fedora)
+ * rpmbuild (in Fedora package rpm-build)
+ * ocaml, ocaml-findlib, ocaml-extlib, ocaml-pcre, ocaml-xml-light,
+   ocaml-newt, ocaml-libvirt, ocaml-fileutils, ocaml-gettext,
+   ocaml-gettext-devel (all in Fedora)
  * qemu and/or KVM (only for testing)
 
 Then:
@@ -53,7 +55,8 @@ Then:
 
 Then:
 
-       make build      (as root) builds an ISO image
+       make rpm        builds the virt-p2v RPM
+       make build      (AS ROOT) builds an ISO image
                        called virt-p2v-$VERSION.iso
 
 Other useful commands:
index fb8ae7c..6dd5fa7 100644 (file)
@@ -16,7 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(virt-p2v,0.9.7)
+AC_INIT(virt-p2v,0.9.8)
 
 AC_PROG_INSTALL
 
@@ -80,6 +80,7 @@ AC_SUBST(LOCALREPO)
 
 dnl Check for basic OCaml script interpreter.
 AC_PROG_OCAML
+AC_PROG_FINDLIB
 
 dnl Check for required OCaml modules.
 AC_CHECK_OCAML_MODULE(unix,pkg_unix,Unix,[.])
@@ -112,6 +113,11 @@ if test "x$pkg_libvirt" = "xno"; then
     AC_MSG_ERROR([Cannot find required OCaml package 'ocaml-libvirt'])
 fi
 
+AC_CHECK_OCAML_MODULE(gettext,pkg_gettext,Gettext,[+gettext])
+if test "x$pkg_gettext" = "xno"; then
+    AC_MSG_ERROR([Cannot find required OCaml package 'ocaml-gettext'])
+fi
+
 dnl Check for recommended livecd-creator (for building ISOs).
 AC_CHECK_PROG(HAVE_LIVECD_CREATOR,livecd-creator,livecd-creator)
 
@@ -125,11 +131,14 @@ dnl Check for optional qemu or qemu-kvm (for test-booting).
 AC_CHECK_PROG(HAVE_QEMU,qemu,qemu)
 AC_CHECK_PROG(HAVE_QEMU_KVM,qemu-kvm,qemu-kvm)
 
+dnl Check for recommended ocaml-gettext tool.
+AC_CHECK_PROG(OCAML_GETTEXT,ocaml-gettext,ocaml-gettext)
+
 dnl Summary.
 echo "------------------------------------------------------------"
 echo "Thanks for downloading" $PACKAGE_STRING
 echo "------------------------------------------------------------"
 
 dnl Produce output files.
-AC_CONFIG_FILES([Makefile p2v.ks])
+AC_CONFIG_FILES([Makefile po/Makefile p2v.ks virt-p2v.spec])
 AC_OUTPUT
index a590d70..ae385d1 100644 (file)
--- a/p2v.ks.in
+++ b/p2v.ks.in
@@ -25,10 +25,16 @@ auth --useshadow --enablemd5
 selinux --enforcing
 firewall --disabled
 
+# Basic Fedora repo.
 repo --name=released --baseurl=@CD_BASE_URL@
 #repo --name=released --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-@CD_BASE@&arch=@CD_ARCH@
+
+# A local repository if selected by ./configure --enable-localrepo=...
 @LOCALREPO@
 
+# The rpmbuild subdirectory, containing virt-p2v RPM.
+repo --name=p2v --baseurl=file://@abs_top_builddir@/rpmbuild
+
 %packages
 bash
 kernel
@@ -63,20 +69,7 @@ findutils
 iproute
 net-tools
 
-# For OCaml
-ocaml
-ocaml-runtime
-ocaml-pcre
-ocaml-extlib
-ocaml-xml-light
-# REQUIRED: ocaml-libvirt >= 0.4.1.1
-ocaml-libvirt
-# REQUIRED: ocaml-newt >= 0.9
-ocaml-newt
-
 # For network configuration
-# dhclient >= 4.0.0 fixes the cwd-holds-filesystem-open problem.
-# REQUIRED: dhclient >= 4.0.0
 dhclient
 
 # Some other generally useful packages
@@ -90,6 +83,9 @@ vim-enhanced
 bind-utils
 file
 
+# virt-p2v package and its deps
+virt-p2v
+
 
 %post --nochroot
 
@@ -103,7 +99,6 @@ if test "x$INSTALL_ROOT" = "x"; then ERROR=1; fi
 if ! test -d "$INSTALL_ROOT/usr/bin"; then ERROR=1; fi
 if ! test -d "@abs_top_srcdir@"; then ERROR=1; fi
 if ! test -d "@abs_top_srcdir@/extras"; then ERROR=1; fi
-if ! test -f "@abs_top_srcdir@/virt-p2v"; then ERROR=1; fi
 
 if test "x$ERROR" = "x1"; then
     echo "**************************************************"
@@ -117,15 +112,6 @@ if test "x$ERROR" = "x1"; then
     exit 1
 fi
 
-install -m 0755 -o root -g root \
-       @abs_top_srcdir@/virt-p2v \
-       @abs_top_srcdir@/virt-p2v-update-wrapper \
-       @abs_top_srcdir@/iso-attach \
-       $INSTALL_ROOT/usr/bin
-
-install -m 0644 -o root -g root @abs_top_srcdir@/inittab \
-       $INSTALL_ROOT/etc
-
 cp -a $INSTALL_ROOT/etc/lvm $INSTALL_ROOT/etc/lvm.new
 install -m 0644 -o root -g root @abs_top_srcdir@/lvm.conf \
        $INSTALL_ROOT/etc/lvm.new
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/po/Makefile.in b/po/Makefile.in
new file mode 100644 (file)
index 0000000..46f1a13
--- /dev/null
@@ -0,0 +1,76 @@
+# Makefile for po subdirectory.
+# @configure_input@
+#
+# Copyright (C) 2007-2008 Red Hat Inc.
+# Written by Richard W.M. Jones <rjones@redhat.com>
+#
+# This program 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 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+OCAML_GETTEXT_PACKAGE = virt-p2v
+LINGUAS                = $(shell cat LINGUAS)
+SOURCES                = POTFILES
+
+OCAML_GETTEXT  = @OCAML_GETTEXT@
+OCAML_GETTEXT_EXTRACT_OPTIONS =
+OCAML_GETTEXT_COMPILE_OPTIONS =
+OCAML_GETTEXT_INSTALL_OPTIONS =
+OCAML_GETTEXT_MERGE_OPTIONS   =
+
+PODIR          = @prefix@/share/locale
+
+POFILES                = $(addsuffix .po,$(LINGUAS))
+MOFILES                = $(addsuffix .mo,$(LINGUAS))
+POTFILE                = $(OCAML_GETTEXT_PACKAGE).pot
+
+all: $(MOFILES) $(POTFILE)
+
+install: install-po
+
+uninstall: uninstall-po
+
+clean:: clean-po
+
+%.mo: %.po
+       $(OCAML_GETTEXT) --action compile $(OCAML_GETTEXT_COMPILE_OPTIONS) \
+       --compile-output $@ $^
+
+%.pot: $(SOURCES) $(shell cat $(SOURCES))
+       $(OCAML_GETTEXT) --action extract $(OCAML_GETTEXT_EXTRACT_OPTIONS) \
+       --extract-pot $@ $<
+
+%.po: $(POTFILE)
+       $(OCAML_GETTEXT) --action merge   $(OCAML_GETTEXT_MERGE_OPTIONS) \
+       --merge-pot $(POTFILE) $@
+
+$(BUILDPO):
+       mkdir -p $(BUILDPO)
+
+.PRECIOUS: $(POTFILE) 
+
+install-po: $(MOFILES) 
+       $(OCAML_GETTEXT) --action install $(OCAML_GETTEXT_INSTALL_OPTIONS) \
+       --install-textdomain $(OCAML_GETTEXT_PACKAGE) \
+       --install-destdir $(PODIR) $(MOFILES)
+
+uninstall-po:
+       $(OCAML_GETTEXT) --action uninstall $(OCAML_GETTEXT_INSTALL_OPTIONS) \
+       --uninstall-textdomain $(OCAML_GETTEXT_PACKAGE) \
+       --uninstall-orgdir $(PODIR) $(MOFILES)
+
+clean-po:
+       -$(OCAML_GETTEXT) --action uninstall $(OCAML_GETTEXT_INSTALL_OPTIONS) \
+       --uninstall-textdomain $(OCAML_GETTEXT_PACKAGE) \
+       --uninstall-orgdir $(BUILDPO) $(MOFILES)
+       -$(RM) $(MOFILES) 
diff --git a/po/POTFILES b/po/POTFILES
new file mode 100644 (file)
index 0000000..051324f
--- /dev/null
@@ -0,0 +1 @@
+../virt-p2v.ml
\ No newline at end of file
diff --git a/po/virt-p2v.pot b/po/virt-p2v.pot
new file mode 100644 (file)
index 0000000..62a0188
--- /dev/null
@@ -0,0 +1,343 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-03-22 15:53+0000\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+
+#: ../virt-p2v.ml:1876
+msgid " (about %.0f minutes remaining)"
+msgstr ""
+
+#: ../virt-p2v.ml:1879
+msgid " (about %.0f seconds remaining)"
+msgstr ""
+
+#: ../virt-p2v.ml:1902
+msgid "%s has finished"
+msgstr ""
+
+#: ../virt-p2v.ml:813
+msgid "%s starting up ...\\n%!"
+msgstr ""
+
+#: ../virt-p2v.ml:1424
+msgid "(leave MAC blank for random)"
+msgstr ""
+
+#: ../virt-p2v.ml:1391
+msgid "Architecture:"
+msgstr ""
+
+#: ../virt-p2v.ml:1120
+msgid "Automatic from:"
+msgstr ""
+
+#: ../virt-p2v.ml:1356
+msgid "Block devices"
+msgstr ""
+
+#: ../virt-p2v.ml:1418
+msgid "CPUs:"
+msgstr ""
+
+#: ../virt-p2v.ml:428
+msgid "Command failed:\\n\\n%s"
+msgstr ""
+
+#: ../virt-p2v.ml:1090
+msgid "Configure network"
+msgstr ""
+
+#: ../virt-p2v.ml:1382
+msgid "Configure target system"
+msgstr ""
+
+#: ../virt-p2v.ml:825
+msgid "Detecting hard drives (this may take some time) ..."
+msgstr ""
+
+#: ../virt-p2v.ml:571
+msgid "Disk snapshot failed: unable to read the size in sectors of block device %s"
+msgstr ""
+
+#: ../virt-p2v.ml:1136
+msgid "Don't configure the network"
+msgstr ""
+
+#: ../virt-p2v.ml:323
+msgid "Error"
+msgstr ""
+
+#: ../virt-p2v.ml:295
+msgid "F12 for next screen | [ALT] [F2] root / no password for shell"
+msgstr ""
+
+#: ../virt-p2v.ml:1021
+msgid "Finished detecting hard drives."
+msgstr ""
+
+#: ../virt-p2v.ml:1147
+msgid "Gateway"
+msgstr ""
+
+#: ../virt-p2v.ml:1384
+msgid "Hypervisor:"
+msgstr ""
+
+#: ../virt-p2v.ml:1143
+msgid "IP"
+msgstr ""
+
+#: ../virt-p2v.ml:1141
+msgid "Interface"
+msgstr ""
+
+#: ../virt-p2v.ml:212
+msgid "Linux /boot"
+msgstr ""
+
+#: ../virt-p2v.ml:208
+msgid "Linux swap"
+msgstr ""
+
+#: ../virt-p2v.ml:1421
+msgid "MAC addr:"
+msgstr ""
+
+#: ../virt-p2v.ml:1415
+msgid "Memory (MB):"
+msgstr ""
+
+#: ../virt-p2v.ml:213
+msgid "Mountable non-root"
+msgstr ""
+
+#: ../virt-p2v.ml:1149
+msgid "Nameserver"
+msgstr ""
+
+#: ../virt-p2v.ml:1145
+msgid "Netmask"
+msgstr ""
+
+#: ../virt-p2v.ml:1089
+msgid "Network"
+msgstr ""
+
+#: ../virt-p2v.ml:1237
+msgid "Network configuration.\\n\\nPlease configure the network from this shell.\\n\\nWhen you have finished, exit the shell with ^D or exit.\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:853
+msgid "No non-removable block devices (hard disks, etc.) could be found on this machine."
+msgstr ""
+
+#: ../virt-p2v.ml:1557
+msgid "Note"
+msgstr ""
+
+#: ../virt-p2v.ml:1599
+msgid "Performing LVM snapshots ...\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:1076
+msgid "Physical to Virtual (P2V)"
+msgstr ""
+
+#: ../virt-p2v.ml:1133
+msgid "QEMU user network"
+msgstr ""
+
+#: ../virt-p2v.ml:1287
+msgid "Remote directory"
+msgstr ""
+
+#: ../virt-p2v.ml:1283
+msgid "Remote host"
+msgstr ""
+
+#: ../virt-p2v.ml:1552
+msgid "Remote hypervisor claims not to support fully virtualized %s guests.\\n\\nContinuing anyway.\\n\\n%!"
+msgstr ""
+
+#: ../virt-p2v.ml:1558
+msgid "Remote hypervisor supports multiple types of fully virtualized %s guests.\\n\\nPlease help further development of libvirt and virt-p2v by sending the file /tmp/virt-p2v.log back to the developers.  See the main virt-p2v website for contact details."
+msgstr ""
+
+#: ../virt-p2v.ml:1285
+msgid "Remote port"
+msgstr ""
+
+#: ../virt-p2v.ml:1373
+msgid "Root filesystem"
+msgstr ""
+
+#: ../virt-p2v.ml:1281 ../virt-p2v.ml:1280
+msgid "SSH configuration"
+msgstr ""
+
+#: ../virt-p2v.ml:1338
+msgid "SSH configuration failed"
+msgstr ""
+
+#: ../virt-p2v.ml:1289
+msgid "SSH username"
+msgstr ""
+
+#: ../virt-p2v.ml:1358
+msgid "Select block devices to send"
+msgstr ""
+
+#: ../virt-p2v.ml:1374
+msgid "Select root filesystem"
+msgstr ""
+
+#: ../virt-p2v.ml:1123
+msgid "Start a shell"
+msgstr ""
+
+#: ../virt-p2v.ml:1139
+msgid "Static configuration:"
+msgstr ""
+
+#: ../virt-p2v.ml:1381
+msgid "Target system"
+msgstr ""
+
+#: ../virt-p2v.ml:1302
+msgid "Test SSH connection"
+msgstr ""
+
+#: ../virt-p2v.ml:676
+msgid "Testing SSH connection by listing files in remote directory ...\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:1081 ../virt-p2v.ml:1080
+msgid "Transfer type"
+msgstr ""
+
+#: ../virt-p2v.ml:1505
+msgid "Try to fetch remote hypervisor capabilities ...\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:1266
+msgid "Trying QEMU network configuration.\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:1250
+msgid "Trying network auto-configuration from root filesystem ...\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:1241
+msgid "Trying static network configuration.\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:214
+msgid "Unknown partition type"
+msgstr ""
+
+#: ../virt-p2v.ml:1298
+msgid "Use SSH compression (not good for LANs)"
+msgstr ""
+
+#: ../virt-p2v.ml:1427
+msgid "Use remote libvirtd"
+msgstr ""
+
+#: ../virt-p2v.ml:1077
+msgid "Virtual to Virtual (V2V)"
+msgstr ""
+
+#: ../virt-p2v.ml:1551
+msgid "Warning"
+msgstr ""
+
+#: ../virt-p2v.ml:1068
+msgid "Welcome to %s, a live CD for migrating a physical machine to a virtualized host.\\n\\nTo continue press the Return key.\\n\\nTo get a shell you can use [ALT] [F2] and log in as root with no password.\\n\\nExtra information is logged in /tmp/virt-p2v.log but this file disappears when the machine reboots."
+msgstr ""
+
+#: ../virt-p2v.ml:211
+msgid "Windows root"
+msgstr ""
+
+#: ../virt-p2v.ml:821
+msgid "You should only run this script from the live CD or a USB key."
+msgstr ""
+
+#: ../virt-p2v.ml:1801
+msgid "\\\n<!--\n  This is an automatically generated libvirt configuration file.\n  It was written by the %s program.\n\n  Please check the values in this configuration file carefully,\n  particularly maxmem, memory, vcpu and any paths.\n\n  To start the domain, do:\n    virsh%s define %s\n    virsh%s start %s\n-->\\n\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:1256 ../virt-p2v.ml:1244
+msgid "\\nAuto-configuration failed.  Starting a shell.\\n\\nPlease configure the network from this shell.\\n\\nWhen you have finished, exit the shell with ^D or exit.\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:1840
+msgid "\\nSending /dev/%s (%.3f GB) to remote machine\\n\\n%!"
+msgstr ""
+
+#: ../virt-p2v.ml:1903
+msgid "\\nThe physical to virtual migration is complete.\\n\\nPlease verify the disk image(s) and configuration file on the remote host, and then start up the virtual machine by doing:\\n\\ncd %s\\nvirsh define %s\\n\\nWhen you press [OK] this machine will reboot."
+msgstr ""
+
+#: ../virt-p2v.ml:1819
+msgid "\\nWriting configuration file ...\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:683
+msgid "\\n\\nDid SSH work?\\nHint: If not sure, there is a shell on console [ALT] [F2]\\n"
+msgstr ""
+
+#: ../virt-p2v.ml:599
+msgid "\\n\\nDid automatic network configuration work?\\nHint: If not sure, there is a shell on console [ALT] [F2]"
+msgstr ""
+
+#: ../virt-p2v.ml:322
+msgid "\\n\\nIf you want to report this error, there is a shell on [ALT] [F2], log in as root with no password.\\n\\nPlease provide the contents of /tmp/virt-p2v.log and output of the 'dmesg' command."
+msgstr ""
+
+#: ../virt-p2v.ml:286
+msgid "open_centered_window: not in newt mode"
+msgstr ""
+
+#: ../virt-p2v.ml:447
+msgid "shget: command killed by signal %d"
+msgstr ""
+
+#: ../virt-p2v.ml:449
+msgid "shget: command stopped by signal %d"
+msgstr ""
+
+#: ../virt-p2v.ml:661
+msgid "ssh: exited with error code %d"
+msgstr ""
+
+#: ../virt-p2v.ml:662
+msgid "ssh: killed by signal %d"
+msgstr ""
+
+#: ../virt-p2v.ml:663
+msgid "ssh: stopped by signal %d"
+msgstr ""
+
+#: ../virt-p2v.ml:528
+msgid "unexpected output: "
+msgstr ""
+
+#: ../virt-p2v.ml:1915
+msgid "usage: virt-p2v [--test] [ttyname]\\n%!"
+msgstr ""
+
old mode 100755 (executable)
new mode 100644 (file)
similarity index 88%
rename from virt-p2v
rename to virt-p2v.ml
index ca75df9..e61e62d
--- a/virt-p2v
@@ -1,4 +1,3 @@
-#!/usr/bin/ocamlrun /usr/bin/ocaml
 (* -*- tuareg -*- *)
 (* virt-p2v is a script which performs a physical to
  * virtual conversion of local disks.
@@ -108,26 +107,33 @@ let test_dialog_stages = false
 (* END OF CUSTOM virt-p2v SCRIPT SECTION.                               *)
 (*----------------------------------------------------------------------*)
 
-(* Load external libraries. *)
-;;
-#load "unix.cma";;
-#directory "+extlib";;
-#load "extLib.cma";;
-#directory "+pcre";;
-#load "pcre.cma";;
-#directory "+newt";;
-#load "mlnewt.cma";;
-#directory "+xml-light";;
-#load "xml-light.cma";;
-#directory "+libvirt";;
-#load "mllibvirt.cma";;
-
 open Unix
 open Printf
 open ExtList
 open ExtString
 
 (*----------------------------------------------------------------------*)
+(* Gettext support.
+ *
+ * Use s_ "string" to mark a translatable string, and f_ "string %s"
+ * to mark a format string (eg. for printf).  There are other
+ * functions: see ocaml-gettext manual and GNU gettext info.
+ *
+ * Try not to mark strings which always go to the log file (eg.
+ * eprintf messages).
+ *)
+
+module P2VGettext = Gettext.Program (
+  struct
+    let textdomain   = "virt-p2v"
+    let codeset      = None
+    let dir          = None
+    let dependencies = []
+  end
+) (GettextStub.Native)
+open P2VGettext
+
+(*----------------------------------------------------------------------*)
 (* General helper functions. *)
 
 let sort_uniq ?(cmp = compare) xs =    (* sort and uniq a list *)
@@ -199,13 +205,13 @@ and linux_distro = RHEL of int * int
                 | OtherLinux
 
 let rec string_of_nature = function
-  | LinuxSwap -> "Linux swap"
+  | LinuxSwap -> s_ "Linux swap"
   | LinuxRoot (architecture, distro) ->
       string_of_linux_distro distro ^ " " ^ string_of_architecture architecture
-  | WindowsRoot -> "Windows root"
-  | LinuxBoot -> "Linux /boot"
-  | NotRoot -> "Mountable non-root"
-  | UnknownNature -> "Unknown"
+  | WindowsRoot -> s_ "Windows root"
+  | LinuxBoot -> s_ "Linux /boot"
+  | NotRoot -> s_ "Mountable non-root"
+  | UnknownNature -> s_ "Unknown partition type"
 and string_of_linux_distro = function
   | RHEL (a,b) -> sprintf "RHEL %d.%d" a b
   | Fedora v -> sprintf "Fedora %d" v
@@ -277,7 +283,7 @@ let with_newt f =
  * and help messages are consistent.
  *)
 let open_centered_window ?stage width height title =
-  if not !in_newt then failwith "open_centered_window: not in newt mode";
+  if not !in_newt then failwith (s_ "open_centered_window: not in newt mode");
   Newt.cls ();
   Newt.centered_window width height title;
   let root_text =
@@ -285,7 +291,10 @@ let open_centered_window ?stage width height title =
                    | None -> ""
                    | Some stage -> " - " ^ stage) in
   Newt.draw_root_text 0 0 root_text;
-  Newt.push_help_line "F12 for next screen | [ALT] [F2] root / no password for shell"
+  Newt.push_help_line
+    (s_ "F12 for next screen | [ALT] [F2] root / no password for shell")
+
+let ok_button = "  OK  "
 
 (* Some general dialog boxes. *)
 let message_box title text =
@@ -295,7 +304,7 @@ let message_box title text =
 
       let textbox = Newt.textbox 1 1 36 14 [Newt.WRAP; Newt.SCROLL] in
       Newt.textbox_set_text textbox text;
-      let ok = Newt.button 28 16 "  OK  " in
+      let ok = Newt.button 28 16 ok_button in
       let form = Newt.form None None [] in
       Newt.form_add_components form [textbox; ok];
 
@@ -308,8 +317,10 @@ let message_box title text =
 (* Fail and exit with error. *)
 let failwith text =
   prerr_endline text;
-  let text = "\n" ^ text ^ "\n\nIf you want to report this error, there is a shell on [ALT] [F2], log in as root with no password.\n\nPlease provide the contents of /tmp/virt-p2v.log and output of the 'dmesg' command." in
-  message_box "Error" text;
+  let text = "\n"
+    ^ text
+    ^ s_ "\n\nIf you want to report this error, there is a shell on [ALT] [F2], log in as root with no password.\n\nPlease provide the contents of /tmp/virt-p2v.log and output of the 'dmesg' command." in
+  message_box (s_ "Error") text;
   exit 1
 
 (* Display a dialog with checkboxes, return the multiple selected items. *)
@@ -327,7 +338,7 @@ let select_multiple ?stage ?(force_one = false) width title items =
            (handle, cb)
        ) items in
 
-      let ok = Newt.button 48 16 "  OK  " in
+      let ok = Newt.button 48 16 ok_button in
 
       let vb =
        if List.length entries > 10 then
@@ -374,7 +385,7 @@ let select_single ?stage width title items =
            (handle, rb)
        ) items in
 
-      let ok = Newt.button (width-12) 16 "  OK  " in
+      let ok = Newt.button (width-12) 16 ok_button in
 
       let vb =
        if List.length entries > 10 then
@@ -413,7 +424,8 @@ let quote = Filename.quote
 (* Run a shell command and check it returns 0. *)
 let sh cmd =
   eprintf "sh: %s\n%!" cmd;
-  if Sys.command cmd <> 0 then failwith (sprintf "Command failed:\n\n%s" cmd)
+  if Sys.command cmd <> 0 then
+    failwith (sprintf (f_ "Command failed:\n\n%s") cmd)
 
 let shfailok cmd =
   eprintf "shfailok: %s\n%!" cmd;
@@ -431,8 +443,10 @@ let shget cmd =
   match close_process_in chan with
   | WEXITED 0 -> Some lines            (* command succeeded *)
   | WEXITED _ -> None                  (* command failed *)
-  | WSIGNALED i -> failwith (sprintf "shget: command killed by signal %d" i)
-  | WSTOPPED i -> failwith (sprintf "shget: command stopped by signal %d" i)
+  | WSIGNALED i ->
+      failwith (sprintf (f_ "shget: command killed by signal %d") i)
+  | WSTOPPED i ->
+      failwith (sprintf (f_ "shget: command stopped by signal %d") i)
 
 (* Start an interactive shell.  Need to juggle file descriptors a bit
  * because bash write PS1 to stderr (currently directed to the logfile).
@@ -511,7 +525,8 @@ let get_lvs =
              ) pvs in
              LV (vg, lv), pvs, lvsize
          | line ->
-             failwith ("lvs: unexpected output: " ^ String.concat "," line)
+             failwith ("lvs: " ^ s_ "unexpected output: " ^
+                         String.concat "," line)
        ) lines
 
 (* Get the partitions on a block device.
@@ -553,7 +568,7 @@ let snapshot =
       match lines with
       | Some (sectors::_) -> Int64.of_string sectors
       | Some [] | None ->
-         failwith (sprintf "Snapshot failed - unable to read the size in sectors of block device %s" origin_dev) in
+         failwith (sprintf (f_ "Disk snapshot failed: unable to read the size in sectors of block device %s") origin_dev) in
 
     (* Create the snapshot origin device.  Called, eg. snap_sda1_org *)
     sh (sprintf "dmsetup create %s_org --table='0 %Ld snapshot-origin /dev/%s'"
@@ -581,8 +596,7 @@ let auto_network () =
   shfailok "ping -c3 `/sbin/ip route list match 0.0.0.0 | head -1 | awk '{print $3}'`";
 
   if !config_greeting then (
-    printf "\n\nDid automatic network configuration work?\n";
-    printf "Hint: If not sure, there is a shell on console [ALT] [F2]\n";
+    print_endline (s_ "\n\nDid automatic network configuration work?\nHint: If not sure, there is a shell on console [ALT] [F2]");
     printf "    (y/n) %!";
     let line = read_line () in
     String.length line > 0 && (line.[0] = 'y' || line.[0] = 'Y')
@@ -644,9 +658,9 @@ let ssh_disconnect (_, chan) =
   eprintf "ssh_disconnect\n%!";
   match close_process_out chan with
   | WEXITED 0 -> ()            (* OK *)
-  | WEXITED i -> failwith (sprintf "ssh: exited with error code %d" i)
-  | WSIGNALED i -> failwith (sprintf "ssh: killed by signal %d" i)
-  | WSTOPPED i -> failwith (sprintf "ssh: stopped by signal %d" i)
+  | WEXITED i -> failwith (sprintf (f_ "ssh: exited with error code %d") i)
+  | WSIGNALED i -> failwith (sprintf (f_ "ssh: killed by signal %d") i)
+  | WSTOPPED i -> failwith (sprintf (f_ "ssh: stopped by signal %d") i)
 
 (* Use these functions to upload a file. *)
 let ssh_start_upload config filename =
@@ -658,15 +672,15 @@ let ssh_finish_upload = ssh_disconnect
 
 (* Test SSH connection. *)
 let test_ssh config =
-  printf "Testing SSH connection by listing files in remote directory ...\n\n%!";
+  print_endline
+    (s_ "Testing SSH connection by listing files in remote directory ...\n");
 
   let cmd = sprintf "/bin/ls %s" (quote config.ssh_directory) in
   let conn = ssh_connect config cmd in
   ssh_disconnect conn;
 
   if !config_greeting then (
-    printf "\n\nDid SSH work?\n";
-    printf "Hint: If not sure, there is a shell on console [ALT] [F2]\n";
+    print_endline (s_ "\n\nDid SSH work?\nHint: If not sure, there is a shell on console [ALT] [F2]\n");
     printf "    (y/n) %!";
     let line = read_line () in
     String.length line > 0 && (line.[0] = 'y' || line.[0] = 'Y')
@@ -794,8 +808,9 @@ let rec main ttyname =
        let fd = openfile ("/dev/" ^ ttyname) [ O_RDWR ] 0 in
        dup2 fd stdin;
        dup2 fd stdout;
-       close fd);
-  printf "%s starting up ...\n%!" program_name;
+       close fd
+  );
+  let () = printf (f_ "%s starting up ...\n%!") program_name in
 
   (* Disable screen blanking on tty. *)
   sh "setterm -blank 0";
@@ -803,10 +818,11 @@ let rec main ttyname =
   (* Check that the environment is a sane-looking live CD.  If not, bail. *)
   if not test_dialog_stages && is_dir "/mnt/root" <> Some true then
     failwith
-      "You should only run this script from the live CD or a USB key.";
+      (s_ "You should only run this script from the live CD or a USB key.");
 
   (* Start of the information gathering phase. *)
-  printf "Detecting hard drives (this may take some time) ...\n%!";
+  print_endline
+    (s_ "Detecting hard drives (this may take some time) ...");
 
   (* Search for all non-removable block devices.  Do this early and bail
    * if we can't find anything.  This is a list of strings, like "hda".
@@ -833,7 +849,8 @@ let rec main ttyname =
       (String.concat "; "
         (List.map (fun (d, b) -> sprintf "%s [%Ld]" d b) devices));
     if devices = [] then
-      failwith "No non-removable block devices (hard disks, etc.) could be found on this machine.";
+      failwith
+       (s_ "No non-removable block devices (hard disks, etc.) could be found on this machine.");
     devices in
 
   (* Search for partitions and LVs (anything that could contain a
@@ -1001,7 +1018,7 @@ let rec main ttyname =
     ) all_partitions
   in
 
-  printf "Finished detecting hard drives.\n%!";
+  print_endline (s_ "Finished detecting hard drives.");
 
   (* Autodetect system memory. *)
   let system_memory =
@@ -1048,7 +1065,7 @@ let rec main ttyname =
       fun () ->
        (* Greeting. *)
        if !config_greeting then
-         message_box program_name (sprintf "Welcome to %s, a live CD for migrating a physical machine to a virtualized host.\n\nTo continue press the Return key.\n\nTo get a shell you can use [ALT] [F2] and log in as root with no password.\n\nExtra information is logged in /tmp/virt-p2v.log but this file disappears when the machine reboots." program_name);
+         message_box program_name (sprintf (f_ "Welcome to %s, a live CD for migrating a physical machine to a virtualized host.\n\nTo continue press the Return key.\n\nTo get a shell you can use [ALT] [F2] and log in as root with no password.\n\nExtra information is logged in /tmp/virt-p2v.log but this file disappears when the machine reboots.") program_name);
 
        (* Type of transfer. *)
        let config_transfer_type =
@@ -1056,12 +1073,12 @@ let rec main ttyname =
          | Some t -> t
          | None ->
              let items = [
-               "Physical to Virtual (P2V)", P2V;
-               "Virtual to Virtual (V2V)", V2V;
+               s_ "Physical to Virtual (P2V)", P2V;
+               s_ "Virtual to Virtual (V2V)", V2V;
              ] in
 
-             select_single ~stage:"Transfer type" 40
-               "Transfer type"
+             select_single ~stage:(s_ "Transfer type") 40
+               (s_ "Transfer type")
                items in
 
        (* Network configuration. *)
@@ -1069,8 +1086,8 @@ let rec main ttyname =
          match !config_network with
          | Some n -> n
          | None ->
-             open_centered_window ~stage:"Network"
-               60 20 "Configure network";
+             open_centered_window ~stage:(s_ "Network")
+               60 20 (s_ "Configure network");
 
              let autolist = Newt.listbox 4 2 4 [Newt.SCROLL] in
              Newt.listbox_set_width autolist 52;
@@ -1100,10 +1117,10 @@ let rec main ttyname =
 
              let auto =
                Newt.radio_button 1 1
-                 "Automatic from:" (not no_auto) None in
+                 (s_ "Automatic from:") (not no_auto) None in
              let shell =
                Newt.radio_button 1 6
-                 "Start a shell" no_auto (Some auto) in
+                 (s_ "Start a shell") no_auto (Some auto) in
 
              if no_auto then (
                Newt.component_takes_focus auto false;
@@ -1113,24 +1130,23 @@ let rec main ttyname =
 
              let qemu =
                Newt.radio_button 1 7
-                 "QEMU user network" false (Some shell) in
+                 (s_ "QEMU user network") false (Some shell) in
              let nonet =
                Newt.radio_button 1 8
-                 "No network or network already configured" false
-                 (Some qemu) in
+                 (s_ "Don't configure the network") false (Some qemu) in
              let static =
                Newt.radio_button 1 9
-                 "Static configuration:" false (Some nonet) in
+                 (s_ "Static configuration:") false (Some nonet) in
 
-             let label1 = Newt.label 4 10 "Interface" in
+             let label1 = Newt.label 4 10 (s_ "Interface") in
              let entry1 = Newt.entry 16 10 (Some "eth0") 8 [] in
-             let label2 = Newt.label 4 11 "Address" in
+             let label2 = Newt.label 4 11 (s_ "IP") in
              let entry2 = Newt.entry 16 11 None 16 [] in
-             let label3 = Newt.label 4 12 "Netmask" in
+             let label3 = Newt.label 4 12 (s_ "Netmask") in
              let entry3 = Newt.entry 16 12 (Some "255.255.255.0") 16 [] in
-             let label4 = Newt.label 4 13 "Gateway" in
+             let label4 = Newt.label 4 13 (s_ "Gateway") in
              let entry4 = Newt.entry 16 13 None 16 [] in
-             let label5 = Newt.label 4 14 "Nameserver" in
+             let label5 = Newt.label 4 14 (s_ "Nameserver") in
              let entry5 = Newt.entry 16 14 None 16 [] in
 
              let enable_static () =
@@ -1170,7 +1186,7 @@ let rec main ttyname =
              Newt.component_add_callback static
                (fun () -> enable_static (); disable_autolist ());
 
-             let ok = Newt.button 48 16 "  OK  " in
+             let ok = Newt.button 48 16 ok_button in
 
              let form = Newt.form None None [] in
              Newt.form_add_components form [auto;
@@ -1218,32 +1234,26 @@ let rec main ttyname =
   (* Try to bring up the network. *)
   (match config_network with
    | Shell ->
-       printf "Network configuration.\n\n";
-       printf "Please configure the network from this shell.\n\n";
-       printf "When you have finished, exit the shell with ^D or exit.\n\n%!";
+       print_endline (s_ "Network configuration.\n\nPlease configure the network from this shell.\n\nWhen you have finished, exit the shell with ^D or exit.\n");
        shell ()
 
    | Static (interface, address, netmask, gateway, nameserver) ->
-       printf "Trying static network configuration.\n\n%!";
+       print_endline (s_ "Trying static network configuration.\n");
        if not (static_network
                 (interface, address, netmask, gateway, nameserver)) then (
-        printf "\nAuto-configuration failed.  Starting a shell.\n\n";
-        printf "Please configure the network from this shell.\n\n";
-        printf "When you have finished, exit the shell with ^D or exit.\n\n";
+        print_endline (s_ "\nAuto-configuration failed.  Starting a shell.\n\nPlease configure the network from this shell.\n\nWhen you have finished, exit the shell with ^D or exit.\n");
         shell ()
        )
 
    | Auto rootfs ->
-       printf
-        "Trying network auto-configuration from root filesystem ...\n\n%!";
+       print_endline
+        (s_ "Trying network auto-configuration from root filesystem ...\n");
 
        (* Mount the root filesystem read-only under /mnt/root. *)
        sh ("mount -o ro " ^ quote (dev_of_partition rootfs) ^ " /mnt/root");
 
        if not (auto_network ()) then (
-        printf "\nAuto-configuration failed.  Starting a shell.\n\n";
-        printf "Please configure the network from this shell.\n\n";
-        printf "When you have finished, exit the shell with ^D or exit.\n\n";
+        print_endline (s_ "\nAuto-configuration failed.  Starting a shell.\n\nPlease configure the network from this shell.\n\nWhen you have finished, exit the shell with ^D or exit.\n");
         shell ()
        );
 
@@ -1253,7 +1263,7 @@ let rec main ttyname =
        sh ("umount -l /mnt/root");
 
    | QEMUUserNet ->
-       printf "Trying QEMU network configuration.\n\n%!";
+       print_endline (s_ "Trying QEMU network configuration.\n");
        qemu_network ()
 
    | NoNetwork -> (* this is easy ... *) ()
@@ -1267,30 +1277,31 @@ let rec main ttyname =
        | Some c -> c
        | None ->
            (* Query the user for SSH configuration. *)
-           open_centered_window ~stage:"SSH configuration"
-             60 20 "SSH configuration";
+           open_centered_window ~stage:(s_ "SSH configuration")
+             60 20 (s_ "SSH configuration");
 
-           let label1 = Newt.label 1 1 "Remote host" in
+           let label1 = Newt.label 1 1 (s_ "Remote host") in
            let host = Newt.entry 20 1 None 36 [] in
-           let label2 = Newt.label 1 2 "Remote port" in
+           let label2 = Newt.label 1 2 (s_ "Remote port") in
            let port = Newt.entry 20 2 (Some "22") 6 [] in
-           let label3 = Newt.label 1 3 "Remote directory" in
+           let label3 = Newt.label 1 3 (s_ "Remote directory") in
            let dir = Newt.entry 20 3 (Some "/var/lib/xen/images") 36 [] in
-           let label4 = Newt.label 1 4 "SSH username" in
+           let label4 = Newt.label 1 4 (s_ "SSH username") in
            let user = Newt.entry 20 4 (Some "root") 16 [] in
            (*
              There's no sensible way to support this for SSH:
-           let label5 = Newt.label 1 5 "SSH password" in
+           let label5 = Newt.label 1 5 (s_ "SSH password") in
            let pass = Newt.entry 20 5 None 16 [Newt.PASSWORD] in
            *)
 
            let compr =
-             Newt.checkbox 16 7 "Use SSH compression (not good for LANs)"
+             Newt.checkbox 16 7 (s_ "Use SSH compression (not good for LANs)")
                ' ' None in
 
-           let check = Newt.checkbox 16 9 "Test SSH connection" '*' None in
+           let check =
+             Newt.checkbox 16 9 (s_ "Test SSH connection") '*' None in
 
-           let ok = Newt.button 48 16 "  OK  " in
+           let ok = Newt.button 48 16 ok_button in
 
            let form = Newt.form None None [] in
            Newt.form_add_components form [label1;label2;label3;label4;
@@ -1324,7 +1335,7 @@ let rec main ttyname =
   (* If asked, check the SSH connection. *)
   if config_ssh.ssh_check then
     if not (test_ssh config_ssh) then
-      failwith "SSH configuration failed";
+      failwith (s_ "SSH configuration failed");
 
   (* Devices and root partition and target configuration selection stage. *)
   let config_devices_to_send, config_root_filesystem, config_target =
@@ -1342,8 +1353,9 @@ let rec main ttyname =
                    (label, dev, true)
              ) all_block_devices in
 
-             select_multiple ~stage:"Block devices" ~force_one:true 60
-               "Select block devices to send"
+             select_multiple ~stage:(s_ "Block devices")
+               ~force_one:true 60
+               (s_ "Select block devices to send")
                items in
 
        let config_root_filesystem =
@@ -1358,25 +1370,25 @@ let rec main ttyname =
                  (label, part)
              ) all_partitions in
 
-             select_single ~stage:"Root filesystem" 60
-               "Select root filesystem"
+             select_single ~stage:(s_ "Root filesystem") 60
+               (s_ "Select root filesystem")
                items in
 
        let config_target =
          match !config_target with
          | Some t -> t
          | None ->
-             open_centered_window ~stage:"Target system" 40 20
-               "Configure target system";
+             open_centered_window ~stage:(s_ "Target system") 40 20
+               (s_ "Configure target system");
 
-             let hvlabel = Newt.label 1 1 "Hypervisor:" in
+             let hvlabel = Newt.label 1 1 (s_ "Hypervisor:") in
              let hvlistbox = Newt.listbox 16 1 4 [Newt.SCROLL] in
              Newt.listbox_append_entry hvlistbox "Xen" (Some Xen);
              Newt.listbox_append_entry hvlistbox "QEMU" (Some QEMU);
              Newt.listbox_append_entry hvlistbox "KVM" (Some KVM);
              Newt.listbox_append_entry hvlistbox "Other" None;
 
-             let archlabel = Newt.label 1 5 "Architecture:" in
+             let archlabel = Newt.label 1 5 (s_ "Architecture:") in
              let archlistbox = Newt.listbox 16 5 4 [Newt.SCROLL] in
              Newt.listbox_append_entry archlistbox "i386" I386;
              Newt.listbox_append_entry archlistbox
@@ -1400,20 +1412,21 @@ let rec main ttyname =
                with
                  Not_found -> ());
 
-             let memlabel = Newt.label 1 9 "Memory (MB):" in
+             let memlabel = Newt.label 1 9 (s_ "Memory (MB):") in
              let mementry = Newt.entry 16 9
                (Some (string_of_int system_memory)) 8 [] in
-             let cpulabel = Newt.label 1 10 "CPUs:" in
+             let cpulabel = Newt.label 1 10 (s_ "CPUs:") in
              let cpuentry = Newt.entry 16 10
                (Some (string_of_int system_nr_cpus)) 4 [] in
-             let maclabel = Newt.label 1 11 "MAC addr:" in
+             let maclabel = Newt.label 1 11 (s_ "MAC addr:") in
              let macentry = Newt.entry 16 11 None 20 [] in
-             let maclabel2 = Newt.label 1 12 "(leave MAC blank for random)" in
+             let maclabel2 =
+               Newt.label 1 12 (s_ "(leave MAC blank for random)") in
 
              let libvirtd =
-               Newt.checkbox 12 14 "Use remote libvirtd" '*' None in
+               Newt.checkbox 12 14 (s_ "Use remote libvirtd") '*' None in
 
-             let ok = Newt.button 28 16 "  OK  " in
+             let ok = Newt.button 28 16 ok_button in
 
              let form = Newt.form None None [] in
              Newt.form_add_components form
@@ -1489,7 +1502,7 @@ let rec main ttyname =
          config_ssh.ssh_host config_ssh.ssh_port path in
       eprintf "capabilities URI = %S\n%!" name;
 
-      printf "Try to fetch remote hypervisor capabilities ...\n\n%!";
+      print_endline (s_ "Try to fetch remote hypervisor capabilities ...\n");
 
       let conn = Libvirt.Connect.connect_readonly ~name () in
       let caps = Libvirt.Connect.get_capabilities conn in
@@ -1535,14 +1548,14 @@ let rec main ttyname =
        *)
       let len = List.length guests in
       if len = 0 then (
-       message_box "Warning"
-         (sprintf "Remote hypervisor claims not to support fully virtualized %s guests.\n\nContinuing anyway.\n\n%!" arch_str);
+       message_box (s_ "Warning")
+         (sprintf (f_ "Remote hypervisor claims not to support fully virtualized %s guests.\n\nContinuing anyway.\n\n%!") arch_str);
        raise Not_found
       );
 
       if len > 1 then (
-       message_box "Note"
-         (sprintf "Remote hypervisor supports multiple types of fully virtualized %s guests.\n\nPlease help further development of libvirt and virt-p2v by sending the file /tmp/virt-p2v.log back to the developers.  See the main virt-p2v website for contact details." arch_str)
+       message_box (s_ "Note")
+         (sprintf (f_ "Remote hypervisor supports multiple types of fully virtualized %s guests.\n\nPlease help further development of libvirt and virt-p2v by sending the file /tmp/virt-p2v.log back to the developers.  See the main virt-p2v website for contact details.") arch_str)
       );
 
       let guest = List.hd guests in
@@ -1583,6 +1596,8 @@ let rec main ttyname =
    *)
   if test_dialog_stages then exit 1;
 
+  print_endline (s_ "Performing LVM snapshots ...\n");
+
   (* Switch LVM config. *)
   sh "vgchange -a n";
   putenv "LVM_SYSTEM_DIR" "/etc/lvm.new"; (* see lvm(8) *)
@@ -1783,7 +1798,7 @@ let rec main ttyname =
       match config_target.tgt_hypervisor with
       | Some Xen | None -> ""
       | Some QEMU | Some KVM -> " -c qemu:///system" in
-    let xml = sprintf "\
+    let xml = sprintf (f_ "\
 <!--
   This is an automatically generated libvirt configuration file.
   It was written by the %s program.
@@ -1794,14 +1809,14 @@ let rec main ttyname =
   To start the domain, do:
     virsh%s define %s
     virsh%s start %s
--->\n\n" program_name conn_arg conf_filename conn_arg hostname
+-->\n\n") program_name conn_arg conf_filename conn_arg hostname
       ^ xml
       ^ "\n" in
 
     let xml_len = String.length xml in
     eprintf "length of configuration file is %d bytes\n%!" xml_len;
 
-    printf "\nWriting configuration file ...\n\n%!";
+    print_endline (s_ "\nWriting configuration file ...\n");
 
     let (sock,_) as conn = ssh_start_upload config_ssh conf_filename in
     (* In OCaml this actually loops calling write(2) *)
@@ -1821,8 +1836,9 @@ let rec main ttyname =
        try List.assoc origin_dev all_block_devices
        with Not_found -> assert false (* internal error *) in
 
-      printf "\nSending /dev/%s (%.3f GB) to remote machine\n\n%!" origin_dev
-       ((Int64.to_float size) /. (1024.*.1024.*.1024.));
+      let () =
+       printf (f_ "\nSending /dev/%s (%.3f GB) to remote machine\n\n%!")
+         origin_dev ((Int64.to_float size) /. (1024.*.1024.*.1024.)) in
 
       (* Open the snapshot device. *)
       let fd = openfile ("/dev/mapper/" ^ snapshot_dev) [O_RDONLY] 0 in
@@ -1857,9 +1873,10 @@ let rec main ttyname =
                let remaining = 1. -. elapsed in
                let secs_remaining = (remaining /. elapsed) *. secs_elapsed in
                if secs_remaining > 120. then
-                 printf " (about %.0f minutes remaining)" (secs_remaining/.60.)
+                 printf (f_ " (about %.0f minutes remaining)")
+                   (secs_remaining/.60.)
                else
-                 printf " (about %.0f seconds remaining)"
+                 printf (f_ " (about %.0f seconds remaining)")
                    secs_remaining
              );
              printf "          \r%!";
@@ -1882,8 +1899,8 @@ let rec main ttyname =
 
   (* Clean up and reboot. *)
   ignore (
-    message_box (sprintf "%s completed" program_name)
-      (sprintf "\nThe physical to virtual migration is complete.\n\nPlease verify the disk image(s) and configuration file on the remote host, and then start up the virtual machine by doing:\n\ncd %s\nvirsh define %s\n\nWhen you press [OK] this machine will reboot."
+    message_box (sprintf (f_ "%s has finished") program_name)
+      (sprintf (f_ "\nThe physical to virtual migration is complete.\n\nPlease verify the disk image(s) and configuration file on the remote host, and then start up the virtual machine by doing:\n\ncd %s\nvirsh define %s\n\nWhen you press [OK] this machine will reboot.")
         config_ssh.ssh_directory conf_filename)
   );
 
@@ -1895,7 +1912,7 @@ let rec main ttyname =
 (*----------------------------------------------------------------------*)
 
 let usage () =
-  eprintf "usage: virt-p2v [--test] [ttyname]\n%!";
+  let () = eprintf (f_ "usage: virt-p2v [--test] [ttyname]\n%!") in
   exit 2
 
 (* Make sure that exceptions from 'main' get printed out on stdout
diff --git a/virt-p2v.ml0 b/virt-p2v.ml0
new file mode 100644 (file)
index 0000000..0d5fb10
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/ocamlrun /usr/bin/ocaml
+(* Load external libraries. *)
+#use "topfind";;
+#require "extlib";;
+#require "pcre";;
+#require "newt";;
+#require "xml-light";;
+#require "gettext-stub";;
+#require "libvirt";;
+
+(* WARNING !!! WARNING !!! WARNING !!!
+ *
+ * Do not edit 'virt-p2v' directly.  It is autogenerated from the
+ * files 'virt-p2v.ml0' and 'virt-p2v.ml' by the Makefile.
+ *)
+
+(* virt-p2v.ml is concatenated here to form the full script virt-p2v *)
diff --git a/virt-p2v.spec.in b/virt-p2v.spec.in
new file mode 100644 (file)
index 0000000..dab5f58
--- /dev/null
@@ -0,0 +1,68 @@
+Name:           @PACKAGE_NAME@
+Version:        @PACKAGE_VERSION@
+# Please keep the release as '1' for compatibility
+# with the Makefile.
+Release:        1
+Summary:        Virt-p2v
+
+Group:          Development/Libraries
+License:        GPLv2+
+URL:            http://et.redhat.com/~rjones/virt-p2v
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+#ExclusiveArch:  noarch
+
+Source0:        virt-p2v
+Source1:        virt-p2v-update-wrapper
+Source2:        iso-attach
+Source3:        inittab
+
+Requires:       ocaml >= 3.10.0
+Requires:       ocaml-runtime
+Requires:       ocaml-findlib
+Requires:       ocaml-pcre
+Requires:       ocaml-extlib
+Requires:       ocaml-xml-light
+Requires:       ocaml-libvirt >= 0.4.1.1
+Requires:       ocaml-newt >= 0.9
+Requires:       ocaml-fileutils
+Requires:       ocaml-gettext >= 0.2.0-1rwmj20080321
+
+# libvirt >= 0.4.0 fixes a problem with authentication over ssh.
+Requires:       libvirt >= 0.4.0
+
+# dhclient >= 4.0.0 fixes the cwd-holds-filesystem-open problem.
+Requires:       dhclient >= 4.0.0
+
+
+%description
+P2V, V2V and V2P virtual machine migration.
+
+
+%prep
+
+
+%build
+
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT%{_bindir}
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}
+install -m 0755 %{SOURCE0} %{SOURCE1} %{SOURCE2} $RPM_BUILD_ROOT%{_bindir}
+install -m 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/*
+%{_sysconfdir}/*
+
+
+%changelog
+* Fri Feb 22 2008 Richard W.M. Jones <rjones@redhat.com> - 1.2.3-1
+- Initial RPM release.