With the three privileged packages, this needs rewriting from scratch. Besides, the script is messy anyway.