menu "Firmware packaging (fwmod) options"
	visible if FREETZ_SHOW_EXPERT

	comment "ATTENTION: you probably want to activate unpacking"
		depends on FREETZ_FWMOD_SKIP_UNPACK
		depends on !FREETZ_FWMOD_SKIP_ALL

	config FREETZ_FWMOD_SKIP_ALL
		bool
		depends on FREETZ_FWMOD_SKIP_UNPACK && FREETZ_FWMOD_SKIP_MODIFY && FREETZ_FWMOD_SKIP_PACK && !FREETZ_FWMOD_USBROOT && !FREETZ_FWMOD_NFSROOT
		default y

	config FREETZ_FWMOD_SKIP_UNPACK
		bool "Skip unpacking original firmware"
		default n
		help
			In 99,9% of all cases you want this option deactivated because usually
			it makes a lot of sense to unpack a firmware before modifying it. ;-)

	config FREETZ_FWMOD_SKIP_MODIFY
		bool "Skip modifying unpacked firmware, adding Freetz stuff"
		default n
		help
			Usually you want this option deactivated, but maybe you want to use
			the Freetz build infrastructure to build your own custom firmware mod
			without actually adding any Freetz-specific stuff. If so, activate
			this option.

	config FREETZ_FWMOD_SKIP_PACK
		bool "Skip packing modified firmware"
		default n
		help
			If you are a USB root or NFS root user, you probably do not need a
			packed firmware image for flashing. It might not fit into the box's
			flash memory anyway if you have chosen a lot of packages. In that
			case you want to activate this option.

	config FREETZ_FWMOD_FORCE_PACK
		bool "Force pack even if image is too big (SDK stick mode)"
		depends on ! FREETZ_FWMOD_SKIP_PACK
		default n
		help
			Choose this option if you intend to use the packed image on an SDK
			stick (see http://web.archive.org/20200701000000/wehavemorefun.de/fritzbox/SDK-Firmware).
			At the time of writing this, SDK stick mode is only supported on
			7270_v2/3, but maybe you found a way to port it to another firmware,
			so you are free to use this option at will.

	config FREETZ_FWMOD_SIGN
		bool "Sign image"
		depends on ! FREETZ_FWMOD_SKIP_PACK
		default n

	config FREETZ_FWMOD_SIGN_KEY_FILES_PREFIX
		depends on FREETZ_FWMOD_SIGN
		string "Location of the key files used for signing"
		default "${HOME}/.freetz.image_signing"

	config FREETZ_FWMOD_SIGN_PRIVATE_KEY_PASSWORD
		string "Password of the private key to be used for signing"
		depends on FREETZ_FWMOD_SIGN
		default ""

	config FREETZ_FWMOD_CREATE_IN_MEMORY_IMAGE
		bool "Create in-memory image file"
		depends on ! FREETZ_FWMOD_SKIP_PACK
		depends on !FREETZ_SYSTEM_TYPE_MULTICORE && FREETZ_AVM_HAS_SEPARATE_FILESYSTEM_IMAGE
		default n
		help
			Creates a so-called in-memory image suitable to be loaded
			into the box memory and used for booting the box from there.

			On NAND boxes this procedure (booting from the in-memory image)
			corresponds to a regular recovery process. Every image (original
			and a modified one) automatically detects the location it has been
			started from: 1) flash memory partitions, or 2) box memory (RAM).
			In the 2nd case instead of just running the image as in the 1st one
			it flashes itself into the flash memory partitions marked as being
			active (linux_fs_start urlader variable).

			This flashing procedure doesn't require the image being flashed
			to be signed. That's why the in-memory image can and should be
			used for modifying a NAND box for the very 1st time.

			The flashing scripts required and a detailed description could be
			found within the 'eva_tools' directory of the YourFritz project:
			  https://github.com/PeterPawn/YourFritz/tree/master/eva_tools

	config FREETZ_FWMOD_USBROOT
		bool "Pack file system into archive (USB root mode)"
		default n
		help
			Choose this option if you intend to use the modified file system as a
			USB root and want it packed into a .tar.gz archive for later transfer
			to the USB medium.

			This option can also be useful for NFS root, if you want to archive
			the file system in addition to or instead of copying it to a target
			directory directly using the next option.

	config FREETZ_FWMOD_NFSROOT
		bool "Copy file system to target folder (NFS root mode)"
		default n
		select FREETZ_FWMOD_USBROOT
		help
			Choose this option if you intend to use the modified file system as
			an NFS root and want it copied to a target folder of your choice.

			This option can also be useful for USB root, if the target USB medium
			is already attached to your workstation or accessible via NFS (*not*
			Samba/CIFS!).

			ATTENTION: Make sure that the target folder is *not* mounted as a
			USB/NFS root while copying files into it. This would probably cause
			your box to reboot and lead to an inconsistent root file system.
			You should also be aware of the fact that in order to cleanly unpack
			file root system to the target folder we need to be root (fakeroot is
			enough to pack, but not to unpack). So please be ready to enter your
			user password for sudo.

	comment "ATTENTION: target folder name must not be empty"
		depends on FREETZ_FWMOD_NFSROOT
		depends on FREETZ_FWMOD_NFSROOT_DIR = ""

	config FREETZ_FWMOD_NFSROOT_DIR
		string "Target folder name"
		depends on FREETZ_FWMOD_NFSROOT
		default ""
		help
			Enter the target folder name here. It can be either absolute or
			relative to the Freetz build system's base directory (where e.g.
			fwmod is located).

endmenu # Firmware packaging (fwmod) special options
