Make kernel version customizable

This commit is contained in:
Victor 2023-02-18 23:14:08 +00:00
parent 2885e9c222
commit 2b24a0dc3b
3 changed files with 14 additions and 11 deletions

View File

@ -13,5 +13,6 @@ if [ "$sproc" -gt 1 ]; then
fi fi
fi fi
kernelver=${kernelver:-$(uname -r)} KVER="${KVER:-$(uname -r)}"
make "-j$sproc" "KVER=$kernelver" "KSRC=/lib/modules/$kernelver/build" KSRC="/lib/modules/$KVER/build"
make "-j$sproc" "KVER=$KVER" "KSRC=$KSRC"

View File

@ -28,8 +28,9 @@ SCRIPT_VERSION="20230126"
MODULE_NAME="88x2bu" MODULE_NAME="88x2bu"
DRV_VERSION="5.13.1" DRV_VERSION="5.13.1"
KARCH="$(uname -m)" KARCH="${KARCH:-$(uname -m)}"
KVER="$(uname -r)" KVER="${KVER:-$(uname -r)}"
KSRC="/lib/modules/$KVER/build"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/" MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl${MODULE_NAME}" DRV_NAME="rtl${MODULE_NAME}"
@ -91,7 +92,7 @@ if ! command -v make >/dev/null 2>&1; then
fi fi
# check to see if the correct header files are installed # check to see if the correct header files are installed
if [ ! -d "/lib/modules/$(uname -r)/build" ]; then if [ ! -d "$KSRC" ]; then
echo "Your kernel header files aren't properly installed." echo "Your kernel header files aren't properly installed."
echo "Please consult your distro documentation or user support forums." echo "Please consult your distro documentation or user support forums."
echo "Once the header files are properly installed, please run \"sudo ./${SCRIPT_NAME}\"" echo "Once the header files are properly installed, please run \"sudo ./${SCRIPT_NAME}\""
@ -309,9 +310,9 @@ else
fi fi
if command -v /usr/bin/time >/dev/null 2>&1; then if command -v /usr/bin/time >/dev/null 2>&1; then
/usr/bin/time -f "Compile time: %U seconds" dkms build -m ${DRV_NAME} -v ${DRV_VERSION} /usr/bin/time -f "Compile time: %U seconds" dkms build -m ${DRV_NAME} -v ${DRV_VERSION} -k "$KVER" --kernelsourcedir "$KSRC"
else else
dkms build -m ${DRV_NAME} -v ${DRV_VERSION} dkms build -m ${DRV_NAME} -v ${DRV_VERSION} -k "$KVER" --kernelsourcedir "$KSRC"
fi fi
RESULT=$? RESULT=$?
@ -326,7 +327,7 @@ else
echo "The driver was built by dkms successfully." echo "The driver was built by dkms successfully."
fi fi
dkms install -m ${DRV_NAME} -v ${DRV_VERSION} dkms install -m ${DRV_NAME} -v ${DRV_VERSION} -k "$KVER" --kernelsourcedir "$KSRC"
RESULT=$? RESULT=$?
if [ "$RESULT" != "0" ]; then if [ "$RESULT" != "0" ]; then

View File

@ -28,8 +28,9 @@ SCRIPT_VERSION="20230126"
MODULE_NAME="88x2bu" MODULE_NAME="88x2bu"
DRV_VERSION="5.13.1" DRV_VERSION="5.13.1"
KARCH="$(uname -m)" KARCH="${KARCH:-$(uname -m)}"
KVER="$(uname -r)" KVER="${KVER:-$(uname -r)}"
KSRC="/lib/modules/$KVER/build"
MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/" MODDESTDIR="/lib/modules/${KVER}/kernel/drivers/net/wireless/"
DRV_NAME="rtl${MODULE_NAME}" DRV_NAME="rtl${MODULE_NAME}"
@ -104,7 +105,7 @@ fi
if command -v dkms >/dev/null 2>&1; then if command -v dkms >/dev/null 2>&1; then
echo "Removing a dkms installation." echo "Removing a dkms installation."
# 2>/dev/null suppresses the output of dkms # 2>/dev/null suppresses the output of dkms
dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} --all 2>/dev/null dkms remove -m ${DRV_NAME} -v ${DRV_VERSION} -k "$KVER" --kernelsourcedir "$KSRC" --all 2>/dev/null
RESULT=$? RESULT=$?
#echo "Result=${RESULT}" #echo "Result=${RESULT}"