-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathos_release_validator.sh
More file actions
executable file
·119 lines (106 loc) · 6.21 KB
/
os_release_validator.sh
File metadata and controls
executable file
·119 lines (106 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
# ============================================================================
# OS Release Validator for blxshell
# ============================================================================
# Sources /etc/os-release and determines distro compatibility.
# Sets IS_ARCH_LIKE=true/false and SKIP_PACKAGES=true/false
# for install.sh to use.
#
# Usage: source os_release_validator.sh
# ============================================================================
IS_ARCH_LIKE=false
IS_OPENSUSE=false
SKIP_PACKAGES=false
validate_os() {
if [[ ! -f /etc/os-release ]]; then
warning "/etc/os-release not found"
warning "Cannot determine your distribution"
IS_ARCH_LIKE=false
SKIP_PACKAGES=true
_show_non_arch_notice
return
fi
# shellcheck source=/dev/null
source /etc/os-release
local id="${ID:-unknown}"
local id_like="${ID_LIKE:-}"
local pretty="${PRETTY_NAME:-$id}"
info "Detected: ${BOLD}$pretty${NC}"
log "OS: ID=$id ID_LIKE=$id_like PRETTY_NAME=$pretty"
# openSUSE Tumbleweed (and Leap as ID_LIKE fallback)
if [[ "$id" == "opensuse-tumbleweed" ]] || [[ "$id_like" == *"suse"* ]]; then
IS_OPENSUSE=true
SKIP_PACKAGES=false
_show_opensuse_notice "$pretty"
return
fi
# Pure Arch
if [[ "$id" == "arch" ]]; then
success "Arch Linux detected"
IS_ARCH_LIKE=true
SKIP_PACKAGES=false
return
fi
# Arch-based distros (ID_LIKE contains "arch")
if [[ "$id_like" == *"arch"* ]]; then
# Manjaro warning
if [[ "$id" == "manjaro" ]]; then
echo ""
echo -e "${YELLOW}${BOLD} ┌─────────────────────────────────────────────────────┐${NC}"
echo -e "${YELLOW}${BOLD} │ Manjaro Detected │${NC}"
echo -e "${YELLOW}${BOLD} ├─────────────────────────────────────────────────────┤${NC}"
echo -e "${YELLOW} │ Manjaro uses its own delayed repositories which │${NC}"
echo -e "${YELLOW} │ may cause version mismatches and broken packages. │${NC}"
echo -e "${YELLOW} │ AUR packages expect up-to-date Arch repos. │${NC}"
echo -e "${YELLOW} │ │${NC}"
echo -e "${YELLOW} │ Proceed with caution — things may break. │${NC}"
echo -e "${YELLOW}${BOLD} └─────────────────────────────────────────────────────┘${NC}"
echo ""
warning "Manjaro's repositories are known to cause issues with AUR"
confirm "Continue anyway?" || exit 1
else
success "Arch-based distro detected ($pretty)"
fi
IS_ARCH_LIKE=true
SKIP_PACKAGES=false
return
fi
# Not Arch-based at all
IS_ARCH_LIKE=false
SKIP_PACKAGES=true
_show_non_arch_notice
}
_show_opensuse_notice() {
local pretty="$1"
echo ""
echo -e "${GREEN}${BOLD} ┌─────────────────────────────────────────────────────┐${NC}"
echo -e "${GREEN}${BOLD} │ openSUSE Tumbleweed Detected │${NC}"
echo -e "${GREEN}${BOLD} ├─────────────────────────────────────────────────────┤${NC}"
echo -e "${GREEN} │ Detected: ${BOLD}$pretty${NC}${GREEN} │${NC}"
echo -e "${GREEN} │ │${NC}"
echo -e "${GREEN} │ The blxshell OBS repository will be added: │${NC}"
echo -e "${GREEN} │ home:binarylinuxx:blxshell (build.opensuse.org) │${NC}"
echo -e "${GREEN} │ │${NC}"
echo -e "${GREEN} │ This provides all custom packages not available │${NC}"
echo -e "${GREEN} │ in the default Tumbleweed repositories. │${NC}"
echo -e "${GREEN}${BOLD} └─────────────────────────────────────────────────────┘${NC}"
echo ""
warning "An additional OBS repository will be added to your system"
confirm "Continue?" || exit 1
}
_show_non_arch_notice() {
echo ""
echo -e "${YELLOW}${BOLD} ┌─────────────────────────────────────────────────────┐${NC}"
echo -e "${YELLOW}${BOLD} │ Non-Arch System Detected │${NC}"
echo -e "${YELLOW}${BOLD} ├─────────────────────────────────────────────────────┤${NC}"
echo -e "${YELLOW} │ blxshell currently supports Arch-based distros │${NC}"
echo -e "${YELLOW} │ only for automatic package installation. │${NC}"
echo -e "${YELLOW} │ │${NC}"
echo -e "${YELLOW} │ Only .config dotfiles will be installed. │${NC}"
echo -e "${YELLOW} │ You will need to manually install dependencies │${NC}"
echo -e "${YELLOW} │ listed in: arch-deps/blxshell-*/PKGBUILD │${NC}"
echo -e "${YELLOW}${BOLD} └─────────────────────────────────────────────────────┘${NC}"
echo ""
warning "Package installation will be skipped"
confirm "Continue with dotfiles only?" || exit 1
}