exec cp ../misc/image/init.dev %tmp%/init.dev
exec cp ../misc/image/init.sys %tmp%/init.sys
exec mv %tmp%/boot/vmlinuz* %img%.krn
del-alw %tmp%/boot
del-alw %tmp%/usr/src
del-alw %tmp%/usr/include
del-alw %tmp%/usr/share/info
del-alw %tmp%/usr/share/man
del-alw %tmp%/usr/share/doc
del-alw %tmp%/usr/share/bug
del-alw %tmp%/usr/lib/x86_64-linux-gnu/gconv

find-clear
#find-file %tmp%/lib/modules/ .*-generic
#find-file %tmp%/lib/modules/ .*-virtual
#find-file %tmp%/lib/modules/ .*-kvm
find-file %tmp%/lib/modules/ .*-%arch%
find-result
del-alw %tmp%/lib/modules/%find%/kernel/sound
del-alw %tmp%/lib/modules/%find%/kernel/drivers/gpu
del-alw %tmp%/lib/modules/%find%/kernel/drivers/iio
del-alw %tmp%/lib/modules/%find%/kernel/drivers/media
del-alw %tmp%/lib/modules/%find%/kernel/drivers/infiniband
del-alw %tmp%/lib/modules/%find%/kernel/drivers/net/wireless

exec mv %tmp%/lib/modules/%find%/kernel/net/packet %tmp%/tmp/
exec mv %tmp%/lib/modules/%find%/kernel/net/core %tmp%/tmp/
exec mv %tmp%/lib/modules/%find%/kernel/net/*.ko %tmp%/tmp/
del-alw %tmp%/lib/modules/%find%/kernel/net
exec mkdir %tmp%/lib/modules/%find%/kernel/net
exec mv %tmp%/tmp/* %tmp%/lib/modules/%find%/kernel/net

exec mv %tmp%/lib/modules/%find%/kernel/drivers/scsi/*.ko %tmp%/tmp/
del-alw %tmp%/lib/modules/%find%/kernel/drivers/scsi
exec mkdir %tmp%/lib/modules/%find%/kernel/drivers/scsi
exec mv %tmp%/tmp/* %tmp%/lib/modules/%find%/kernel/drivers/scsi/

exec chmod 755 %tmp%/init*
exec touch %tmp%/rtr/rtr-hw.txt
exec cp ../misc/default.cfg %tmp%/rtr/rtr-sw.txt
exec for a in `busybox --list`; do ln -s /bin/busybox %tmp%/bin/$a; done

exec du -sh %tmp%
exec cd %tmp%;find . | cpio --quiet -H newc --owner root:root -O ../cpio -o
exec mv %tmp%/../cpio %img%.cpio
exec zstd -9 %img%.cpio
exec mv %img%.cpio.zst %img%.ird
exec wraplinux -M -l -i %img%.ird -o %img%.wrp %img%.krn

exec grub-mkimage -o %tmp%/grub.efi -c ../misc/image/boot.efi -O x86_64-efi -p grub normal search boot linux part_msdos part_gpt fat ext2 iso9660 syslinuxcfg test progress
exec dd if=/dev/zero of=%img%.efi bs=1K count=1024
exec /sbin/mkfs.vfat %img%.efi
exec mmd -i %img%.efi efi efi/boot
exec mcopy -i %img%.efi %tmp%/grub.efi ::efi/boot/bootx64.efi

exec cp /usr/lib/ISOLINUX/isolinux.bin %tmp%/isolinux.bin
exec cp /usr/lib/syslinux/modules/bios/ldlinux.c32 %tmp%/ldlinux.c32
exec cp ../misc/image/boot.cfg %tmp%/syslinux.cfg
exec xorriso -as mkisofs -o %img%.iso -r -J -l -b isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -c isolinux.cat -eltorito-alt-boot -e rtr.efi -no-emul-boot %img%.krn %img%.ird %tmp%/syslinux.cfg %tmp%/isolinux.bin %tmp%/ldlinux.c32 %img%.efi
exec isohybrid -u %img%.iso
exec mktorrent -o %img%.torrent -w http://dl.nop.hu/rtr.iso %img%.iso
del-alw %tmp%
