Yes, that's a good idea. This code is still rather primitive, and contributions are very welcome.
The m4 script is really just shell code in disguise. SYSTEM_PACKAGES is a shell variable, and you could use something like "sort -u" to process it.
I have a task ticket that lists several directions of improvement of this code related to system packages: