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
+88
View File
@@ -0,0 +1,88 @@
# Handle args for subcmd: exp-update
# shellcheck shell=bash
showhelp(){
echo -e "Usage: $0 exp-update [OPTIONS]...
Experimental updating without full reinstall.
Updates dotfiles by syncing configuration files to home directory.
Options:
-f, --force Force check all files even if no new commits
-p, --packages Enable package checking and building
-n, --dry-run Show what would be done without making changes
-v, --verbose Enable verbose output
-h, --help Show this help message
-s, --skip-notice Skip notice about script being untested
--non-interactive Run without prompting for user input
This script updates your dotfiles by:
1. Auto-detecting repository structure (dots/ prefix or direct)
2. Pulling latest changes from git remote
3. Optionally rebuilding packages (if -p flag is used)
4. Syncing configuration files to home directory
5. Updating script permissions
Ignore file patterns support:
- Exact matches (e.g., 'path/to/file')
- Directory patterns (e.g., 'path/to/dir/')
- Wildcards (e.g., '*.log', 'path/*/file')
- Root-relative patterns (e.g., '/.config')
- Substring matching (prefix with '**', e.g., '**temp' matches any path containing 'temp')
"
}
# `man getopt` to see more
para=$(getopt \
-o hfpnv \
-l help,force,packages,dry-run,verbose,skip-notice,non-interactive \
-n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
#####################################################################################
## getopt Phase 1
# ignore parameter's order, execute options below first
eval set -- "$para"
while true ; do
case "$1" in
-h|--help) showhelp;exit;;
--) break ;;
*) shift ;;
esac
done
#####################################################################################
## getopt Phase 2
FORCE_CHECK=false
CHECK_PACKAGES=false
DRY_RUN=false
VERBOSE=false
SKIP_NOTICE=false
NON_INTERACTIVE=false
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"
;;
## Ending
--) break ;;
*) echo -e "$0: Wrong parameters.";exit 1;;
esac
done
+83
View File
@@ -0,0 +1,83 @@
# Handle args for subcmd: install
# shellcheck shell=bash
showhelp(){
echo -e "Syntax: $0 install [OPTIONS]...
Idempotent installation for dotfiles.
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
"
}
cleancache(){
rm -rf "${REPO_ROOT}/cache"
}
# `man getopt` to see more
para=$(getopt \
-o hfk:cs \
-l help,force,fontset:,clean,skip-allgreeting,skip-alldeps,skip-allsetups,skip-allfiles,skip-sysupdate,skip-fish,skip-hyprland,skip-plasmaintg,skip-miscconf,exp-files,via-nix \
-n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
#####################################################################################
## getopt Phase 1
# ignore parameter's order, execute options below first
eval set -- "$para"
while true ; do
case "$1" in
-h|--help) showhelp;exit;;
-c|--clean) cleancache;shift;;
--) break ;;
*) shift ;;
esac
done
#####################################################################################
## getopt Phase 2
eval set -- "$para"
while true ; do
case "$1" in
## Already processed in phase 1, but not exited
-c|--clean) shift;;
## Ones without parameter
-f|--force) ask=false;shift;;
--skip-allgreeting) SKIP_ALLGREETING=true;shift;;
--skip-alldeps) SKIP_ALLDEPS=true;shift;;
--skip-allsetups) SKIP_ALLSETUPS=true;shift;;
--skip-allfiles) SKIP_ALLFILES=true;shift;;
-s|--skip-sysupdate) SKIP_SYSUPDATE=true;shift;;
--skip-hyprland) SKIP_HYPRLAND=true;shift;;
--skip-fish) SKIP_FISH=true;shift;;
--skip-miscconf) SKIP_MISCCONF=true;shift;;
--skip-plasmaintg) SKIP_PLASMAINTG=true;shift;;
--exp-files) EXPERIMENTAL_FILES_SCRIPT=true;shift;;
--via-nix) INSTALL_VIA_NIX=true;shift;;
## Ones with parameter
--fontset)
case $2 in
"default"|"zh-CN"|"vi") fontset="$2";;
*) echo -e "Wrong argument for $1.";exit 1;;
esac;echo "The fontset is ${fontset}.";shift 2;;
## Ending
--) break ;;
*) echo -e "$0: Wrong parameters.";exit 1;;
esac
done