Blame SOURCES/0045-convert-convert_windows.ml-Handle-date-formats-with-.patch

61e9b3
From 84cb43440a2ad143eb7474a028b1b1549cb8c0f1 Mon Sep 17 00:00:00 2001
61e9b3
From: "Richard W.M. Jones" <rjones@redhat.com>
61e9b3
Date: Fri, 12 Nov 2021 08:47:55 +0000
61e9b3
Subject: [PATCH] convert/convert_windows.ml: Handle date formats with dots
61e9b3
 instead of /
61e9b3
61e9b3
If the ShortDatePattern is yy.M.d (as can happen for US locale) we may
61e9b3
not always reformat the date for schtasks.exe correctly.  For
61e9b3
explanation and testing see:
61e9b3
61e9b3
https://bugzilla.redhat.com/show_bug.cgi?id=1895323#c46 (- #c50)
61e9b3
61e9b3
Thanks: Xiaodai Wang for suggesting the fix and testing it
61e9b3
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1895323
61e9b3
(cherry picked from commit d9dc6c42ae64ba92993dbd9477f003ba73fcfa2f)
61e9b3
---
61e9b3
 v2v/convert_windows.ml | 7 +++++--
61e9b3
 1 file changed, 5 insertions(+), 2 deletions(-)
61e9b3
61e9b3
diff --git a/v2v/convert_windows.ml b/v2v/convert_windows.ml
61e9b3
index 13de10cb..6c7440aa 100644
61e9b3
--- a/v2v/convert_windows.ml
61e9b3
+++ b/v2v/convert_windows.ml
61e9b3
@@ -422,12 +422,15 @@ popd
61e9b3
  and configure_qemu_ga files =
61e9b3
    List.iter (
61e9b3
      fun msi_path ->
61e9b3
-       (* Windows is a trashfire. https://stackoverflow.com/a/18730884 *)
61e9b3
+       (* Windows is a trashfire.
61e9b3
+        * https://stackoverflow.com/a/18730884
61e9b3
+        * https://bugzilla.redhat.com/show_bug.cgi?id=1895323
61e9b3
+        *)
61e9b3
        let fb_script = sprintf "\
61e9b3
 echo Removing any previously scheduled qemu-ga installation
61e9b3
 schtasks.exe /Delete /TN Firstboot-qemu-ga /F
61e9b3
 echo Scheduling delayed installation of qemu-ga from %s
61e9b3
-powershell.exe -command \"$d = (get-date).AddSeconds(120); $FormatHack = ($([System.Globalization.DateTimeFormatInfo]::CurrentInfo.ShortDatePattern) -replace 'M+/', 'MM/') -replace 'd+/', 'dd/'; schtasks.exe /Create /SC ONCE /ST $d.ToString('HH:mm') /SD $d.ToString($FormatHack) /RU SYSTEM /TN Firstboot-qemu-ga /TR \\\"C:\\%s /forcerestart /qn /l+*vx C:\\%s.log\\\"\"
61e9b3
+powershell.exe -command \"$d = (get-date).AddSeconds(120); $FormatHack = (($([System.Globalization.DateTimeFormatInfo]::CurrentInfo.ShortDatePattern) -replace 'y+', 'yyyy') -replace 'M+', 'MM') -replace 'd+', 'dd'; schtasks.exe /Create /SC ONCE /ST $d.ToString('HH:mm') /SD $d.ToString($FormatHack) /RU SYSTEM /TN Firstboot-qemu-ga /TR \\\"C:\\%s /forcerestart /qn /l+*vx C:\\%s.log\\\"\"
61e9b3
       "
61e9b3
       msi_path msi_path msi_path in
61e9b3
       Firstboot.add_firstboot_script g inspect.i_root
61e9b3
-- 
61e9b3
2.27.0
61e9b3