Migrated to meson/ninja for building. There may be bugs. Thanks Claud for the assist.
This commit is contained in:
209
clean-local.sh
209
clean-local.sh
@@ -1,118 +1,109 @@
|
||||
#!/bin/bash
|
||||
# Clean script for Cthulhu development
|
||||
# Removes build artifacts and optionally uninstalls local installation
|
||||
#
|
||||
# Clean script for Cthulhu screen reader Meson build
|
||||
# This script removes build artifacts and optionally the local installation
|
||||
#
|
||||
|
||||
set -e
|
||||
set -e # Exit on error
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
# Colors for output (only if stdout is a terminal)
|
||||
if [[ -t 1 ]]; then
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
else
|
||||
RED=''
|
||||
GREEN=''
|
||||
YELLOW=''
|
||||
BLUE=''
|
||||
NC=''
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}=== Cthulhu Clean Script ===${NC}"
|
||||
echo -e "${BLUE}Cthulhu Meson Clean Script${NC}"
|
||||
echo "Cleaning build artifacts and local installation"
|
||||
echo "=============================================="
|
||||
|
||||
LOCAL_PREFIX="$HOME/.local"
|
||||
# Clean build directory
|
||||
if [[ -d "_build" ]]; then
|
||||
echo -e "${YELLOW}Removing build directory...${NC}"
|
||||
rm -rf _build
|
||||
echo -e "${GREEN}Build directory cleaned${NC}"
|
||||
else
|
||||
echo "No build directory found"
|
||||
fi
|
||||
|
||||
# Function to clean build artifacts
|
||||
clean_build() {
|
||||
echo -e "${YELLOW}Cleaning build artifacts...${NC}"
|
||||
# Ask about local installation cleanup
|
||||
echo
|
||||
read -p "Remove local installation from ~/.local? (y/N): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo -e "${YELLOW}Removing local installation...${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 and UI files
|
||||
if [[ -d "${LOCAL_PREFIX}/share/cthulhu" ]]; then
|
||||
# Backup user settings and UI files 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
|
||||
if [[ -d "${LOCAL_PREFIX}/share/cthulhu/ui" ]]; then
|
||||
cp -r "${LOCAL_PREFIX}/share/cthulhu/ui" /tmp/cthulhu-ui.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
|
||||
if [[ -d /tmp/cthulhu-ui.backup ]]; then
|
||||
mv /tmp/cthulhu-ui.backup "${LOCAL_PREFIX}/share/cthulhu/ui"
|
||||
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}"
|
||||
# Remove binary
|
||||
if [[ -f "$HOME/.local/bin/cthulhu" ]]; then
|
||||
rm -f "$HOME/.local/bin/cthulhu"
|
||||
echo " Removed: ~/.local/bin/cthulhu"
|
||||
fi
|
||||
}
|
||||
|
||||
# Remove Python modules
|
||||
PYTHON_SITE="$HOME/.local/lib/python$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')/site-packages"
|
||||
if [[ -d "$PYTHON_SITE/cthulhu" ]]; then
|
||||
rm -rf "$PYTHON_SITE/cthulhu"
|
||||
echo " Removed: $PYTHON_SITE/cthulhu/"
|
||||
fi
|
||||
|
||||
# Remove data files
|
||||
if [[ -d "$HOME/.local/share/cthulhu" ]]; then
|
||||
rm -rf "$HOME/.local/share/cthulhu"
|
||||
echo " Removed: ~/.local/share/cthulhu/"
|
||||
fi
|
||||
|
||||
# Remove desktop files
|
||||
if [[ -f "$HOME/.local/share/applications/cthulhu-autostart.desktop" ]]; then
|
||||
rm -f "$HOME/.local/share/applications/cthulhu-autostart.desktop"
|
||||
echo " Removed: ~/.local/share/applications/cthulhu-autostart.desktop"
|
||||
fi
|
||||
|
||||
# Remove icons
|
||||
for size in 16x16 22x22 24x24 32x32 48x48 256x256 scalable symbolic; do
|
||||
icon_path="$HOME/.local/share/icons/hicolor/$size/apps"
|
||||
if [[ -f "$icon_path/cthulhu.png" ]]; then
|
||||
rm -f "$icon_path/cthulhu.png"
|
||||
echo " Removed: $icon_path/cthulhu.png"
|
||||
fi
|
||||
if [[ -f "$icon_path/cthulhu.svg" ]]; then
|
||||
rm -f "$icon_path/cthulhu.svg"
|
||||
echo " Removed: $icon_path/cthulhu.svg"
|
||||
fi
|
||||
if [[ -f "$icon_path/cthulhu-symbolic.svg" ]]; then
|
||||
rm -f "$icon_path/cthulhu-symbolic.svg"
|
||||
echo " Removed: $icon_path/cthulhu-symbolic.svg"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove man page
|
||||
if [[ -f "$HOME/.local/share/man/man1/cthulhu.1" ]]; then
|
||||
rm -f "$HOME/.local/share/man/man1/cthulhu.1"
|
||||
echo " Removed: ~/.local/share/man/man1/cthulhu.1"
|
||||
fi
|
||||
|
||||
# Update caches
|
||||
if command -v update-desktop-database &> /dev/null; then
|
||||
echo -e "${YELLOW}Updating desktop database...${NC}"
|
||||
update-desktop-database "$HOME/.local/share/applications" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if command -v gtk-update-icon-cache &> /dev/null; then
|
||||
echo -e "${YELLOW}Updating icon cache...${NC}"
|
||||
gtk-update-icon-cache -f -t "$HOME/.local/share/icons/hicolor" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Local installation cleaned${NC}"
|
||||
else
|
||||
echo "Local installation preserved"
|
||||
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}"
|
||||
echo
|
||||
echo -e "${GREEN}Cleanup completed!${NC}"
|
||||
Reference in New Issue
Block a user