@@ -105,7 +105,7 @@ ARCH=$4
105105UPGRADE=$5
106106
107107if [ -z " $NAME " ] || [ -z " $VERSION " ]; then
108- echo " Need NAME, and VERSION defined"
108+ echo " Need NAME and VERSION defined"
109109 echo " ARCH is optional"
110110 exit 1
111111fi
@@ -115,6 +115,8 @@ if [ -f /etc/dkms/no-autoinstall ]; then
115115 exit 0
116116fi
117117
118+ continue_on_error=" true"
119+
118120# read framework configuration options
119121for fwcf in /etc/dkms/framework.conf /etc/dkms/framework.conf.d/* .conf ; do
120122 if [ -f " $fwcf " ] && [ -r " $fwcf " ]; then
@@ -128,13 +130,13 @@ done
128130KERNELS=$( ls -dv " $MODDIR " /* /build 2> /dev/null | sed ' s|' " $MODDIR " ' /\(.*\)/build|\1|' || true)
129131CURRENT_KERNEL=$( uname -r)
130132
131- # We never want to keep an older version side by side to prevent conflicts
133+ # We never want to keep an older version side by side to prevent conflicts
132134if [ -e " /var/lib/dkms/$NAME /$VERSION " ]; then
133135 echo " Removing old $NAME /$VERSION DKMS files..."
134136 dkms remove -m " $NAME " -v " $VERSION " --all
135137fi
136138
137- # Load new files, by source package and by tarball
139+ # Load new files, by source package and by tarball
138140if [ -f " $TARBALL_ROOT /$NAME -$VERSION .dkms.tar.gz" ]; then
139141 if ! dkms ldtarball --archive " $TARBALL_ROOT /$NAME -$VERSION .dkms.tar.gz" ; then
140142 echo " "
@@ -216,16 +218,18 @@ if [ -n "$ARCH" ]; then
216218 echo " Building for architecture $ARCH "
217219fi
218220
221+ exit_code=0
222+ failed_kernels=" "
219223for KERNEL in $KERNELS ; do
220224 echo " "
221- dkms_status=$( dkms status -m " $NAME " -v " $VERSION " -k " $KERNEL " ${ARCH: +-a " $ARCH " } )
222225 if [ " $( echo " $KERNEL " | grep -c " BOOT" ) " -gt 0 ]; then
223226 echo " Module build and install for $KERNEL was skipped as "
224227 echo " it is a BOOT variant"
225228 continue
226229 fi
227230
228- # if the module isn't yet built, try to build it
231+ # if the module isn't yet built, try to build it
232+ dkms_status=$( dkms status -m " $NAME " -v " $VERSION " -k " $KERNEL " ${ARCH: +-a " $ARCH " } )
229233 if [ " $( echo " $dkms_status " | grep -c " : built" ) " -eq 0 ]; then
230234 if [ ! -L " /var/lib/dkms/$NAME /$VERSION /source" ]; then
231235 echo " This package appears to be a binaries-only package"
@@ -245,21 +249,28 @@ for KERNEL in $KERNELS; do
245249 0)
246250 ;;
247251 * )
248- exit $res
252+ exit_code=$res
253+ [ " $continue_on_error " != " true" ] && break
254+ failed_kernels+=" $KERNEL "
255+ continue
249256 ;;
250257 esac
251- dkms_status=$( dkms status -m " $NAME " -v " $VERSION " -k " $KERNEL " ${ARCH: +-a " $ARCH " } )
252258 else
253259 echo " Module build for kernel $KERNEL was skipped since the"
254260 echo " kernel headers for this kernel do not seem to be installed."
261+ continue
255262 fi
263+ dkms_status=$( dkms status -m " $NAME " -v " $VERSION " -k " $KERNEL " ${ARCH: +-a " $ARCH " } )
256264 fi
257265
258- # if the module is built (either pre-built or just now), install it
259- if [ " $( echo " $dkms_status " | grep -c " : built" ) " -eq 1 ] &&
260- [ " $( echo " $dkms_status " | grep -c " : installed" ) " -eq 0 ]; then
266+ # if the module is built (either pre-built or just now), install it
267+ if [ " $( echo " $dkms_status " | grep -c " : built" ) " -ne 0 ]; then
261268 dkms install -m " $NAME " -v " $VERSION " -k " $KERNEL " ${ARCH: +-a " $ARCH " }
262269 fi
263270done
264271
272+ [ -n " $failed_kernels " ] && echo " Builds for the following kernel(s) failed:$failed_kernels "
273+
274+ exit $exit_code
275+
265276# vim: et:ts=4:sw=4
0 commit comments