79 lines
2.6 KiB
Bash
79 lines
2.6 KiB
Bash
#!/bin/bash
|
|
# Принять лицензию KRT и посмотреть главное окно.
|
|
set -e
|
|
STAGE=/path/to/pf/KRD/files
|
|
IMG=/root/krd24/ui-fat32.img
|
|
|
|
rm -f "$IMG"; truncate -s 8G "$IMG"
|
|
mkfs.vfat -F 32 -n PARAVIS "$IMG" >/dev/null 2>&1
|
|
mkdir -p /mnt/krdtest; mount -o loop "$IMG" /mnt/krdtest
|
|
mkdir -p /mnt/krdtest/efi/Paravis/KRD
|
|
cp -r "$STAGE/." /mnt/krdtest/efi/Paravis/KRD/
|
|
sync; umount /mnt/krdtest
|
|
|
|
rm -f /tmp/qmon9.sock /tmp/ui*.ppm
|
|
qemu-system-x86_64 -m 4096 -smp 4 -machine q35 \
|
|
-kernel "$STAGE/live/vmlinuz" -initrd "$STAGE/live/initrd.img" \
|
|
-append "boot=live components live-media-path=/efi/Paravis/KRD/live locales=ru_RU.UTF-8 trace" \
|
|
-drive file="$IMG",format=raw,if=ide \
|
|
-netdev user,id=n0 -device e1000,netdev=n0 \
|
|
-device qemu-xhci -device usb-tablet -display none -vga std \
|
|
-monitor unix:/tmp/qmon9.sock,server,nowait -daemonize
|
|
|
|
python3 - <<'EOF'
|
|
import socket, time
|
|
def mon(cmds, pause=0.6):
|
|
s = socket.socket(socket.AF_UNIX); s.connect('/tmp/qmon9.sock'); time.sleep(0.25)
|
|
s.recv(65536)
|
|
for c in cmds:
|
|
s.sendall((c+'\n').encode()); time.sleep(pause)
|
|
s.settimeout(1.0)
|
|
try: s.recv(65536)
|
|
except Exception: pass
|
|
s.close()
|
|
|
|
time.sleep(150)
|
|
mon(['screendump /tmp/ui0.ppm'])
|
|
|
|
# мышью — по одному чекбоксу, с проверкой
|
|
for i,(x,y) in enumerate([(366,525),(366,558),(366,611)], start=1):
|
|
mon([f'mouse_move {x} {y}', 'mouse_button 1', 'mouse_button 0'], 0.4)
|
|
time.sleep(1.0)
|
|
mon([f'screendump /tmp/ui{i}.ppm'])
|
|
|
|
# "Принять"
|
|
mon(['mouse_move 865 657', 'mouse_button 1', 'mouse_button 0'], 0.5)
|
|
time.sleep(8)
|
|
mon(['screendump /tmp/ui4.ppm'])
|
|
time.sleep(8)
|
|
mon(['screendump /tmp/ui5.ppm'])
|
|
mon(['quit'])
|
|
EOF
|
|
sleep 3
|
|
pkill -f 'qemu-system-x86_64.*ui-fat32.img' 2>/dev/null || true
|
|
python3 - <<'EOF'
|
|
import zlib, struct
|
|
def ppm2png(src, dst):
|
|
d=open(src,'rb').read()
|
|
parts=[]; i=0
|
|
while len(parts)<4:
|
|
while d[i:i+1].isspace(): i+=1
|
|
j=i
|
|
while not d[j:j+1].isspace(): j+=1
|
|
parts.append(d[i:j]); i=j
|
|
i+=1
|
|
w=int(parts[1]); h=int(parts[2]); px=d[i:i+w*h*3]
|
|
raw=b''.join(b'\x00'+px[y*w*3:(y+1)*w*3] for y in range(h))
|
|
def chunk(t,data):
|
|
c=t+data
|
|
return struct.pack('>I',len(data))+c+struct.pack('>I',zlib.crc32(c)&0xffffffff)
|
|
png=b'\x89PNG\r\n\x1a\n'
|
|
png+=chunk(b'IHDR',struct.pack('>IIBBBBB',w,h,8,2,0,0,0))
|
|
png+=chunk(b'IDAT',zlib.compress(raw,9))
|
|
png+=chunk(b'IEND',b'')
|
|
open(dst,'wb').write(png)
|
|
print(dst,w,h)
|
|
for n in range(6):
|
|
ppm2png(f'/tmp/ui{n}.ppm', f'/path/to/pf/KRD/ui-{n}.png')
|
|
EOF
|