diff --git a/lib/qemu_store.ml b/lib/qemu_store.ml
index d6b86aa5..13d68a0c 100644
--- a/lib/qemu_store.ml
+++ b/lib/qemu_store.ml
@@ -140,8 +140,8 @@ let cache ~user:_ t name : (string * (unit -> unit Lwt.t)) Lwt.t =
let release () =
Lwt_mutex.with_lock cache.lock @@ fun () ->
cache.children <- cache.children - 1;
- let cache_stat = Unix.stat master in
- let tmp_stat = Unix.stat tmp in
+ let cache_stat = Unix.stat (master / "rootfs" / "image.qcow2") in
+ let tmp_stat = Unix.stat (tmp / "rootfs" / "image.qcow2") in
(if tmp_stat.st_size > cache_stat.st_size then
Os.cp ~src:tmp master
else
diff --git a/qemu/Makefile b/qemu/Makefile
index bac8fc91..17690bca 100644
--- a/qemu/Makefile
+++ b/qemu/Makefile
@@ -8,21 +8,29 @@ clean:
windows-server-2022-x86_64-ocaml-5.2.img: unattend-5.2.0.iso
qemu-img create -f qcow2 windows-server-2022-x86_64-ocaml-5.2.img 40G
- qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=q35 -drive file=windows-server-2022-x86_64-ocaml-5.2.img -drive file=SW_DVD9_Win_Server_STD_CORE_2022_2108.6_64Bit_English_DC_STD_MLF_X23-03231.ISO,media=cdrom -drive file=unattend-5.2.0.iso,media=cdrom -cpu host -display none -vnc :0 -nic user,hostfwd=tcp::60022-:22
- # -drive file=virtio-win.iso,media=cdrom
+ qemu-img create -f qcow2 cache.qcow2 20G
+ qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=q35 -cpu host -display none -vnc :0 -nic user,hostfwd=tcp::60022-:22 \
+ -drive file=windows-server-2022-x86_64-ocaml-5.2.img \
+ -drive file=cache.qcow2 \
+ -drive file=SW_DVD9_Win_Server_STD_CORE_2022_2108.6_64Bit_English_DC_STD_MLF_X23-03231.ISO,media=cdrom \
+ -drive file=unattend-5.2.0.iso,media=cdrom
windows-server-2022-x86_64-ocaml-4.14.img: unattend-4.14.2.iso
qemu-img create -f qcow2 windows-server-2022-x86_64-ocaml-4.14.img 40G
- qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=q35 -drive file=windows-server-2022-x86_64-ocaml-4.14.img -drive file=SW_DVD9_Win_Server_STD_CORE_2022_2108.6_64Bit_English_DC_STD_MLF_X23-03231.ISO,media=cdrom -drive file=unattend-4.14.2.iso,media=cdrom -cpu host -display none -vnc :0 -nic user,hostfwd=tcp::60022-:22
- # -drive file=virtio-win.iso,media=cdrom
-
-unattend-4.14.2.iso: autounattend.xml.m4 id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe
+ qemu-img create -f qcow2 cache.qcow2 20G
+ qemu-system-x86_64 -m 16G -smp 8 -machine accel=kvm,type=q35 -cpu host -display none -vnc :0 -nic user,hostfwd=tcp::60022-:22 \
+ -drive file=windows-server-2022-x86_64-ocaml-4.14.img \
+ -drive file=cache.qcow2 \
+ -drive file=SW_DVD9_Win_Server_STD_CORE_2022_2108.6_64Bit_English_DC_STD_MLF_X23-03231.ISO,media=cdrom \
+ -drive file=unattend-4.14.2.iso,media=cdrom
+
+unattend-4.14.2.iso: autounattend.xml.m4 id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe cygsympathy.cmd cygsympathy.sh
m4 -D VERSION=4.14.2 autounattend.xml.m4 > autounattend.xml
- mkisofs -o unattend-4.14.2.iso -r -J autounattend.xml id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe
+ mkisofs -o unattend-4.14.2.iso -r -J autounattend.xml id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe cygsympathy.cmd cygsympathy.sh
-unattend-5.2.0.iso: autounattend.xml.m4 id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe
+unattend-5.2.0.iso: autounattend.xml.m4 id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe cygsympathy.cmd cygsympathy.sh
m4 -D VERSION=5.2.0 autounattend.xml.m4 > autounattend.xml
- mkisofs -o unattend-5.2.0.iso -r -J autounattend.xml id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe
+ mkisofs -o unattend-5.2.0.iso -r -J autounattend.xml id_ed25519.pub openssh-win64.msi opam-2.2.exe opam-dev.exe setup-x86_64.exe cygsympathy.cmd cygsympathy.sh
opam-2.2.exe:
curl -L https://github.com/ocaml/opam/releases/download/2.2.1/opam-2.2.1-x86_64-windows.exe -o opam-2.2.exe
@@ -39,6 +47,12 @@ setup-x86_64.exe:
virtio-win.iso:
curl -L https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.262-2/virtio-win.iso -o virtio-win.iso
+cygsympathy.cmd:
+ curl -L https://raw.githubusercontent.com/metastack/cygsympathy/master/cygsympathy.cmd -o cygsympathy.cmd
+
+cygsympathy.sh:
+ curl -L https://raw.githubusercontent.com/metastack/cygsympathy/master/cygsympathy.sh -o cygsympathy.sh
+
# Ubuntu
seed.iso: user-data.yaml
diff --git a/qemu/autounattend.xml.m4 b/qemu/autounattend.xml.m4
index f99f0d54..8becf7e3 100644
--- a/qemu/autounattend.xml.m4
+++ b/qemu/autounattend.xml.m4
@@ -33,7 +33,7 @@
cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d 1
-
+
@@ -65,6 +65,25 @@
0
true
+
+
+
+ 1
+ Primary
+ true
+
+
+
+
+ NTFS
+ D
+ 1
+ 1
+
+
+ 1
+ true
+
@@ -160,7 +179,7 @@
9
- cmd /c "copy e:\setup-x86_64.exe c:\windows\setup-x86_64.exe"
+ cmd /c "copy f:\setup-x86_64.exe c:\windows\setup-x86_64.exe"
Copy cygwin executable
@@ -172,102 +191,132 @@
11
+ cmd /c "mkdir C:\cygwin64\lib\cygsympathy"
+ Create lib/cygsympathy
+
+
+
+ 12
+ cmd /c "mkdir C:\cygwin64\etc\postinstall"
+ Create etc/postinstall
+
+
+
+ 13
+ cmd /c "copy f:\cygsympathy.cmd C:\cygwin64\lib\cygsympathy"
+ Install cmd script
+
+
+
+ 14
+ cmd /c "copy f:\cygsympathy.sh C:\cygwin64\lib\cygsympathy\cygsympathy"
+ Install cmd script
+
+
+
+ 15
+ mklink C:\cygwin64\etc\postinstall\zp_zcygsympathy.sh C:\cygwin64\lib\cygsympathy\cygsympathy
+ Install cmd script
+
+
+
+ 16
c:\windows\setup-x86_64.exe -q -O -s https://cygwin.mirror.uk.sargasso.net -P mingw64-x86_64-gcc-core,rsync,git,make,patch,unzip,pkgconf,pkg-config
Install cygwin
- 12
+ 17
setx /m PATH "c:\cygwin64\bin;c:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin;%PATH%"
Set PATH environment variable
- 13
+ 18
c:\cygwin64\bin\gawk.exe -i inplace "/(^#)|(^$)/{print;next}{$4=""noacl,""$4;print}" C:\cygwin64\etc\fstab
Add opam-repository
- 14
+ 19
setx /m OPAMCONFIRMLEVEL unsafe-yes
Set PATH environment variable
- 15
+ 20
setx /m OPAMYES 1
Set PATH environment variable
- 16
+ 21
reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d c:\cygwin64\bin\bash.exe
Configure WinRM
- 17
- cmd /c "msiexec /q /norestart /i e:\openssh-win64.msi"
+ 22
+ cmd /c "msiexec /q /norestart /i f:\openssh-win64.msi"
Install OpenSSH
- 18
- cmd /c "copy e:\id_ed25519.pub c:\programdata\ssh\administrators_authorized_keys"
+ 23
+ cmd /c "copy f:\id_ed25519.pub c:\programdata\ssh\administrators_authorized_keys"
Install public key
- 19
+ 24
cmd /c "echo AcceptENV * >> c:\programdata\ssh\sshd_config"
Install public key
- 20
+ 25
netsh advfirewall firewall set rule group="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes
Configure OpenSSH
- 21
- cmd /c "copy e:\opam-2.2.exe c:\cygwin64\bin\opam.exe"
+ 26
+ cmd /c "copy f:\opam-2.2.exe c:\cygwin64\bin\opam.exe"
Copy opam executable
- 22
- cmd /c "copy e:\opam-2.2.exe c:\cygwin64\bin\opam-2.2.exe"
+ 27
+ cmd /c "copy f:\opam-2.2.exe c:\cygwin64\bin\opam-2.2.exe"
Copy opam executable
- 23
- cmd /c "copy e:\opam-dev.exe c:\cygwin64\bin\opam-dev.exe"
+ 28
+ cmd /c "copy f:\opam-dev.exe c:\cygwin64\bin\opam-dev.exe"
Copy opam executable
- 24
+ 29
c:\cygwin64\bin\bash.exe --login -c "cd /cygdrive/c/Users/opam && git clone https://github.com/ocaml/opam-repository"
Add opam-repository
- 25
+ 30
c:\cygwin64\bin\opam init -y -k local -a c:\users\opam\opam-repository --bare --cygwin-location=c:\cygwin64
Opam init
- 26
+ 31
c:\cygwin64\bin\opam switch create VERSION --packages=ocaml-base-compiler.VERSION
Opam switch
- 27
+ 32
c:\cygwin64\bin\opam pin add -k version ocaml-base-compiler VERSION
Opam switch
@@ -319,3 +368,4 @@
+