merge-package-lists.py 931 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python
  2. # Copyright 2016 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """Merge package entries from different package lists.
  6. """
  7. # This is used for replacing packages in eg. bullseye with those in bookworm.
  8. # The updated packages are ABI compatible, but include security patches, so we
  9. # should use those instead in our sysroots.
  10. import sys
  11. if len(sys.argv) != 2:
  12. exit(1)
  13. packages = {}
  14. def AddPackagesFromFile(file):
  15. global packages
  16. lines = file.readlines()
  17. if len(lines) % 3 != 0:
  18. exit(1)
  19. for i in range(0, len(lines), 3):
  20. packages[lines[i]] = (lines[i + 1], lines[i + 2])
  21. AddPackagesFromFile(open(sys.argv[1], 'r'))
  22. AddPackagesFromFile(sys.stdin)
  23. output_file = open(sys.argv[1], 'w')
  24. for (package, (filename, sha256)) in packages.items():
  25. output_file.write(package + filename + sha256)