packages: Rewrite 'transitive-inputs' to be linear and remove duplicates.