From ec0c0f7ea396890e9d5f107ed6c136c099ac657b Mon Sep 17 00:00:00 2001 From: Fahad Alduraibi Date: Tue, 9 Jun 2026 23:10:14 +0300 Subject: [PATCH] Refactor module installation and restoration logic to work with Fedora 44 Updated the install_module and do_restore functions to handle module installation and restoration for Fedora 44. --- scripts/bc250-enable-40cu-fedora.sh | 30 +++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/scripts/bc250-enable-40cu-fedora.sh b/scripts/bc250-enable-40cu-fedora.sh index 52f29fc..c6bd02a 100755 --- a/scripts/bc250-enable-40cu-fedora.sh +++ b/scripts/bc250-enable-40cu-fedora.sh @@ -252,25 +252,15 @@ build_module() { install_module() { local built="$1" - local target="${MODPATH}" - - if [ -f "${target}.zst" ]; then - target="${target}.zst" - elif [ ! -f "$target" ]; then - target="${target}.zst" - fi + local target="$(ls "${MODPATH}"* 2>/dev/null | grep -E '\.ko(\.xz)?$' | head -n 1)" if [ -f "$target" ] && [ ! -f "${target}${BACKUP_SUFFIX}" ]; then info "Backing up original to ${target}${BACKUP_SUFFIX}" - cp "$target" "${target}${BACKUP_SUFFIX}" + mv "$target" "${target}${BACKUP_SUFFIX}" fi - if [ "${target%.zst}" != "$target" ]; then - info "Compressing and installing module..." - zstd -f "$built" -o "$target" - else - cp "$built" "$target" - fi + info "Compressing and installing module..." + zstd -f "$built" -o "${MODPATH}.zst" depmod -a "$KVER" info "Module installed at ${target}" @@ -311,11 +301,17 @@ do_disable() { do_restore() { local target="${MODPATH}" - if [ -f "${target}.zst" ]; then target="${target}.zst"; fi local backup - backup="$(ls -1 "${target}.bc250-backup-"* 2>/dev/null | head -1)" + backup="$(ls -1 "${target}"*".bc250-backup-"* 2>/dev/null | head -1)" [ -n "$backup" ] || die "No backup found" - cp "$backup" "$target" + + # Wipe the patched module(s) + rm -f "${target}.zst" "${target}.xz" "${target}" + + # Restore the original + local orig_name="${backup%.bc250-backup-*}" + mv "$backup" "$orig_name" + rm -f "$CONF40" depmod -a "$KVER" info "Original module restored. Reboot to apply."