#!/bin/bash # Clean script for Cthulhu development # Removes build artifacts and optionally uninstalls local installation set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color echo -e "${GREEN}=== Cthulhu Clean Script ===${NC}" LOCAL_PREFIX="$HOME/.local" # Function to clean build artifacts clean_build() { echo -e "${YELLOW}Cleaning build artifacts...${NC}" # Clean generated files make distclean 2>/dev/null || true # Remove autotools generated files rm -rf autom4te.cache rm -f aclocal.m4 configure config.h.in config.h config.log config.status rm -f compile config.guess config.sub depcomp install-sh missing rm -f py-compile ltmain.sh libtool rm -f stamp-h1 # Remove generated Makefiles find . -name "Makefile" -delete 2>/dev/null || true find . -name "Makefile.in" -delete 2>/dev/null || true # Remove Python bytecode find . -name "*.pyc" -delete 2>/dev/null || true find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true # Remove generated .py files rm -f src/cthulhu/cthulhu_bin.py src/cthulhu/cthulhu_i18n.py src/cthulhu/cthulhu_platform.py # Remove translation files find . -name "*.mo" -delete 2>/dev/null || true find . -name "*.pot" -delete 2>/dev/null || true echo -e "${GREEN}Build artifacts cleaned.${NC}" } # Function to uninstall local installation uninstall_local() { echo -e "${YELLOW}Uninstalling local Cthulhu installation...${NC}" if [[ -f "${LOCAL_PREFIX}/bin/cthulhu" ]]; then # Remove binaries rm -f "${LOCAL_PREFIX}/bin/cthulhu" # Remove Python modules rm -rf "${LOCAL_PREFIX}/lib/python"*/site-packages/cthulhu* # Remove data files rm -rf "${LOCAL_PREFIX}/share/cthulhu" # Remove docs rm -rf "${LOCAL_PREFIX}/share/help/*/cthulhu" # Remove desktop files rm -f "${LOCAL_PREFIX}/share/applications/cthulhu"* # Remove autostart rm -f "${LOCAL_PREFIX}/etc/xdg/autostart/cthulhu"* echo -e "${GREEN}Local installation removed.${NC}" else echo -e "${YELLOW}No local installation found.${NC}" fi } # Parse arguments case "$1" in --build-only) clean_build ;; --install-only) uninstall_local ;; *) clean_build uninstall_local ;; esac echo -e "${GREEN}=== Clean Complete ===${NC}"