Skip to content

Commit f0e8e11

Browse files
committed
Revert "Reattempt to speed up deleting"
This reverts commit 6b53cfb.
1 parent ce5b7e5 commit f0e8e11

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

src/ci/scripts/free-disk-space.sh

+20-24
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@
66
# ======
77

88
fast_rmdir() {
9-
if [[ -d "$1" ]] && [[ -n "$1" ]] && [[ ! "$1" = "/" ]] && [[ ! "$1" = "~" ]]; then
10-
echo "Removing directory: $1"
11-
sudo find "$1" -type f -delete -print | wc -l
12-
sudo rm -rf "$1"
13-
fi
14-
}
15-
16-
list_installed_dpkg() {
17-
dpkg --get-selections $@ | grep -v deinstall | awk '{print $1}'
9+
if [[ -d "$1" ]] && [[ -n "$1" ]] && [[ ! "$1" = "/" ]] && [[ ! "$1" = "~" ]]; then
10+
echo "Removing directory: $1"
11+
sudo find "$1" -type f -delete -print | wc -l
12+
sudo rm -rf "$1"
13+
fi
1814
}
1915

2016
# macro to print a line of equals
@@ -162,19 +158,19 @@ printSavedSpace $SAVED "Haskell runtime"
162158

163159
BEFORE=$(getAvailableSpace)
164160

165-
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)
166-
gcloud_prerm='#!/bin/sh
167-
echo $0
168-
if [ -d "/usr/lib/google-cloud-sdk" ]; then
169-
echo "Cleaning Google Cloud CLI files..."
170-
find /usr/lib/google-cloud-sdk -type f -delete -print | wc -l
171-
rm -rf /usr/lib/google-cloud-sdk
172-
echo "Cleaning Google Cloud CLI manuals..."
173-
find /usr/share/man -type f -name "gcloud*" -delete -print | wc -l
174-
fi'
175-
echo "$gcloud_prerm" | sudo tee /var/lib/dpkg/info/google-cloud-cli-anthoscli.prerm >/dev/null
176-
echo "$gcloud_prerm" | sudo tee /var/lib/dpkg/info/google-cloud-cli.prerm >/dev/null
177-
sudo apt-get remove --autoremove -y $pkgs || echo "::warning::The command [sudo apt-get remove -y] failed to complete successfully. Proceeding..."
161+
sudo apt-get remove -y '^aspnetcore-.*' || echo "::warning::The command [sudo apt-get remove -y '^aspnetcore-.*'] failed to complete successfully. Proceeding..."
162+
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..."
163+
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..."
164+
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..."
165+
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..."
166+
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..."
167+
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..."
168+
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..."
169+
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..."
170+
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..."
171+
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..."
172+
sudo apt-get autoremove -y || echo "::warning::The command [sudo apt-get autoremove -y] failed to complete successfully. Proceeding..."
173+
sudo apt-get clean || echo "::warning::The command [sudo apt-get clean] failed to complete successfully. Proceeding..."
178174

179175
AFTER=$(getAvailableSpace)
180176
SAVED=$((AFTER-BEFORE))
@@ -195,7 +191,7 @@ printSavedSpace $SAVED "Docker images"
195191

196192
BEFORE=$(getAvailableSpace)
197193

198-
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
194+
fast_rmdir "$AGENT_TOOLSDIRECTORY" || true
199195

200196
AFTER=$(getAvailableSpace)
201197
SAVED=$((AFTER-BEFORE))
@@ -206,7 +202,7 @@ printSavedSpace $SAVED "Tool cache"
206202
BEFORE=$(getAvailableSpace)
207203

208204
sudo swapoff -a || true
209-
sudo rm -f /mnt/swapfile || true
205+
fast_rmdir /mnt/swapfile || true
210206
free -h
211207

212208
AFTER=$(getAvailableSpace)

0 commit comments

Comments
 (0)