| Current Path : /var/lib/dpkg/info/ |
| Current File : /var/lib/dpkg/info/google-cloud-cli-anthoscli.prerm |
#!/bin/sh
set -e
PACKAGE="google-cloud-cli-anthoscli"
if command -v py3clean >/dev/null 2>&1; then
# Standard Debian tool for Python 3
py3clean -p "${PACKAGE}"
else
# Fast fallback: Python 2 and Python 3 bytecode cleanup
dpkg -L "${PACKAGE}" | grep '\.py$' | while IFS= read -r file
do
dir="${file%/*}"
base="${file##*/}"
base_noext="${base%.py}"
# Clean up legacy Python 2 adjacent bytecode
rm -f "${file}"[co]
# Target only the Python 3 __pycache__ directory
rm -f "${dir}/__pycache__/${base_noext}".*py[co]
done
fi
# Clean up the empty directories
find /usr/lib/google-cloud-sdk/ -type d -name __pycache__ -empty -print0 \
| xargs --null --no-run-if-empty rmdir