Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions scripts/local-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,39 @@ comprehensive_cleanup() {
return 0
}

# Detect if kernel was compiled with LLVM/Clang (e.g., CachyOS, some Arch variants)
# Returns 0 (true) if LLVM kernel detected, 1 (false) otherwise
is_llvm_kernel() {
# Check kernel build info
if grep -qi "clang\|llvm" /proc/version 2>/dev/null; then
return 0
fi
# Check for known LLVM-based distros
if [ -f /etc/os-release ]; then
if grep -qi "cachyos" /etc/os-release; then
return 0
fi
fi
return 1
}

# Install build dependencies based on distribution
install_build_deps() {
if command -v pacman &> /dev/null; then
# Arch-based (including CachyOS, Manjaro, EndeavourOS)
pacman -S --needed --noconfirm base-devel
if is_llvm_kernel; then
pacman -S --needed --noconfirm clang llvm lld
fi
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y build-essential
elif command -v dnf &> /dev/null; then
dnf install -y gcc make kernel-devel
elif command -v zypper &> /dev/null; then
zypper install -y gcc make kernel-devel
fi
}

install_drivers() {
echo -e "${YELLOW}Installing Linuwu-Sense drivers...${NC}"

Expand All @@ -179,16 +212,25 @@ install_drivers() {

cd Linuwu-Sense

# Check if make is installed
# Install required build dependencies
if ! command -v make &> /dev/null; then
echo -e "${YELLOW}Installing build tools...${NC}"
apt-get update && apt-get install -y build-essential
install_build_deps
fi

# Build and install drivers
make clean
make
make install
# Build driver with appropriate compiler flags
# LLVM-compiled kernels (CachyOS, etc.) require matching compiler
if is_llvm_kernel; then
echo -e "${YELLOW}Detected LLVM-compiled kernel, using Clang...${NC}"
install_build_deps # Ensure clang is installed
make clean LLVM=1 CC=clang
make LLVM=1 CC=clang
make install LLVM=1 CC=clang
else
make clean
make
make install
fi

if [ $? -eq 0 ]; then
echo -e "${GREEN}Linuwu-Sense drivers installed successfully!${NC}"
Expand Down
46 changes: 42 additions & 4 deletions scripts/remote-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,33 @@ extract_release() {
tar -xJf "$tarball" -C "$target_dir"
}

# Detect if kernel was compiled with LLVM/Clang (e.g., CachyOS, some Arch variants)
is_llvm_kernel() {
if grep -qi "clang\|llvm" /proc/version 2>/dev/null; then
return 0
fi
if [ -f /etc/os-release ] && grep -qi "cachyos" /etc/os-release; then
return 0
fi
return 1
}

# Install build dependencies based on distribution
install_build_deps() {
if command -v pacman &> /dev/null; then
pacman -S --needed --noconfirm base-devel
if is_llvm_kernel; then
pacman -S --needed --noconfirm clang llvm lld
fi
elif command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y build-essential
elif command -v dnf &> /dev/null; then
dnf install -y gcc make kernel-devel
elif command -v zypper &> /dev/null; then
zypper install -y gcc make kernel-devel
fi
}

clone_and_install_linuwu_sense() {
echo -e "${YELLOW}Cloning and installing Linuwu-Sense drivers...${NC}"
rm -rf Linuwu-Sense
Expand All @@ -202,14 +229,25 @@ clone_and_install_linuwu_sense() {

cd Linuwu-Sense

# Install build dependencies if needed
if ! command -v make &> /dev/null; then
echo -e "${YELLOW}Installing build tools...${NC}"
apt-get update && apt-get install -y build-essential
install_build_deps
fi

# Build with appropriate compiler for the kernel
if is_llvm_kernel; then
echo -e "${YELLOW}Detected LLVM-compiled kernel, using Clang...${NC}"
install_build_deps # Ensure clang is installed
make clean LLVM=1 CC=clang
make LLVM=1 CC=clang
make install LLVM=1 CC=clang
else
make clean
make
make install
fi

make clean
make
make install
local result=$?
cd ..
if [ $result -eq 0 ]; then
Expand Down
59 changes: 43 additions & 16 deletions scripts/remoteSetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,35 @@ comprehensive_cleanup() {
return 0
}

# Detect if kernel was compiled with LLVM/Clang (e.g., CachyOS, some Arch variants)
is_llvm_kernel() {
if grep -qi "clang\|llvm" /proc/version 2>/dev/null; then
return 0
fi
if [ -f /etc/os-release ] && grep -qi "cachyos" /etc/os-release; then
return 0
fi
return 1
}

# Install build dependencies based on distribution
install_build_deps() {
if command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y build-essential linux-headers-$(uname -r)
elif command -v yum &> /dev/null; then
yum install -y gcc make kernel-devel
elif command -v dnf &> /dev/null; then
dnf install -y gcc make kernel-devel
elif command -v pacman &> /dev/null; then
pacman -S --needed --noconfirm base-devel linux-headers
if is_llvm_kernel; then
pacman -S --needed --noconfirm clang llvm lld
fi
elif command -v zypper &> /dev/null; then
zypper install -y gcc make kernel-devel
fi
}

install_drivers() {
echo -e "${YELLOW}Installing Linuwu-Sense drivers...${NC}"

Expand All @@ -305,26 +334,24 @@ install_drivers() {

cd "$EXTRACTED_DIR/Linuwu-Sense"

# Check if make is installed
# Install build dependencies if needed
if ! command -v make &> /dev/null; then
echo -e "${YELLOW}Installing build tools...${NC}"
if command -v apt-get &> /dev/null; then
apt-get update && apt-get install -y build-essential linux-headers-$(uname -r)
elif command -v yum &> /dev/null; then
yum install -y gcc make kernel-devel
elif command -v dnf &> /dev/null; then
dnf install -y gcc make kernel-devel
elif command -v pacman &> /dev/null; then
pacman -S --noconfirm base-devel linux-headers
elif command -v zypper &> /dev/null; then
zypper install -y gcc make kernel-devel
fi
install_build_deps
fi

# Build and install drivers
make clean
make
make install
# Build with appropriate compiler for the kernel
if is_llvm_kernel; then
echo -e "${YELLOW}Detected LLVM-compiled kernel, using Clang...${NC}"
install_build_deps # Ensure clang is installed
make clean LLVM=1 CC=clang
make LLVM=1 CC=clang
make install LLVM=1 CC=clang
else
make clean
make
make install
fi

if [ $? -eq 0 ]; then
echo -e "${GREEN}Linuwu-Sense drivers installed successfully!${NC}"
Expand Down