Bring back old update.sh (#2284)

This commit is contained in:
clsty
2025-10-25 08:11:42 +08:00
parent 7662e4f904
commit d8aa0de443
3 changed files with 17 additions and 86 deletions
+15 -36
View File
@@ -4,37 +4,28 @@
showhelp(){ showhelp(){
echo -e "Syntax: $0 exp-update-old [OPTIONS]... echo -e "Syntax: $0 exp-update-old [OPTIONS]...
Experimental updating without full reinstall.
Updates dotfiles by syncing configuration files to home directory.
Options: Options:
-f, --force Force check all files even if no new commits -f, --force Force check all files even if no new commits
-p, --packages Enable package checking and building -p, --packages Enable package checking and building
-n, --dry-run Show what would be done without making changes -h, --help Show this help message
-v, --verbose Enable verbose output --skip-notice Skip the notice message at the beginning
-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: It updates your dotfiles by:
1. Auto-detecting repository structure (dots/ prefix or direct) 1. Pulling latest changes from git remote
2. Pulling latest changes from git remote 2. Optionally rebuilding packages (if -p flag is used)
3. Optionally rebuilding packages (if -p flag is used) 3. Syncing configuration files
4. Syncing configuration files to home directory 4. Updating script permissions
5. Updating script permissions
Ignore file patterns support: Package modes (when -p is used):
- Exact matches (e.g., 'path/to/file') - If no PKGBUILDs changed: asks if you want to check packages anyway
- Directory patterns (e.g., 'path/to/dir/') - If PKGBUILDs changed: offers to build changed packages
- Wildcards (e.g., '*.log', 'path/*/file') - Interactive selection of packages to build
- Root-relative patterns (e.g., '/.config')
- Substring matching (prefix with '**', e.g., '**temp' matches any path containing 'temp')
" "
} }
# `man getopt` to see more # `man getopt` to see more
para=$(getopt \ para=$(getopt \
-o hfpnv \ -o hfp \
-l help,force,packages,dry-run,verbose,skip-notice,non-interactive \ -l help,force,packages,skip-notice \
-n "$0" -- "$@") -n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1 [ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
##################################################################################### #####################################################################################
@@ -53,10 +44,7 @@ done
FORCE_CHECK=false FORCE_CHECK=false
CHECK_PACKAGES=false CHECK_PACKAGES=false
DRY_RUN=false
VERBOSE=false
SKIP_NOTICE=false SKIP_NOTICE=false
NON_INTERACTIVE=false
eval set -- "$para" eval set -- "$para"
while true ; do while true ; do
@@ -68,18 +56,9 @@ while true ; do
-p|--packages) CHECK_PACKAGES=true;shift -p|--packages) CHECK_PACKAGES=true;shift
log_info "Package checking enabled" 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 --skip-notice) SKIP_NOTICE=true;shift
log_warning "Skipping notice about script being untested" 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 -49
View File
@@ -472,55 +472,7 @@ has_new_commits() {
# Main script starts here # Main script starts here
log_header "Dotfiles Update Script" log_header "Dotfiles Update Script"
check=true if [[ "${SKIP_NOTICE}" == false ]]; then
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
-f | --force)
FORCE_CHECK=true
log_info "Force check mode enabled - will check all files regardless of git changes"
shift
;;
-p | --packages)
CHECK_PACKAGES=true
log_info "Package checking enabled"
shift
;;
-h | --help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " -f, --force Force check all files even if no new commits"
echo " -p, --packages Enable package checking and building"
echo " -h, --help Show this help message"
echo ""
echo "This script updates your dotfiles by:"
echo " 1. Pulling latest changes from git remote"
echo " 2. Optionally rebuilding packages (if -p flag is used)"
echo " 3. Syncing configuration files"
echo " 4. Updating script permissions"
echo ""
echo "Package modes (when -p is used):"
echo " - If no PKGBUILDs changed: asks if you want to check packages anyway"
echo " - If PKGBUILDs changed: offers to build changed packages"
echo " - Interactive selection of packages to build"
exit 0
;;
--skip-notice)
log_warning "Skipping notice about script being untested"
check=false
shift
;;
*)
log_error "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
if [[ "$check" == true ]]; 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."
+1 -1
View File
@@ -23,7 +23,7 @@ Subcommands:
install-files Run the install step \"3. Copying config files\" install-files Run the install step \"3. Copying config files\"
exp-uninstall (Experimental) Uninstall illogical-impulse. exp-uninstall (Experimental) Uninstall illogical-impulse.
exp-update (Experimental) Update illogical-impulse without fully reinstall. exp-update (Experimental) Update illogical-impulse without fully reinstall.
exp-update-old (WIP) exp-update but use behaves like old version. exp-update-old (Experimental) exp-update but use behaves like old version.
help Show this help message. help Show this help message.
For each <subcommand>, use -h for details: For each <subcommand>, use -h for details: