Using ./setup install instead of ./install.sh

This commit is contained in:
clsty
2025-10-19 08:44:12 +08:00
parent 0e6779fafc
commit 8ca46aecdd
10 changed files with 118 additions and 173 deletions
+1 -1
View File
@@ -29,7 +29,7 @@
<summary>Installation (illogical-impulse Quickshell)</summary> <summary>Installation (illogical-impulse Quickshell)</summary>
- Just run `bash <(curl -s https://ii.clsty.link/setup)` - 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. - 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: - **Default keybinds**: Should be somewhat familiar to Windows or GNOME users. Important ones:
- `Super`+`/` = keybind list - `Super`+`/` = keybind list
+6 -46
View File
@@ -1,48 +1,8 @@
#!/usr/bin/env bash #!/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")" cd "$(dirname "$0")"
# Use REPO_ROOT instead of base - when scripts are sourced they do not need export to inherit vars ./setup install "$@"
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
+17
View File
@@ -287,3 +287,20 @@ function check_disk_space() {
return 0 return 0
} }
function showhelp_global(){
echo -e "
Syntax:
$0 <subcommand> [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 <subcommand> -h
"
}
-74
View File
@@ -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 <set> (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
@@ -2,7 +2,7 @@
# shellcheck shell=bash # shellcheck shell=bash
showhelp(){ showhelp(){
echo -e "Usage: install.sh exp-update [OPTIONS]... echo -e "Usage: $0 exp-update [OPTIONS]...
Experimental updating without full reinstall. Experimental updating without full reinstall.
Updates dotfiles by syncing configuration files to home directory. Updates dotfiles by syncing configuration files to home directory.
@@ -62,18 +62,24 @@ eval set -- "$para"
while true ; do while true ; do
case "$1" in case "$1" in
## Ones without parameter ## Ones without parameter
-f|--force) FORCE_CHECK=true;shift;; -f|--force) FORCE_CHECK=true;shift
# log_info "Force check mode enabled - will check all files regardless of git changes" 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" -p|--packages) CHECK_PACKAGES=true;shift
-n|--dry-run) DRY_RUN=true;shift;; log_info "Package checking enabled"
# log_info "Dry-run mode enabled - no changes will be made" ;;
-v|--verbose) VERBOSE=true;shift;; -n|--dry-run) DRY_RUN=true;shift
# log_info "Verbose mode enabled" log_info "Dry-run mode enabled - no changes will be made"
--skip-notice) SKIP_NOTICE=true;shift;; ;;
# log_warning "Skipping notice about script being untested" -v|--verbose) VERBOSE=true;shift
--non-interactive) NON_INTERACTIVE=true;shift;; log_info "Verbose mode enabled"
# log_info "Non-interactive 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 ## Ending
--) break ;; --) break ;;
@@ -1,9 +1,9 @@
# Handle args for subcmd: install # Handle args for subcmd: install
# shellcheck shell=bash # shellcheck shell=bash
showhelp(){ showhelp(){
echo -e "Syntax: $0 [OPTIONS]... echo -e "Syntax: $0 install [OPTIONS]...
Idempotent installation script for dotfiles. Idempotent installation for dotfiles.
Options for install: Options for install:
-h, --help Print this help message and exit -h, --help Print this help message and exit
+2 -2
View File
@@ -5,7 +5,7 @@
printf 'Hi there!\n' printf 'Hi there!\n'
printf 'This script 1. will uninstall [end-4/dots-hyprland > illogical-impulse] dotfiles\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 ' 3. has not been tested, use at your own risk.\n'
printf ' 4. will show all commands that it runs.\n' printf ' 4. will show all commands that it runs.\n'
printf 'Ctrl+C to exit. Enter to continue.\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 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}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}"
+15 -34
View File
@@ -75,29 +75,11 @@ run_test() {
fi 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 2: Script has no syntax errors
test_syntax() { test_syntax() {
log_test "Checking script syntax" log_test "Checking script syntax"
if bash -n install.sh; then if bash -n setup; then
log_pass "No syntax errors found" log_pass "No syntax errors found"
return 0 return 0
else else
@@ -110,7 +92,7 @@ test_syntax() {
test_help_option() { test_help_option() {
log_test "Testing --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" log_pass "Help option works"
return 0 return 0
else else
@@ -411,11 +393,11 @@ test_dry_run() {
cd "$test_repo" || { log_fail "Failed to cd to test directory"; return 1; } cd "$test_repo" || { log_fail "Failed to cd to test directory"; return 1; }
# Copy necessary files for install.sh to run # Copy necessary files for setup to run
cp "$ORIGINAL_DIR/install.sh" . cp "$ORIGINAL_DIR/setup" .
cp -r "$ORIGINAL_DIR/sdata" . cp -r "$ORIGINAL_DIR/sdata" .
cp -r "$ORIGINAL_DIR/dots" . cp -r "$ORIGINAL_DIR/dots" .
chmod +x install.sh chmod +x setup
# Create a test config file in repo # Create a test config file in repo
mkdir -p dots/.config/test-app mkdir -p dots/.config/test-app
@@ -428,7 +410,7 @@ test_dry_run() {
rm -rf "${HOME}/.config/test-app" 2>/dev/null || true rm -rf "${HOME}/.config/test-app" 2>/dev/null || true
# Use non-interactive mode and check for DRY-RUN marker # 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 if grep -q "DRY-RUN" dry_run_output.txt; then
log_pass "Dry-run mode detected in output" log_pass "Dry-run mode detected in output"
@@ -461,7 +443,7 @@ test_flags() {
local all_passed=true local all_passed=true
for flag in "${flags[@]}"; do 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" log_test "$flag recognized"
else else
log_test "$flag not recognized" log_test "$flag not recognized"
@@ -487,7 +469,7 @@ test_shellcheck() {
return 0 return 0
fi 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" log_pass "shellcheck passed"
return 0 return 0
else else
@@ -507,10 +489,10 @@ test_lock_file() {
cd "$test_repo" || { log_fail "Failed to cd to test directory"; return 1; } cd "$test_repo" || { log_fail "Failed to cd to test directory"; return 1; }
# Copy necessary files # Copy necessary files
cp "$ORIGINAL_DIR/install.sh" . cp "$ORIGINAL_DIR/setup" .
cp -r "$ORIGINAL_DIR/sdata" . cp -r "$ORIGINAL_DIR/sdata" .
mkdir -p dots/.config mkdir -p dots/.config
chmod +x install.sh chmod +x setup
git add . git add .
git commit -m "Add files" -q git commit -m "Add files" -q
@@ -519,7 +501,7 @@ test_lock_file() {
echo "99999" > .update-lock echo "99999" > .update-lock
# Try to run update - should fail due to 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 if grep -q "stale lock" lock_test_output.txt; then
log_pass "Lock file mechanism works (detected stale lock)" log_pass "Lock file mechanism works (detected stale lock)"
cd "$ORIGINAL_DIR" cd "$ORIGINAL_DIR"
@@ -777,16 +759,15 @@ main() {
echo -e "${BLUE} Update.sh Test Suite (Enhanced)${NC}" echo -e "${BLUE} Update.sh Test Suite (Enhanced)${NC}"
echo -e "${BLUE}================================${NC}\n" echo -e "${BLUE}================================${NC}\n"
if [[ ! -f "install.sh" ]]; then if [[ ! -f "setup" ]]; then
log_error "Please run this test from the directory containing install.sh" log_error "Please run this test from the directory containing setup"
exit 1 exit 1
fi fi
chmod +x install.sh 2>/dev/null || true chmod +x setup 2>/dev/null || true
# Define tests # Define tests
tests=( tests=(
"test_script_exists"
"test_syntax" "test_syntax"
"test_help_option" "test_help_option"
"test_dots_structure" "test_dots_structure"
@@ -844,4 +825,4 @@ trap cleanup EXIT INT TERM
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main "$@" main "$@"
fi fi
+1 -1
View File
@@ -748,7 +748,7 @@ if [[ "$SKIP_NOTICE" == false ]]; then
log_warning "THIS SCRIPT IS NOT FULLY TESTED AND MAY CAUSE ISSUES!" 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 "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 " 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" safe_read "Continue? (y/N): " response "N"
if [[ ! "$response" =~ ^[Yy]$ ]]; then if [[ ! "$response" =~ ^[Yy]$ ]]; then
Executable
+55
View File
@@ -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