Metadata for the ArchiveTeam Docker Hub repositories
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

49 lignes
1.6 KiB

  1. #!/bin/bash
  2. # Run this in the directory that contains the git repository (branch) with the output
  3. readarray -t profiles <dockerhub-metadata.profiles
  4. codePath="$(cd "$(dirname "$0")" >/dev/null 2>&1; pwd -P)"
  5. # Check that we're in the right place; there should be one dir for each profile and a dockerhub-metadata.retrieve.log in this directory and nothing else (except possibly hidden stuff like .git)
  6. files=("${profiles[@]}" dockerhub-metadata.profiles dockerhub-metadata.retrieve.log)
  7. if ! diff -q <(printf "%s\0" "${files[@]}" | LC_ALL=C sort -z) <(printf "%s\0" * | LC_ALL=C sort -z) >/dev/null
  8. then
  9. echo "ERROR: Current directory appears to not match the expected structure; refusing to continue" >&2
  10. echo "Expected: ${files[@]}" >&2
  11. exit 1
  12. fi
  13. # Create a temporary directory for the new run's output (hidden so it isn't caught in the deletion below)
  14. tmpDir="$(mktemp --directory --tmpdir=. .tmp.XXXXXXXXXX)"
  15. # Run (and exit if something goes wrong)
  16. pushd "${tmpDir}" 2>/dev/null
  17. set -e
  18. PYTHONUNBUFFERED=1 "${codePath}"/retrieve "${profiles[@]}" 2> >(tee dockerhub-metadata.retrieve.log >&2)
  19. set +e
  20. popd 2>/dev/null
  21. # Delete the old stuff
  22. rm -r *
  23. # Move new stuff here
  24. mv -n "${tmpDir}"/* .
  25. # Delete the temporary directory, which should now be empty
  26. rmdir "${tmpDir}"
  27. if [[ $? -ne 0 ]]
  28. then
  29. echo "ERROR: Could not delete temporary directory ${tmpDir}; not empty?" >&2
  30. #TODO: This should block future runs as well to prevent mixed up data or something.
  31. exit 1
  32. fi
  33. # Recreate the profiles file, sorted
  34. printf "%s\n" "${profiles[@]}" | LC_ALL=C sort >dockerhub-metadata.profiles
  35. # git stuffs
  36. git add --all -- ':!.tmp.*'
  37. git commit --message 'Automatic run'
  38. git push