From 7187134e95a858a63813eb6ec2fac1a6ad67ce4d Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Fri, 14 Jun 2024 15:02:01 -0500 Subject: [PATCH] get weird with it --- .github/actions/clean-disk/action.yml | 57 ++++++++++++++++----------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/.github/actions/clean-disk/action.yml b/.github/actions/clean-disk/action.yml index feff264..1ce7387 100644 --- a/.github/actions/clean-disk/action.yml +++ b/.github/actions/clean-disk/action.yml @@ -17,32 +17,43 @@ runs: run: | set -euo pipefail + non_manifest_packages() { + manifest='https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.manifest' + comm -2 -3 \ + <(sudo apt-mark showmanual | sort) \ + <(curl --silent "$manifest" | grep --perl-regexp --only-matching '^[\w-.+]+' | sort) + } + # remove_non_essential_package_files() { + # # dpkg -L $(non_manifest_packages) | while read p; do [ -f "$p" ] && echo "$p"; done | xargs -n 10000 sudo rm -f + # # dpkg -L $(non_manifest_packages) | while read p; do {[ -f "$p" ] && rm -f "$p";} &; done + # while read -r p; do + # { + # if [[ -f "$p" ]]; then + # sudo rm -f "$p" + # fi + # } & + # done <<< "$(dpkg -L $(non_manifest_packages))" + # } echo "Removing unwanted software... " - sudo rm -rf /usr/share/dotnet - sudo rm -rf /usr/local/lib/android - sudo rm -rf /opt - sudo rm -rf /opt/ghc - sudo rm -rf /usr/local/.ghcup - sudo rm -rf /opt/hostedtoolcache - sudo docker image prune --all --force > /dev/null - sudo rm -rf /usr/local - sudo apt-get remove -y '^aspnetcore-.*' > /dev/null - sudo apt-get remove -y '^dotnet-.*' > /dev/null - sudo apt-get remove -y '^llvm-.*' > /dev/null - sudo apt-get remove -y 'php.*' > /dev/null - sudo apt-get remove -y '^mongodb-.*' > /dev/null - sudo apt-get remove -y '^mysql-.*' > /dev/null - sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri --fix-missing > /dev/null - sudo apt-get remove -y google-cloud-sdk --fix-missing > /dev/null - sudo apt-get remove -y google-cloud-cli --fix-missing > /dev/null - sudo apt-get autoremove -y > /dev/null - sudo apt-get clean > /dev/null - sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo rm -rf /opt & + sudo rm -rf "$AGENT_TOOLSDIRECTORY" & - sudo swapoff -a - sudo rm -f /mnt/swapfile - free -h + + sudo apt-get purge -y --allow-remove-essential \ + $(non_manifest_packages) & + + wait + + sudo rm -rf /var/lib/docker & + sudo rm -rf /usr/{local,share} & + + { + sudo swapoff -a + sudo rm -f /mnt/swapfile & + } & + + wait echo "... done" - name: Disk space report after modification