Files
chromebrew/packages/clear_cache.rb
supechicken 0e532bef6d Update homepage URL in packages from skycocker/chromebrew to chromebrew/chromebrew (#7146)
* Change homepage URL from skycocker/chromebrew to chromebrew/chromebrew

* Use https

* Bump version
2022-06-15 12:49:40 -05:00

41 lines
1.0 KiB
Ruby

require 'package'
class Clear_cache < Package
description 'Script to remove system cache files'
homepage 'https://github.com/chromebrew/chromebrew/wiki/FAQ'
version '1.0'
license 'GPL-3+'
compatibility 'all'
source_url 'SKIP'
def self.build
system "cat << 'EOF' > clear-cache
#!/bin/bash
cd \$HOME
SPACE_BEFORE=\$(du -s | cut -f1)
SPACE_BEFORE_HUMAN=\$(du -hs | cut -f1)
DIRS=\".cache Cache Application_Cache Code_Cache GCache GPUCache Service_Worker\"
for D in \$DIRS; do
DIR=\$(echo \$D | sed \'s,_, ,\')
[ -d \"\$DIR\" ] && rm -rf \"\$DIR\"
done
SPACE_AFTER=\$(du -s | cut -f1)
SPACE_AFTER_HUMAN=\$(du -hs | cut -f1)
SPACE_RECOVERED=\$((\$SPACE_BEFORE-\$SPACE_AFTER))
echo \"Space used before: \$SPACE_BEFORE_HUMAN\"
echo \"Space used after: \$SPACE_AFTER_HUMAN\"
echo \"Space recovered: \${SPACE_RECOVERED}KB\"
EOF"
end
def self.install
system "install -Dm755 clear-cache #{CREW_DEST_PREFIX}/bin/clear-cache"
end
def self.postinstall
puts
puts "Type 'clear-cache' to remove system cache files.".lightblue
puts
end
end