yank_stale_rpm.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. #
  3. # This script is responsible for the removal of stale RPM/DEB files.
  4. # It runs on the pre-deploy step and takes care of the removal of the files
  5. # prior to the upload of the freshly built ones
  6. #
  7. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  8. #
  9. # Author : Pavlos Emm. Katsoulakis (paul@netdata.cloud)
  10. #shellcheck disable=SC2010,SC2068
  11. set -e
  12. # If we are not in netdata git repo, at the top level directory, fail
  13. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  14. CWD=$(git rev-parse --show-cdup)
  15. if [ -n "$CWD" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  16. echo "Run as .travis/package_management/$(basename "$0") from top level directory of netdata git repository"
  17. echo "Package yanking cancelled"
  18. exit 1
  19. fi
  20. PACKAGES_DIR="$1"
  21. DISTRO="$2"
  22. PACKAGES_LIST="$(ls -AR "${PACKAGES_DIR}" | grep -e '\.rpm' -e '\.deb' -e '\.ddeb' )"
  23. if [ ! -d "${PACKAGES_DIR}" ] || [ -z "${PACKAGES_LIST}" ]; then
  24. echo "Folder ${PACKAGES_DIR} does not seem to be a valid directory or is empty. No packages to check for yanking"
  25. exit 1
  26. fi
  27. for pkg in ${PACKAGES_LIST[@]}; do
  28. echo "Attempting yank on ${pkg}.."
  29. .travis/package_management/package_cloud_wrapper.sh yank "${PACKAGING_USER}/${DEPLOY_REPO}/${DISTRO}" "${pkg}" || echo "Nothing to yank or error on ${pkg}"
  30. done