Skip to content

Commit

Permalink
Add cygsympathy to base images
Browse files Browse the repository at this point in the history
  • Loading branch information
mtelvers committed Oct 28, 2024
1 parent 8890afb commit 502c87c
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 34 deletions.
4 changes: 2 additions & 2 deletions lib/qemu_store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 23 additions & 9 deletions qemu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
96 changes: 73 additions & 23 deletions qemu/autounattend.xml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Path>cmd /c reg add "HKLM\SYSTEM\Setup\LabConfig" /v "BypassRAMCheck" /t REG_DWORD /d 1</Path>
</RunSynchronousCommand>
</RunSynchronous>

<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
Expand Down Expand Up @@ -65,6 +65,25 @@
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Order>1</Order>
<Type>Primary</Type>
<Extend>true</Extend>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Format>NTFS</Format>
<Letter>D</Letter>
<Order>1</Order>
<PartitionID>1</PartitionID>
</ModifyPartition>
</ModifyPartitions>
<DiskID>1</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
</DiskConfiguration>

<ImageInstall>
Expand Down Expand Up @@ -160,7 +179,7 @@

<SynchronousCommand wcm:action="add">
<Order>9</Order>
<CommandLine>cmd /c "copy e:\setup-x86_64.exe c:\windows\setup-x86_64.exe"</CommandLine>
<CommandLine>cmd /c "copy f:\setup-x86_64.exe c:\windows\setup-x86_64.exe"</CommandLine>
<Description>Copy cygwin executable</Description>
</SynchronousCommand>

Expand All @@ -172,102 +191,132 @@

<SynchronousCommand wcm:action="add">
<Order>11</Order>
<CommandLine>cmd /c "mkdir C:\cygwin64\lib\cygsympathy"</CommandLine>
<Description>Create lib/cygsympathy</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>12</Order>
<CommandLine>cmd /c "mkdir C:\cygwin64\etc\postinstall"</CommandLine>
<Description>Create etc/postinstall</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>13</Order>
<CommandLine>cmd /c "copy f:\cygsympathy.cmd C:\cygwin64\lib\cygsympathy"</CommandLine>
<Description>Install cmd script</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>14</Order>
<CommandLine>cmd /c "copy f:\cygsympathy.sh C:\cygwin64\lib\cygsympathy\cygsympathy"</CommandLine>
<Description>Install cmd script</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>15</Order>
<CommandLine>mklink C:\cygwin64\etc\postinstall\zp_zcygsympathy.sh C:\cygwin64\lib\cygsympathy\cygsympathy</CommandLine>
<Description>Install cmd script</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>16</Order>
<CommandLine>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</CommandLine>
<Description>Install cygwin</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>12</Order>
<Order>17</Order>
<CommandLine>setx /m PATH "c:\cygwin64\bin;c:\cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\bin;%PATH%"</CommandLine>
<Description>Set PATH environment variable</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>13</Order>
<Order>18</Order>
<CommandLine>c:\cygwin64\bin\gawk.exe -i inplace "/(^#)|(^$)/{print;next}{$4=""noacl,""$4;print}" C:\cygwin64\etc\fstab</CommandLine>
<Description>Add opam-repository</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>14</Order>
<Order>19</Order>
<CommandLine>setx /m OPAMCONFIRMLEVEL unsafe-yes</CommandLine>
<Description>Set PATH environment variable</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>15</Order>
<Order>20</Order>
<CommandLine>setx /m OPAMYES 1</CommandLine>
<Description>Set PATH environment variable</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>16</Order>
<Order>21</Order>
<CommandLine>reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d c:\cygwin64\bin\bash.exe</CommandLine>
<Description>Configure WinRM</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>17</Order>
<CommandLine>cmd /c "msiexec /q /norestart /i e:\openssh-win64.msi"</CommandLine>
<Order>22</Order>
<CommandLine>cmd /c "msiexec /q /norestart /i f:\openssh-win64.msi"</CommandLine>
<Description>Install OpenSSH</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>18</Order>
<CommandLine>cmd /c "copy e:\id_ed25519.pub c:\programdata\ssh\administrators_authorized_keys"</CommandLine>
<Order>23</Order>
<CommandLine>cmd /c "copy f:\id_ed25519.pub c:\programdata\ssh\administrators_authorized_keys"</CommandLine>
<Description>Install public key</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>19</Order>
<Order>24</Order>
<CommandLine>cmd /c "echo AcceptENV * >> c:\programdata\ssh\sshd_config"</CommandLine>
<Description>Install public key</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>20</Order>
<Order>25</Order>
<CommandLine>netsh advfirewall firewall set rule group="OpenSSH SSH Server Preview (sshd)" new profile=any enable=yes</CommandLine>
<Description>Configure OpenSSH</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>21</Order>
<CommandLine>cmd /c "copy e:\opam-2.2.exe c:\cygwin64\bin\opam.exe"</CommandLine>
<Order>26</Order>
<CommandLine>cmd /c "copy f:\opam-2.2.exe c:\cygwin64\bin\opam.exe"</CommandLine>
<Description>Copy opam executable</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>22</Order>
<CommandLine>cmd /c "copy e:\opam-2.2.exe c:\cygwin64\bin\opam-2.2.exe"</CommandLine>
<Order>27</Order>
<CommandLine>cmd /c "copy f:\opam-2.2.exe c:\cygwin64\bin\opam-2.2.exe"</CommandLine>
<Description>Copy opam executable</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>23</Order>
<CommandLine>cmd /c "copy e:\opam-dev.exe c:\cygwin64\bin\opam-dev.exe"</CommandLine>
<Order>28</Order>
<CommandLine>cmd /c "copy f:\opam-dev.exe c:\cygwin64\bin\opam-dev.exe"</CommandLine>
<Description>Copy opam executable</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>24</Order>
<Order>29</Order>
<CommandLine>c:\cygwin64\bin\bash.exe --login -c "cd /cygdrive/c/Users/opam && git clone https://github.com/ocaml/opam-repository"</CommandLine>
<Description>Add opam-repository</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>25</Order>
<Order>30</Order>
<CommandLine>c:\cygwin64\bin\opam init -y -k local -a c:\users\opam\opam-repository --bare --cygwin-location=c:\cygwin64</CommandLine>
<Description>Opam init</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>26</Order>
<Order>31</Order>
<CommandLine>c:\cygwin64\bin\opam switch create VERSION --packages=ocaml-base-compiler.VERSION</CommandLine>
<Description>Opam switch</Description>
</SynchronousCommand>

<SynchronousCommand wcm:action="add">
<Order>27</Order>
<Order>32</Order>
<CommandLine>c:\cygwin64\bin\opam pin add -k version ocaml-base-compiler VERSION</CommandLine>
<Description>Opam switch</Description>
</SynchronousCommand>
Expand Down Expand Up @@ -319,3 +368,4 @@
</settings>

</unattend>

0 comments on commit 502c87c

Please sign in to comment.