[Libguestfs] [PATCH v2v v2 1/2] v2v: windows: Add a helper function for installing Powershell firstboot scripts.
Richard W.M. Jones
rjones at redhat.com
Fri Apr 26 16:08:21 UTC 2019
On Thu, Apr 25, 2019 at 04:26:53PM +0200, Pino Toscano wrote:
> On Tuesday, 16 April 2019 10:55:39 CEST Richard W.M. Jones wrote:
> > +(* Unfortunately Powershell scripts cannot be directly executed
> > + * (unless some system config changes are made which for other
> > + * reasons we don't want to do) and so we have to run this via
> > + * a regular batch file.
> > + *)
> > +let install_firstboot_powershell g { Types.i_windows_systemroot; i_root }
> > + filename code =
> > + let tempdir = sprintf "%s/Temp" i_windows_systemroot in
> > + g#mkdir_p tempdir;
> > + let code = String.concat "\r\n" code ^ "\r\n" in
>
> The Firstboot module uses String.unix2dos to convert the script to the
> proper newline style for Windows. What about assuming that 'code' is a
> single Unix-style string with the whole script, calling String.unix2dos,
> instead of taking the list of lines? Mostly for consistency, so
> everything that writes files on Windows uses String.unix2dos.
>
> > + (* Powershell interpreter. Should we check this exists? XXX *)
> > + let ps_exe =
> > + i_windows_systemroot ^
> > + "\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" in
>
> According to the Interweb, it looks like this location was kept even
> for PowerShell 2.0+ for "compatibility".
>
> OTOH the comment raises another concern: what about old Windows versions
> without PowerShell?
PS was introduced in Windows 7 and this patch series won't work with
older versions. If we don't use PS then we'd have to upload a
compiled program (batch files are useless).
> Most probably virt-v2v needs to report that to the
> user (a warning, perhaps) so they know that the static IPs (specified
> on the command line) cannot be preserved anyway. Otherwise, the
> conversion will work fine, and the user realize that this did not work
> only when booting the converted Windows.
>
> Maybe add a simple is_powershell_available helper to this (Windows)
> module?
OK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
More information about the Libguestfs
mailing list