Add distro and arch detect, add skip options

This commit is contained in:
clsty
2025-10-02 00:35:33 +08:00
parent 7aa1230553
commit 852172a7ff
10 changed files with 121 additions and 35 deletions
+12 -1
View File
@@ -13,12 +13,23 @@ set -e
# 0. Before we start # 0. Before we start
source ./scriptdata/install-greeting.sh source ./scriptdata/install-greeting.sh
##################################################################################### #####################################################################################
if [[ "${SKIP_ALLDEPS}" != true ]]; then
printf "${COLOR_CYAN}[$0]: 1. Install dependencies\n${COLOR_RESET}" printf "${COLOR_CYAN}[$0]: 1. Install dependencies\n${COLOR_RESET}"
# TODO: if `--via-nix` is specified, source `install-deps-nix` instead. if [[ "${INSTALL_VIA_NIX}" == "true" ]]; then
source ./scriptdata/install-deps-nix.sh
elif [[ "${OS_DISTRO_ID}" == "arch" || "${OS_DISTRO_ID_LIKE}" == "arch" ]]; then
source ./scriptdata/install-deps-arch.sh source ./scriptdata/install-deps-arch.sh
else
source ./scriptdata/install-deps-any.sh
fi
fi
##################################################################################### #####################################################################################
if [[ "${SKIP_ALLSETUPS}" != true ]]; then
printf "${COLOR_CYAN}[$0]: 2. Setup for user groups/services etc\n${COLOR_RESET}" printf "${COLOR_CYAN}[$0]: 2. Setup for user groups/services etc\n${COLOR_RESET}"
source ./scriptdata/install-setups.sh source ./scriptdata/install-setups.sh
fi
##################################################################################### #####################################################################################
if [[ "${SKIP_ALLFILES}" != true ]]; then
printf "${COLOR_CYAN}[$0]: 3. Copying + Configuring\n${COLOR_RESET}" printf "${COLOR_CYAN}[$0]: 3. Copying + Configuring\n${COLOR_RESET}"
source ./scriptdata/install-files.sh source ./scriptdata/install-files.sh
fi
+1
View File
@@ -17,3 +17,4 @@ COLOR_RESET='\e[00m'
STYLE_UNDERLINE='\e[4m' STYLE_UNDERLINE='\e[4m'
BG_COLOR_CYAN='\e[30m\e[46m' BG_COLOR_CYAN='\e[30m\e[46m'
BG_COLOR_RED='\e[30m\e[41m'
+11
View File
@@ -0,0 +1,11 @@
# This script is meant to be sourced.
# It's not for directly running.
# This file is currently WIP.
v install-Rubik
v install-Gabarito
v install-OneUI
v install-bibata
v install-MicroTeX
v install-uv
+4
View File
@@ -0,0 +1,4 @@
# This script is meant to be sourced.
# It's not for directly running.
# This file is currently WIP.
+63 -1
View File
@@ -11,9 +11,9 @@ printf ' If you aren'\''t running on ewaste, the Quickshell version is reco
printf ' If you would like the AGS version anyway, run the script in its branch instead: git checkout ii-ags && ./install.sh\n' printf ' If you would like the AGS version anyway, run the script in its branch instead: git checkout ii-ags && ./install.sh\n'
printf '\n' printf '\n'
printf 'This script does not handle system-level/hardware stuff like Nvidia drivers.\n' printf 'This script does not handle system-level/hardware stuff like Nvidia drivers.\n'
printf "\n"
printf "${COLOR_RESET}" printf "${COLOR_RESET}"
case $ask in case $ask in
false) sleep 0 ;; false) sleep 0 ;;
*) *)
@@ -32,3 +32,65 @@ case $ask in
printf "${COLOR_RESET}" printf "${COLOR_RESET}"
;; ;;
esac esac
####################
# Detect architecture
# Helpful link(s):
# http://stackoverflow.com/questions/45125516
export MACHINE_ARCH=$(uname -m)
case $MACHINE_ARCH in
"x86_64") sleep 0;;
*)
printf "${COLOR_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 "${COLOR_RESET}"
;;
esac
####################
# Detect distro
# Helpful link(s):
# http://stackoverflow.com/questions/29581754
# https://github.com/which-distro/os-release
export OS_RELEASE_FILE=${OS_RELEASE_FILE:-/etc/os-release}
test -f ${OS_RELEASE_FILE} || \
( echo "${OS_RELEASE_FILE} does not exist. Aborting..." ; exit 1 ; )
export OS_DISTRO_ID=$(awk -F'=' '/^ID=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null)
export OS_DISTRO_ID_LIKE=$(awk -F'=' '/^ID_LIKE=/ { gsub("\"","",$2); print tolower($2) }' ${OS_RELEASE_FILE} 2> /dev/null)
case $OS_DISTRO_ID in
"arch"|"endeavouros"|"cachyos") sleep 0;;
*)
case $OS_DISTRO_ID_LIKE in
"arch")
printf "${COLOR_YELLOW}"
printf "===WARNING===\n"
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
printf "Detected distro ID_LIKE: ${OS_DISTRO_ID_LIKE}\n"
printf "This script supports Arch Linux, so it should also work for your distro ideally.\n"
printf "Still, there is a chance that it not works as expected or even fails.\n"
printf "\n"
printf "${COLOR_RESET}"
;;
*)
printf "${COLOR_RED}"
printf "===URGENT===\n"
printf "Detected distro ID: ${OS_DISTRO_ID}\n"
printf "Currently, only Arch(-based) distros are supported.\n"
printf "If you continue, this script will still move on and try to install some dependencies for you.\n"
printf "But it may disrupt your system and will likely fail without your manual intervention. Only continue at your own risk.\n"
printf "${COLOR_RESET}"
printf "${BG_COLOR_RED}"
printf "To tell you the truth, it is completely not worky at this time. The prompt here is only for testing and WIP. PLEASE JUST QUIT IMMEDIATELY.${COLOR_RESET}\n"
read -p "Still continue? [y/N] ====> " p
case $p in
[yY]) sleep 0 ;;
*) exit 1 ;;
esac
;;
esac
;;
esac
+9 -12
View File
@@ -12,15 +12,17 @@ If no option is specified, run default install process.
-h, --help Print this help message and exit -h, --help Print this help message and exit
-f, --force (Dangerous) Force mode without any confirm -f, --force (Dangerous) Force mode without any confirm
-c, --clean Clean the build cache first -c, --clean Clean the build cache first
--skip-alldeps Skip the whole process installing dependency
--skip-allsetups Skip the whole process setting up user groups/services etc
--skip-allfiles Skip the whole process copying configuration files
-s, --skip-sysupdate Skip system package upgrade e.g. \"sudo pacman -Syu\" -s, --skip-sysupdate Skip system package upgrade e.g. \"sudo pacman -Syu\"
--skip-hyprland Skip installing the config for Hyprland --skip-hyprland Skip installing the config for Hyprland
--skip-fish Skip installing the config for Fish --skip-fish Skip installing the config for Fish
--skip-plasmaintg Skip installing plasma-browser-integration --skip-plasmaintg Skip installing plasma-browser-integration
--skip-miscconf Skip copying the dirs and files to \".configs\" except for --skip-miscconf Skip copying the dirs and files to \".configs\" except for
AGS, Fish and Hyprland AGS, Fish and Hyprland
--deplistfile <path> Specify a dependency list file. By default
\"./scriptdata/dependencies.conf\"
--fontset <set> (Unavailable yet) Use a set of pre-defined font and config --fontset <set> (Unavailable yet) Use a set of pre-defined font and config
--via-nix (Unavailable yet) Use Nix to install dependencies
" "
} }
@@ -31,7 +33,7 @@ cleancache(){
# `man getopt` to see more # `man getopt` to see more
para=$(getopt \ para=$(getopt \
-o hfk:cs \ -o hfk:cs \
-l help,force,fontset:,deplistfile:,clean,skip-sysupdate,skip-fish,skip-hyprland,skip-plasmaintg,skip-miscconf \ -l help,force,fontset:,clean,skip-alldeps,skip-allsetups,skip-allfiles,skip-sysupdate,skip-fish,skip-hyprland,skip-plasmaintg,skip-miscconf,via-nix \
-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
##################################################################################### #####################################################################################
@@ -48,7 +50,6 @@ while true ; do
done done
##################################################################################### #####################################################################################
## getopt Phase 2 ## getopt Phase 2
DEPLISTFILE=./scriptdata/dependencies.conf
eval set -- "$para" eval set -- "$para"
while true ; do while true ; do
@@ -57,21 +58,17 @@ while true ; do
-c|--clean) shift;; -c|--clean) shift;;
## Ones without parameter ## Ones without parameter
-f|--force) ask=false;shift;; -f|--force) ask=false;shift;;
--skip-alldeps) SKIP_PLASMAINTG=true;shift;;
--skip-allsetups) SKIP_ALLSETUPS=true;shift;;
--skip-allfiles) SKIP_ALLFILES=true;shift;;
-s|--skip-sysupdate) SKIP_SYSUPDATE=true;shift;; -s|--skip-sysupdate) SKIP_SYSUPDATE=true;shift;;
--skip-hyprland) SKIP_HYPRLAND=true;shift;; --skip-hyprland) SKIP_HYPRLAND=true;shift;;
--skip-fish) SKIP_FISH=true;shift;; --skip-fish) SKIP_FISH=true;shift;;
--skip-miscconf) SKIP_MISCCONF=true;shift;; --skip-miscconf) SKIP_MISCCONF=true;shift;;
--skip-plasmaintg) SKIP_PLASMAINTG=true;shift;; --skip-plasmaintg) SKIP_PLASMAINTG=true;shift;;
--via-nix) INSTALL_VIA_NIX=true;shift;;
## Ones with parameter ## Ones with parameter
--deplistfile)
if [ -f "$2" ];then
DEPLISTFILE="$2"
else
echo -e "Deplist file \"$2\" does not exist.";exit 1
fi
shift 2 ;;
--fontset) --fontset)
case $2 in case $2 in
"default"|"zh-CN"|"vi") fontset="$2";; "default"|"zh-CN"|"vi") fontset="$2";;