#!/usr/bin/python3

# This script can be used when new versions of Coq packages get
# released, to check everything is ok with the rest of the stack.
#
# You're supposed to call it with a space-separated list of packages
# with a new version, and the result is generally several lines of
# space-separated package names corresponding to what needs to be
# rebuilt, where packages on the same line can be compiled at the same
# time.
#
# If you use sbuild to compile the packages, with sbuid configured
# with a local repo, you can then put the packages in the repo step by
# step and check that the new versions don't break anything.

import sys
from coq_packages import group_by, hauteur, transitive_rdeps

groups = group_by(transitive_rdeps(sys.argv[1:]), hauteur)

for group in groups:
    print(' '.join([f'{name}' for name in group]))
