From 3ceabdb9a38e2461646c8b65f5b4c8c05151093c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=A5=D1=80?= =?UTF-8?q?=D0=B0=D0=BC=D0=BE=D0=B2?= Date: Thu, 27 Nov 2025 18:53:41 +0300 Subject: [PATCH] linux-xanmod-bin 6.17.6-1 --- linux-xanmode-bin/alr.sh | 209 +++++++++++++++++++++++++++++++ linux-xanmode-bin/postinstall.sh | 93 ++++++++++++++ linux-xanmode-bin/postremove.sh | 59 +++++++++ 3 files changed, 361 insertions(+) create mode 100644 linux-xanmode-bin/alr.sh create mode 100644 linux-xanmode-bin/postinstall.sh create mode 100644 linux-xanmode-bin/postremove.sh diff --git a/linux-xanmode-bin/alr.sh b/linux-xanmode-bin/alr.sh new file mode 100644 index 0000000..61235e5 --- /dev/null +++ b/linux-xanmode-bin/alr.sh @@ -0,0 +1,209 @@ +check_psabi() { + awk 'BEGIN { + while (!/flags/) if (getline < "/proc/cpuinfo" != 1) exit 1 + if (/lm/&&/cmov/&&/cx8/&&/fpu/&&/fxsr/&&/mmx/&&/syscall/&&/sse2/) level = 1 + if (level == 1 && /cx16/&&/lahf/&&/popcnt/&&/sse4_1/&&/sse4_2/&&/ssse3/) level = 2 + if (level == 2 && /avx/&&/avx2/&&/bmi1/&&/bmi2/&&/f16c/&&/fma/&&/abm/&&/movbe/&&/xsave/) level = 3 + if (level == 3 && /avx512f/&&/avx512bw/&&/avx512cd/&&/avx512dq/&&/avx512vl/) level = 4 + if (level > 0) { print "x64v" level } + }' 2>/dev/null||echo "x64v1" +} + +is_exe_exist() { command -v "$@" &>/dev/null ; } + +check_url_stat_code() { + set -o pipefail + if is_exe_exist curl + then curl -sL -o /dev/null -I -w "%{http_code}" "$@" 2>/dev/null + elif is_exe_exist wget + then wget --no-check-certificate --server-response \ + --spider "$@"|& awk '/^ HTTP/{print$2}'|tail -1 + else return 1 + fi +} + +is_url() { + [ ! -n "$1" ] && \ + return 1 + if [ -n "$2" ] + then [ "$(check_url_stat_code "$1")" == "$2" ] + else [ "$(check_url_stat_code "$1")" == "200" ] + fi +} + +name='linux-xanmod-bin' +version='6.17.6' +release='1' +branch='main' +pkgverdl="${version%-*}" +desc='The Linux kernel, modules and headers with Xanmod patches - Prebuilt version' +desc_ru='The Linux kernel, modules and headers with Xanmod patches - Prebuilt version' +homepage='http://www.xanmod.org/' +maintainer="Евгений Храмов (imported from AUR)" +maintainer_ru="Евгений Храмов (импортирован из AUR)" +architectures=('amd64') +license=('GPL2') +provides=('VIRTUALBOX-GUEST-MODULES' 'WIREGUARD-MODULE' 'KSMBD-MODULE' 'NTFS3-MODULE' ) +conflicts=('linux-xanmod-headers' 'linux-xanmod' ) + +# Базовые зависимости +deps=('coreutils' 'kmod') +build_deps=('curl' 'gawk' 'grep' 'tar' 'xz' 'jq' 'binutils') + +# Зависимости для конкретных дистрибутивов +deps_arch=('coreutils' 'kmod' 'mkinitcpio' 'pahole') +deps_debian=('coreutils' 'kmod' 'initramfs-tools' 'pahole') +deps_altlinux=('coreutils' 'kmod' 'make-initrd' 'dwarves') +deps_alpine=('coreutils' 'kmod' 'mkinitfs' 'pahole') +deps_redos=('coreutils' 'kmod' 'dracut' 'dwarves') +deps_fedora=('coreutils' 'kmod' 'dracut' 'dwarves') +deps_rhel=('coreutils' 'kmod' 'dracut' 'dwarves') +deps_rosa=('coreutils' 'kmod' 'dracut' 'dwarves') + +# Опциональные зависимости +opt_deps=( + 'crda' + 'linux-firmware' +) + +scripts=( + ['postinstall']='postinstall.sh' + ['postremove']='postremove.sh' +) + +prepare() { + cd "$srcdir" + + # Determine CPU capabilities + detected_psabi="$(check_psabi)" + + # Determine best available psabi and construct URLs + for v in ${detected_psabi/x64v/} 3 2 1; do + [[ "$v" -le "${detected_psabi/x64v/}" && "$_psabi" != "x64v$v" ]] || continue + _psabi="x64v$v" + _url="https://sourceforge.net/projects/xanmod/files/releases/$branch/${pkgverdl}-xanmod1/${pkgverdl}-${_psabi}-xanmod1" + if is_url "$_url"; then + detected_psabi="$_psabi" + break + fi + done + + echo "==> Определена архитектура процессора: $detected_psabi" + + # Get download URLs + url_info="$(curl -sL "$_url" | grep "net.sf.files" | sed 's|net.sf.files = ||g;s|;$||' | jq -r '.[].download_url' | grep -v '\-dbg_')" + url_image="$(echo "$url_info" | grep -o "https:.*/linux-image.*deb" | head -1)" + url_headers="$(echo "$url_info" | grep -o "https:.*/linux-headers.*deb" | head -1)" + file_image="${url_image##*/}" + file_headers="${url_headers##*/}" + + # Download files if not already present (caching in $srcdir) + if [ ! -f "$file_image" ]; then + echo "==> Загрузка образа ядра: $file_image" + curl -L -o "$file_image" "$url_image" + else + echo "==> Использование кешированного образа ядра: $file_image" + fi + + if [ ! -f "$file_headers" ]; then + echo "==> Загрузка заголовков ядра: $file_headers" + curl -L -o "$file_headers" "$url_headers" + else + echo "==> Использование кешированных заголовков ядра: $file_headers" + fi + + # Extract packages using ar and tar + echo "==> Распаковка образа ядра..." + ar x "$file_image" data.tar.xz + mkdir -p .extract && tar --no-same-owner --no-same-permissions -C .extract -xf data.tar.xz + cp -af .extract/* . 2>/dev/null || true + rm -rf .extract data.tar.xz + + echo "==> Распаковка заголовков ядра..." + ar x "$file_headers" data.tar.xz + mkdir -p .extract && tar --no-same-owner --no-same-permissions -C .extract -xf data.tar.xz + cp -af .extract/* . 2>/dev/null || true + rm -rf .extract data.tar.xz + + # Save psabi for package() function + echo "$detected_psabi" > "$srcdir/.psabi" +} + +# Бинарный пакет - сборка не требуется + +package() { + cd "$srcdir" + + # Read psabi from file + detected_psabi="$(cat "$srcdir/.psabi")" + kernver="${pkgverdl}-${detected_psabi}-xanmod1" + modulesdir="$pkgdir/usr/lib/modules/${kernver}" + + echo "==> Установка модулей ядра для ${kernver}..." + mkdir -p "${modulesdir}" + + # Copy modules directory + if [ -d "lib/modules/${kernver}" ]; then + cp -r --no-preserve=ownership "lib/modules/${kernver}"/* "${modulesdir}/" || \ + cp -R "lib/modules/${kernver}"/* "${modulesdir}/" + fi + + # Установка образа ядра в /boot для загрузки + echo "==> Установка образа ядра в /boot..." + mkdir -p "$pkgdir/boot" + install -Dm755 "boot/vmlinuz-${kernver}" "$pkgdir/boot/vmlinuz-${kernver}" + + # systemd expects to find the kernel here to allow hibernation + # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 + install -Dm755 "boot/vmlinuz-${kernver}" "$modulesdir/vmlinuz" + + # Used by mkinitcpio to name the kernel + echo "${name%-bin}" | install -Dm644 /dev/stdin "$modulesdir/pkgbase" + + # Установка System.map если есть + if [ -f "boot/System.map-${kernver}" ]; then + install -Dm644 "boot/System.map-${kernver}" "$pkgdir/boot/System.map-${kernver}" + fi + + # Установка конфигурации ядра если есть + if [ -f "boot/config-${kernver}" ]; then + install -Dm644 "boot/config-${kernver}" "$modulesdir/config" + fi + + # Установка заголовков из usr если есть + if [ -d usr ]; then + echo "==> Установка заголовков ядра..." + mkdir -p "$pkgdir/usr" + # Copy recursively with fallback for different cp versions + cp -r --no-preserve=ownership usr/* "$pkgdir/usr/" 2>/dev/null || \ + cp -R usr/* "$pkgdir/usr/" 2>/dev/null || \ + (cd usr && find . -type f -exec install -Dm644 {} "$pkgdir/usr"/{} \;) + fi +} + +files() { + # Find all files recursively in boot + if [ -d ./boot ]; then + find ./boot -type f -printf '%p\n' + fi + + # Find all files in modules directory + if [ -d ./usr/lib/modules ]; then + find ./usr/lib/modules -type f -printf '%p\n' + find ./usr/lib/modules -type l -printf '%p\n' + fi + + # Find additional files in /usr + if [ -d ./usr/include ]; then + find ./usr/include -type f -printf '%p\n' + fi + + if [ -d ./usr/share ]; then + find ./usr/share -type f -printf '%p\n' + fi + + if [ -d ./usr/src ]; then + find ./usr/src -type f -printf '%p\n' + find ./usr/src -type l -printf '%p\n' + fi +} \ No newline at end of file diff --git a/linux-xanmode-bin/postinstall.sh b/linux-xanmode-bin/postinstall.sh new file mode 100644 index 0000000..1a733ce --- /dev/null +++ b/linux-xanmode-bin/postinstall.sh @@ -0,0 +1,93 @@ +#!/bin/bash +# Post-install script for linux-xanmod-bin + +set -e + +# Get kernel version from the installed files +kernel_version=$(basename /usr/lib/modules/*-xanmod1 2>/dev/null | head -n 1) + +if [ -z "$kernel_version" ]; then + echo "Error: Could not determine kernel version" + exit 1 +fi + +if [ ! -f "/boot/vmlinuz-$kernel_version" ]; then + echo "Error: Kernel image /boot/vmlinuz-$kernel_version not found" + exit 1 +fi + +echo "Detected kernel $kernel_version, running system hooks..." + +# For RedOS/RHEL/Fedora systems with dracut +if command -v dracut >/dev/null 2>&1; then + initramfs_img="/boot/initramfs-$kernel_version.img" + echo "Creating initramfs for $kernel_version using dracut..." + dracut --force --kmoddir "/usr/lib/modules/$kernel_version" "$initramfs_img" "$kernel_version" + echo "Initramfs created: $initramfs_img" +fi + +# For Arch-based systems with mkinitcpio +if command -v mkinitcpio >/dev/null 2>&1; then + echo "Creating initramfs for $kernel_version using mkinitcpio..." + mkinitcpio -k "$kernel_version" -g "/boot/initramfs-$kernel_version.img" +fi + +# For Debian-based systems with update-initramfs +if command -v update-initramfs >/dev/null 2>&1; then + echo "Creating initramfs for $kernel_version using update-initramfs..." + update-initramfs -c -k "$kernel_version" +fi + +# For Alpine Linux with mkinitfs +if command -v mkinitfs >/dev/null 2>&1; then + echo "Creating initramfs for $kernel_version using mkinitfs..." + mkinitfs -o "/boot/initramfs-$kernel_version" "$kernel_version" +fi + +# Update GRUB configuration +echo "Updating bootloader configuration..." + +# For RHEL/Fedora/RedOS with grubby (BLS - Boot Loader Specification) +if command -v grubby >/dev/null 2>&1; then + echo "Adding kernel to bootloader using grubby..." + kernel_path="/boot/vmlinuz-$kernel_version" + initrd_path="/boot/initramfs-$kernel_version.img" + + # Check if kernel already exists in grubby + if grubby --info="$kernel_path" >/dev/null 2>&1; then + echo "Kernel already registered in bootloader" + else + # Add kernel entry + grubby --add-kernel="$kernel_path" \ + --initrd="$initrd_path" \ + --title="Red OS Linux ($kernel_version) - Xanmod" \ + --copy-default + echo "Kernel added to bootloader" + fi + +# For Debian/Ubuntu with update-grub +elif command -v update-grub >/dev/null 2>&1; then + echo "Updating GRUB configuration..." + update-grub + +# For other systems with grub2-mkconfig +elif command -v grub2-mkconfig >/dev/null 2>&1; then + echo "Updating GRUB2 configuration..." + grub2-mkconfig -o /boot/grub2/grub.cfg + +# For systems with grub-mkconfig +elif command -v grub-mkconfig >/dev/null 2>&1; then + echo "Updating GRUB configuration..." + grub-mkconfig -o /boot/grub/grub.cfg +else + echo "Warning: No bootloader configuration tool found. Please update your bootloader manually." +fi + +echo "" +echo "==========================================" +echo "Kernel $kernel_version installed successfully!" +echo "" +echo "To boot into this kernel:" +echo "1. Reboot your system" +echo "2. Select 'linux-xanmod' from the GRUB menu" +echo "==========================================" \ No newline at end of file diff --git a/linux-xanmode-bin/postremove.sh b/linux-xanmode-bin/postremove.sh new file mode 100644 index 0000000..d38379d --- /dev/null +++ b/linux-xanmode-bin/postremove.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# Post-remove script for linux-xanmod-bin + +# Get kernel version from boot files (since modules may already be removed) +kernel_version=$(ls /boot/vmlinuz-*-xanmod1 2>/dev/null | head -n 1 | sed 's|/boot/vmlinuz-||') + +if [ -z "$kernel_version" ]; then + echo "Kernel version could not be determined, cleanup may be incomplete" + exit 0 +fi + +echo "Cleaning up after removal of kernel $kernel_version..." + +kernel_path="/boot/vmlinuz-$kernel_version" + +# Remove from bootloader first +echo "Removing kernel from bootloader..." +if command -v grubby >/dev/null 2>&1; then + # For RHEL/Fedora/RedOS with grubby + if grubby --info="$kernel_path" >/dev/null 2>&1; then + echo "Removing kernel entry using grubby..." + grubby --remove-kernel="$kernel_path" + echo "Kernel removed from bootloader" + fi +fi + +# Remove initramfs if it exists +initramfs_img="/boot/initramfs-$kernel_version.img" +if [ -f "$initramfs_img" ]; then + echo "Removing initramfs: $initramfs_img" + rm -f "$initramfs_img" +fi + +# Remove kernel image from /boot if it still exists +if [ -f "$kernel_path" ]; then + echo "Removing kernel image: $kernel_path" + rm -f "$kernel_path" +fi + +# Remove System.map if it exists +if [ -f "/boot/System.map-$kernel_version" ]; then + echo "Removing System.map: /boot/System.map-$kernel_version" + rm -f "/boot/System.map-$kernel_version" +fi + +# Update GRUB configuration (for non-BLS systems) +if command -v update-grub >/dev/null 2>&1; then + echo "Updating GRUB configuration..." + update-grub +elif command -v grub2-mkconfig >/dev/null 2>&1 && ! command -v grubby >/dev/null 2>&1; then + echo "Updating GRUB2 configuration..." + grub2-mkconfig -o /boot/grub2/grub.cfg +elif command -v grub-mkconfig >/dev/null 2>&1 && ! command -v grubby >/dev/null 2>&1; then + echo "Updating GRUB configuration..." + grub-mkconfig -o /boot/grub/grub.cfg +fi + +echo "Kernel $kernel_version has been removed." +echo "Please ensure you have another kernel installed before rebooting."