From 918997acfa7b56eaf9e15f785809fc48f8c5883d Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 16:38:43 +0800 Subject: [PATCH 01/10] Rearrange install scripts. This commit is a preparation for detection about whether a dist-/ folder is outdated. --- .../install-deps.sh | 0 .../install-setups.sh | 0 .../install-deps.sh | 0 .../install-setups.sh | 0 .../install-deps.sh | 0 .../install-setups.sh | 0 install.sh | 10 +++---- ...tall-greeting.sh => 0.install-greeting.sh} | 0 ...all-deps.sh => 1.install-deps-selector.sh} | 27 +++++++++++-------- ...setups.sh => 2.install-setups-selector.sh} | 27 +++++++++++-------- .../{install-files.sh => 3.install-files.sh} | 0 .../{installers.sh => package-installers.sh} | 0 12 files changed, 37 insertions(+), 27 deletions(-) rename scriptdata/install-deps-arch.sh => dist-arch/install-deps.sh (100%) rename scriptdata/install-setups-arch.sh => dist-arch/install-setups.sh (100%) rename scriptdata/install-deps-fallback.sh => dist-fallback/install-deps.sh (100%) rename scriptdata/install-setups-fallback.sh => dist-fallback/install-setups.sh (100%) rename scriptdata/install-deps-nix.sh => dist-nix/install-deps.sh (100%) rename scriptdata/install-setups-nix.sh => dist-nix/install-setups.sh (100%) rename scriptdata/{install-greeting.sh => 0.install-greeting.sh} (100%) rename scriptdata/{install-deps.sh => 1.install-deps-selector.sh} (81%) rename scriptdata/{install-setups.sh => 2.install-setups-selector.sh} (77%) rename scriptdata/{install-files.sh => 3.install-files.sh} (100%) rename scriptdata/{installers.sh => package-installers.sh} (100%) diff --git a/scriptdata/install-deps-arch.sh b/dist-arch/install-deps.sh similarity index 100% rename from scriptdata/install-deps-arch.sh rename to dist-arch/install-deps.sh diff --git a/scriptdata/install-setups-arch.sh b/dist-arch/install-setups.sh similarity index 100% rename from scriptdata/install-setups-arch.sh rename to dist-arch/install-setups.sh diff --git a/scriptdata/install-deps-fallback.sh b/dist-fallback/install-deps.sh similarity index 100% rename from scriptdata/install-deps-fallback.sh rename to dist-fallback/install-deps.sh diff --git a/scriptdata/install-setups-fallback.sh b/dist-fallback/install-setups.sh similarity index 100% rename from scriptdata/install-setups-fallback.sh rename to dist-fallback/install-setups.sh diff --git a/scriptdata/install-deps-nix.sh b/dist-nix/install-deps.sh similarity index 100% rename from scriptdata/install-deps-nix.sh rename to dist-nix/install-deps.sh diff --git a/scriptdata/install-setups-nix.sh b/dist-nix/install-setups.sh similarity index 100% rename from scriptdata/install-setups-nix.sh rename to dist-nix/install-setups.sh diff --git a/install.sh b/install.sh index 32f924cd2..63f64d6d8 100755 --- a/install.sh +++ b/install.sh @@ -3,7 +3,7 @@ cd "$(dirname "$0")" export base="$(pwd)" source ./scriptdata/environment-variables.sh source ./scriptdata/functions.sh -source ./scriptdata/installers.sh +source ./scriptdata/package-installers.sh source ./scriptdata/options.sh prevent_sudo_or_root @@ -11,19 +11,19 @@ set -e ##################################################################################### # 0. Before we start -source ./scriptdata/install-greeting.sh +source ./scriptdata/0.install-greeting.sh ##################################################################################### if [[ "${SKIP_ALLDEPS}" != true ]]; then printf "${STY_CYAN}[$0]: 1. Install dependencies\n${STY_RESET}" - source ./scriptdata/install-deps.sh + source ./scriptdata/1.install-deps-selector.sh fi ##################################################################################### if [[ "${SKIP_ALLSETUPS}" != true ]]; then printf "${STY_CYAN}[$0]: 2. Setup for permissions/services etc\n${STY_RESET}" - source ./scriptdata/install-setups.sh + source ./scriptdata/2.install-setups-selector.sh fi ##################################################################################### if [[ "${SKIP_ALLFILES}" != true ]]; then printf "${STY_CYAN}[$0]: 3. Copying config files\n${STY_RESET}" - source ./scriptdata/install-files.sh + source ./scriptdata/3.install-files.sh fi diff --git a/scriptdata/install-greeting.sh b/scriptdata/0.install-greeting.sh similarity index 100% rename from scriptdata/install-greeting.sh rename to scriptdata/0.install-greeting.sh diff --git a/scriptdata/install-deps.sh b/scriptdata/1.install-deps-selector.sh similarity index 81% rename from scriptdata/install-deps.sh rename to scriptdata/1.install-deps-selector.sh index 379e524fb..cda6bdea3 100644 --- a/scriptdata/install-deps.sh +++ b/scriptdata/1.install-deps-selector.sh @@ -34,6 +34,7 @@ export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolo if [[ "$INSTALL_VIA_NIX" == "true" ]]; then + TARGET_ID=nix printf "${STY_YELLOW}" printf "===WARNING===\n" printf "Nix will be used to install dependencies.\n" @@ -42,25 +43,27 @@ if [[ "$INSTALL_VIA_NIX" == "true" ]]; then printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-deps-nix.sh + source ./dist-${TARGET_ID}/install-deps.sh elif [[ "$OS_DISTRO_ID" =~ ^(arch|endeavouros)$ ]]; then + TARGET_ID=arch printf "${STY_GREEN}" printf "===INFO===\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" - printf "./scriptdata/install-deps-arch.sh will be used.\n" + printf "./dist-${TARGET_ID}/install-deps.sh will be used.\n" printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-deps-arch.sh + source ./dist-${TARGET_ID}/install-deps.sh -elif [[ -f "./scriptdata/install-deps-${OS_DISTRO_ID}.sh" ]]; then +elif [[ -f "./dist-${OS_DISTRO_ID}/install-deps.sh" ]]; then + TARGET_ID=${OS_DISTRO_ID} printf "${STY_PURPLE}" printf "===NOTICE===\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" - printf "./scriptdata/install-deps-${OS_DISTRO_ID}.sh detected and will be used.\n" + printf "./dist-${TARGET_ID}/install-deps.sh will be used.\n" printf "This file is provided by the community.\n" printf "It is not officially supported by github:end-4/dots-hyprland .\n" printf "${STY_BG_PURPLE}" @@ -70,36 +73,38 @@ elif [[ -f "./scriptdata/install-deps-${OS_DISTRO_ID}.sh" ]]; then printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-deps-${OS_DISTRO_ID}.sh + source ./dist-${TARGET_ID}/install-deps.sh elif [[ "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then + TARGET_ID=arch printf "${STY_YELLOW}" printf "===WARNING===\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n" - printf "./scriptdata/install-deps-arch.sh will be used.\n" + printf "./dist-${TARGET_ID}/install-deps.sh will be used.\n" printf "Ideally, it should also work for your distro.\n" printf "Still, there is a chance that it not works as expected or even fails.\n" printf "Proceed only at your own risk.\n" printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-deps-arch.sh + source ./dist-${TARGET_ID}/install-deps.sh else + TARGET_ID=fallback printf "${STY_RED}" printf "${STY_BOLD}===URGENT===${STY_RED}\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n" - printf "./scriptdata/install-deps-${OS_DISTRO_ID}.sh not found.\n" - printf "./scriptdata/install-deps-fallback.sh will be used.\n" + printf "./dist-${OS_DISTRO_ID}/install-deps.sh not found.\n" + printf "./dist-${TARGET_ID}/install-deps.sh will be used.\n" printf "1. It may disrupt your system and will likely fail without your manual intervention.\n" printf "2. It's WIP and only contains small number of dependencies far from enough.\n" printf "Proceed only at your own risk.\n" printf "${STY_RESET}" pause - source ./scriptdata/install-deps-fallback.sh + source ./dist-${TARGET_ID}/install-deps.sh fi diff --git a/scriptdata/install-setups.sh b/scriptdata/2.install-setups-selector.sh similarity index 77% rename from scriptdata/install-setups.sh rename to scriptdata/2.install-setups-selector.sh index 4c513399b..44e97b2c3 100644 --- a/scriptdata/install-setups.sh +++ b/scriptdata/2.install-setups-selector.sh @@ -16,6 +16,7 @@ export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolo if [[ "$INSTALL_VIA_NIX" == "true" ]]; then + TARGET_ID=nix printf "${STY_YELLOW}" printf "===WARNING===\n" printf "Nix will be used to do setups.\n" @@ -24,25 +25,27 @@ if [[ "$INSTALL_VIA_NIX" == "true" ]]; then printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-setups-nix.sh + source ./dist-${TARGET_ID}/install-setups.sh elif [[ "$OS_DISTRO_ID" == "arch" ]]; then + TARGET_ID=arch printf "${STY_GREEN}" printf "===INFO===\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" - printf "./scriptdata/install-setups-arch.sh will be used.\n" + printf "./dist-${TARGET_ID}/install-setups.sh will be used.\n" printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-setups-arch.sh + source ./dist-${TARGET_ID}/install-setups.sh -elif [[ -f "./scriptdata/install-setups-${OS_DISTRO_ID}.sh" ]]; then +elif [[ -f "./dist-${OS_DISTRO_ID}/install-setups.sh" ]]; then + TARGET_ID=${OS_DISTRO_ID} printf "${STY_PURPLE}" printf "===NOTICE===\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" - printf "./scriptdata/install-setups-${OS_DISTRO_ID}.sh detected and will be used.\n" + printf "./dist-${TARGET_ID}/install-setups.sh will be used.\n" printf "This file is provided by the community.\n" printf "It is not officially supported by github:end-4/dots-hyprland .\n" printf "${STY_BG_PURPLE}" @@ -52,36 +55,38 @@ elif [[ -f "./scriptdata/install-setups-${OS_DISTRO_ID}.sh" ]]; then printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-setups-${OS_DISTRO_ID}.sh + source ./dist-${TARGET_ID}/install-setups.sh elif [[ "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then + TARGET_ID=arch printf "${STY_YELLOW}" printf "===WARNING===\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n" - printf "./scriptdata/install-setups-arch.sh will be used.\n" + printf "./dist-${TARGET_ID}/install-setups.sh will be used.\n" printf "Ideally, it should also work for your distro.\n" printf "Still, there is a chance that it not works as expected or even fails.\n" printf "Proceed only at your own risk.\n" printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-setups-arch.sh + source ./dist-${TARGET_ID}/install-setups.sh else + TARGET_ID=fallback printf "${STY_RED}" printf "===WARNING===\n" printf "Detected distro ID: ${OS_DISTRO_ID}\n" printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n" - printf "./scriptdata/install-setups-${OS_DISTRO_ID}.sh not found.\n" - printf "./scriptdata/install-setups-fallback.sh will be used.\n" + printf "./dist-${OS_DISTRO_ID}/install-setups.sh not found.\n" + printf "./dist-${TARGET_ID}/install-setups.sh will be used.\n" printf "It might fail or disrupt your system.\n" printf "Proceed only at your own risk.\n" printf "\n" printf "${STY_RESET}" pause - source ./scriptdata/install-setups-fallback.sh + source ./dist-${TARGET_ID}/install-setups.sh fi diff --git a/scriptdata/install-files.sh b/scriptdata/3.install-files.sh similarity index 100% rename from scriptdata/install-files.sh rename to scriptdata/3.install-files.sh diff --git a/scriptdata/installers.sh b/scriptdata/package-installers.sh similarity index 100% rename from scriptdata/installers.sh rename to scriptdata/package-installers.sh From 88c3b0ba83e91b525c422dd337c3b1818a76de54 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 16:48:45 +0800 Subject: [PATCH 02/10] Remove old ags entries from .gitignore --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index e8c1afabe..416e808c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,4 @@ -.config/ags/node_modules -.config/ags/scss/_musicmaterial.scss -.config/ags/scss/_musicwal.scss -.config/ags/scss/_material.scss /diagnose.result -/ii_ags.log /cache # Ignore Python cache files __pycache__/ From 343a7ef4fe8fca75d02dd063a709041a4a299fb5 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 18:47:14 +0800 Subject: [PATCH 03/10] Add git_unshallow and latest_commit_hash --- scriptdata/functions.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scriptdata/functions.sh b/scriptdata/functions.sh index 531df3ef3..208c48b28 100644 --- a/scriptdata/functions.sh +++ b/scriptdata/functions.sh @@ -75,3 +75,17 @@ function prevent_sudo_or_root(){ root) echo -e "${STY_RED}[$0]: This script is NOT to be executed with sudo or as root. Aborting...${STY_RESET}";exit 1;; esac } +function git_unshallow(){ +# We need this function for latest_commit_hash to work properly + if [[ -f "$(git rev-parse --git-dir)/shallow" ]]; then + echo "Shallow clone detected. Unshallowing..." + git fetch --unshallow + fi +} +function latest_commit_hash(){ + local target_path="$1" + if [[ ! -e "$target_path" ]]; then + echo "[latest_commit_hash] '$target_path' does not exist. Aborting...";exit 1 + fi + echo $(git log -1 --format="%H" -- "$target_path" 2>/dev/null) +} From 9f7a2d86cf72a2cbd81669dbc5ac0cbded3e223a Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 18:55:33 +0800 Subject: [PATCH 04/10] No hash, just timestamp --- scriptdata/functions.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scriptdata/functions.sh b/scriptdata/functions.sh index 208c48b28..f6644f3f1 100644 --- a/scriptdata/functions.sh +++ b/scriptdata/functions.sh @@ -82,10 +82,11 @@ function git_unshallow(){ git fetch --unshallow fi } -function latest_commit_hash(){ +function latest_commit_timestamp(){ local target_path="$1" if [[ ! -e "$target_path" ]]; then - echo "[latest_commit_hash] '$target_path' does not exist. Aborting...";exit 1 + echo "[latest_commit_timestamp] '$target_path' does not exist. Aborting..." + return 1 fi - echo $(git log -1 --format="%H" -- "$target_path" 2>/dev/null) + echo $(git log -1 --format="%ct" -- "$target_path" 2>/dev/null) } From b380a77a7dedb4c4dc970f48ff50491ab2d8e92d Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 20:56:43 +0800 Subject: [PATCH 05/10] Add outdate detect logic for dist- --- dist-arch/outdate-detect-mode | 1 + dist-fallback/outdate-detect-mode | 1 + dist-nix/outdate-detect-mode | 1 + scriptdata/1.install-deps-selector.sh | 60 ++++++++++++++++++++++----- scriptdata/functions.sh | 23 ++++++---- uninstall.sh | 2 +- 6 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 dist-arch/outdate-detect-mode create mode 100644 dist-fallback/outdate-detect-mode create mode 100644 dist-nix/outdate-detect-mode diff --git a/dist-arch/outdate-detect-mode b/dist-arch/outdate-detect-mode new file mode 100644 index 000000000..0fd754152 --- /dev/null +++ b/dist-arch/outdate-detect-mode @@ -0,0 +1 @@ +AUTO diff --git a/dist-fallback/outdate-detect-mode b/dist-fallback/outdate-detect-mode new file mode 100644 index 000000000..00d7bdd40 --- /dev/null +++ b/dist-fallback/outdate-detect-mode @@ -0,0 +1 @@ +WIP diff --git a/dist-nix/outdate-detect-mode b/dist-nix/outdate-detect-mode new file mode 100644 index 000000000..00d7bdd40 --- /dev/null +++ b/dist-nix/outdate-detect-mode @@ -0,0 +1 @@ +WIP diff --git a/scriptdata/1.install-deps-selector.sh b/scriptdata/1.install-deps-selector.sh index cda6bdea3..bcf3199f5 100644 --- a/scriptdata/1.install-deps-selector.sh +++ b/scriptdata/1.install-deps-selector.sh @@ -1,6 +1,32 @@ # This script is meant to be sourced. # It's not for directly running. +function outdate_detect(){ + # Shallow clone makes latest_commit_timestamp() not worky. + git_auto_unshallow + + local source_path="$1" + local target_path="$2" + local source_timestamp="$(latest_commit_timestamp $source_path 2>/dev/null)" + local target_timestamp="$(latest_commit_timestamp $target_path 2>/dev/null)" + local outdate_detect_mode="$(cat ${target_path}/outdate-detect-mode)" + + # Does target path have an outdate-detect-mode file which content is special? + if [[ "${outdate_detect_mode}" =~ ^(WIP|FORCE_OUTDATED|FORCE_UPDATED)$ ]]; then + echo "${outdate_detect_mode}" + # Does source path has an empty timestamp? + elif [ -z "$source_timestamp" ]; then + echo "EMPTY_SOURCE" + # Does target path has an empty timestamp? + elif [ -z "$target_timestamp" ]; then + echo "EMPTY_TARGET" + # If target path is older than source path, it's outdated. + elif [[ "$target_timestamp" -lt "$source_timestamp" ]]; then + echo "OUTDATED" + else + echo "UPDATED" + fi +} #################### # Detect architecture # Helpful link(s): @@ -9,15 +35,15 @@ export MACHINE_ARCH=$(uname -m) case $MACHINE_ARCH in "x86_64") sleep 0;; *) - printf "${STY_YELLOW}" - printf "===WARNING===\n" - printf "Detected machine architecture: ${MACHINE_ARCH}\n" - printf "This script only supports x86_64.\n" - printf "It is very likely to fail when installing dependencies on your machine.\n" - printf "\n" - printf "${STY_RESET}" - ;; - esac + printf "${STY_YELLOW}" + printf "===WARNING===\n" + printf "Detected machine architecture: ${MACHINE_ARCH}\n" + printf "This script only supports x86_64.\n" + printf "It is very likely to fail when installing dependencies on your machine.\n" + printf "\n" + printf "${STY_RESET}" + ;; +esac #################### # Detect distro @@ -31,7 +57,6 @@ export OS_DISTRO_ID=$(awk -F'=' '/^ID=/ { gsub("\"","",$2); print tolower($2) }' export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null) - if [[ "$INSTALL_VIA_NIX" == "true" ]]; then TARGET_ID=nix @@ -73,6 +98,21 @@ elif [[ -f "./dist-${OS_DISTRO_ID}/install-deps.sh" ]]; then printf "\n" printf "${STY_RESET}" pause + tmp_update_status="$(outdate_detect dist-arch dist-${TARGET_ID})" + if [[ "${tmp_update_status}" =~ ^(OUTDATED|EMPTY_TARGET|EMPTY_SOURCE|FORCE_OUTDATED|WIP)$ ]]; then + printf "${STY_RED}" + printf "${STY_BOLD}===URGENT===${STY_RED}\n" + printf "The community provided ./dist-${TARGET_ID}/ is not updated (update status: ${tmp_update_status}),\n" + printf "which means it does not fully reflect the latest changes of ./dist-arch/ .\n" + printf "You are highly recommended to abort this script, until someone (maybe you?) has updated the ./dist-${TARGET_ID}/ to fully reflect the latest changes in ./dist-arch/ . PR is welcomed.\n" + printf "${STY_INVERT}If you are proceeding anyway, illogical-impulse will very likely not work as expected.${STY_RESET}\n" + printf "${STY_RED}Still proceed?${STY_RESET}\n" + read -p "[y/N]: " p + case "$p" in + [yY])sleep 0;; + *)echo "Aborting...";exit 1;; + esac + fi source ./dist-${TARGET_ID}/install-deps.sh elif [[ "$OS_DISTRO_ID_LIKE" == "arch" || "$OS_DISTRO_ID" == "cachyos" ]]; then diff --git a/scriptdata/functions.sh b/scriptdata/functions.sh index f6644f3f1..b829c6be8 100644 --- a/scriptdata/functions.sh +++ b/scriptdata/functions.sh @@ -10,7 +10,7 @@ function v(){ echo -e "####################################################" echo -e "${STY_BLUE}[$0]: Next command:${STY_RESET}" echo -e "${STY_GREEN}$@${STY_RESET}" - execute=true + local execute=true if $ask;then while true;do echo -e "${STY_BLUE}Execute? ${STY_RESET}" @@ -18,7 +18,7 @@ function v(){ echo " e = Exit now" echo " s = Skip this command (NOT recommended - your setup might not work correctly)" echo " yesforall = Yes and don't ask again; NOT recommended unless you really sure" - read -p "====> " p + local p; read -p "====> " p case $p in [yY]) echo -e "${STY_BLUE}OK, executing...${STY_RESET}" ;break ;; [eE]) echo -e "${STY_BLUE}Exiting...${STY_RESET}" ;exit ;break ;; @@ -34,7 +34,7 @@ function v(){ } # When use v() for a defined function, use x() INSIDE its definition to catch errors. function x(){ - if "$@";then cmdstatus=0;else cmdstatus=1;fi # 0=normal; 1=failed; 2=failed but ignored + if "$@";then local cmdstatus=0;else local cmdstatus=1;fi # 0=normal; 1=failed; 2=failed but ignored while [ $cmdstatus == 1 ] ;do echo -e "${STY_RED}[$0]: Command \"${STY_GREEN}$@${STY_RED}\" has failed." echo -e "You may need to resolve the problem manually BEFORE repeating this command." @@ -42,7 +42,7 @@ function x(){ echo " r = Repeat this command (DEFAULT)" echo " e = Exit now" echo " i = Ignore this error and continue (your setup might not work correctly)" - read -p " [R/e/i]: " p + local p; read -p " [R/e/i]: " p case $p in [iI]) echo -e "${STY_BLUE}Alright, ignore and continue...${STY_RESET}";cmdstatus=2;; [eE]) echo -e "${STY_BLUE}Alright, will exit.${STY_RESET}";break;; @@ -64,7 +64,11 @@ function showfun(){ printf "${STY_RESET}" } function pause(){ - if [ ! "$ask" == "false" ];then printf "${STY_FAINT}${STY_SLANT}";read -p "(Ctrl-C to abort, others to proceed)" p;printf "${STY_RESET}";fi + if [ ! "$ask" == "false" ];then + printf "${STY_FAINT}${STY_SLANT}" + local p; read -p "(Ctrl-C to abort, others to proceed)" p + printf "${STY_RESET}" + fi } function remove_bashcomments_emptylines(){ mkdir -p $(dirname $2) @@ -75,7 +79,7 @@ function prevent_sudo_or_root(){ root) echo -e "${STY_RED}[$0]: This script is NOT to be executed with sudo or as root. Aborting...${STY_RESET}";exit 1;; esac } -function git_unshallow(){ +function git_auto_unshallow(){ # We need this function for latest_commit_hash to work properly if [[ -f "$(git rev-parse --git-dir)/shallow" ]]; then echo "Shallow clone detected. Unshallowing..." @@ -84,9 +88,10 @@ function git_unshallow(){ } function latest_commit_timestamp(){ local target_path="$1" - if [[ ! -e "$target_path" ]]; then - echo "[latest_commit_timestamp] '$target_path' does not exist. Aborting..." + local result=$(git log -1 --format="%ct" -- "$target_path" 2>/dev/null) + if [[ -z "$result" ]]; then + echo "[latest_commit_timestamp] The timestamp of \"$target_path\" is empty. Aborting..." >&2 return 1 fi - echo $(git log -1 --format="%ct" -- "$target_path" 2>/dev/null) + echo $result } diff --git a/uninstall.sh b/uninstall.sh index d76104166..2e7cd895e 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -52,7 +52,7 @@ v sudo rm /etc/modules-load.d/i2c-dev.conf ############################################################################################################################## read -p "Do you want to uninstall the illogical-impulse-* meta packages (Arch Linux only)? -Ctrl+C to exit, or press Enter to proceed" +Ctrl+C to exit, or press Enter to proceed" p # Removing installed yay packages and dependencies v yay -Rns illogical-impulse-{agsv1,audio,backlight,basic,bibata-modern-classic-bin,fonts-themes,gnome,gtk,hyprland,microtex-git,oneui4-icons-git,portal,python,screencapture,widgets} plasma-browser-integration From 98ddce24ad8c2162e2a3696a5cfa7f2ea7fe65b3 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 23:51:59 +0800 Subject: [PATCH 06/10] Re-arrange scripts; fix comments in dist-nix --- dist-arch/install-deps.sh | 38 +++++++------- .../previous_dependencies.conf | 0 dist-nix/install-deps.sh | 6 +-- dist-nix/install-setups.sh | 15 ------ install.sh | 16 +++--- scriptdata/{ => lib}/environment-variables.sh | 0 scriptdata/{ => lib}/functions.sh | 0 scriptdata/{ => lib}/options.sh | 0 scriptdata/{ => lib}/package-installers.sh | 2 +- scriptdata/requirements.txt | 50 ------------------- scriptdata/{ => step}/0.install-greeting.sh | 0 .../{ => step}/1.install-deps-selector.sh | 2 +- .../{ => step}/2.install-setups-selector.sh | 4 +- scriptdata/{ => step}/3.install-files.sh | 0 scriptdata/{ => uv}/requirements.in | 0 scriptdata/uv/requirements.txt | 50 +++++++++++++++++++ uninstall.sh | 4 +- 17 files changed, 86 insertions(+), 101 deletions(-) rename {scriptdata => dist-arch}/previous_dependencies.conf (100%) delete mode 100644 dist-nix/install-setups.sh rename scriptdata/{ => lib}/environment-variables.sh (100%) rename scriptdata/{ => lib}/functions.sh (100%) rename scriptdata/{ => lib}/options.sh (100%) rename scriptdata/{ => lib}/package-installers.sh (98%) delete mode 100644 scriptdata/requirements.txt rename scriptdata/{ => step}/0.install-greeting.sh (100%) rename scriptdata/{ => step}/1.install-deps-selector.sh (98%) rename scriptdata/{ => step}/2.install-setups-selector.sh (97%) rename scriptdata/{ => step}/3.install-files.sh (100%) rename scriptdata/{ => uv}/requirements.in (100%) create mode 100644 scriptdata/uv/requirements.txt diff --git a/dist-arch/install-deps.sh b/dist-arch/install-deps.sh index 7e02f05a4..2add68bdb 100644 --- a/dist-arch/install-deps.sh +++ b/dist-arch/install-deps.sh @@ -16,17 +16,17 @@ handle-deprecated-dependencies(){ printf "${STY_CYAN}[$0]: Removing deprecated dependencies:${STY_RESET}\n" for i in illogical-impulse-{microtex,pymyc-aur,ags,agsv1} {hyprutils,hyprpicker,hyprlang,hypridle,hyprland-qt-support,hyprland-qtutils,hyprlock,xdg-desktop-portal-hyprland,hyprcursor,hyprwayland-scanner,hyprland}-git;do try sudo pacman --noconfirm -Rdd $i;done # Convert old dependencies to non explicit dependencies so that they can be orphaned if not in meta packages - remove_bashcomments_emptylines ./scriptdata/previous_dependencies.conf ./cache/old_deps_stripped.conf - readarray -t old_deps_list < ./cache/old_deps_stripped.conf - pacman -Qeq > ./cache/pacman_explicit_packages - readarray -t explicitly_installed < ./cache/pacman_explicit_packages + remove_bashcomments_emptylines ./dist-arch/previous_dependencies.conf ./cache/old_deps_stripped.conf + readarray -t old_deps_list < ./cache/old_deps_stripped.conf + pacman -Qeq > ./cache/pacman_explicit_packages + readarray -t explicitly_installed < ./cache/pacman_explicit_packages - echo "Attempting to set previously explicitly installed deps as implicit..." - for i in "${explicitly_installed[@]}"; do for j in "${old_deps_list[@]}"; do - [ "$i" = "$j" ] && yay -D --asdeps "$i" - done; done + echo "Attempting to set previously explicitly installed deps as implicit..." + for i in "${explicitly_installed[@]}"; do for j in "${old_deps_list[@]}"; do + [ "$i" = "$j" ] && yay -D --asdeps "$i" + done; done - return 0 + return 0 } ##################################################################################### @@ -55,16 +55,16 @@ v handle-deprecated-dependencies # https://github.com/end-4/dots-hyprland/issues/581 # yay -Bi is kinda hit or miss, instead cd into the relevant directory and manually source and install deps install-local-pkgbuild() { - local location=$1 - local installflags=$2 + local location=$1 + local installflags=$2 - x pushd $location + x pushd $location - source ./PKGBUILD - x yay -S $installflags --asdeps "${depends[@]}" - x makepkg -Asi --noconfirm + source ./PKGBUILD + x yay -S $installflags --asdeps "${depends[@]}" + x makepkg -Asi --noconfirm - x popd + x popd } # Install core dependencies from the meta-packages @@ -76,9 +76,9 @@ metapkgs+=(./dist-arch/illogical-impulse-microtex-git) metapkgs+=(./dist-arch/illogical-impulse-bibata-modern-classic-bin) for i in "${metapkgs[@]}"; do - metainstallflags="--needed" - $ask && showfun install-local-pkgbuild || metainstallflags="$metainstallflags --noconfirm" - v install-local-pkgbuild "$i" "$metainstallflags" + metainstallflags="--needed" + $ask && showfun install-local-pkgbuild || metainstallflags="$metainstallflags --noconfirm" + v install-local-pkgbuild "$i" "$metainstallflags" done ## Optional dependencies diff --git a/scriptdata/previous_dependencies.conf b/dist-arch/previous_dependencies.conf similarity index 100% rename from scriptdata/previous_dependencies.conf rename to dist-arch/previous_dependencies.conf diff --git a/dist-nix/install-deps.sh b/dist-nix/install-deps.sh index 0342b1996..340153a2e 100644 --- a/dist-nix/install-deps.sh +++ b/dist-nix/install-deps.sh @@ -5,16 +5,16 @@ # # # TODO: -# Write a proper `flake.nix` and optionally `home.nix` and other files (under a new folder `scriptdata/iiqs-hm`) to install all dependencies that `scriptdata/install-deps-arch.sh` does. (excluding the screenlock) +# Write a proper `flake.nix` and optionally `home.nix` and other files under ./dist-nix/iiqs-hm/ to install all dependencies that `./dist-arch/install-deps.sh` does. (**excluding** the screenlock) # # TODO: -# In this script, i.e. `scriptdata/install-deps.nix.sh`, implement the process below: +# In this script, implement the process below: # 1. Warning user about "this script is only experimental and must only use it at your own risks.", and prompt `y/N` (default N) before proceeding. # 2. If nix not installed: # 1. install nix via [DeterminateSystems/nix-installer](https://github.com/DeterminateSystems/nix-installer). # 2. Enable nix (probably in `.zshrc` or `~/.config/fish`). # 3. Ensure the experimental feature, Nix Flake, is enabled. -# 3. Sync (copy) `iiqs-hm` folder to `~/.config/iiqs-hm` using `rsync`. +# 3. Sync (copy) `./dist-nix/iiqs-hm/` folder to `~/.config/iiqs-hm/` using `rsync`. # 4. Use something like `home-manager switch --flake .#iiqs` to install the dependencies. # 5. Install screen lock using system package manager of the current distro. # Note that this script must be idempotent. diff --git a/dist-nix/install-setups.sh b/dist-nix/install-setups.sh deleted file mode 100644 index 923ac2bc5..000000000 --- a/dist-nix/install-setups.sh +++ /dev/null @@ -1,15 +0,0 @@ -# This script is meant to be sourced. -# It's not for directly running. - -##################################################################################### -# These python packages are installed using uv into the venv (virtual environment). Once the folder of the venv gets deleted, they are all gone cleanly. So it's considered as setups, not dependencies. -showfun install-python-packages -v install-python-packages - -v sudo usermod -aG video,i2c,input "$(whoami)" -v bash -c "echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf" -v systemctl --user enable ydotool --now -v sudo systemctl enable bluetooth --now -v gsettings set org.gnome.desktop.interface font-name 'Rubik 11' -v gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' -v kwriteconfig6 --file kdeglobals --group KDE --key widgetStyle Darkly diff --git a/install.sh b/install.sh index 63f64d6d8..bfddd6903 100755 --- a/install.sh +++ b/install.sh @@ -1,29 +1,29 @@ #!/usr/bin/env bash cd "$(dirname "$0")" export base="$(pwd)" -source ./scriptdata/environment-variables.sh -source ./scriptdata/functions.sh -source ./scriptdata/package-installers.sh -source ./scriptdata/options.sh +source ./scriptdata/lib/environment-variables.sh +source ./scriptdata/lib/functions.sh +source ./scriptdata/lib/package-installers.sh +source ./scriptdata/lib/options.sh prevent_sudo_or_root set -e ##################################################################################### # 0. Before we start -source ./scriptdata/0.install-greeting.sh +source ./scriptdata/step/0.install-greeting.sh ##################################################################################### if [[ "${SKIP_ALLDEPS}" != true ]]; then printf "${STY_CYAN}[$0]: 1. Install dependencies\n${STY_RESET}" - source ./scriptdata/1.install-deps-selector.sh + source ./scriptdata/step/1.install-deps-selector.sh fi ##################################################################################### if [[ "${SKIP_ALLSETUPS}" != true ]]; then printf "${STY_CYAN}[$0]: 2. Setup for permissions/services etc\n${STY_RESET}" - source ./scriptdata/2.install-setups-selector.sh + source ./scriptdata/step/2.install-setups-selector.sh fi ##################################################################################### if [[ "${SKIP_ALLFILES}" != true ]]; then printf "${STY_CYAN}[$0]: 3. Copying config files\n${STY_RESET}" - source ./scriptdata/3.install-files.sh + source ./scriptdata/step/3.install-files.sh fi diff --git a/scriptdata/environment-variables.sh b/scriptdata/lib/environment-variables.sh similarity index 100% rename from scriptdata/environment-variables.sh rename to scriptdata/lib/environment-variables.sh diff --git a/scriptdata/functions.sh b/scriptdata/lib/functions.sh similarity index 100% rename from scriptdata/functions.sh rename to scriptdata/lib/functions.sh diff --git a/scriptdata/options.sh b/scriptdata/lib/options.sh similarity index 100% rename from scriptdata/options.sh rename to scriptdata/lib/options.sh diff --git a/scriptdata/package-installers.sh b/scriptdata/lib/package-installers.sh similarity index 98% rename from scriptdata/package-installers.sh rename to scriptdata/lib/package-installers.sh index ffbf2bc53..c4d6e03a6 100644 --- a/scriptdata/package-installers.sh +++ b/scriptdata/lib/package-installers.sh @@ -106,6 +106,6 @@ install-python-packages(){ # we need python 3.12 https://github.com/python-pillow/Pillow/issues/8089 x uv venv --prompt .venv $(eval echo $ILLOGICAL_IMPULSE_VIRTUAL_ENV) -p 3.12 x source $(eval echo $ILLOGICAL_IMPULSE_VIRTUAL_ENV)/bin/activate - x uv pip install -r scriptdata/requirements.txt + x uv pip install -r scriptdata/uv/requirements.txt x deactivate # We don't need the virtual environment anymore } diff --git a/scriptdata/requirements.txt b/scriptdata/requirements.txt deleted file mode 100644 index e6b96aba1..000000000 --- a/scriptdata/requirements.txt +++ /dev/null @@ -1,50 +0,0 @@ -# This file was autogenerated by uv via the following command: -# uv pip compile scriptdata/requirements.in -o scriptdata/requirements.txt -build==1.2.2.post1 - # via -r scriptdata/requirements.in -cffi==1.17.1 - # via pywayland -click==8.2.1 - # via -r scriptdata/requirements.in -libsass==0.23.0 - # via -r scriptdata/requirements.in -loguru==0.7.3 - # via -r scriptdata/requirements.in -material-color-utilities==0.2.1 - # via -r scriptdata/requirements.in -materialyoucolor==2.0.10 - # via -r scriptdata/requirements.in -numpy==2.2.2 - # via material-color-utilities -packaging==24.2 - # via - # build - # setuptools-scm -pillow==11.1.0 - # via - # -r scriptdata/requirements.in - # material-color-utilities -psutil==6.1.1 - # via -r scriptdata/requirements.in -pycairo==1.28.0 - # via - # -r scriptdata/requirements.in - # pygobject -pycparser==2.22 - # via cffi -pygobject==3.52.3 - # via -r scriptdata/requirements.in -pyproject-hooks==1.2.0 - # via build -pywayland==0.4.18 - # via -r scriptdata/requirements.in -setproctitle==1.3.4 - # via -r scriptdata/requirements.in -setuptools==80.9.0 - # via setuptools-scm -setuptools-scm==8.1.0 - # via -r scriptdata/requirements.in -tqdm==4.67.1 - # via -r scriptdata/requirements.in -wheel==0.45.1 - # via -r scriptdata/requirements.in diff --git a/scriptdata/0.install-greeting.sh b/scriptdata/step/0.install-greeting.sh similarity index 100% rename from scriptdata/0.install-greeting.sh rename to scriptdata/step/0.install-greeting.sh diff --git a/scriptdata/1.install-deps-selector.sh b/scriptdata/step/1.install-deps-selector.sh similarity index 98% rename from scriptdata/1.install-deps-selector.sh rename to scriptdata/step/1.install-deps-selector.sh index bcf3199f5..90f1182a7 100644 --- a/scriptdata/1.install-deps-selector.sh +++ b/scriptdata/step/1.install-deps-selector.sh @@ -62,7 +62,7 @@ if [[ "$INSTALL_VIA_NIX" == "true" ]]; then TARGET_ID=nix printf "${STY_YELLOW}" printf "===WARNING===\n" - printf "Nix will be used to install dependencies.\n" + printf "./dist-${TARGET_ID}/install-deps.sh will be used.\n" printf "The process is still WIP.\n" printf "Proceed only at your own risk.\n" printf "\n" diff --git a/scriptdata/2.install-setups-selector.sh b/scriptdata/step/2.install-setups-selector.sh similarity index 97% rename from scriptdata/2.install-setups-selector.sh rename to scriptdata/step/2.install-setups-selector.sh index 44e97b2c3..2ca344014 100644 --- a/scriptdata/2.install-setups-selector.sh +++ b/scriptdata/step/2.install-setups-selector.sh @@ -16,10 +16,10 @@ export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolo if [[ "$INSTALL_VIA_NIX" == "true" ]]; then - TARGET_ID=nix + TARGET_ID=fallback printf "${STY_YELLOW}" printf "===WARNING===\n" - printf "Nix will be used to do setups.\n" + printf "./dist-${TARGET_ID}/install-setups.sh will be used.\n" printf "The process is still WIP.\n" printf "Proceed only at your own risk.\n" printf "\n" diff --git a/scriptdata/3.install-files.sh b/scriptdata/step/3.install-files.sh similarity index 100% rename from scriptdata/3.install-files.sh rename to scriptdata/step/3.install-files.sh diff --git a/scriptdata/requirements.in b/scriptdata/uv/requirements.in similarity index 100% rename from scriptdata/requirements.in rename to scriptdata/uv/requirements.in diff --git a/scriptdata/uv/requirements.txt b/scriptdata/uv/requirements.txt new file mode 100644 index 000000000..912fc2460 --- /dev/null +++ b/scriptdata/uv/requirements.txt @@ -0,0 +1,50 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile scriptdata/uv/requirements.in -o scriptdata/uv/requirements.txt +build==1.2.2.post1 + # via -r scriptdata/uv/requirements.in +cffi==1.17.1 + # via pywayland +click==8.2.1 + # via -r scriptdata/uv/requirements.in +libsass==0.23.0 + # via -r scriptdata/uv/requirements.in +loguru==0.7.3 + # via -r scriptdata/uv/requirements.in +material-color-utilities==0.2.1 + # via -r scriptdata/uv/requirements.in +materialyoucolor==2.0.10 + # via -r scriptdata/uv/requirements.in +numpy==2.2.2 + # via material-color-utilities +packaging==24.2 + # via + # build + # setuptools-scm +pillow==11.1.0 + # via + # -r scriptdata/uv/requirements.in + # material-color-utilities +psutil==6.1.1 + # via -r scriptdata/uv/requirements.in +pycairo==1.28.0 + # via + # -r scriptdata/uv/requirements.in + # pygobject +pycparser==2.22 + # via cffi +pygobject==3.52.3 + # via -r scriptdata/uv/requirements.in +pyproject-hooks==1.2.0 + # via build +pywayland==0.4.18 + # via -r scriptdata/uv/requirements.in +setproctitle==1.3.4 + # via -r scriptdata/uv/requirements.in +setuptools==80.9.0 + # via setuptools-scm +setuptools-scm==8.1.0 + # via -r scriptdata/uv/requirements.in +tqdm==4.67.1 + # via -r scriptdata/uv/requirements.in +wheel==0.45.1 + # via -r scriptdata/uv/requirements.in diff --git a/uninstall.sh b/uninstall.sh index 2e7cd895e..561f11aa5 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash cd "$(dirname "$0")" -source ./scriptdata/environment-variables.sh -source ./scriptdata/functions.sh +source ./scriptdata/lib/environment-variables.sh +source ./scriptdata/lib/functions.sh prevent_sudo_or_root function v() { From be7ff94ae37e04cb43c3b2eb535f62ca34201fba Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 2 Oct 2025 23:56:38 +0800 Subject: [PATCH 07/10] Fix comment --- dist-nix/install-deps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dist-nix/install-deps.sh b/dist-nix/install-deps.sh index 340153a2e..c46510c8d 100644 --- a/dist-nix/install-deps.sh +++ b/dist-nix/install-deps.sh @@ -3,6 +3,7 @@ # This file is currently WIP. # +# NOTE: The dist-nix is not for NixOS but every distro, using Nix and home-manager. # # TODO: # Write a proper `flake.nix` and optionally `home.nix` and other files under ./dist-nix/iiqs-hm/ to install all dependencies that `./dist-arch/install-deps.sh` does. (**excluding** the screenlock) From a0229e8132664186be8b08747decb2464eaaf825 Mon Sep 17 00:00:00 2001 From: clsty Date: Fri, 3 Oct 2025 00:03:41 +0800 Subject: [PATCH 08/10] Fix comment. --- dist-arch/install-deps.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist-arch/install-deps.sh b/dist-arch/install-deps.sh index 2add68bdb..487bb79ff 100644 --- a/dist-arch/install-deps.sh +++ b/dist-arch/install-deps.sh @@ -12,6 +12,8 @@ install-yay(){ rm -rf /tmp/buildyay } +# NOTE: `handle-deprecated-dependencies` was for the old days when we just switch from dependencies.conf to local PKGBUILDs. +# However, let's just keep it as references for other distros writing their `dist-/install-deps.sh`, if they need it. handle-deprecated-dependencies(){ printf "${STY_CYAN}[$0]: Removing deprecated dependencies:${STY_RESET}\n" for i in illogical-impulse-{microtex,pymyc-aur,ags,agsv1} {hyprutils,hyprpicker,hyprlang,hypridle,hyprland-qt-support,hyprland-qtutils,hyprlock,xdg-desktop-portal-hyprland,hyprcursor,hyprwayland-scanner,hyprland}-git;do try sudo pacman --noconfirm -Rdd $i;done From cd48f4546290ac43d336d9671b48dfa01b382378 Mon Sep 17 00:00:00 2001 From: clsty Date: Fri, 3 Oct 2025 00:10:45 +0800 Subject: [PATCH 09/10] Del `chmod +x` in update.sh targeting scriptdata Although I am not the one creating update.sh, I am certain that giving execute permission for scripts under scriptdata/ is wrong cuz they are not for executing independently, but for being sourced by other scripts. --- update.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/update.sh b/update.sh index 8fb7a299a..38cd7a999 100755 --- a/update.sh +++ b/update.sh @@ -813,12 +813,6 @@ fi # Step 4: Update script permissions log_header "Updating Script Permissions" -if [[ -d "${REPO_DIR}/scriptdata" ]]; then - find "${REPO_DIR}/scriptdata" -type f -name "*.sh" -exec chmod +x {} \; - find "${REPO_DIR}/scriptdata" -type f -executable -exec chmod +x {} \; - log_success "Updated script permissions" -fi - # Make sure local bin scripts are executable if [[ -d "${HOME}/.local/bin" ]]; then find "${HOME}/.local/bin" -type f -exec chmod +x {} \; 2>/dev/null || true From e3d596e034d6b2758f9d73b2af2af7534c9bbf0c Mon Sep 17 00:00:00 2001 From: clsty Date: Fri, 3 Oct 2025 00:30:18 +0800 Subject: [PATCH 10/10] Add TODO in comment --- scriptdata/step/3.install-files.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scriptdata/step/3.install-files.sh b/scriptdata/step/3.install-files.sh index 8a4ca9ba7..ac0639567 100644 --- a/scriptdata/step/3.install-files.sh +++ b/scriptdata/step/3.install-files.sh @@ -33,6 +33,12 @@ case $ask in *) ask_backup_configs ;; esac +# TODO: A better method for users to choose their customization, +# for example some users may prefer ZSH over FISH, and foot over kitty. +# But the dot files are using FISH and kitty as the default software, e.g. `.local/share/Konsole` has `Command=/bin/fish`. +# It may be possible that we provide options for users to make their decision. + + # `--delete' for rsync to make sure that # original dotfiles and new ones in the SAME DIRECTORY # (eg. in ~/.config/hypr) won't be mixed together