MEDIA_TYPE = netboot image

TARGET = $(INITRD) $(KERNEL) n2100 glantank
EXTRANAME = $(MEDIUM)/
TYPE = netboot/network-console

MANIFEST-INITRD = "netboot initrd"
MANIFEST-KERNEL = "kernel image to netboot"

# Thecus N2100
n2100:
	mkdir -p $(TEMP)/n2100/upgrade
	install -m 755 util/arm/thecus/up.sh $(TEMP)/n2100/upgrade/
	cp $(TEMP_INITRD) $(TEMP)/n2100/upgrade/initrd
	# Set machine id 1101 (0x044d)
	devio > $(TEMP)/n2100/upgrade/vmlinuz 'wl 0xe3a01c04,4' 'wl 0xe381104d,4'
	cat $(TEMP_KERNEL) >> $(TEMP)/n2100/upgrade/vmlinuz
	echo 9.9.9 > $(TEMP)/n2100/upgrade/version
	(cd $(TEMP)/n2100 && tar -cpzf n2100.tar.gz upgrade)
	util/arm/thecus/pad $(TEMP)/n2100/n2100.tar.gz
	openssl enc -e -des -in $(TEMP)/n2100/n2100.tar.gz -out $(SOME_DEST)/$(EXTRANAME)/n2100.bin -K 7A9816A4C275D557 -iv 0 -nosalt -nopad
	update-manifest $(SOME_DEST)/$(EXTRANAME)n2100.bin "Firmware for Thecus N2100"

# GLAN Tank
glantank:
	mkdir -p $(SOME_DEST)/$(EXTRANAME)/glantank
	cat boot/arm/glantank.preseed >> $(TREE)/preseed.cfg
	cp boot/arm/glantank.preseed $(SOME_DEST)/$(EXTRANAME)/glantank/preseed.cfg
	(cd $(TREE) && find . | cpio --quiet -o -H newc) > $(TEMP)/initramfs
	gzip -v9f $(TEMP)/initramfs
	cp $(TEMP)/initramfs.gz $(SOME_DEST)/$(EXTRANAME)/glantank/initrd
	update-manifest $(SOME_DEST)/$(EXTRANAME)glantank/initrd "initrd for GLAN Tank"
	# Set machine id to 1100 (0x044c)
	devio > $(SOME_DEST)/$(EXTRANAME)/glantank/zImage 'wl 0xe3a01c04,4' 'wl 0xe381104c,4'
	cat $(TEMP_KERNEL) >> $(SOME_DEST)/$(EXTRANAME)/glantank/zImage
	update-manifest $(SOME_DEST)/$(EXTRANAME)glantank/zImage "kernel for GLAN Tank"

