mirror of
https://github.com/dolphin-emu/sadm
synced 2025-10-06 00:02:50 +02:00
flatpak-worker: Add script to automatically clear the flatpak-builder cache if it gets too large
This commit is contained in:
@@ -30,8 +30,23 @@ let
|
||||
pkgs.buildbot-worker
|
||||
]);
|
||||
|
||||
flatpakScripts = with pkgs; stdenv.mkDerivation {
|
||||
name = "flatpak-scripts";
|
||||
src = ./utils;
|
||||
|
||||
propagatedBuildInputs = [ bash coreutils ];
|
||||
|
||||
unpackPhase = "true";
|
||||
installPhase = ''
|
||||
mkdir $out $out/bin
|
||||
install -m755 $src/clean_cache.sh $out/bin
|
||||
patchShebangs $out/bin
|
||||
'';
|
||||
};
|
||||
|
||||
flatpakEnvPackages = with pkgs; [
|
||||
bash
|
||||
flatpakScripts
|
||||
flatpak
|
||||
git
|
||||
];
|
||||
|
16
roles/flatpak-worker/utils/clean_cache.sh
Executable file
16
roles/flatpak-worker/utils/clean_cache.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIRECTORY_SIZE=$(du -sb .flatpak-builder | cut -f1)
|
||||
MAX_SIZE=10737418240 # 10GiB
|
||||
|
||||
if [[ $DIRECTORY_SIZE -eq "" ]]; then
|
||||
echo "Failed to calculate cache size, bailing out"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $DIRECTORY_SIZE -gt $MAX_SIZE ]]; then
|
||||
echo "Cache is too large ($DIRECTORY_SIZE bytes), clearing"
|
||||
rm -rf .flatpak-builder
|
||||
else
|
||||
echo "Cache is still within a reasonable size ($DIRECTORY_SIZE bytes)"
|
||||
fi
|
Reference in New Issue
Block a user