diff --git a/README.md b/README.md index 4bdbbeb10..ab8306427 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Installation (illogical-impulse Quickshell) - Just run `bash <(curl -s https://ii.clsty.link/setup)` - - Or, clone this repo and run `./install.sh` + - Or, clone this repo and run `./setup install` - See [document](https://ii.clsty.link/en/ii-qs/01setup/) for details. - **Default keybinds**: Should be somewhat familiar to Windows or GNOME users. Important ones: - `Super`+`/` = keybind list diff --git a/install.sh b/install.sh index a6650e2f9..c8b7e8118 100755 --- a/install.sh +++ b/install.sh @@ -1,48 +1,8 @@ #!/usr/bin/env bash +# TODO: Remove this script after 2025.12.01 +STY_RED='\e[31m' +STY_RST='\e[00m' +printf "${STY_RED}You are using \"./install.sh\" which is kept for compatibility and will be removed in future.\n" +printf "Please use \"./setup install\" instead.${STY_RST}\n" cd "$(dirname "$0")" -# Use REPO_ROOT instead of base - when scripts are sourced they do not need export to inherit vars -REPO_ROOT="$(pwd)" -source ./sdata/lib/environment-variables.sh -source ./sdata/lib/functions.sh -source ./sdata/lib/package-installers.sh -source ./sdata/lib/options.sh - -prevent_sudo_or_root -set -e - -##################################################################################### -# For subcommands -case ${SCRIPT_SUBCOMMAND} in - exp-uninstall) - source ./sdata/step/exp-uninstall.sh - exit - ;; - exp-update) - source ./sdata/step/exp-update.sh - exit - ;; -esac -##################################################################################### -# 0. Before we start -if [[ "${SKIP_ALLGREETING}" != true ]]; then - source ./sdata/step/0.install-greeting.sh -fi -##################################################################################### -if [[ "${SKIP_ALLDEPS}" != true ]]; then - printf "${STY_CYAN}[$0]: 1. Install dependencies\n${STY_RST}" - source ./sdata/step/1.install-deps-selector.sh -fi -##################################################################################### -if [[ "${SKIP_ALLSETUPS}" != true ]]; then - printf "${STY_CYAN}[$0]: 2. Setup for permissions/services etc\n${STY_RST}" - source ./sdata/step/2.install-setups-selector.sh -fi -##################################################################################### -if [[ "${SKIP_ALLFILES}" != true ]]; then - printf "${STY_CYAN}[$0]: 3. Copying config files\n${STY_RST}" - if [[ "${EXPERIMENTAL_FILES_SCRIPT}" == true ]]; then - source ./sdata/step/3.install-files.experimental.sh - else - source ./sdata/step/3.install-files.sh - fi -fi +./setup install "$@" diff --git a/sdata/lib/functions.sh b/sdata/lib/functions.sh index 496397f83..c1aa6504e 100644 --- a/sdata/lib/functions.sh +++ b/sdata/lib/functions.sh @@ -287,3 +287,20 @@ function check_disk_space() { return 0 } + +function showhelp_global(){ +echo -e " + +Syntax: + $0 [OPTIONS]... + +Subcommands: + install Idempotent installation for dotfiles. + exp-uninstall Experimental uninstall + exp-update Experimental update + help Show this help message + +Please run the following for details: + $0 -h +" +} diff --git a/sdata/lib/options.sh b/sdata/lib/options.sh deleted file mode 100644 index cc4fdeddc..000000000 --- a/sdata/lib/options.sh +++ /dev/null @@ -1,74 +0,0 @@ -# This is NOT a script for execution, but for loading functions, so NOT need execution permission or shebang. -# NOTE that you NOT need to `cd ..' because the `$0' is NOT this file, but the script file which will source this file. - -# shellcheck shell=bash - -showhelp_global(){ -echo -e "Syntax: $0 [subcommand] [options]... - -Idempotent installation script for dotfiles. -If no option nor subcommand is specified, run default install process. - -Subcommand: - install The default subcommand which can be omitted. -Options for install: - -h, --help Print this help message and exit - -f, --force (Dangerous) Force mode without any confirm - -c, --clean Clean the build cache first - --skip-allgreeting Skip the whole process greeting - --skip-alldeps Skip the whole process installing dependency - --skip-allsetups Skip the whole process setting up permissions/services etc - --skip-allfiles Skip the whole process copying configuration files - -s, --skip-sysupdate Skip system package upgrade e.g. \"sudo pacman -Syu\" - --skip-hyprland Skip installing the config for Hyprland - --skip-fish Skip installing the config for Fish - --skip-plasmaintg Skip installing plasma-browser-integration - --skip-miscconf Skip copying the dirs and files to \".configs\" except for - AGS, Fish and Hyprland - --exp-files Use experimental script for the third step copying files - --fontset (Unavailable yet) Use a set of pre-defined font and config - --via-nix (Unavailable yet) Use Nix to install dependencies - -Subcommand: - exp-uninstall Using experimental uninstall script. - -Subcommand: - exp-update Using experimental update script. -Options for exp-update: - -f, --force Force check all files even if no new commits (update script) - -p, --packages Enable package checking and building (update script) - -n, --dry-run Show what would be done without making changes (update script) - -v, --verbose Enable verbose output (update script) - --skip-notice Skip warning notice (for experimental scripts) - --non-interactive Run without prompting for user input -" -} - -# Handle subcommand -case $1 in - # subcommand specified - install|exp-uninstall|exp-update) - SCRIPT_SUBCOMMAND=$1 - shift - ;; - # Global help - help|--help|-h) - showhelp_global;exit - ;; - # no subcommand (has options: -* ; no options: "") - -*|"") - SCRIPT_SUBCOMMAND=install - ;; - # wrong subcommand - *)echo "Unknown subcommand \"$1\", aborting...";exit 1;; -esac - -# Handle options for subcommand -case ${SCRIPT_SUBCOMMAND} in - install) - source ./sdata/lib/options-install.sh - ;; - exp-update) - source ./sdata/lib/options-exp-update.sh - ;; -esac diff --git a/sdata/lib/options-exp-update.sh b/sdata/options/exp-update.sh similarity index 76% rename from sdata/lib/options-exp-update.sh rename to sdata/options/exp-update.sh index d815e9172..b28a3dd82 100644 --- a/sdata/lib/options-exp-update.sh +++ b/sdata/options/exp-update.sh @@ -2,7 +2,7 @@ # shellcheck shell=bash showhelp(){ -echo -e "Usage: install.sh exp-update [OPTIONS]... +echo -e "Usage: $0 exp-update [OPTIONS]... Experimental updating without full reinstall. Updates dotfiles by syncing configuration files to home directory. @@ -62,18 +62,24 @@ eval set -- "$para" while true ; do case "$1" in ## Ones without parameter - -f|--force) FORCE_CHECK=true;shift;; - # log_info "Force check mode enabled - will check all files regardless of git changes" - -p|--packages) CHECK_PACKAGES=true;shift;; - # log_info "Package checking enabled" - -n|--dry-run) DRY_RUN=true;shift;; - # log_info "Dry-run mode enabled - no changes will be made" - -v|--verbose) VERBOSE=true;shift;; - # log_info "Verbose mode enabled" - --skip-notice) SKIP_NOTICE=true;shift;; - # log_warning "Skipping notice about script being untested" - --non-interactive) NON_INTERACTIVE=true;shift;; - # log_info "Non-interactive mode enabled" + -f|--force) FORCE_CHECK=true;shift + log_info "Force check mode enabled - will check all files regardless of git changes" + ;; + -p|--packages) CHECK_PACKAGES=true;shift + log_info "Package checking enabled" + ;; + -n|--dry-run) DRY_RUN=true;shift + log_info "Dry-run mode enabled - no changes will be made" + ;; + -v|--verbose) VERBOSE=true;shift + log_info "Verbose mode enabled" + ;; + --skip-notice) SKIP_NOTICE=true;shift + log_warning "Skipping notice about script being untested" + ;; + --non-interactive) NON_INTERACTIVE=true;shift + log_info "Non-interactive mode enabled" + ;; ## Ending --) break ;; diff --git a/sdata/lib/options-install.sh b/sdata/options/install.sh similarity index 97% rename from sdata/lib/options-install.sh rename to sdata/options/install.sh index 6d5cab787..0093e106b 100644 --- a/sdata/lib/options-install.sh +++ b/sdata/options/install.sh @@ -1,9 +1,9 @@ # Handle args for subcmd: install # shellcheck shell=bash showhelp(){ -echo -e "Syntax: $0 [OPTIONS]... +echo -e "Syntax: $0 install [OPTIONS]... -Idempotent installation script for dotfiles. +Idempotent installation for dotfiles. Options for install: -h, --help Print this help message and exit diff --git a/sdata/step/exp-uninstall.sh b/sdata/step/exp-uninstall.sh index 44525fd36..17aae32b4 100644 --- a/sdata/step/exp-uninstall.sh +++ b/sdata/step/exp-uninstall.sh @@ -5,7 +5,7 @@ printf 'Hi there!\n' printf 'This script 1. will uninstall [end-4/dots-hyprland > illogical-impulse] dotfiles\n' -printf ' 2. will try to revert *mostly everything* installed using install.sh, so it'\''s pretty destructive\n' +printf ' 2. will try to revert *mostly everything* installed using "./setup install", so it'\''s pretty destructive\n' printf ' 3. has not been tested, use at your own risk.\n' printf ' 4. will show all commands that it runs.\n' printf 'Ctrl+C to exit. Enter to continue.\n' @@ -77,4 +77,4 @@ Ctrl+C to exit, or press Enter to proceed" p v yay -Rns illogical-impulse-{audio,backlight,basic,bibata-modern-classic-bin,fonts-themes,hyprland,kde,microtex-git,oneui4-icons-git,portal,python,screencapture,toolkit,widgets} plasma-browser-integration printf "${STY_CYAN}Uninstall Complete.\n${STY_RST}" -printf "${STY_CYAN}Hint: If you had agreed to backup when you ran \"install.sh\", you should be able to find it under \"$BACKUP_DIR\".\n${STY_RST}" +printf "${STY_CYAN}Hint: If you had agreed to backup when you ran \"./setup install\", you should be able to find it under \"$BACKUP_DIR\".\n${STY_RST}" diff --git a/sdata/step/exp-update-tester.sh b/sdata/step/exp-update-tester.sh index 6b6dc9e6e..668ca7bb5 100755 --- a/sdata/step/exp-update-tester.sh +++ b/sdata/step/exp-update-tester.sh @@ -75,29 +75,11 @@ run_test() { fi } -# Test 1: Script exists and is executable -test_script_exists() { - log_test "Checking if install.sh exists and is executable" - - if [[ ! -f "install.sh" ]]; then - log_fail "install.sh not found" - return 1 - fi - - if [[ ! -x "install.sh" ]]; then - log_fail "install.sh is not executable" - return 1 - fi - - log_pass "Script exists and is executable" - return 0 -} - # Test 2: Script has no syntax errors test_syntax() { log_test "Checking script syntax" - if bash -n install.sh; then + if bash -n setup; then log_pass "No syntax errors found" return 0 else @@ -110,7 +92,7 @@ test_syntax() { test_help_option() { log_test "Testing --help option" - if ./install.sh exp-update --help 2>&1 | grep -qiE "(Usage|Options|exp-update)"; then + if ./setup exp-update --help 2>&1 | grep -qiE "(Usage|Options|exp-update)"; then log_pass "Help option works" return 0 else @@ -411,11 +393,11 @@ test_dry_run() { cd "$test_repo" || { log_fail "Failed to cd to test directory"; return 1; } - # Copy necessary files for install.sh to run - cp "$ORIGINAL_DIR/install.sh" . + # Copy necessary files for setup to run + cp "$ORIGINAL_DIR/setup" . cp -r "$ORIGINAL_DIR/sdata" . cp -r "$ORIGINAL_DIR/dots" . - chmod +x install.sh + chmod +x setup # Create a test config file in repo mkdir -p dots/.config/test-app @@ -428,7 +410,7 @@ test_dry_run() { rm -rf "${HOME}/.config/test-app" 2>/dev/null || true # Use non-interactive mode and check for DRY-RUN marker - ./install.sh exp-update -n --skip-notice --non-interactive 2>&1 | tee dry_run_output.txt + ./setup exp-update -n --skip-notice --non-interactive 2>&1 | tee dry_run_output.txt if grep -q "DRY-RUN" dry_run_output.txt; then log_pass "Dry-run mode detected in output" @@ -461,7 +443,7 @@ test_flags() { local all_passed=true for flag in "${flags[@]}"; do - if ./install.sh exp-update "$flag" 2>&1 | grep -qiE "(Usage|Options|exp-update)"; then + if ./setup exp-update "$flag" 2>&1 | grep -qiE "(Usage|Options|exp-update)"; then log_test " ✓ $flag recognized" else log_test " ✗ $flag not recognized" @@ -487,7 +469,7 @@ test_shellcheck() { return 0 fi - if shellcheck -e SC1090,SC1091,SC2148,SC2034,SC2155,SC2164 install.sh; then + if shellcheck -e SC1090,SC1091,SC2148,SC2034,SC2155,SC2164 setup then log_pass "shellcheck passed" return 0 else @@ -507,10 +489,10 @@ test_lock_file() { cd "$test_repo" || { log_fail "Failed to cd to test directory"; return 1; } # Copy necessary files - cp "$ORIGINAL_DIR/install.sh" . + cp "$ORIGINAL_DIR/setup" . cp -r "$ORIGINAL_DIR/sdata" . mkdir -p dots/.config - chmod +x install.sh + chmod +x setup git add . git commit -m "Add files" -q @@ -519,7 +501,7 @@ test_lock_file() { echo "99999" > .update-lock # Try to run update - should fail due to lock - if ./install.sh exp-update --skip-notice --non-interactive > lock_test_output.txt 2>&1; then + if ./setup exp-update --skip-notice --non-interactive > lock_test_output.txt 2>&1; then if grep -q "stale lock" lock_test_output.txt; then log_pass "Lock file mechanism works (detected stale lock)" cd "$ORIGINAL_DIR" @@ -777,16 +759,15 @@ main() { echo -e "${BLUE} Update.sh Test Suite (Enhanced)${NC}" echo -e "${BLUE}================================${NC}\n" - if [[ ! -f "install.sh" ]]; then - log_error "Please run this test from the directory containing install.sh" + if [[ ! -f "setup" ]]; then + log_error "Please run this test from the directory containing setup" exit 1 fi - chmod +x install.sh 2>/dev/null || true + chmod +x setup 2>/dev/null || true # Define tests tests=( - "test_script_exists" "test_syntax" "test_help_option" "test_dots_structure" @@ -844,4 +825,4 @@ trap cleanup EXIT INT TERM if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then main "$@" -fi \ No newline at end of file +fi diff --git a/sdata/step/exp-update.sh b/sdata/step/exp-update.sh index 9b7aa79ae..7949803cd 100644 --- a/sdata/step/exp-update.sh +++ b/sdata/step/exp-update.sh @@ -748,7 +748,7 @@ if [[ "$SKIP_NOTICE" == false ]]; then log_warning "THIS SCRIPT IS NOT FULLY TESTED AND MAY CAUSE ISSUES!" log_warning "It might be safer if you want to preserve your modifications and not delete added files," log_warning " but this can cause partial updates and therefore unexpected behavior like in #1856." - log_warning "In general, prefer install.sh for updates if available." + log_warning "In general, prefer \"./setup install\" for updates if available." safe_read "Continue? (y/N): " response "N" if [[ ! "$response" =~ ^[Yy]$ ]]; then diff --git a/setup b/setup new file mode 100755 index 000000000..706850208 --- /dev/null +++ b/setup @@ -0,0 +1,55 @@ +#!/usr/bin/env bash +cd "$(dirname "$0")" +# Use REPO_ROOT instead of base - when scripts are sourced they do not need export to inherit vars +REPO_ROOT="$(pwd)" +source ./sdata/lib/environment-variables.sh +source ./sdata/lib/functions.sh +source ./sdata/lib/package-installers.sh + +prevent_sudo_or_root +set -e + +##################################################################################### +case $1 in + # Global help + ""|help|--help|-h) showhelp_global;exit;; + # Correct subcommand + install|exp-uninstall|exp-update) SCRIPT_SUBCOMMAND=$1;shift;; + # Wrong subcommand + *)echo "Unknown subcommand \"$1\", aborting...";exit 1;; +esac +##################################################################################### +case ${SCRIPT_SUBCOMMAND} in + exp-uninstall) + #source ./sdata/options/exp-install.sh + source ./sdata/step/exp-uninstall.sh + exit + ;; + exp-update) + source ./sdata/options/exp-update.sh + source ./sdata/step/exp-update.sh + exit + ;; + install) + source ./sdata/options/install.sh + if [[ "${SKIP_ALLGREETING}" != true ]]; then + source ./sdata/step/0.install-greeting.sh + fi + if [[ "${SKIP_ALLDEPS}" != true ]]; then + printf "${STY_CYAN}[$0]: 1. Install dependencies\n${STY_RST}" + source ./sdata/step/1.install-deps-selector.sh + fi + if [[ "${SKIP_ALLSETUPS}" != true ]]; then + printf "${STY_CYAN}[$0]: 2. Setup for permissions/services etc\n${STY_RST}" + source ./sdata/step/2.install-setups-selector.sh + fi + if [[ "${SKIP_ALLFILES}" != true ]]; then + printf "${STY_CYAN}[$0]: 3. Copying config files\n${STY_RST}" + if [[ "${EXPERIMENTAL_FILES_SCRIPT}" == true ]]; then + source ./sdata/step/3.install-files.experimental.sh + else + source ./sdata/step/3.install-files.sh + fi + fi + ;; +esac