112 lines
3.6 KiB
Bash
Executable File
112 lines
3.6 KiB
Bash
Executable File
#!/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 but preserve user settings
|
|
if [[ -d "${LOCAL_PREFIX}/share/cthulhu" ]]; then
|
|
# Backup user settings if they exist
|
|
if [[ -f "${LOCAL_PREFIX}/share/cthulhu/user-settings.conf" ]]; then
|
|
cp "${LOCAL_PREFIX}/share/cthulhu/user-settings.conf" /tmp/cthulhu-user-settings.backup
|
|
fi
|
|
if [[ -f "${LOCAL_PREFIX}/share/cthulhu/cthulhu-customizations.py" ]]; then
|
|
cp "${LOCAL_PREFIX}/share/cthulhu/cthulhu-customizations.py" /tmp/cthulhu-customizations.backup
|
|
fi
|
|
|
|
# Remove the directory
|
|
rm -rf "${LOCAL_PREFIX}/share/cthulhu"
|
|
|
|
# Recreate directory and restore user files
|
|
mkdir -p "${LOCAL_PREFIX}/share/cthulhu"
|
|
if [[ -f /tmp/cthulhu-user-settings.backup ]]; then
|
|
mv /tmp/cthulhu-user-settings.backup "${LOCAL_PREFIX}/share/cthulhu/user-settings.conf"
|
|
fi
|
|
if [[ -f /tmp/cthulhu-customizations.backup ]]; then
|
|
mv /tmp/cthulhu-customizations.backup "${LOCAL_PREFIX}/share/cthulhu/cthulhu-customizations.py"
|
|
fi
|
|
fi
|
|
|
|
# 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}" |