download 3
reget-time 8
kern http://download.freebsd.org/releases/%arch%/

mkdir %tmp%
binary-down %dwn%/%arch%-fbsd.html %kern%
find-clear
find-link 1-1111 %dwn%/%arch%-fbsd.html [0-9][0-9]\.[0-9].*/
find-result
kern %kern%%find%

file-read 0 %dwn%/%arch%-fbsd.txt
del %dwn%/%arch%-fbsd.txt
download 1
if-compare 0 %read% %find%
download 2

binary-xtra fbsd-base.txz %kern%base.txz
binary-xtra fbsd-kern.txz %kern%kernel.txz

file-line %dwn%/%arch%-fbsd.txt %find%
package-xtra

move %tmp%/boot/kernel/* %tmp%/tmp/
move %tmp%/tmp/kernel %tmp%/boot/kernel/
move %tmp%/tmp/linux.ko %tmp%/boot/kernel/
move %tmp%/tmp/linux64.ko %tmp%/boot/kernel/
move %tmp%/tmp/linux_common.ko %tmp%/boot/kernel/
move %tmp%/tmp/mqueuefs.ko %tmp%/boot/kernel/
move %tmp%/tmp/linprocfs.ko %tmp%/boot/kernel/
move %tmp%/tmp/linsysfs.ko %tmp%/boot/kernel/
move %tmp%/tmp/unionfs.ko %tmp%/boot/kernel/
del %tmp%/boot/firmware
del %tmp%/tmp/*

move %tmp%/usr/sbin/ndp %tmp%/sbin/
copy ../misc/image/boot.fbsd %tmp%/boot/loader.conf
copy ../misc/image/init.fbsd %tmp%/etc/rc
mkdir %tmp%/compat
kern freebsd
boot compat/linux

include ../misc/image/image.xbsd

exec xorriso -as mkisofs -o %img%-fbsd.iso -r -J -l -b boot/cdboot -no-emul-boot -c isolinux.cat %tmp%/

del %tmp%
