Sort gluon packages
Add legacy upgrade support