From f0e8e11347fa1c72cb0570d0d1ab130d6c030330 Mon Sep 17 00:00:00 2001 From: Chris White Date: Fri, 13 Dec 2024 20:34:15 +0000 Subject: [PATCH] Revert "Reattempt to speed up deleting" This reverts commit 6b53cfb1c519be382b2eee7a214a503a78d656a0. --- src/ci/scripts/free-disk-space.sh | 44 ++++++++++++++----------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index 3164f9d947f85..927565092efb5 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -6,15 +6,11 @@ # ====== fast_rmdir() { -if [[ -d "$1" ]] && [[ -n "$1" ]] && [[ ! "$1" = "/" ]] && [[ ! "$1" = "~" ]]; then - echo "Removing directory: $1" - sudo find "$1" -type f -delete -print | wc -l - sudo rm -rf "$1" -fi -} - -list_installed_dpkg() { - dpkg --get-selections $@ | grep -v deinstall | awk '{print $1}' + if [[ -d "$1" ]] && [[ -n "$1" ]] && [[ ! "$1" = "/" ]] && [[ ! "$1" = "~" ]]; then + echo "Removing directory: $1" + sudo find "$1" -type f -delete -print | wc -l + sudo rm -rf "$1" + fi } # macro to print a line of equals @@ -162,19 +158,19 @@ printSavedSpace $SAVED "Haskell runtime" BEFORE=$(getAvailableSpace) -pkgs=$(list_installed_dpkg 'microsoft-edge-*' 'snapd-*' 'aspnetcore-*' 'dotnet-*' 'llvm-*' '*php*' 'mongodb-*' 'mysql-*' azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri 'google-cloud-*' 'gcloud-*' || true) -gcloud_prerm='#!/bin/sh -echo $0 -if [ -d "/usr/lib/google-cloud-sdk" ]; then - echo "Cleaning Google Cloud CLI files..." - find /usr/lib/google-cloud-sdk -type f -delete -print | wc -l - rm -rf /usr/lib/google-cloud-sdk - echo "Cleaning Google Cloud CLI manuals..." - find /usr/share/man -type f -name "gcloud*" -delete -print | wc -l -fi' -echo "$gcloud_prerm" | sudo tee /var/lib/dpkg/info/google-cloud-cli-anthoscli.prerm >/dev/null -echo "$gcloud_prerm" | sudo tee /var/lib/dpkg/info/google-cloud-cli.prerm >/dev/null -sudo apt-get remove --autoremove -y $pkgs || echo "::warning::The command [sudo apt-get remove -y] failed to complete successfully. Proceeding..." +sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..." +sudo apt-get remove -y '^dotnet-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^dotnet-.*' --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y '^llvm-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^llvm-.*' --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y 'php.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y 'php.*' --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y '^mongodb-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mongodb-.*' --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y '^mysql-.*' --fix-missing || echo "::warning::The command [sudo apt-get remove -y '^mysql-.*' --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing || echo "::warning::The command [sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y google-cloud-sdk --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-sdk --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y google-cloud-cli --fix-missing || echo "::debug::The command [sudo apt-get remove -y google-cloud-cli --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y microsoft-edge-stable --fix-missing || echo "::debug::The command [sudo apt-get remove -y microsoft-edge-stable --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get remove -y snapd --fix-missing || echo "::debug::The command [sudo apt-get remove -y snapd --fix-missing] failed to complete successfully. Proceeding..." +sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..." +sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..." AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -195,7 +191,7 @@ printSavedSpace $SAVED "Docker images" BEFORE=$(getAvailableSpace) -sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true +fast_rmdir "$AGENT_TOOLSDIRECTORY" || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -206,7 +202,7 @@ printSavedSpace $SAVED "Tool cache" BEFORE=$(getAvailableSpace) sudo swapoff -a || true -sudo rm -f /mnt/swapfile || true +fast_rmdir /mnt/swapfile || true free -h AFTER=$(getAvailableSpace)