Skip to content

Commit 8385e38

Browse files
Add a Linutil package installation & update script (#526)
* AUR Installation * Finished the scripts * Forgot about $RC * Fixed func name * oopsie 2 * Replaced `jq` with `grep`
1 parent 6a1df3c commit 8385e38

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh -e
2+
3+
. ../common-script.sh
4+
5+
installLinutil() {
6+
printf "%b\n" "${YELLOW}Installing Linutil...${RC}"
7+
case "$PACKAGER" in
8+
pacman)
9+
printf "%b\n" "-----------------------------------------------------"
10+
printf "%b\n" "Select the package to install:"
11+
printf "%b\n" "1. ${CYAN}linutil${RC} (stable release compiled from source)"
12+
printf "%b\n" "2. ${CYAN}linutil-bin${RC} (stable release pre-compiled)"
13+
printf "%b\n" "3. ${CYAN}linutil-git${RC} (compiled from the latest commit)"
14+
printf "%b\n" "-----------------------------------------------------"
15+
printf "%b" "Enter your choice: "
16+
read -r choice
17+
case $choice in
18+
1) "$AUR_HELPER" -S --noconfirm linutil ;;
19+
2) "$AUR_HELPER" -S --noconfirm linutil-bin ;;
20+
3) "$AUR_HELPER" -S --noconfirm linutil-git ;;
21+
*)
22+
printf "%b\n" "${RED}Invalid choice:${RC} $choice"
23+
exit 1
24+
;;
25+
esac
26+
printf "%b\n" "${GREEN}Installed successfully.${RC}"
27+
;;
28+
*)
29+
printf "%b\n" "${RED}There are no official packages for your distro.${RC}"
30+
printf "%b" "${YELLOW}Do you want to install the crates.io package? (y/N) ${RC}"
31+
read -r choice
32+
case $choice in
33+
y|Y)
34+
if ! command_exists cargo; then
35+
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
36+
case "$PACKAGER" in
37+
pacman)
38+
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
39+
;;
40+
zypper)
41+
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
42+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
43+
. $HOME/.cargo/env
44+
;;
45+
*)
46+
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
47+
;;
48+
esac
49+
fi
50+
rustup default stable
51+
cargo install --force linutil_tui
52+
printf "%b\n" "${GREEN}Installed successfully.${RC}"
53+
;;
54+
*) printf "%b\n" "${RED}Linutil not installed.${RC}" ;;
55+
esac
56+
esac
57+
}
58+
59+
checkEnv
60+
checkEscalationTool
61+
checkAURHelper
62+
installLinutil
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh -e
2+
3+
. ../common-script.sh
4+
5+
updateLinutil() {
6+
if [ ! -e "$HOME/.cargo/bin/linutil" ]; then
7+
printf "%b\n" "${RED}This script only updates the binary installed through cargo.\nlinutil_tui is not installed.${RC}"
8+
exit 1
9+
fi
10+
11+
if ! command_exists cargo; then
12+
printf "%b\n" "${YELLOW}Installing rustup...${RC}"
13+
case "$PACKAGER" in
14+
pacman)
15+
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm rustup
16+
;;
17+
zypper)
18+
"$ESCALATION_TOOL" "$PACKAGER" install -n curl gcc make
19+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
20+
. $HOME/.cargo/env
21+
;;
22+
*)
23+
"$ESCALATION_TOOL" "$PACKAGER" install -y rustup
24+
;;
25+
esac
26+
fi
27+
28+
INSTALLED_VERSION=$(cargo install --list | grep "linutil_tui" | awk '{print $2}' | tr -d 'v:')
29+
LATEST_VERSION=$(curl -s https://crates.io/api/v1/crates/linutil_tui | grep -oP '"max_version":\s*"\K[^"]+')
30+
31+
if [ "$INSTALLED_VERSION" = "$LATEST_VERSION" ]; then
32+
printf "%b\n" "${GREEN}linutil_tui is up to date.${RC}"
33+
exit 0
34+
fi
35+
36+
printf "%b\n" "${YELLOW}Updating linutil_tui...${RC}"
37+
rustup default stable
38+
cargo install --force linutil_tui
39+
printf "%b\n" "${GREEN}Updated successfully.${RC}"
40+
}
41+
42+
checkEnv
43+
checkEscalationTool
44+
checkAURHelper
45+
updateLinutil

core/tabs/applications-setup/tab_data.toml

+20
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,23 @@ script = "rofi-setup.sh"
5353
name = "ZSH Prompt"
5454
description = "The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.\nThis command installs ZSH prompt and provides basic configuration."
5555
script = "zsh-setup.sh"
56+
57+
[[data]]
58+
name = "Install Linutil"
59+
description = "Installs a distro-specific Linutil package locally."
60+
script = "linutil-installer.sh"
61+
62+
[[data.preconditions]]
63+
matches = false
64+
data = "command_exists"
65+
values = [ "linutil" ]
66+
67+
[[data]]
68+
name = "Update Linutil"
69+
description = "Updates your local Linutil crate installation."
70+
script = "linutil-updater.sh"
71+
72+
[[data.preconditions]]
73+
matches = true
74+
data = "command_exists"
75+
values = [ "linutil" ]

0 commit comments

Comments
 (0)