download-lockfile.py 924 B

12345678910111213141516171819202122232425262728293031
  1. #! /usr/bin/env python3
  2. """
  3. Download the lockfile.yml produced by a CI pipeline, specified by the GitLab
  4. server, full name of the meta-arm project, and the refspec that was executed.
  5. For example,
  6. $ ./download-lockfile.py https://gitlab.com/ rossburton/meta-arm master
  7. SPDX-FileCopyrightText: Copyright 2023 Arm Limited and Contributors
  8. SPDX-License-Identifier: GPL-2.0-only
  9. """
  10. import argparse
  11. import gitlab
  12. import io
  13. import zipfile
  14. parser = argparse.ArgumentParser()
  15. parser.add_argument("server", help="GitLab server name")
  16. parser.add_argument("project", help="meta-arm project name")
  17. parser.add_argument("refspec", help="Branch/commit")
  18. args = parser.parse_args()
  19. gl = gitlab.Gitlab(args.server)
  20. project = gl.projects.get(args.project)
  21. artefact = project.artifacts.download(ref_name=args.refspec, job="update-repos")
  22. z = zipfile.ZipFile(io.BytesIO(artefact))
  23. z.extract("lockfile.yml")
  24. print("Fetched lockfile.yml")