From e0d0d4bf5ef1e15577c05718edc933404b0d13eb 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 | 56 ++++++++++++------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/src/ci/scripts/free-disk-space.sh b/src/ci/scripts/free-disk-space.sh index 3164f9d947f85..cd40a7da33a9d 100755 --- a/src/ci/scripts/free-disk-space.sh +++ b/src/ci/scripts/free-disk-space.sh @@ -5,18 +5,6 @@ # MACROS # ====== -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}' -} - # macro to print a line of equals # # (silly but works) printSeparationLine() { @@ -89,7 +77,7 @@ echo "" BEFORE=$(getAvailableSpace) -fast_rmdir "$AGENT_TOOLSDIRECTORY" || true +sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -97,7 +85,7 @@ printSavedSpace $SAVED "Agent tools" BEFORE=$(getAvailableSpace) -fast_rmdir /usr/local/share/powershell || true +sudo rm -rf /usr/local/share/powershell || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -105,7 +93,7 @@ printSavedSpace $SAVED "Powershell" BEFORE=$(getAvailableSpace) -fast_rmdir /usr/local/share/chromium || true +sudo rm -rf /usr/local/share/chromium || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -113,7 +101,7 @@ printSavedSpace $SAVED "Chromium" BEFORE=$(getAvailableSpace) -fast_rmdir /usr/local/lib/node_modules || true +sudo rm -rf /usr/local/lib/node_modules || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -121,7 +109,7 @@ printSavedSpace $SAVED "Node modules" BEFORE=$(getAvailableSpace) -fast_rmdir /usr/share/swift || true +sudo rm -rf /usr/share/swift || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -130,7 +118,7 @@ printSavedSpace $SAVED "Swift" # Remove Android library BEFORE=$(getAvailableSpace) -fast_rmdir /usr/local/lib/android || true +sudo rm -rf /usr/local/lib/android || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -141,7 +129,7 @@ printSavedSpace $SAVED "Android library" BEFORE=$(getAvailableSpace) # https://github.community/t/bigger-github-hosted-runners-disk-space/17267/11 -fast_rmdir /usr/share/dotnet || true +sudo rm -rf /usr/share/dotnet || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -150,8 +138,8 @@ printSavedSpace $SAVED ".NET runtime" # Remove Haskell runtime BEFORE=$(getAvailableSpace) -fast_rmdir /opt/ghc || true -fast_rmdir /usr/local/.ghcup || true +sudo rm -rf /opt/ghc || true +sudo rm -rf /usr/local/.ghcup || true AFTER=$(getAvailableSpace) SAVED=$((AFTER-BEFORE)) @@ -162,19 +150,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))