diff --git a/hooks/dapper/80-install-modules b/hooks/dapper/80-install-modules index 9ea1a55..76380fe 100755 --- a/hooks/dapper/80-install-modules +++ b/hooks/dapper/80-install-modules @@ -33,11 +33,28 @@ logMessage Script $0 starting # -# Copy the modules from the host to the new system - we should only -# really copy the *correct* modules, but we don't know what they are. +# The name of the package containing the correct modules. # -mkdir -p ${prefix}/lib/modules -cp -au /lib/modules/*/ ${prefix}/lib/modules +linux_modules_package="linux-modules-$(uname -r)" + +# +# Attempt to install that package. This will either work on an Etch +# system, or fail on a Sarge/custom kernel. +# +if chroot ${prefix} apt-cache policy ${linux_modules_package} 2>/dev/null; then + + # + # If it worked then we can install the package. + # + installDebianPackage ${prefix} ${linux_modules_package} +else + # + # Fall back to copying over modules from the host to the new + # system. + mkdir -p ${prefix}/lib/modules + cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules +fi + # # Install the module-init-tools package. diff --git a/hooks/debian/80-install-modules b/hooks/debian/80-install-modules index 9ea1a55..71e8ce1 100755 --- a/hooks/debian/80-install-modules +++ b/hooks/debian/80-install-modules @@ -33,11 +33,27 @@ logMessage Script $0 starting # -# Copy the modules from the host to the new system - we should only -# really copy the *correct* modules, but we don't know what they are. +# The name of the package containing the correct modules. # -mkdir -p ${prefix}/lib/modules -cp -au /lib/modules/*/ ${prefix}/lib/modules +linux_modules_package="linux-modules-$(uname -r)" + +# +# Attempt to install that package. This will either work on an Etch +# system, or fail on a Sarge/custom kernel. +# +if chroot ${prefix} apt-cache policy ${linux_modules_package} 2>/dev/null; then + + # + # If it worked then we can install the package. + # + installDebianPackage ${prefix} ${linux_modules_package} +else + # + # Fall back to copying over modules from the host to the new + # system. + mkdir -p ${prefix}/lib/modules + cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules +fi # # Install the module-init-tools package. diff --git a/hooks/edgy/80-install-modules b/hooks/edgy/80-install-modules index 9ea1a55..76380fe 100755 --- a/hooks/edgy/80-install-modules +++ b/hooks/edgy/80-install-modules @@ -33,11 +33,28 @@ logMessage Script $0 starting # -# Copy the modules from the host to the new system - we should only -# really copy the *correct* modules, but we don't know what they are. +# The name of the package containing the correct modules. # -mkdir -p ${prefix}/lib/modules -cp -au /lib/modules/*/ ${prefix}/lib/modules +linux_modules_package="linux-modules-$(uname -r)" + +# +# Attempt to install that package. This will either work on an Etch +# system, or fail on a Sarge/custom kernel. +# +if chroot ${prefix} apt-cache policy ${linux_modules_package} 2>/dev/null; then + + # + # If it worked then we can install the package. + # + installDebianPackage ${prefix} ${linux_modules_package} +else + # + # Fall back to copying over modules from the host to the new + # system. + mkdir -p ${prefix}/lib/modules + cp -au /lib/modules/$(uname -r) ${prefix}/lib/modules +fi + # # Install the module-init-tools package.