Does opkg clean files or directories in /var at reboot?

In traditional linux, all files and directories in /tmp are cleaned up at reboot.
Let's check the ubuntu os,the cleaning of /tmp is done by the upstart script /etc/init/mounted-tmp.conf. The script is run by upstart everytime /tmp is mounted. Practically that means at every boot.

I find that not all files and directories be cleaned up in openwrt at every boot.

root@OpenWrt:~# df  /var
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                  3932384      3924   3928460   0% /tmp

I know that tree command installed in /var.

 opkg install tree
Package tree (1.8.0-1) installed in /var is up to date.

The tree command don't lost after every reboot.

In openwrt ,tmpfs file system don't be cleaned up at every reboot?

tmpfs is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage device. A similar construction is a RAM disk, which appears as a virtual disk drive and hosts a disk file system.

OpenWrt as most other routers and embedded devices use this to avoid writing to the device flash memory. Flash memory is not built for millions of write operations, like hard-drives and SSDs. They would wear-out after weeks or months, but can't be replaced like hard-drives, as they are soldered on the main-board.

Thus only the operating system and rarely changed configuration data is stored on the flash memory. Everything else which is not needed to boot the router up again is kept in volatile memory only.

Therefore there is no need to clean anything after a reboot.

You binaries however are not installed in /var. You can use the which command to see where they are:

$ which tree