linux-xanmod-bin 6.17.9-2

This commit is contained in:
2025-11-27 19:39:53 +03:00
parent 6fb20605de
commit d153f8e667
3 changed files with 52 additions and 56 deletions

View File

@@ -33,7 +33,7 @@ is_url() {
name='linux-xanmod-bin' name='linux-xanmod-bin'
version='6.17.9' version='6.17.9'
release='1' release='2'
branch='main' branch='main'
pkgverdl="${version%-*}" pkgverdl="${version%-*}"
desc='The Linux kernel, modules and headers with Xanmod patches - Prebuilt version' desc='The Linux kernel, modules and headers with Xanmod patches - Prebuilt version'

View File

@@ -1,24 +1,30 @@
#!/bin/bash #!/bin/bash
# Post-install script for linux-xanmod-bin
set -e set -e
# Get kernel version from the installed files kernel_version=$(ls -1 /usr/lib/modules/ 2>/dev/null | grep -E '\-xanmod[0-9]*$' | sort -V | tail -n 1)
kernel_version=$(basename /usr/lib/modules/*-xanmod1 2>/dev/null | head -n 1)
if [ -z "$kernel_version" ]; then if [ -z "$kernel_version" ]; then
echo "Error: Could not determine kernel version" echo "Error: Could not determine kernel version"
exit 1 exit 1
fi 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..." echo "Detected kernel $kernel_version, running system hooks..."
# For RedOS/RHEL/Fedora systems with dracut kernel_path="/boot/vmlinuz-$kernel_version"
modules_vmlinuz="/usr/lib/modules/$kernel_version/vmlinuz"
if [ ! -f "$kernel_path" ]; then
if [ -f "$modules_vmlinuz" ]; then
echo "Copying kernel image to /boot..."
cp "$modules_vmlinuz" "$kernel_path"
chmod 755 "$kernel_path"
else
echo "Error: Kernel image not found in /boot or modules directory"
exit 1
fi
fi
if command -v dracut >/dev/null 2>&1; then if command -v dracut >/dev/null 2>&1; then
initramfs_img="/boot/initramfs-$kernel_version.img" initramfs_img="/boot/initramfs-$kernel_version.img"
echo "Creating initramfs for $kernel_version using dracut..." echo "Creating initramfs for $kernel_version using dracut..."
@@ -26,38 +32,30 @@ if command -v dracut >/dev/null 2>&1; then
echo "Initramfs created: $initramfs_img" echo "Initramfs created: $initramfs_img"
fi fi
# For Arch-based systems with mkinitcpio
if command -v mkinitcpio >/dev/null 2>&1; then if command -v mkinitcpio >/dev/null 2>&1; then
echo "Creating initramfs for $kernel_version using mkinitcpio..." echo "Creating initramfs for $kernel_version using mkinitcpio..."
mkinitcpio -k "$kernel_version" -g "/boot/initramfs-$kernel_version.img" mkinitcpio -k "$kernel_version" -g "/boot/initramfs-$kernel_version.img"
fi fi
# For Debian-based systems with update-initramfs
if command -v update-initramfs >/dev/null 2>&1; then if command -v update-initramfs >/dev/null 2>&1; then
echo "Creating initramfs for $kernel_version using update-initramfs..." echo "Creating initramfs for $kernel_version using update-initramfs..."
update-initramfs -c -k "$kernel_version" update-initramfs -c -k "$kernel_version"
fi fi
# For Alpine Linux with mkinitfs
if command -v mkinitfs >/dev/null 2>&1; then if command -v mkinitfs >/dev/null 2>&1; then
echo "Creating initramfs for $kernel_version using mkinitfs..." echo "Creating initramfs for $kernel_version using mkinitfs..."
mkinitfs -o "/boot/initramfs-$kernel_version" "$kernel_version" mkinitfs -o "/boot/initramfs-$kernel_version" "$kernel_version"
fi fi
# Update GRUB configuration
echo "Updating bootloader configuration..." echo "Updating bootloader configuration..."
# For RHEL/Fedora/RedOS with grubby (BLS - Boot Loader Specification)
if command -v grubby >/dev/null 2>&1; then if command -v grubby >/dev/null 2>&1; then
echo "Adding kernel to bootloader using grubby..." echo "Adding kernel to bootloader using grubby..."
kernel_path="/boot/vmlinuz-$kernel_version"
initrd_path="/boot/initramfs-$kernel_version.img" initrd_path="/boot/initramfs-$kernel_version.img"
# Check if kernel already exists in grubby
if grubby --info="$kernel_path" >/dev/null 2>&1; then if grubby --info="$kernel_path" >/dev/null 2>&1; then
echo "Kernel already registered in bootloader" echo "Kernel already registered in bootloader"
else else
# Add kernel entry
grubby --add-kernel="$kernel_path" \ grubby --add-kernel="$kernel_path" \
--initrd="$initrd_path" \ --initrd="$initrd_path" \
--title="Red OS Linux ($kernel_version) - Xanmod" \ --title="Red OS Linux ($kernel_version) - Xanmod" \
@@ -65,17 +63,14 @@ if command -v grubby >/dev/null 2>&1; then
echo "Kernel added to bootloader" echo "Kernel added to bootloader"
fi fi
# For Debian/Ubuntu with update-grub
elif command -v update-grub >/dev/null 2>&1; then elif command -v update-grub >/dev/null 2>&1; then
echo "Updating GRUB configuration..." echo "Updating GRUB configuration..."
update-grub update-grub
# For other systems with grub2-mkconfig
elif command -v grub2-mkconfig >/dev/null 2>&1; then elif command -v grub2-mkconfig >/dev/null 2>&1; then
echo "Updating GRUB2 configuration..." echo "Updating GRUB2 configuration..."
grub2-mkconfig -o /boot/grub2/grub.cfg grub2-mkconfig -o /boot/grub2/grub.cfg
# For systems with grub-mkconfig
elif command -v grub-mkconfig >/dev/null 2>&1; then elif command -v grub-mkconfig >/dev/null 2>&1; then
echo "Updating GRUB configuration..." echo "Updating GRUB configuration..."
grub-mkconfig -o /boot/grub/grub.cfg grub-mkconfig -o /boot/grub/grub.cfg

View File

@@ -1,49 +1,49 @@
#!/bin/bash #!/bin/bash
# Post-remove script for linux-xanmod-bin
# Get kernel version from boot files (since modules may already be removed) kernel_versions=$(ls /boot/vmlinuz-*-xanmod* 2>/dev/null | sed 's|/boot/vmlinuz-||' || true)
kernel_version=$(ls /boot/vmlinuz-*-xanmod1 2>/dev/null | head -n 1 | sed 's|/boot/vmlinuz-||')
if [ -z "$kernel_version" ]; then if [ -z "$kernel_versions" ]; then
echo "Kernel version could not be determined, cleanup may be incomplete" echo "No xanmod kernels found in /boot, cleanup may be incomplete"
exit 0 exit 0
fi fi
echo "Cleaning up after removal of kernel $kernel_version..." for kernel_version in $kernel_versions; do
echo "Cleaning up kernel $kernel_version..."
kernel_path="/boot/vmlinuz-$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 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 if grubby --info="$kernel_path" >/dev/null 2>&1; then
echo "Removing kernel entry using grubby..." echo "Removing kernel entry using grubby..."
grubby --remove-kernel="$kernel_path" grubby --remove-kernel="$kernel_path" || true
echo "Kernel removed from bootloader" echo "Kernel removed from bootloader"
fi fi
fi fi
# Remove initramfs if it exists
initramfs_img="/boot/initramfs-$kernel_version.img" initramfs_img="/boot/initramfs-$kernel_version.img"
if [ -f "$initramfs_img" ]; then if [ -f "$initramfs_img" ]; then
echo "Removing initramfs: $initramfs_img" echo "Removing initramfs: $initramfs_img"
rm -f "$initramfs_img" rm -f "$initramfs_img"
fi fi
# Remove kernel image from /boot if it still exists
if [ -f "$kernel_path" ]; then if [ -f "$kernel_path" ]; then
echo "Removing kernel image: $kernel_path" echo "Removing kernel image: $kernel_path"
rm -f "$kernel_path" rm -f "$kernel_path"
fi fi
# Remove System.map if it exists
if [ -f "/boot/System.map-$kernel_version" ]; then if [ -f "/boot/System.map-$kernel_version" ]; then
echo "Removing System.map: /boot/System.map-$kernel_version" echo "Removing System.map: /boot/System.map-$kernel_version"
rm -f "/boot/System.map-$kernel_version" rm -f "/boot/System.map-$kernel_version"
fi fi
# Update GRUB configuration (for non-BLS systems) if [ -d "/usr/lib/modules/$kernel_version" ]; then
echo "Removing modules: /usr/lib/modules/$kernel_version"
rm -rf "/usr/lib/modules/$kernel_version"
fi
echo "Kernel $kernel_version has been removed."
done
if command -v update-grub >/dev/null 2>&1; then if command -v update-grub >/dev/null 2>&1; then
echo "Updating GRUB configuration..." echo "Updating GRUB configuration..."
update-grub update-grub
@@ -55,5 +55,6 @@ elif command -v grub-mkconfig >/dev/null 2>&1 && ! command -v grubby >/dev/null
grub-mkconfig -o /boot/grub/grub.cfg grub-mkconfig -o /boot/grub/grub.cfg
fi fi
echo "Kernel $kernel_version has been removed." echo ""
echo "All xanmod kernels have been removed."
echo "Please ensure you have another kernel installed before rebooting." echo "Please ensure you have another kernel installed before rebooting."