Removing all iptables packages from custom imagebuilder build 22.03

Hi all,

I use the imagebuilder to build for my x86 router, to ensure all the required drivers are installed for my hardware.

Each time I build I use the command referenced in the wiki to list installed packages:

echo $(opkg list-installed | sed -e "s/\s.*$//")

I'm noticing that over time this is adding a lot of bulk to my image as old dependencies are never removed, particularly when building 22.03rc1 I've noticed a lot of references to ipt/iptables remain in my package list as it's come from the pre-nftables build.

I realise now (5 years too late) I should have been better at maintaining a seperate list of these strictly required non-default packages for my hardware, because now I've lost track of what I initially needed to get my system working and now have years worth of package bloat from continually using the 'list all packages' command for each subsequent build.

So... a two parter. Firstly, is it safe to remove all these iptables related packages and modules from a 22.03 build?

iptables - 1.8.7-1
iptables-mod-conntrack-extra - 1.8.7-1
iptables-mod-ipopt - 1.8.7-1
iptables-mod-physdev - 1.8.7-1
kmod-ipt-conntrack - 5.4.143-1
kmod-ipt-conntrack-extra - 5.4.143-1
kmod-ipt-core - 5.4.143-1
kmod-ipt-ipopt - 5.4.143-1
kmod-ipt-ipset - 5.4.143-1
kmod-ipt-nat - 5.4.143-1
kmod-ipt-nat6 - 5.4.143-1
kmod-ipt-offload - 5.4.143-1
kmod-ipt-physdev - 5.4.143-1
kmod-ipt-raw - 5.4.143-1
kmod-nf-ipt - 5.4.143-1
kmod-nf-ipt6 - 5.4.143-1

Secondly, is there an automated way to clean up my packages list? Or do I need to spend a few hours going through manually and simply removing anything I don't think I need anymore?!