108
108
# Error if # of arches doesn't match # of kernels
109
109
if [ ${#kernelver_array[@]} -ne ${#arch_array[@]} ] && [ ${#arch_array[@]} -gt 1 ]; then
111
echo $"Error! If more than one arch is specified on the command line, then there" >&2
112
echo $"must be an equal number of kernel versions also specified (1:1 relationship)." >&2
111
echo $"Error! If more than one arch is specified on the command line, then there" >&2
112
echo $"must be an equal number of kernel versions also specified (1:1 relationship)." >&2
116
116
# Check that kernel version and all aren't both set simultaneously
117
117
if [ -n "${kernelver_array[0]}" ] && [ -n "$all" ]; then
119
echo $"Error! You cannot specify a kernel version and also specify" >&2
120
echo $"--all on the command line." >&2
119
echo $"Error! You cannot specify a kernel version and also specify" >&2
120
echo $"--all on the command line." >&2
124
124
# Check that arch and all aren't both set simultaneously
125
125
if [ -n "${arch_array[0]}" ] && [ -n "$all" ]; then
127
echo $"Error! You cannot specify an arch and also specify" >&2
128
echo $"--all on the command line." >&2
127
echo $"Error! You cannot specify an arch and also specify" >&2
128
echo $"--all on the command line." >&2
132
132
# Check that the actions supports multiple kernels
134
134
add | build | install | match | uninstall | mkkmp )
135
if [ ${#kernelver_array[@]} -gt 1 ]; then
137
echo $"Error! The action $1 does not support multiple kernel version" >&2
138
echo $"parameters on the command line." >&2
141
if [ -n "$all" ]; then
143
echo $"Error! The action $1 does not support the --all" >&2
144
echo $"parameter." >&2
135
if [ ${#kernelver_array[@]} -gt 1 ]; then
137
echo $"Error! The action $1 does not support multiple kernel version" >&2
138
echo $"parameters on the command line." >&2
141
if [ -n "$all" ]; then
143
echo $"Error! The action $1 does not support the --all" >&2
144
echo $"parameter." >&2
150
150
# If all is set, use dkms status to fill the arrays
151
151
if [ -n "$all" ] && [ "$1" != "status" ]; then
154
# (I would leave out the delimiters in the status output
155
# in the first place.)
156
kernelver_array[$i]=`echo $line | awk {'print $3'} | sed 's/,$//'`
157
arch_array[$i]=`echo $line | awk {'print $4'} | sed 's/:$//'`
159
done < <($0 status -m "$module" -v "$module_version" 2>/dev/null | \
160
egrep "built|installed" | egrep -v 'installed-weak')
154
# (I would leave out the delimiters in the status output
155
# in the first place.)
156
kernelver_array[$i]=`echo $line | awk {'print $3'} | sed 's/,$//'`
157
arch_array[$i]=`echo $line | awk {'print $4'} | sed 's/:$//'`
159
done < <($0 status -m "$module" -v "$module_version" 2>/dev/null | \
160
egrep "built|installed" | egrep -v 'installed-weak')
163
163
# Set default kernel version and arch, if none set (but only --all isn't set)
164
164
if [ "$1" != "status" ]; then
165
[ -z "${kernelver_array[0]}" ] && [ -z "$all" ] && kernelver_array[0]=`uname -r`
166
if [ -z "${arch_array[0]}" ] && [ -n "${kernelver_array[0]}" ]; then
167
kernelver_rpm=`rpm -qf "/lib/modules/${kernelver_array[0]}" 2>/dev/null | grep -v "not owned by any package" | grep kernel | head -n 1`
168
if ! arch_array[0]=`rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null`; then
169
arch_array[0]=`uname -m`
170
if [ ${arch_array[0]} == "x86_64" ] && \
171
grep -q Intel /proc/cpuinfo && \
172
ls $install_tree/${kernelver_array[0]}/build/configs \
173
2>/dev/null | grep -q "ia32e"; then
174
arch_array[0]="ia32e"
165
[ -z "${kernelver_array[0]}" ] && [ -z "$all" ] && kernelver_array[0]=`uname -r`
166
if [ -z "${arch_array[0]}" ] && [ -n "${kernelver_array[0]}" ]; then
167
kernelver_rpm=`rpm -qf "/lib/modules/${kernelver_array[0]}" 2>/dev/null | grep -v "not owned by any package" | grep kernel | head -n 1`
168
if ! arch_array[0]=`rpm -q --queryformat "%{ARCH}" "$kernelver_rpm" 2>/dev/null`; then
169
arch_array[0]=`uname -m`
170
if [ ${arch_array[0]} == "x86_64" ] && \
171
grep -q Intel /proc/cpuinfo && \
172
ls $install_tree/${kernelver_array[0]}/build/configs \
173
2>/dev/null | grep -q "ia32e"; then
174
arch_array[0]="ia32e"
180
180
# If only one arch is specified, make it so for all the kernels
181
181
if [ ${#arch_array[@]} -eq 1 ] && [ ${#kernelver_array[@]} -gt 1 ]; then
182
while [ ${#arch_array[@]} -lt ${#kernelver_array[@]} ]; do
183
arch_array[${#arch_array[@]}]=${arch_array[0]}
182
while [ ${#arch_array[@]} -lt ${#kernelver_array[@]} ]; do
183
arch_array[${#arch_array[@]}]=${arch_array[0]}
187
187
# Set global multi_arch
190
190
while [ $i -lt ${#arch_array[@]} ]; do
191
[ "${arch_array[0]}" != "${arch_array[$i]}" ] && multi_arch="true"
191
[ "${arch_array[0]}" != "${arch_array[$i]}" ] && multi_arch="true"
211
211
# Support initramfs distributions (Debian/Ubuntu).
212
212
if [ -x "/usr/sbin/update-initramfs" ]; then
213
mkinitrd='update-initramfs'
213
mkinitrd='update-initramfs'
216
216
$mkinitrd --version >/dev/null 2>&1
217
217
if [ "$?" -eq 0 ]; then
220
[ "$2" == "ia64" ] && [ -d "/boot/efi/efi/redhat" ] && initrd_dir="/boot/efi/efi/redhat"
221
echo $"Saving old initrd as $initrd_dir/initrd-$1_old.img"
222
cp -f "$initrd_dir/initrd-$1.img" "$initrd_dir/initrd-$1_old.img"
223
echo $"Making new initrd as $initrd_dir/initrd-$1.img"
224
echo $"(If next boot fails, revert to the _old initrd image)"
225
invoke_command "$mkinitrd -f $initrd_dir/initrd-$1.img $1" "$mkinitrd" background
220
[ "$2" == "ia64" ] && [ -d "/boot/efi/efi/redhat" ] && initrd_dir="/boot/efi/efi/redhat"
221
echo $"Saving old initrd as $initrd_dir/initrd-$1_old.img"
222
cp -f "$initrd_dir/initrd-$1.img" "$initrd_dir/initrd-$1_old.img"
223
echo $"Making new initrd as $initrd_dir/initrd-$1.img"
224
echo $"(If next boot fails, revert to the _old initrd image)"
225
invoke_command "$mkinitrd -f $initrd_dir/initrd-$1.img $1" "$mkinitrd" background
227
227
elif [ -e /etc/SuSE-release ] || [ -d /etc/SuSEconfig ]; then
230
kernel_file="vmlinuz"
231
if [ ! -f "$initrd_dir/$kernel_file-$1" ]; then
232
kernel_file="vmlinux"
233
if [ ! -f "$initrd_dir/$kernel_file-$1" ]; then
234
echo $"Error! Unable to find valid kernel file under " >&2
235
echo $"$initrd_dir for kernel version $1" >&2
240
echo $"Saving old initrd as $initrd_dir/initrd-$1_old"
241
cp -f "$initrd_dir/initrd-$1" "$initrd_dir/initrd-$1_old"
242
echo $"Making new initrd as $initrd_dir/initrd-$1"
243
echo $"(If next boot fails, revert to the _old initrd image)"
244
invoke_command "$mkinitrd -k $kernel_file-$1 -i initrd-$1" "$mkinitrd" background
230
kernel_file="vmlinuz"
231
if [ ! -f "$initrd_dir/$kernel_file-$1" ]; then
232
kernel_file="vmlinux"
233
if [ ! -f "$initrd_dir/$kernel_file-$1" ]; then
234
echo $"Error! Unable to find valid kernel file under " >&2
235
echo $"$initrd_dir for kernel version $1" >&2
240
echo $"Saving old initrd as $initrd_dir/initrd-$1_old"
241
cp -f "$initrd_dir/initrd-$1" "$initrd_dir/initrd-$1_old"
242
echo $"Making new initrd as $initrd_dir/initrd-$1"
243
echo $"(If next boot fails, revert to the _old initrd image)"
244
invoke_command "$mkinitrd -k $kernel_file-$1 -i initrd-$1" "$mkinitrd" background
246
246
elif [ -e /etc/debian_version ]; then
249
echo $"Updating initrd"
250
echo $"Making new initrd as $initrd_dir/initrd.img-$1"
251
echo $"(If next boot fails, revert to the .bak initrd image)"
252
if [ "$mkinitrd" == "update-initramfs" ]; then
253
invoke_command "$mkinitrd -u" "$mkinitrd" background
255
echo $"Saving old initrd as $initrd_dir/initrd.img-$1.bak"
256
# we use the same convention as update-initramfs, so that we just
257
# print the warning once
258
cp -f "$initrd_dir/initrd.img-$1" "$initrd_dir/initrd.img-$1.bak"
259
invoke_command "$mkinitrd -o $initrd_dir/initrd.img-$1 $1" "$mkinitrd" background
249
echo $"Updating initrd"
250
echo $"Making new initrd as $initrd_dir/initrd.img-$1"
251
echo $"(If next boot fails, revert to the .bak initrd image)"
252
if [ "$mkinitrd" == "update-initramfs" ]; then
253
invoke_command "$mkinitrd -u" "$mkinitrd" background
255
echo $"Saving old initrd as $initrd_dir/initrd.img-$1.bak"
256
# we use the same convention as update-initramfs, so that we just
257
# print the warning once
258
cp -f "$initrd_dir/initrd.img-$1" "$initrd_dir/initrd.img-$1.bak"
259
invoke_command "$mkinitrd -o $initrd_dir/initrd.img-$1 $1" "$mkinitrd" background
264
echo $"Calling $mkinitrd (bad exit status 9 may occur)"
265
invoke_command "$mkinitrd" "$mkinitrd" background
264
echo $"Calling $mkinitrd (bad exit status 9 may occur)"
265
invoke_command "$mkinitrd" "$mkinitrd" background
303
303
[ $? -eq 0 ] && DISTRO=ovm
305
305
case "${DISTRO}" in
307
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
308
# format is 3AS, 4AS, 5Desktop...
309
VER=$(echo "${VER}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
313
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
314
# format is 3, 4, ...
318
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
319
# format is 3, 4, ...
323
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_ovm})
328
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
330
VER=$(echo "${VER}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
334
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
338
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_sles})
342
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_suse})
307
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
308
# format is 3AS, 4AS, 5Desktop...
309
VER=$(echo "${VER}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
313
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
314
# format is 3, 4, ...
318
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
319
# format is 3, 4, ...
323
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_ovm})
328
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
330
VER=$(echo "${VER}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
334
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_redhat})
338
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_sles})
342
VER=$(rpm -q --qf "%{version}\n" ${whatprovides_suse})
362
362
# try the LSB-provided strings first
363
363
if [ -r /etc/lsb-release ]; then
366
366
elif type lsb_release >/dev/null 2>&1; then
367
DISTRIB_ID=$(lsb_release -i -s)
368
DISTRIB_RELEASE=$(lsb_release -r -s)
367
DISTRIB_ID=$(lsb_release -i -s)
368
DISTRIB_RELEASE=$(lsb_release -r -s)
372
372
case "${DISTRIB_ID}" in
373
Fedora) dist=fc${DISTRIB_RELEASE} ;;
374
RedHatEnterprise*) # OEL also reports as such
376
VER=$(echo "${DISTRIB_RELEASE}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
381
VER=$(echo "${DISTRIB_RELEASE}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
386
VER=$(echo "${DISTRIB_RELEASE}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
390
LSB_DESCRIPTION="$(lsb_release -d -s)"
391
if echo "${LSB_DESCRIPTION}" | grep Enterprise > /dev/null 2>&1; then
392
dist=sles${DISTRIB_RELEASE}
394
dist=suse${DISTRIB_RELEASE}
398
if [ -n "${LSB_RELEASE}" -a -n "${DISTRIB_ID}" -a -n "${DISTRIB_RELEASE}" ]; then
399
dist="${DISTRIB_ID}${DISTRIB_RELEASE}"
373
Fedora) dist=fc${DISTRIB_RELEASE} ;;
374
RedHatEnterprise*) # OEL also reports as such
376
VER=$(echo "${DISTRIB_RELEASE}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
381
VER=$(echo "${DISTRIB_RELEASE}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
386
VER=$(echo "${DISTRIB_RELEASE}" | sed -e 's/^\([[:digit:]]*\).*/\1/g')
390
LSB_DESCRIPTION="$(lsb_release -d -s)"
391
if echo "${LSB_DESCRIPTION}" | grep Enterprise > /dev/null 2>&1; then
392
dist=sles${DISTRIB_RELEASE}
394
dist=suse${DISTRIB_RELEASE}
398
if [ -n "${LSB_RELEASE}" -a -n "${DISTRIB_ID}" -a -n "${DISTRIB_RELEASE}" ]; then
399
dist="${DISTRIB_ID}${DISTRIB_RELEASE}"
404
404
if [ "${dist}" == "unknown" ]; then
405
dist=$(distro_version_rpm)
405
dist=$(distro_version_rpm)
534
534
array_size=`echo -e "${#BUILT_MODULE_NAME[@]}\n${#BUILT_MODULE_LOCATION[@]}\n${#DEST_MODULE_NAME[@]}\n${#DEST_MODULE_LOCATION[@]}\n" | sort -n | tail -n 1`
535
535
while [ "$index" -lt "$array_size" ]; do
537
built_module_name[$index]=${BUILT_MODULE_NAME[$index]}
538
built_module_location[$index]=${BUILT_MODULE_LOCATION[$index]}
539
dest_module_name[$index]=${DEST_MODULE_NAME[$index]}
540
dest_module_location[$index]=${DEST_MODULE_LOCATION[$index]}
541
modules_conf_obsoletes[$index]=${MODULES_CONF_OBSOLETES[$index]}
542
modules_conf_alias_type[$index]=${MODULES_CONF_ALIAS_TYPE[$index]}
543
case "${MODULES_CONF_OBSOLETE_ONLY[$index]}" in
545
modules_conf_obsolete_only[$index]="yes"
548
case "${STRIP[$index]}" in
557
# If unset, set by defaults
558
[ -z "${built_module_name[$index]}" ] && [ ${#DEST_MODULE_LOCATION[@]} -eq 1 ] && built_module_name[$index]=$module
559
[ -z "${dest_module_name[$index]}" ] && dest_module_name[$index]=${built_module_name[$index]}
560
if [ -n "${built_module_location[$index]}" ] && \
561
[ "${built_module_location[$index]:(-1)}" != "/" ]; then
562
built_module_location[$index]="${built_module_location[$index]}/"
565
# FAIL if no built_module_name
566
if [ -z "${built_module_name[$index]}" ]; then
567
echo $"dkms.conf: Error! No 'BUILT_MODULE_NAME' directive specified for record #$index." >&2
571
# FAIL if built_module_name ends in .o or .ko
572
case "${built_module_name[$index]}" in
574
echo $"dkms.conf: Error! 'BUILT_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
579
# FAIL if dest_module_name ends in .o or .ko
580
case "${dest_module_name[$index]}" in
582
echo $"dkms.conf: Error! 'DEST_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
587
# Override location for specific kernels
588
dest_module_location[$index]="$(override_dest_module_location ${dest_module_location[$index]})"
590
# Fail if no DEST_MODULE_LOCATION
591
if [ -z "${DEST_MODULE_LOCATION[$index]}" ]; then
592
echo $"dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #$index.">&2
595
# Fail if bad DEST_MODULE_LOCATION
596
case "${DEST_MODULE_LOCATION[$index]}" in
604
echo $"dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with">&2
605
echo $"'/kernel', '/updates', or '/extra' in record #$index.">&2
537
built_module_name[$index]=${BUILT_MODULE_NAME[$index]}
538
built_module_location[$index]=${BUILT_MODULE_LOCATION[$index]}
539
dest_module_name[$index]=${DEST_MODULE_NAME[$index]}
540
dest_module_location[$index]=${DEST_MODULE_LOCATION[$index]}
541
modules_conf_obsoletes[$index]=${MODULES_CONF_OBSOLETES[$index]}
542
modules_conf_alias_type[$index]=${MODULES_CONF_ALIAS_TYPE[$index]}
543
case "${MODULES_CONF_OBSOLETE_ONLY[$index]}" in
545
modules_conf_obsolete_only[$index]="yes"
548
case "${STRIP[$index]}" in
557
# If unset, set by defaults
558
[ -z "${built_module_name[$index]}" ] && [ ${#DEST_MODULE_LOCATION[@]} -eq 1 ] && built_module_name[$index]=$module
559
[ -z "${dest_module_name[$index]}" ] && dest_module_name[$index]=${built_module_name[$index]}
560
if [ -n "${built_module_location[$index]}" ] && \
561
[ "${built_module_location[$index]:(-1)}" != "/" ]; then
562
built_module_location[$index]="${built_module_location[$index]}/"
565
# FAIL if no built_module_name
566
if [ -z "${built_module_name[$index]}" ]; then
567
echo $"dkms.conf: Error! No 'BUILT_MODULE_NAME' directive specified for record #$index." >&2
571
# FAIL if built_module_name ends in .o or .ko
572
case "${built_module_name[$index]}" in
574
echo $"dkms.conf: Error! 'BUILT_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
579
# FAIL if dest_module_name ends in .o or .ko
580
case "${dest_module_name[$index]}" in
582
echo $"dkms.conf: Error! 'DEST_MODULE_NAME' directive ends in '.o' or '.ko' in record #$index." >&2
587
# Override location for specific kernels
588
dest_module_location[$index]="$(override_dest_module_location ${dest_module_location[$index]})"
590
# Fail if no DEST_MODULE_LOCATION
591
if [ -z "${DEST_MODULE_LOCATION[$index]}" ]; then
592
echo $"dkms.conf: Error! No 'DEST_MODULE_LOCATION' directive specified for record #$index.">&2
595
# Fail if bad DEST_MODULE_LOCATION
596
case "${DEST_MODULE_LOCATION[$index]}" in
601
echo $"dkms.conf: Error! Directive 'DEST_MODULE_LOCATION' does not begin with">&2
602
echo $"'/kernel', '/updates', or '/extra' in record #$index.">&2
613
610
# Get the correct make command
615
612
[ -z "${MAKE_MATCH[0]}" ] && make_command="${MAKE[0]}"
616
613
while [ "$index" -lt ${#MAKE[@]} ]; do
617
if [ -n "${MAKE[$index]}" ] && \
618
[ -n "${MAKE_MATCH[$index]}" ] && \
619
echo $1 | egrep -q "${MAKE_MATCH[$index]}"; then
620
make_command="${MAKE[$index]}"
614
if [ -n "${MAKE[$index]}" ] && \
615
[ -n "${MAKE_MATCH[$index]}" ] && \
616
echo $1 | egrep -q "${MAKE_MATCH[$index]}"; then
617
make_command="${MAKE[$index]}"
625
622
# Use the generic make and make clean commands if not specified
626
623
if [[ $(VER $1) < $(VER 2.6.6) ]]; then
627
if [ -z "$make_command" ]; then
628
make_command="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build modules"
630
if [ -z "$clean" ]; then
631
clean="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build clean"
624
if [ -z "$make_command" ]; then
625
make_command="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build modules"
627
if [ -z "$clean" ]; then
628
clean="make -C $kernel_source_dir SUBDIRS=$dkms_tree/$module/$module_version/build clean"
634
if [ -z "$make_command" ]; then
635
make_command="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build"
637
if [ -z "$clean" ]; then
638
clean="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build clean"
631
if [ -z "$make_command" ]; then
632
make_command="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build"
634
if [ -z "$clean" ]; then
635
clean="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build clean"
642
639
# Set modules_conf_array
644
641
while [ "$index" -lt ${#MODULES_CONF[@]} ]; do
645
[ -n "${MODULES_CONF[$index]}" ] && modules_conf_array[$index]="${MODULES_CONF[$index]}"
642
[ -n "${MODULES_CONF[$index]}" ] && modules_conf_array[$index]="${MODULES_CONF[$index]}"
649
646
# Set patch_array (including kernel specific patches)
652
649
while [ "$index" -lt ${#PATCH[@]} ]; do
653
if [ -n "${PATCH[$index]}" ]; then
654
if [ -z "${PATCH_MATCH[$index]}" ] || \
655
echo $1 | egrep -q "${PATCH_MATCH[$index]}"; then
656
patch_array[$count]="${PATCH[$index]}"
650
if [ -n "${PATCH[$index]}" ]; then
651
if [ -z "${PATCH_MATCH[$index]}" ] || \
652
echo $1 | egrep -q "${PATCH_MATCH[$index]}"; then
653
patch_array[$count]="${PATCH[$index]}"
663
660
# Set remake_initrd
706
703
local lib_tree="$install_tree/$1"
707
704
echo $"Running module version sanity check."
708
local module_count=`find $lib_tree -name ${4}$module_suffix | wc -l | awk {'print $1'}`
709
if [ $module_count -gt 1 ]; then
710
echo $"Warning! Cannot do version sanity checking because multiple ${4}$module_suffix" >&2
711
echo $"modules were found in kernel $1." >&2
712
elif [ $module_count -eq 1 ]; then
713
local kernels_module=`find $lib_tree -name ${4}$module_suffix`
714
local kernels_ver_string=`modinfo $kernels_module | grep "^version:"`
715
local kernels_ver_value=`echo $kernels_ver_string | awk {'print $2'}`
716
local dkms_module="$dkms_tree/$module/$module_version/$1/$2/module/${4}$module_suffix"
717
local dkms_ver_string=`modinfo $dkms_module | grep "^version:"`
718
local dkms_ver_value=`echo $dkms_ver_string | awk {'print $2'}`
720
# there are 2 possible srcversion checksums
721
# one in the 'srcversion' tag alone (preferred)
722
# and one following the version field in the 'version' tag (deprecated)
723
local kernels_ver_checksum=`modinfo $kernels_module | awk '/^srcversion:/ {print $2}'`
724
local dkms_ver_checksum=`modinfo $dkms_module | awk '/^srcversion:/ {print $2}'`
725
if [ -z "$kernels_ver_checksum" -a -z "$dkms_ver_checksum" ]; then
726
kernels_ver_checksum=`echo $kernels_ver_string | awk {'print $3'}`
727
dkms_ver_checksum=`echo $dkms_ver_string | awk {'print $3'}`
730
if [ -n "$kernels_ver_checksum" -a -n "$dkms_ver_checksum" -a \
731
"$kernels_ver_checksum" == "$dkms_ver_checksum" -a -z "$force" ]; then
733
echo $"Good news! Module version $dkms_ver_value for ${4}$module_suffix" >&2
734
echo $"exactly matches what is already found in kernel $1." >&2
735
echo $"DKMS will not replace this module." >&2
736
echo $"You may override by specifying --force." >&2
740
if [ -n "$kernels_ver_value" -a -n "$dkms_ver_value" ]; then
741
if [[ ! ( $(VER $dkms_ver_value) > \
742
$(VER $kernels_ver_value) ) && -z "$force" ]]; then
744
echo $"Error! Module version $dkms_ver_value for ${4}$module_suffix" >&2
745
echo $"is not newer than what is already found in kernel $1 ($kernels_ver_value)." >&2
746
echo $"You may override by specifying --force." >&2
751
local obs_upstream=`echo $3 | cut -d- -f 1`
752
local obs_local=`echo $3 | cut -d- -f 2`
753
local my_upstream=`echo $1 | cut -d- -f 1`
754
local my_local=`echo $1 | cut -d- -f 2`
756
if [ -n "$obs_upstream" -a -n "$my_upstream" ]; then
757
if [[ ( $(VER $obs_upstream) == $(VER $my_upstream) ) && -z "$force" ]]; then
758
#they get obsoleted possibly in this kernel release
759
if [ -z "$obs_local" ]; then
760
#they were obsoleted in this upstream kernel
762
elif [[ ( $(VER $my_local) > $(VER $obs_local) ) ]]; then
763
#they were obsoleted in an earlier ABI bump of the kernel
765
elif [[ ( $(VER $my_local) = $(VER $obs_local) ) ]]; then
766
#they were obsoleted in this ABI bump of the kernel
769
elif [[ ( $(VER $my_upstream) > $(VER $obs_upstream) ) && -z "$force" ]]; then
770
#they were obsoleted in an earlier kernel release
775
if [ "$obsolete" == 1 ]; then
777
echo $"Module has been obsoleted due to being included" >&2
778
echo $"in kernel $3. We will avoid installing" >&2
779
echo $"for future kernels above $3." >&2
780
echo $"You may override by specifying --force." >&2
705
local module_count=`find $lib_tree -name ${4}$module_suffix | wc -l | awk {'print $1'}`
706
if [ $module_count -gt 1 ]; then
707
echo $"Warning! Cannot do version sanity checking because multiple ${4}$module_suffix" >&2
708
echo $"modules were found in kernel $1." >&2
709
elif [ $module_count -eq 1 ]; then
710
local kernels_module=`find $lib_tree -name ${4}$module_suffix`
711
local kernels_ver_string=`modinfo $kernels_module | grep "^version:"`
712
local kernels_ver_value=`echo $kernels_ver_string | awk {'print $2'}`
713
local dkms_module="$dkms_tree/$module/$module_version/$1/$2/module/${4}$module_suffix"
714
local dkms_ver_string=`modinfo $dkms_module | grep "^version:"`
715
local dkms_ver_value=`echo $dkms_ver_string | awk {'print $2'}`
717
# there are 2 possible srcversion checksums
718
# one in the 'srcversion' tag alone (preferred)
719
# and one following the version field in the 'version' tag (deprecated)
720
local kernels_ver_checksum=`modinfo $kernels_module | awk '/^srcversion:/ {print $2}'`
721
local dkms_ver_checksum=`modinfo $dkms_module | awk '/^srcversion:/ {print $2}'`
722
if [ -z "$kernels_ver_checksum" -a -z "$dkms_ver_checksum" ]; then
723
kernels_ver_checksum=`echo $kernels_ver_string | awk {'print $3'}`
724
dkms_ver_checksum=`echo $dkms_ver_string | awk {'print $3'}`
727
if [ -n "$kernels_ver_checksum" -a -n "$dkms_ver_checksum" -a \
728
"$kernels_ver_checksum" == "$dkms_ver_checksum" -a -z "$force" ]; then
730
echo $"Good news! Module version $dkms_ver_value for ${4}$module_suffix" >&2
731
echo $"exactly matches what is already found in kernel $1." >&2
732
echo $"DKMS will not replace this module." >&2
733
echo $"You may override by specifying --force." >&2
737
if [ -n "$kernels_ver_value" -a -n "$dkms_ver_value" ]; then
738
if [[ ! ( $(VER $dkms_ver_value) > \
739
$(VER $kernels_ver_value) ) && -z "$force" ]]; then
741
echo $"Error! Module version $dkms_ver_value for ${4}$module_suffix" >&2
742
echo $"is not newer than what is already found in kernel $1 ($kernels_ver_value)." >&2
743
echo $"You may override by specifying --force." >&2
748
local obs_upstream=`echo $3 | cut -d- -f 1`
749
local obs_local=`echo $3 | cut -d- -f 2`
750
local my_upstream=`echo $1 | cut -d- -f 1`
751
local my_local=`echo $1 | cut -d- -f 2`
753
if [ -n "$obs_upstream" -a -n "$my_upstream" ]; then
754
if [[ ( $(VER $obs_upstream) == $(VER $my_upstream) ) && -z "$force" ]]; then
755
#they get obsoleted possibly in this kernel release
756
if [ -z "$obs_local" ]; then
757
#they were obsoleted in this upstream kernel
759
elif [[ ( $(VER $my_local) > $(VER $obs_local) ) ]]; then
760
#they were obsoleted in an earlier ABI bump of the kernel
762
elif [[ ( $(VER $my_local) = $(VER $obs_local) ) ]]; then
763
#they were obsoleted in this ABI bump of the kernel
766
elif [[ ( $(VER $my_upstream) > $(VER $obs_upstream) ) && -z "$force" ]]; then
767
#they were obsoleted in an earlier kernel release
772
if [ "$obsolete" == 1 ]; then
774
echo $"Module has been obsoleted due to being included" >&2
775
echo $"in kernel $3. We will avoid installing" >&2
776
echo $"for future kernels above $3." >&2
777
echo $"You may override by specifying --force." >&2
798
795
[ -e /etc/modprobe.d/$package_name.conf ] && modconfig_files="/etc/modprobe.d/$package_name.conf"
800
797
if [ -z "$modconfig_files" ]; then
801
modconfig_files="/etc/modprobe.d/$package_name.conf"
798
modconfig_files="/etc/modprobe.d/$package_name.conf"
805
802
for moduleconfig in $modconfig_files; do
807
while [ $index -lt ${#dest_module_name[@]} ]; do
809
# Replace obsolete references in module-config-file with the new module name
810
if [ -n "${modules_conf_obsoletes[$index]}" ]; then
811
for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
812
sed "s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) $obsolete_module$/\1 ${dest_module_name[$index]}/g" $moduleconfig > $temp_dir_name/moduleconfig.new
813
if ! diff $moduleconfig $temp_dir_name/moduleconfig.new >/dev/null 2>&1; then
814
cp -fp $temp_dir_name/moduleconfig.new $moduleconfig 2>/dev/null
815
rm -f $temp_dir_name/moduleconfig.new 2>/dev/null
816
echo $"$moduleconfig: obsolete alias '$obsolete_module' changed to '${dest_module_name[$index]}'"
804
while [ $index -lt ${#dest_module_name[@]} ]; do
805
# Replace obsolete references in module-config-file with the new module name
806
if [ -n "${modules_conf_obsoletes[$index]}" ]; then
807
for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
808
sed "s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) $obsolete_module$/\1 ${dest_module_name[$index]}/g" $moduleconfig > $temp_dir_name/moduleconfig.new
809
if ! diff $moduleconfig $temp_dir_name/moduleconfig.new >/dev/null 2>&1; then
810
cp -fp $temp_dir_name/moduleconfig.new $moduleconfig 2>/dev/null
811
rm -f $temp_dir_name/moduleconfig.new 2>/dev/null
812
echo $"$moduleconfig: obsolete alias '$obsolete_module' changed to '${dest_module_name[$index]}'"
818
814
if [ -e /etc/sysconfig/kernel ]; then
819
815
sed -e "s/\(INITRD_MODULES.*\)$obsolete_module\b\(.*\)/\1${dest_module_name[$index]}\2/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
820
816
if ! diff $temp_dir_name/kernel.new /etc/sysconfig/kernel >/dev/null 2>&1; then
823
819
echo $"/etc/sysconfig/kernel: obsolete alias '$obsolete_module' changed to '${dest_module_name[$index]}'"
829
# Only add it if it can't be found already in config file
830
if [ -n "${modules_conf_alias_type[$index]}" ] && \
831
! grep -qs "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}\b" $moduleconfig && \
832
[ "${modules_conf_obsolete_only[$index]}" != "yes" ]; then
833
if [ "$modconfig_files" == "/etc/modprobe.d/$package_name.conf" ] && \
834
[ ! -e /etc/modprobe.d/$package_name.conf ]; then
835
touch /etc/modprobe.d/$package_name.conf
836
echo $"created /etc/modprobe.d/$package_name.conf.">&2
838
aliases=$(awk "/^alias ${modules_conf_alias_type[$index]}/ {print \$2}" $moduleconfig)
839
if [ -n "$aliases" ]; then
840
alias_number=$(($(echo "$aliases" | sed "s/${modules_conf_alias_type[$index]}//" | sort -n | tail -n 1) + 1))
844
echo -e "alias ${modules_conf_alias_type[$index]}${alias_number} ${dest_module_name[$index]}" >> $moduleconfig
845
echo $"$moduleconfig: added alias reference for '${dest_module_name[$index]}'"
825
# Only add it if it can't be found already in config file
826
if [ -n "${modules_conf_alias_type[$index]}" ] && \
827
! grep -qs "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}\b" $moduleconfig && \
828
[ "${modules_conf_obsolete_only[$index]}" != "yes" ]; then
829
if [ "$modconfig_files" == "/etc/modprobe.d/$package_name.conf" ] && \
830
[ ! -e /etc/modprobe.d/$package_name.conf ]; then
831
touch /etc/modprobe.d/$package_name.conf
832
echo $"created /etc/modprobe.d/$package_name.conf.">&2
834
aliases=$(awk "/^alias ${modules_conf_alias_type[$index]}/ {print \$2}" $moduleconfig)
835
if [ -n "$aliases" ]; then
836
alias_number=$(($(echo "$aliases" | sed "s/${modules_conf_alias_type[$index]}//" | sort -n | tail -n 1) + 1))
840
echo -e "alias ${modules_conf_alias_type[$index]}${alias_number} ${dest_module_name[$index]}" >> $moduleconfig
841
echo $"$moduleconfig: added alias reference for '${dest_module_name[$index]}'"
852
847
# Add anything else
854
while [ $index -lt ${#modules_conf_array[@]} ]; do
855
if [ -n "${modules_conf_array[$index]}" ] && \
856
! grep -q "${modules_conf_array[$index]}" "$moduleconfig"; then
857
echo -e $"$moduleconfig: added '${modules_conf_array[$index]}'"
858
echo -e "${modules_conf_array[$index]}" >> $moduleconfig
849
while [ $index -lt ${#modules_conf_array[@]} ]; do
850
if [ -n "${modules_conf_array[$index]}" ] && \
851
! grep -q "${modules_conf_array[$index]}" "$moduleconfig"; then
852
echo -e $"$moduleconfig: added '${modules_conf_array[$index]}'"
853
echo -e "${modules_conf_array[$index]}" >> $moduleconfig
864
859
# Delete the temp dir
879
874
[ -e /etc/modprobe.d/$package_name.conf ] && modconfig_files="/etc/modprobe.d/$package_name.conf"
881
876
for moduleconfig in $modconfig_files; do
883
while [ $index -lt ${#dest_module_name[@]} ]; do
885
# Remove/Replace aliases (maybe)
886
if [ -n "${modules_conf_alias_type[$index]}" ] && [ `find $install_tree/$1/ -name "${dest_module_name[$index]}.*" 2>/dev/null | wc -l | awk '{print $1}'` -eq 0 ]; then
888
local conf_replacement=""
889
for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
890
if [ `find $install_tree/$1/ -name "$obsolete_module.*" 2>/dev/null | wc -l | awk '{print $1}'` -gt 0 ] && [ -z "$conf_replacement" ]; then
891
conf_replacement=$obsolete_module
895
if [ -n "$conf_replacement" ] && \
896
grep -q "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}$" $moduleconfig; then
897
sed "s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) ${dest_module_name[$index]}$/\1 $conf_replacement/g" $moduleconfig > $temp_dir_name/moduleconfig.new
898
mv -f $temp_dir_name/moduleconfig.new $moduleconfig
899
echo $"$moduleconfig: alias for '${dest_module_name[$index]}' changed back to '$conf_replacement'"
900
elif [ -z "$conf_replacement" ]; then
901
grep -v "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}" $moduleconfig > $temp_dir_name/moduleconfig.new
902
mv -f $temp_dir_name/moduleconfig.new $moduleconfig
903
echo $"$moduleconfig: removed alias for '${dest_module_name[$index]}'"
904
if [ "$modconfig_files" == "/etc/modprobe.d/$package_name.conf" ]; then
905
rm -f /etc/modprobe.d/$package_name.conf
906
echo $"$moduleconfig: deleted /etc/modprobe.d/$package_name.conf file"
878
while [ $index -lt ${#dest_module_name[@]} ]; do
880
# Remove/Replace aliases (maybe)
881
if [ -n "${modules_conf_alias_type[$index]}" ] && [ `find $install_tree/$1/ -name "${dest_module_name[$index]}.*" 2>/dev/null | wc -l | awk '{print $1}'` -eq 0 ]; then
883
local conf_replacement=""
884
for obsolete_module in ${modules_conf_obsoletes[$index]//,/ }; do
885
if [ `find $install_tree/$1/ -name "$obsolete_module.*" 2>/dev/null | wc -l | awk '{print $1}'` -gt 0 ] && [ -z "$conf_replacement" ]; then
886
conf_replacement=$obsolete_module
890
if [ -n "$conf_replacement" ] && \
891
grep -q "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}$" $moduleconfig; then
892
sed "s/\(alias ${modules_conf_alias_type[$index]}[0-9]*\) ${dest_module_name[$index]}$/\1 $conf_replacement/g" $moduleconfig > $temp_dir_name/moduleconfig.new
893
mv -f $temp_dir_name/moduleconfig.new $moduleconfig
894
echo $"$moduleconfig: alias for '${dest_module_name[$index]}' changed back to '$conf_replacement'"
895
elif [ -z "$conf_replacement" ]; then
896
grep -v "alias ${modules_conf_alias_type[$index]}[0-9]* ${dest_module_name[$index]}" $moduleconfig > $temp_dir_name/moduleconfig.new
897
mv -f $temp_dir_name/moduleconfig.new $moduleconfig
898
echo $"$moduleconfig: removed alias for '${dest_module_name[$index]}'"
899
if [ "$modconfig_files" == "/etc/modprobe.d/$package_name.conf" ]; then
900
rm -f /etc/modprobe.d/$package_name.conf
901
echo $"$moduleconfig: deleted /etc/modprobe.d/$package_name.conf file"
915
909
# Remove static conf entries
917
while [ $index -lt ${#modules_conf_array[@]} ]; do
918
if [ -n "${modules_conf_array[$index]}" ]; then
919
grep -v "${modules_conf_array[$index]}" "$moduleconfig" > $temp_dir_name/moduleconfig.new
920
echo $"$moduleconfig: removed '${modules_conf_array[$index]}'"
921
mv -f $temp_dir_name/moduleconfig.new $moduleconfig
911
while [ $index -lt ${#modules_conf_array[@]} ]; do
912
if [ -n "${modules_conf_array[$index]}" ]; then
913
grep -v "${modules_conf_array[$index]}" "$moduleconfig" > $temp_dir_name/moduleconfig.new
914
echo $"$moduleconfig: removed '${modules_conf_array[$index]}'"
915
mv -f $temp_dir_name/moduleconfig.new $moduleconfig
927
921
# Delete the temp dir
946
940
if [ -e "/etc/sysconfig/kernel" ] && [ -n "$remake_initrd" ]; then
947
941
# Make /etc/sysconfig/kernel changes as necessary
948
if [ "$1" == "add" ]; then
950
eval `grep ^INITRD_MODULES= /etc/sysconfig/kernel`
951
for module_name_after in "${dest_module_name[@]}"; do
952
if ! is_word_in_list "${module_name_after}" "${INITRD_MODULES}"; then
953
sed -e "s/INITRD_MODULES=\"\(.*\)\"/INITRD_MODULES=\"\1 $module_name_after\"/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
954
mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
942
if [ "$1" == "add" ]; then
944
eval `grep ^INITRD_MODULES= /etc/sysconfig/kernel`
945
for module_name_after in "${dest_module_name[@]}"; do
946
if ! is_word_in_list "${module_name_after}" "${INITRD_MODULES}"; then
947
sed -e "s/INITRD_MODULES=\"\(.*\)\"/INITRD_MODULES=\"\1 $module_name_after\"/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
948
mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
959
953
# Remove /etc/sysconfig/kernel entries
960
elif [ "$1" == "delete" ]; then
961
for module_name_after in "${dest_module_name[@]}"; do
962
sed -e "s/\(INITRD_MODULES.*\)$module_name_after\b\(.*\)/\1\2/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
963
mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
954
elif [ "$1" == "delete" ]; then
955
for module_name_after in "${dest_module_name[@]}"; do
956
sed -e "s/\(INITRD_MODULES.*\)$module_name_after\b\(.*\)/\1\2/" /etc/sysconfig/kernel > $temp_dir_name/kernel.new
957
mv $temp_dir_name/kernel.new /etc/sysconfig/kernel
968
962
# Delete the temp dir
976
970
# Check that we have all the arguments
977
971
if [ -z "$module" ] || [ -z "$module_version" ]; then
979
echo $"Error! Invalid number of arguments passed." >&2
980
echo $"Usage: add -m <module> -v <module-version>" >&2
973
echo $"Error! Invalid number of arguments passed." >&2
974
echo $"Usage: add -m <module> -v <module-version>" >&2
984
978
if [ -z "$conf" ]; then
985
conf="$source_tree/$module-$module_version/dkms.conf"
979
conf="$source_tree/$module-$module_version/dkms.conf"
988
982
# Check that /usr/src/$module-$module_version exists
989
983
if ! [ -d "$source_tree/$module-$module_version" ]; then
991
echo $"Error! Could not find module source directory." >&2
992
echo $"Directory: $source_tree/$module-$module_version does not exist." >&2
985
echo $"Error! Could not find module source directory." >&2
986
echo $"Directory: $source_tree/$module-$module_version does not exist." >&2
996
990
# Do stuff for --rpm_safe_upgrade
997
991
if [ -n "$rpm_safe_upgrade" ]; then
998
local pppid=`sed -ne 's/PPid:[ \t]*//p' /proc/$PPID/status`
999
local temp_dir_name=`mktemp $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.XXXXXX 2>/dev/null`
1000
echo "$module-$module_version" >> $temp_dir_name
1001
ps -o lstart --no-headers -p $pppid 2>/dev/null >> $temp_dir_name
992
local pppid=`sed -ne 's/PPid:[ \t]*//p' /proc/$PPID/status`
993
local temp_dir_name=`mktemp $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.XXXXXX 2>/dev/null`
994
echo "$module-$module_version" >> $temp_dir_name
995
ps -o lstart --no-headers -p $pppid 2>/dev/null >> $temp_dir_name
1004
998
# Check that this module-version hasn't already been added
1005
999
if [ -d "$dkms_tree/$module/$module_version" ]; then
1007
echo $"Error! DKMS tree already contains: $module-$module_version" >&2
1008
echo $"You cannot add the same module/version combo more than once." >&2
1001
echo $"Error! DKMS tree already contains: $module-$module_version" >&2
1002
echo $"You cannot add the same module/version combo more than once." >&2
1012
1006
# Check that the conf file exists or any other script specified
1013
1007
if ! [ -e "$conf" ]; then
1015
echo $"Error! Could not locate dkms.conf file." >&2
1016
echo $"File: $conf does not exist." >&2
1009
echo $"Error! Could not locate dkms.conf file." >&2
1010
echo $"File: $conf does not exist." >&2
1020
1014
# Check the conf file for sanity
1021
1015
read_conf "${kernelver_array[0]}" "${arch_array[0]}" "$conf"
1022
1016
if [ "$?" -ne 0 ]; then
1024
echo $"Error! Bad conf file." >&2
1025
echo $"File: $conf" >&2
1026
echo $"does not represent a valid dkms.conf file." >&2
1018
echo $"Error! Bad conf file." >&2
1019
echo $"File: $conf" >&2
1020
echo $"does not represent a valid dkms.conf file." >&2
1030
1024
# Create the necessary dkms tree structure
1085
1087
# Set kernel_config
1086
1088
if [ -e /etc/redhat-release ] || [ -e /etc/fedora-release ]; then
1087
# Note this also applies to VMware 3.x
1088
if [ -z "$kernel_config" ] && [ -d "$kernel_source_dir/configs" ]; then
1089
local kernel_trunc=`echo $1 | sed 's/-.*//'`
1090
for config_type in debug summit smp enterprise bigmem hugemem BOOT vmnix; do
1091
[ `echo "$1" | grep "$config_type"` ] && kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2-$config_type.config"
1092
[ ! -e "$kernel_config" ] && kernel_config=""
1094
[ -z "$kernel_config" ] && kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2.config"
1095
[ ! -e "$kernel_config" ] && kernel_config=""
1089
# Note this also applies to VMware 3.x
1090
if [ -z "$kernel_config" ] && [ -d "$kernel_source_dir/configs" ]; then
1091
local kernel_trunc=`echo $1 | sed 's/-.*//'`
1092
for config_type in debug summit smp enterprise bigmem hugemem BOOT vmnix; do
1093
[ `echo "$1" | grep "$config_type"` ] && kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2-$config_type.config"
1094
[ ! -e "$kernel_config" ] && kernel_config=""
1096
[ -z "$kernel_config" ] && kernel_config="$kernel_source_dir/configs/kernel-$kernel_trunc-$2.config"
1097
[ ! -e "$kernel_config" ] && kernel_config=""
1097
1099
elif [ -e /etc/SuSE-release ] || [ -d /etc/SuSEconfig ]; then
1098
1100
if [ -z "$kernel_config" ] && [ -d "$kernel_source_dir/arch" ]; then
1099
local kernel_trunc=`echo $1 | sed 's/-.*//'`
1101
local kernel_trunc=`echo $1 | sed 's/-.*//'`
1100
1102
if [ "$2" == "i586" ] || [ "$2" == "i686" ]; then
1101
1103
config_arch="i386"
1105
for config_type in default smp bigsmp; do
1106
[ `echo "$1" | grep "$config_type"` ] && kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.$config_type"
1107
[ ! -e "$kernel_config" ] && kernel_config=""
1109
[ -z "$kernel_config" ] && kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.default"
1110
[ ! -e "$kernel_config" ] && kernel_config=""
1107
for config_type in default smp bigsmp; do
1108
[ `echo "$1" | grep "$config_type"` ] && kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.$config_type"
1109
[ ! -e "$kernel_config" ] && kernel_config=""
1111
[ -z "$kernel_config" ] && kernel_config="$kernel_source_dir/arch/$config_arch/defconfig.default"
1112
[ ! -e "$kernel_config" ] && kernel_config=""
1114
1116
# Do preparation
1115
1117
if [ -e /boot/vmlinuz.version.h ]; then
1116
echo $"Running UnitedLinux preparation routine"
1117
local kernel_config="/boot/vmlinuz.config"
1118
invoke_command "make mrproper" "make mrproper" background
1119
[ -n "$config_contents" ] && echo "$config_contents" > .config
1120
invoke_command "cp /boot/vmlinuz.version.h include/linux/version.h" "using /boot/vmlinux.version.h"
1121
invoke_command "cp -f $kernel_config .config" "using $kernel_config"
1122
invoke_command "make KERNELRELEASE=$1 cloneconfig" "make cloneconfig" background
1123
invoke_command "make CONFIG_MODVERSIONS=1 KERNELRELEASE=$1 dep" "make CONFIG_MODVERSIONS=1 dep" background
1118
echo $"Running UnitedLinux preparation routine"
1119
local kernel_config="/boot/vmlinuz.config"
1120
invoke_command "make mrproper" "make mrproper" background
1121
[ -n "$config_contents" ] && echo "$config_contents" > .config
1122
invoke_command "cp /boot/vmlinuz.version.h include/linux/version.h" "using /boot/vmlinux.version.h"
1123
invoke_command "cp -f $kernel_config .config" "using $kernel_config"
1124
invoke_command "make KERNELRELEASE=$1 cloneconfig" "make cloneconfig" background
1125
invoke_command "make CONFIG_MODVERSIONS=1 KERNELRELEASE=$1 dep" "make CONFIG_MODVERSIONS=1 dep" background
1124
1126
elif grep -q rhconfig.h $kernel_source_dir/include/linux/{modversions,version}.h 2>/dev/null; then
1125
echo $"Running Red Hat style preparation routine"
1126
invoke_command "make clean" "make clean" background
1127
[ -n "$config_contents" ] && echo "$config_contents" > .config
1129
if [ -n "$kernel_config" ]; then
1130
echo $"using $kernel_config"
1131
cp -f "$kernel_config" .config
1132
elif [ -e .config ]; then
1133
echo $"using $kernel_source_dir/.config"
1134
echo $"(I hope this is the correct config for this kernel)"
1137
echo $"Warning! Cannot find a .config file to prepare your kernel with." >&2
1138
echo $"Try using the --config option to specify where one can be found." >&2
1139
echo $"Your build will likely fail because of this." >&2
1142
# Hack to workaround broken tmp_include_depends for Red Hat
1143
if grep -q "/usr/src/build" $kernel_source_dir/tmp_include_depends 2>/dev/null; then
1144
sed 's/\/usr\/src\/build\/.*\/install//g' $kernel_source_dir/tmp_include_depends > $kernel_source_dir/tmp_include_depends.new
1145
mv -f $kernel_source_dir/tmp_include_depends.new $kernel_source_dir/tmp_include_depends
1148
invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
1149
kerneldoth_contents=`cat /boot/kernel.h 2>/dev/null`
1150
invoke_command "/usr/lib/dkms/mkkerneldoth --kernelver $1 --targetarch $2 --output /boot/kernel.h" "running mkkerneldoth" background
1127
echo $"Running Red Hat style preparation routine"
1128
invoke_command "make clean" "make clean" background
1129
[ -n "$config_contents" ] && echo "$config_contents" > .config
1131
if [ -n "$kernel_config" ]; then
1132
echo $"using $kernel_config"
1133
cp -f "$kernel_config" .config
1134
elif [ -e .config ]; then
1135
echo $"using $kernel_source_dir/.config"
1136
echo $"(I hope this is the correct config for this kernel)"
1139
echo $"Warning! Cannot find a .config file to prepare your kernel with." >&2
1140
echo $"Try using the --config option to specify where one can be found." >&2
1141
echo $"Your build will likely fail because of this." >&2
1144
# Hack to workaround broken tmp_include_depends for Red Hat
1145
if grep -q "/usr/src/build" $kernel_source_dir/tmp_include_depends 2>/dev/null; then
1146
sed 's/\/usr\/src\/build\/.*\/install//g' $kernel_source_dir/tmp_include_depends > $kernel_source_dir/tmp_include_depends.new
1147
mv -f $kernel_source_dir/tmp_include_depends.new $kernel_source_dir/tmp_include_depends
1150
invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
1151
kerneldoth_contents=`cat /boot/kernel.h 2>/dev/null`
1152
invoke_command "/usr/lib/dkms/mkkerneldoth --kernelver $1 --targetarch $2 --output /boot/kernel.h" "running mkkerneldoth" background
1152
echo $"Running Generic preparation routine"
1153
invoke_command "make mrproper" "make mrproper" background
1154
[ -n "$config_contents" ] && echo "$config_contents" > .config
1156
if [ -n "$kernel_config" ]; then
1157
echo $"using $kernel_config"
1158
cp -f "$kernel_config" .config
1159
elif [ -e .config ]; then
1160
echo $"using $kernel_source_dir/.config"
1161
echo $"(I hope this is the correct config for this kernel)"
1164
echo $"Warning! Cannot find a .config file to prepare your kernel with." >&2
1165
echo $"Try using the --config option to specify where one can be found." >&2
1166
echo $"Your build will likely fail because of this." >&2
1169
invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
1170
if [[ $(VER $1) < $(VER 2.5) ]]; then
1171
invoke_command "make KERNELRELEASE=$1 dep" "make dep" background
1173
invoke_command "make KERNELRELEASE=$1 prepare-all scripts" "make prepare-all" background
1154
echo $"Running Generic preparation routine"
1155
invoke_command "make mrproper" "make mrproper" background
1156
[ -n "$config_contents" ] && echo "$config_contents" > .config
1158
if [ -n "$kernel_config" ]; then
1159
echo $"using $kernel_config"
1160
cp -f "$kernel_config" .config
1161
elif [ -e .config ]; then
1162
echo $"using $kernel_source_dir/.config"
1163
echo $"(I hope this is the correct config for this kernel)"
1166
echo $"Warning! Cannot find a .config file to prepare your kernel with." >&2
1167
echo $"Try using the --config option to specify where one can be found." >&2
1168
echo $"Your build will likely fail because of this." >&2
1171
invoke_command "make KERNELRELEASE=$1 oldconfig" "make oldconfig" background
1172
if [[ $(VER $1) < $(VER 2.5) ]]; then
1173
invoke_command "make KERNELRELEASE=$1 dep" "make dep" background
1175
invoke_command "make KERNELRELEASE=$1 prepare-all scripts" "make prepare-all" background
1176
1178
cd - >/dev/null
1205
1207
# Check that the right arguments were passed
1206
1208
if [ -z "$module" ] || [ -z "$module_version" ]; then
1208
echo $"Error! Invalid number of parameters passed." >&2
1209
echo $"Usage: install -m <module> -v <module-version>" >&2
1210
echo $"Error! Invalid number of parameters passed." >&2
1211
echo $"Usage: install -m <module> -v <module-version>" >&2
1213
1215
# Check that $module-$module_version exists by checking the source symlink
1214
1216
if ! [ -d "$dkms_tree/$module/$module_version/source" ]; then
1216
echo $"Error! DKMS tree does not contain: $module-$module_version" >&2
1217
echo $"Build cannot continue without the proper tree." >&2
1218
echo $"Error! DKMS tree does not contain: $module-$module_version" >&2
1219
echo $"Build cannot continue without the proper tree." >&2
1221
1223
# Make sure that kernel exists to install into
1222
1224
if ! [ -e "$install_tree/${kernelver_array[0]}" ]; then
1224
echo $"Error! The directory $install_tree/${kernelver_array[0]} doesn't exist." >&2
1225
echo $"You cannot install a module onto a non-existant kernel." >&2
1226
echo $"Error! The directory $install_tree/${kernelver_array[0]} doesn't exist." >&2
1227
echo $"You cannot install a module onto a non-existant kernel." >&2
1229
1231
# Read the conf file
1230
1232
read_conf "${kernelver_array[0]}" "${arch_array[0]}"
1231
1233
if [ "$?" -ne 0 ]; then
1233
echo $"Error! Bad conf file." >&2
1234
echo $"Your dkms.conf is not valid." >&2
1235
echo $"Error! Bad conf file." >&2
1236
echo $"Your dkms.conf is not valid." >&2
1238
1240
# Make sure the $module_name_after exists
1239
1241
set_module_suffix "${kernelver_array[0]}"
1240
1242
for module_name_after in "${dest_module_name[@]}"; do
1241
if ! [ -e "$base_dir/module/$module_name_after$module_suffix" ]; then
1243
echo $"Error! Could not locate $module_name_after$module_suffix for module $module in the DKMS tree." >&2
1244
echo $"You must run a dkms build for kernel ${kernelver_array[0]} (${arch_array[0]}) first." >&2
1243
if ! [ -e "$base_dir/module/$module_name_after$module_suffix" ]; then
1245
echo $"Error! Could not locate $module_name_after$module_suffix for module $module in the DKMS tree." >&2
1246
echo $"You must run a dkms build for kernel ${kernelver_array[0]} (${arch_array[0]}) first." >&2
1249
1251
# Check that its not already installed (kernel symlink)
1250
1252
readlink "$dkms_tree/$module/kernel-${kernelver_array[0]}-${arch_array[0]}"
1251
1253
kernel_symlink="$read_link"
1252
1254
if [ "$kernel_symlink" == "$module_version/${kernelver_array[0]}/${arch_array[0]}" ]; then
1254
echo $"Error! This module/version combo is already installed" >&2
1255
echo $"for kernel: ${kernelver_array[0]} (${arch_array[0]})" >&2
1256
echo $"Error! This module/version combo is already installed" >&2
1257
echo $"for kernel: ${kernelver_array[0]} (${arch_array[0]})" >&2
1259
1261
# if upgrading using rpm_safe_upgrade, go ahead and force the install
1261
1263
# while the second half of the upgrade, the removal, then succeeds, leaving us with
1262
1264
# nothing installed.
1263
1265
if [ -n "$rpm_safe_upgrade" ]; then
1267
1269
# Save the original_module if one exists, none have been saved before, and this is the first module for this kernel
1268
1270
local lib_tree="$install_tree/${kernelver_array[0]}"
1270
1272
while [ "$count" -lt ${#built_module_name[@]} ]; do
1272
echo $"${dest_module_name[$count]}$module_suffix:"
1273
# Check this version against what is already in the kernel
1274
if ! check_version_sanity "${kernelver_array[0]}" "${arch_array[0]}" "$obsolete_by" "${dest_module_name[$count]}"; then
1275
count=$(($count + 1))
1279
if [ "$count" -eq 0 ]; then
1280
# Run the pre_install script
1281
if [ -n "$pre_install" ] && [ -x `echo "$dkms_tree/$module/$module_version/source/$pre_install" | sed 's/ .*//'` ]; then
1283
echo $"Running the pre_install script:"
1284
$dkms_tree/$module/$module_version/source/$pre_install
1285
if [ "$?" -ne 0 -a -z "$force" ]; then
1286
echo $"pre_install failed, aborting install." >&2
1287
echo $"You may override by specifying --force." >&2
1292
local module_count=`find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f | wc -l | awk {'print $1'}`
1293
echo $" - Original module"
1294
if ! [ -L "$dkms_tree/$module/kernel-${kernelver_array[0]}-${arch_array[0]}" ]; then
1295
local archive_pref1="$lib_tree/extra/${dest_module_name[$count]}$module_suffix"
1296
local archive_pref2="$lib_tree/updates/${dest_module_name[$count]}$module_suffix"
1297
local archive_pref3="$lib_tree${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
1298
local archive_pref4=""
1299
[ "$module_count" -eq 1 ] && archive_pref4="`find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f`"
1300
local original_module=""
1301
local found_orginal=""
1302
for original_module in $archive_pref1 $archive_pref2 $archive_pref3 $archive_pref4; do
1303
if [ -f "$original_module" ]; then
1304
case "$running_distribution" in
1305
Debian* | Ubuntu* ) ;;
1307
echo $" - Found $original_module"
1308
echo $" - Storing in $dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/"
1309
echo $" - Archiving for uninstallation purposes"
1310
mkdir -p "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}"
1311
mv -f "$original_module" "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/"
1314
found_original="yes"
1318
if [ -z "$found_original" ] && [ "$module_count" -gt 1 ]; then
1319
echo $" - Multiple original modules exist but DKMS does not know which to pick"
1320
echo $" - Due to the confusion, none will be considered during a later uninstall"
1321
elif [ -z "$found_original" ]; then
1322
echo $" - No original module exists within this kernel"
1324
elif [ -L "$dkms_tree/$module/kernel-${kernelver_array[0]}-${arch_array[0]}" ] && [ -e "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/${dest_module_name[$count]}$module_suffix" ]; then
1325
echo $" - An original module was already stored during a previous install"
1327
echo $" - This kernel never originally had a module by this name"
1330
if [ "$module_count" -gt 1 ]; then
1331
echo $" - Multiple same named modules!"
1332
echo $" - $module_count named ${dest_module_name[$count]}$module_suffix in $lib_tree/"
1333
case "$running_distribution" in
1334
Debian* | Ubuntu* ) ;;
1336
echo $" - All instances of this module will now be stored for reference purposes ONLY"
1337
echo $" - Storing in $dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/collisions/"
1340
for module_dup in `find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f`; do
1341
dup_tree=`echo $module_dup | sed "s#^$lib_tree##" | sed "s#${dest_module_name[$count]}$module_suffix##"`
1342
case "$running_distribution" in
1343
Debian* | Ubuntu* ) ;;
1345
echo $" - Stored $module_dup"
1346
mkdir -p "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/collisions/$dup_tree"
1347
mv -f $module_dup "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/collisions/$dup_tree"
1274
echo $"${dest_module_name[$count]}$module_suffix:"
1275
# Check this version against what is already in the kernel
1276
if ! check_version_sanity "${kernelver_array[0]}" "${arch_array[0]}" "$obsolete_by" "${dest_module_name[$count]}"; then
1277
count=$(($count + 1))
1281
if [ "$count" -eq 0 ]; then
1282
# Run the pre_install script
1283
if [ -n "$pre_install" ] && [ -x `echo "$dkms_tree/$module/$module_version/source/$pre_install" | sed 's/ .*//'` ]; then
1285
echo $"Running the pre_install script:"
1286
$dkms_tree/$module/$module_version/source/$pre_install
1287
if [ "$?" -ne 0 -a -z "$force" ]; then
1288
echo $"pre_install failed, aborting install." >&2
1289
echo $"You may override by specifying --force." >&2
1294
local module_count=`find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f | wc -l | awk {'print $1'}`
1295
echo $" - Original module"
1296
if ! [ -L "$dkms_tree/$module/kernel-${kernelver_array[0]}-${arch_array[0]}" ]; then
1297
local archive_pref1="$lib_tree/extra/${dest_module_name[$count]}$module_suffix"
1298
local archive_pref2="$lib_tree/updates/${dest_module_name[$count]}$module_suffix"
1299
local archive_pref3="$lib_tree${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
1300
local archive_pref4=""
1301
[ "$module_count" -eq 1 ] && archive_pref4="`find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f`"
1302
local original_module=""
1303
local found_orginal=""
1304
for original_module in $archive_pref1 $archive_pref2 $archive_pref3 $archive_pref4; do
1305
if [ -f "$original_module" ]; then
1306
case "$running_distribution" in
1307
Debian* | Ubuntu* ) ;;
1309
echo $" - Found $original_module"
1310
echo $" - Storing in $dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/"
1311
echo $" - Archiving for uninstallation purposes"
1312
mkdir -p "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}"
1313
mv -f "$original_module" "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/"
1316
found_original="yes"
1320
if [ -z "$found_original" ] && [ "$module_count" -gt 1 ]; then
1321
echo $" - Multiple original modules exist but DKMS does not know which to pick"
1322
echo $" - Due to the confusion, none will be considered during a later uninstall"
1323
elif [ -z "$found_original" ]; then
1324
echo $" - No original module exists within this kernel"
1326
elif [ -L "$dkms_tree/$module/kernel-${kernelver_array[0]}-${arch_array[0]}" ] && [ -e "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/${dest_module_name[$count]}$module_suffix" ]; then
1327
echo $" - An original module was already stored during a previous install"
1329
echo $" - This kernel never originally had a module by this name"
1332
if [ "$module_count" -gt 1 ]; then
1333
echo $" - Multiple same named modules!"
1334
echo $" - $module_count named ${dest_module_name[$count]}$module_suffix in $lib_tree/"
1335
case "$running_distribution" in
1336
Debian* | Ubuntu* ) ;;
1338
echo $" - All instances of this module will now be stored for reference purposes ONLY"
1339
echo $" - Storing in $dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/collisions/"
1342
for module_dup in `find $lib_tree -name ${dest_module_name[$count]}$module_suffix -type f`; do
1343
dup_tree=`echo $module_dup | sed "s#^$lib_tree##" | sed "s#${dest_module_name[$count]}$module_suffix##"`
1344
case "$running_distribution" in
1345
Debian* | Ubuntu* ) ;;
1347
echo $" - Stored $module_dup"
1348
mkdir -p "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/collisions/$dup_tree"
1349
mv -f $module_dup "$dkms_tree/$module/original_module/${kernelver_array[0]}/${arch_array[0]}/collisions/$dup_tree"
1353
1355
# Copy module to its location
1354
echo $" - Installation"
1355
echo $" - Installing to $install_tree/${kernelver_array[0]}${dest_module_location[$count]}/"
1356
mkdir -p $install_tree/${kernelver_array[0]}${dest_module_location[$count]}
1357
cp -f "$base_dir/module/${dest_module_name[$count]}$module_suffix" "$install_tree/${kernelver_array[0]}${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
1356
echo $" - Installation"
1357
echo $" - Installing to $install_tree/${kernelver_array[0]}${dest_module_location[$count]}/"
1358
mkdir -p $install_tree/${kernelver_array[0]}${dest_module_location[$count]}
1359
cp -f "$base_dir/module/${dest_module_name[$count]}$module_suffix" "$install_tree/${kernelver_array[0]}${dest_module_location[$count]}/${dest_module_name[$count]}$module_suffix"
1359
count=$(($count + 1))
1361
count=$(($count + 1))
1362
1364
# Create the kernel-<kernelver> symlink to designate this version as active
1385
1387
invoke_command "do_depmod ${kernelver_array[0]}" "depmod" background
1386
1388
if [ "$?" -ne 0 ]; then
1387
local unresolved_symbols="$(do_depmod ${kernelver_array[0]} 2>&1)"
1389
while [ "$count" -lt "${#built_module_name[@]}" ]; do
1390
if echo "$unresolved_symbols" | grep -q "${dest_module_name[$count]}$module_suffix$"; then
1392
echo $"Problems with depmod detected. Automatically uninstalling this module."
1394
do_uninstall "${kernelver_array[0]}" "${arch_array[0]}"
1396
echo $"DKMS: Install Failed (depmod problems). Module rolled back to built state."
1399
count=$(($count + 1))
1389
local unresolved_symbols="$(do_depmod ${kernelver_array[0]} 2>&1)"
1391
while [ "$count" -lt "${#built_module_name[@]}" ]; do
1392
if echo "$unresolved_symbols" | grep -q "${dest_module_name[$count]}$module_suffix$"; then
1394
echo $"Problems with depmod detected. Automatically uninstalling this module."
1396
do_uninstall "${kernelver_array[0]}" "${arch_array[0]}"
1398
echo $"DKMS: Install Failed (depmod problems). Module rolled back to built state."
1401
count=$(($count + 1))
1403
1405
# Do remake_initrd things (save old initrd)
1404
1406
if [ -n "$remake_initrd" ]; then
1405
remake_initrd "${kernelver_array[0]}" "${arch_array[0]}"
1406
if [ "$?" -ne 0 ]; then
1407
echo $"Problems with mkinitrd detected. Automatically uninstalling this module."
1409
do_uninstall "${kernelver_array[0]}" "${arch_array[0]}"
1411
echo $"DKMS: Install Failed (mkinitrd problems). Module rolled back to built state."
1407
remake_initrd "${kernelver_array[0]}" "${arch_array[0]}"
1408
if [ "$?" -ne 0 ]; then
1409
echo $"Problems with mkinitrd detected. Automatically uninstalling this module."
1411
do_uninstall "${kernelver_array[0]}" "${arch_array[0]}"
1413
echo $"DKMS: Install Failed (mkinitrd problems). Module rolled back to built state."
1427
1429
# Check that the right arguments were passed
1428
1430
if [ -z "$module" ] || [ -z "$module_version" ]; then
1430
echo $"Error! Invalid number of parameters passed." >&2
1431
echo $"Usage: build -m <module> -v <module-version>" >&2
1432
echo $"Error! Invalid number of parameters passed." >&2
1433
echo $"Usage: build -m <module> -v <module-version>" >&2
1435
1437
# Check that source symlink works
1436
1438
if ! [ -d "$dkms_tree/$module/$module_version/source" ]; then
1438
echo $"Error! DKMS tree does not contain: $module-$module_version" >&2
1439
echo $"Build cannot continue without the proper tree." >&2
1440
echo $"Error! DKMS tree does not contain: $module-$module_version" >&2
1441
echo $"Build cannot continue without the proper tree." >&2
1443
1445
# Check that the module has not already been built for this kernel
1444
1446
if [ -d "$base_dir" ]; then
1446
echo $"Error! This module/version has already been built on: ${kernelver_array[0]}" >&2
1447
echo $"Directory: $base_dir" >&2
1448
echo $"already exists. Use the dkms remove function before trying to build again." >&2
1448
echo $"Error! This module/version has already been built on: ${kernelver_array[0]}" >&2
1449
echo $"Directory: $base_dir" >&2
1450
echo $"already exists. Use the dkms remove function before trying to build again." >&2
1452
1454
# Read the conf file
1453
1455
set_module_suffix "${kernelver_array[0]}"
1454
1456
read_conf "${kernelver_array[0]}" "${arch_array[0]}"
1455
1457
if [ "$?" -ne 0 ]; then
1457
echo $"Error! Bad conf file." >&2
1458
echo $"Your dkms.conf is not valid." >&2
1459
echo $"Error! Bad conf file." >&2
1460
echo $"Your dkms.conf is not valid." >&2
1462
1464
# Error out if build_exclude is set
1463
1465
if [ -n "$build_exclude" ]; then
1465
echo "Error! The dkms.conf for this module includes a BUILD_EXCLUSIVE directive which" >&2
1466
echo "does not match this kernel/arch. This indicates that it should not be built." >&2
1467
echo "Error! The dkms.conf for this module includes a BUILD_EXCLUSIVE directive which" >&2
1468
echo "does not match this kernel/arch. This indicates that it should not be built." >&2
1470
1472
# Error out if source_tree is basically empty (binary-only dkms tarball w/ --force check)
1471
1473
if [ `ls $dkms_tree/$module/$module_version/source | wc -l | awk {'print $1'}` -lt 2 ]; then
1473
echo $"Error! The directory $dkms_tree/$module/$module_version/source/" >&2
1474
echo $"does not appear to have module source located within it. Build halted." >&2
1475
echo $"Error! The directory $dkms_tree/$module/$module_version/source/" >&2
1476
echo $"does not appear to have module source located within it. Build halted." >&2
1478
1480
prepare_kernel "${kernelver_array[0]}" "${arch_array[0]}"
1521
1524
echo $"`date`" >> "$dkms_tree/$module/$module_version/build/make.log"
1522
1525
local the_make_command=`echo $make_command | sed "s/^make/make KERNELRELEASE=${kernelver_array[0]}/"`
1524
#if we're root, try to run as a user instead
1525
if [ "$USER" = "root" ] && getent passwd nobody 1>/dev/null && su nobody -c "/bin/true" 1>/dev/null; then
1526
the_make_command="su nobody -c \"$the_make_command\""
1527
chmod +x $dkms_tree/$module/$module_version/build
1528
chown -R nobody $dkms_tree/$module/$module_version/build
1531
1527
invoke_command "$the_make_command >> $dkms_tree/$module/$module_version/build/make.log 2>&1" "$the_make_command" background
1533
1529
# Make sure good return status
1534
1530
if [ "$?" -ne 0 ]; then
1536
echo $"Error! Bad return status for module build on kernel: ${kernelver_array[0]} (${arch_array[0]})" >&2
1537
echo $"Consult the make.log in the build directory" >&2
1538
echo $"$dkms_tree/$module/$module_version/build/ for more information." >&2
1539
if grep -ic "gcc: Command not found" "$dkms_tree/$module/$module_version/build/make.log"; then
1541
echo $"DO YOU HAVE gcc INSTALLED???" >&2
1543
if grep -ic "make: command not found" "$dkms_tree/$module/$module_version/build/make.log"; then
1545
echo $"DO YOU HAVE make INSTALLED???" >&2
1532
echo $"Error! Bad return status for module build on kernel: ${kernelver_array[0]} (${arch_array[0]})" >&2
1533
echo $"Consult the make.log in the build directory" >&2
1534
echo $"$dkms_tree/$module/$module_version/build/ for more information." >&2
1535
if grep -ic "gcc: Command not found" "$dkms_tree/$module/$module_version/build/make.log"; then
1537
echo $"DO YOU HAVE gcc INSTALLED???" >&2
1539
if grep -ic "make: command not found" "$dkms_tree/$module/$module_version/build/make.log"; then
1541
echo $"DO YOU HAVE make INSTALLED???" >&2
1543
report_build_problem
1550
1547
# Make sure all the modules built successfully
1552
1549
while [ "$count" -lt "${#built_module_name[@]}" ]; do
1553
if ! [ -e "${built_module_location[$count]}${built_module_name[$count]}$module_suffix" ]; then
1555
echo $"Error! Build of ${built_module_name[$count]}$module_suffix failed for: ${kernelver_array[0]} (${arch_array[0]})" >&2
1556
echo $"Consult the make.log in the build directory" >&2
1557
echo $"$dkms_tree/$module/$module_version/build/ for more information." >&2
1550
if ! [ -e "${built_module_location[$count]}${built_module_name[$count]}$module_suffix" ]; then
1552
echo $"Error! Build of ${built_module_name[$count]}$module_suffix failed for: ${kernelver_array[0]} (${arch_array[0]})" >&2
1553
echo $"Consult the make.log in the build directory" >&2
1554
echo $"$dkms_tree/$module/$module_version/build/ for more information." >&2
1555
report_build_problem
1562
1560
cd - >/dev/null
1674
1672
local kernel_symlink="$read_link"
1675
1673
local real_dest_module_location
1676
1674
if [ "$kernel_symlink" == "$module_version/$1/$2" ]; then
1679
echo $"Status: Before uninstall, this module version was ACTIVE on this kernel."
1680
# remove kabi-tracking if last instance removed
1682
if [ -n "${weak_modules}" ] &&
1683
[ `$0 status -m $module -v $module_version | grep -v "installed-weak" | grep -c "installed"` -eq 1 ]; then
1684
echo $"Removing any linked weak-modules"
1685
list_each_installed_module "$module" "$1" "$2" | ${weak_modules} --remove-modules
1689
while [ "$count" -lt "${#built_module_name[@]}" ]; do
1690
real_dest_module_location="$(find_actual_dest_module_location $module $count $1 $2)"
1692
echo $"${dest_module_name[$count]}$module_suffix:"
1693
echo $" - Uninstallation"
1694
echo $" - Deleting from: $install_tree/$1${real_dest_module_location}/"
1695
rm -f "$install_tree/$1${real_dest_module_location}/${dest_module_name[$count]}$module_suffix"
1696
echo $" - Original module"
1697
if [ -e "$dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix" ]; then
1698
case "$running_distribution" in
1699
Debian* | Ubuntu* ) ;;
1701
echo $" - Archived original module found in the DKMS tree"
1702
echo $" - Moving it to: $install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
1703
mkdir -p "$install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
1704
mv -f "$dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix" \
1705
"$install_tree/$1${DEST_MODULE_LOCATION[$count]}/" 2>/dev/null
1709
echo $" - No original module was found for this module on this kernel."
1710
echo $" - Use the dkms install command to reinstall any previous module version."
1712
# Remove modules_conf entries from /etc/modules.conf if remake_initrd is set or if this is last instance removed
1713
if [ -n "$remake_initrd" ] || \
1714
[ `$0 status -m $module -v $module_version | \
1715
grep -c "installed"` -eq 1 ]; then
1717
moduleconfig_remove "$1"
1722
rm -f "$dkms_tree/$module/kernel-$1-$2"
1677
echo $"Status: Before uninstall, this module version was ACTIVE on this kernel."
1678
# remove kabi-tracking if last instance removed
1680
if [ -n "${weak_modules}" ] &&
1681
[ `$0 status -m $module -v $module_version | grep -v "installed-weak" | grep -c "installed"` -eq 1 ]; then
1682
echo $"Removing any linked weak-modules"
1683
list_each_installed_module "$module" "$1" "$2" | ${weak_modules} --remove-modules
1687
while [ "$count" -lt "${#built_module_name[@]}" ]; do
1688
real_dest_module_location="$(find_actual_dest_module_location $module $count $1 $2)"
1690
echo $"${dest_module_name[$count]}$module_suffix:"
1691
echo $" - Uninstallation"
1692
echo $" - Deleting from: $install_tree/$1${real_dest_module_location}/"
1693
rm -f "$install_tree/$1${real_dest_module_location}/${dest_module_name[$count]}$module_suffix"
1694
echo $" - Original module"
1695
if [ -e "$dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix" ]; then
1696
case "$running_distribution" in
1697
Debian* | Ubuntu* ) ;;
1699
echo $" - Archived original module found in the DKMS tree"
1700
echo $" - Moving it to: $install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
1701
mkdir -p "$install_tree/$1${DEST_MODULE_LOCATION[$count]}/"
1702
mv -f "$dkms_tree/$module/original_module/$1/$2/${dest_module_name[$count]}$module_suffix" \
1703
"$install_tree/$1${DEST_MODULE_LOCATION[$count]}/" 2>/dev/null
1707
echo $" - No original module was found for this module on this kernel."
1708
echo $" - Use the dkms install command to reinstall any previous module version."
1710
# Remove modules_conf entries from /etc/modules.conf if remake_initrd is set or if this is last instance removed
1711
if [ -n "$remake_initrd" ] || \
1712
[ `$0 status -m $module -v $module_version | \
1713
grep -c "installed"` -eq 1 ]; then
1715
moduleconfig_remove "$1"
1720
rm -f "$dkms_tree/$module/kernel-$1-$2"
1725
echo $"Status: This module version was INACTIVE for this kernel."
1723
echo $"Status: This module version was INACTIVE for this kernel."
1728
1726
# Run the post_remove script
1729
1727
if [ -n "$post_remove" ] && [ -x `echo "$dkms_tree/$module/$module_version/source/$post_remove" | sed 's/ .*//'` ]; then
1731
echo $"Running the post_remove script:"
1732
$dkms_tree/$module/$module_version/source/$post_remove
1729
echo $"Running the post_remove script:"
1730
$dkms_tree/$module/$module_version/source/$post_remove
1735
1733
# Run depmod because we changed /lib/modules
1738
1736
# Do remake_initrd things (remake initrd)
1739
1737
if [ -n "$remake_initrd" ] && [ -n "$was_active" ]; then
1740
remake_initrd "$1" "$2"
1741
if [ "$?" -ne 0 ]; then
1743
echo $"WARNING! WARNING! WARNING!"
1744
echo $"There was a problem remaking your initrd. You must manually remake it"
1745
echo $"before booting into this kernel."
1738
remake_initrd "$1" "$2"
1739
if [ "$?" -ne 0 ]; then
1741
echo $"WARNING! WARNING! WARNING!"
1742
echo $"There was a problem remaking your initrd. You must manually remake it"
1743
echo $"before booting into this kernel."
1750
1748
# Delete the original_module if nothing for this kernel is installed anymore
1751
1749
if [ -n "$was_active" ] && [ -d "$dkms_tree/$module/original_module/$1/$2" ] && ! [ -d "$dkms_tree/$module/original_module/$1/$2/collisions" ]; then
1753
echo $"Removing original_module from DKMS tree for kernel $1 ($2)"
1754
rm -rf "$dkms_tree/$module/original_module/$1/$2" 2>/dev/null
1755
[ -z "`find $dkms_tree/$module/original_module/$1/* -maxdepth 0 -type d 2>/dev/null`" ] && rm -rf "$dkms_tree/$module/original_module/$1"
1751
echo $"Removing original_module from DKMS tree for kernel $1 ($2)"
1752
rm -rf "$dkms_tree/$module/original_module/$1/$2" 2>/dev/null
1753
[ -z "`find $dkms_tree/$module/original_module/$1/* -maxdepth 0 -type d 2>/dev/null`" ] && rm -rf "$dkms_tree/$module/original_module/$1"
1756
1754
elif [ -n "$was_active" ] && [ -d "$dkms_tree/$module/original_module/$1/$2/collisions" ]; then
1758
echo $"Keeping directory $dkms_tree/$module/original_module/$1/$2/collisions/"
1759
echo $"for your reference purposes. Your kernel originally contained multiple"
1760
echo $"same-named modules and this directory is now where these are located."
1756
echo $"Keeping directory $dkms_tree/$module/original_module/$1/$2/collisions/"
1757
echo $"for your reference purposes. Your kernel originally contained multiple"
1758
echo $"same-named modules and this directory is now where these are located."
1762
1760
[ -z "`find $dkms_tree/$module/original_module/* -maxdepth 0 -type d 2>/dev/null`" ] && rm -rf "$dkms_tree/$module/original_module"
1776
1774
# Check that the right arguments were passed
1777
1775
if [ -z "$module" ] || [ -z "$module_version" ]; then
1779
echo $"Error! Invalid number of parameters passed." >&2
1780
echo $"Usage: uninstall -m <module> -v <module-version>" >&2
1781
echo $" or: uninstall -m <module> -v <module-version> -k <kernel-version>" >&2
1777
echo $"Error! Invalid number of parameters passed." >&2
1778
echo $"Usage: uninstall -m <module> -v <module-version>" >&2
1779
echo $" or: uninstall -m <module> -v <module-version> -k <kernel-version>" >&2
1785
1783
# Check that $module is in the dkms tree
1786
1784
if ! [ -d "$dkms_tree/$module" ]; then
1788
echo $"Error! There are no instances of module: $module" >&2
1789
echo $"located in the DKMS tree." >&2
1786
echo $"Error! There are no instances of module: $module" >&2
1787
echo $"located in the DKMS tree." >&2
1793
1791
# Make sure that its installed in the first place
1794
1792
if ! [ -d "$dkms_tree/$module/$module_version" ]; then
1796
echo $"Error! The module/version combo: $module-$module_version" >&2
1797
echo $"is not located in the DKMS tree." >&2
1794
echo $"Error! The module/version combo: $module-$module_version" >&2
1795
echo $"is not located in the DKMS tree." >&2
1801
1799
# Read the conf file
1802
1800
read_conf "${kernelver_array[0]}" "${arch_array[0]}"
1803
1801
if [ "$?" -ne 0 ]; then
1805
echo $"Error! Bad conf file." >&2
1806
echo $"Your dkms.conf is not valid." >&2
1803
echo $"Error! Bad conf file." >&2
1804
echo $"Your dkms.conf is not valid." >&2
1810
1808
# Only do stuff if module/module version is currently installed
1811
1809
readlink "$dkms_tree/$module/kernel-${kernelver_array[0]}-${arch_array[0]}"
1812
1810
local kernel_symlink="$read_link"
1813
1811
if [ "$kernel_symlink" == "$module_version/${kernelver_array[0]}/${arch_array[0]}" ]; then
1814
do_uninstall "${kernelver_array[0]}" "${arch_array[0]}"
1812
do_uninstall "${kernelver_array[0]}" "${arch_array[0]}"
1817
echo $"Error! The module $module $module_version is not currently installed." >&2
1818
echo $"This module is not currently ACTIVE for kernel ${kernelver_array[0]} (${arch_array[0]})." >&2
1815
echo $"Error! The module $module $module_version is not currently installed." >&2
1816
echo $"This module is not currently ACTIVE for kernel ${kernelver_array[0]} (${arch_array[0]})." >&2
1825
1823
# Check that the right arguments were passed (must be done before setup_kernels_arches)
1826
1824
if [ -z "$module" ] || [ -z "$module_version" ] || $([ -z "${kernelver_array[0]}" ] && [ -z "$all" ]); then
1828
echo $"Error! Invalid number of parameters passed." >&2
1829
echo $"Usage: remove -m <module> -v <module-version> --all" >&2
1830
echo $" or: remove -m <module> -v <module-version> -k <kernel-version>" >&2
1826
echo $"Error! Invalid number of parameters passed." >&2
1827
echo $"Usage: remove -m <module> -v <module-version> --all" >&2
1828
echo $" or: remove -m <module> -v <module-version> -k <kernel-version>" >&2
1834
1832
setup_kernels_arches "remove"
1836
1834
# Check that $module is in the dkms tree
1837
1835
if ! [ -d "$dkms_tree/$module/$module_version" ]; then
1839
echo $"Error! There are no instances of module: $module" >&2
1840
echo $"$module_version located in the DKMS tree." >&2
1837
echo $"Error! There are no instances of module: $module" >&2
1838
echo $"$module_version located in the DKMS tree." >&2
1845
1843
while [ $i -lt ${#kernelver_array[@]} ]; do
1847
1845
# make sure its there first before removing
1848
if ! [ -d "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}" ]; then
1850
echo $"Error! There is no instance of $module $module_version" >&2
1851
echo $"for kernel ${kernelver_array[$i]} (${arch_array[$i]}) located in the DKMS tree." >&2
1846
if ! [ -d "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}" ]; then
1848
echo $"Error! There is no instance of $module $module_version" >&2
1849
echo $"for kernel ${kernelver_array[$i]} (${arch_array[$i]}) located in the DKMS tree." >&2
1855
1853
# Do --rpm_safe_upgrade check (exit out and don't do remove if inter-release RPM upgrade scenario occurs)
1856
if [ -n "$rpm_safe_upgrade" ]; then
1857
local pppid=`cat /proc/$PPID/status | grep PPid: | awk {'print $2'}`
1858
local time_stamp=`ps -o lstart --no-headers -p $pppid 2>/dev/null`
1859
for lock_file in `ls $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.* 2>/dev/null`; do
1860
lock_head=`head -n 1 $lock_file 2>/dev/null`
1861
lock_tail=`tail -n 1 $lock_file 2>/dev/null`
1862
if [ "$lock_head" == "$module-$module_version" ] && [ "$lock_tail" == "$time_stamp" ] && [ -n "$time_stamp" ]; then
1864
echo $"DKMS: Remove cancelled because --rpm_safe_upgrade scenario detected."
1854
if [ -n "$rpm_safe_upgrade" ]; then
1855
local pppid=`cat /proc/$PPID/status | grep PPid: | awk {'print $2'}`
1856
local time_stamp=`ps -o lstart --no-headers -p $pppid 2>/dev/null`
1857
for lock_file in `ls $tmp_location/dkms_rpm_safe_upgrade_lock.$pppid.* 2>/dev/null`; do
1858
lock_head=`head -n 1 $lock_file 2>/dev/null`
1859
lock_tail=`tail -n 1 $lock_file 2>/dev/null`
1860
if [ "$lock_head" == "$module-$module_version" ] && [ "$lock_tail" == "$time_stamp" ] && [ -n "$time_stamp" ]; then
1862
echo $"DKMS: Remove cancelled because --rpm_safe_upgrade scenario detected."
1871
1869
# Read the conf file
1872
read_conf "${kernelver_array[$i]}" "${arch_array[$i]}"
1873
if [ "$?" -ne 0 ]; then
1875
echo $"Error! Bad conf file." >&2
1876
echo $"File: $dkms_tree/$module/$module_version/source/dkms.conf does not represent" >&2
1877
echo $"a valid dkms.conf file." >&2
1870
read_conf "${kernelver_array[$i]}" "${arch_array[$i]}"
1871
if [ "$?" -ne 0 ]; then
1873
echo $"Error! Bad conf file." >&2
1874
echo $"File: $dkms_tree/$module/$module_version/source/dkms.conf does not represent" >&2
1875
echo $"a valid dkms.conf file." >&2
1881
do_uninstall "${kernelver_array[$i]}" "${arch_array[$i]}"
1879
do_uninstall "${kernelver_array[$i]}" "${arch_array[$i]}"
1883
1881
# Delete the $kernel_version/$arch_used part of the tree
1884
rm -rf "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}"
1885
[ -z "`find $dkms_tree/$module/$module_version/${kernelver_array[$i]}/* -maxdepth 0 -type d 2>/dev/null`" ] && rm -rf "$dkms_tree/$module/$module_version/${kernelver_array[$i]}"
1882
rm -rf "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}"
1883
[ -z "`find $dkms_tree/$module/$module_version/${kernelver_array[$i]}/* -maxdepth 0 -type d 2>/dev/null`" ] && rm -rf "$dkms_tree/$module/$module_version/${kernelver_array[$i]}"
1890
1888
# Delete the $module_version part of the tree if no other $module_version/$kernel_version dirs exist
1891
1889
if [ -z "$(find $dkms_tree/$module/$module_version/* -maxdepth 0 -type d 2>/dev/null | egrep -v "(build|tarball|driver_disk|rpm|deb|source)$")" ]; then
1893
echo $"------------------------------"
1894
echo $"Deleting module version: $module_version"
1895
echo $"completely from the DKMS tree."
1896
echo $"------------------------------"
1897
rm -rf "$dkms_tree/$module/$module_version"
1891
echo $"------------------------------"
1892
echo $"Deleting module version: $module_version"
1893
echo $"completely from the DKMS tree."
1894
echo $"------------------------------"
1895
rm -rf "$dkms_tree/$module/$module_version"
1901
1899
# Get rid of any remnant directories if necessary
1902
1900
if [ `ls "$dkms_tree/$module" | wc -w | awk '{print $1}'` -eq 0 ]; then
1903
rm -rf "$dkms_tree/$module" 2>/dev/null
1901
rm -rf "$dkms_tree/$module" 2>/dev/null
1905
# Its now safe to completely remove references in /etc/sysconfig/kernel for SuSE
1906
etc_sysconfig_kernel_modify "delete"
1903
# Its now safe to completely remove references in /etc/sysconfig/kernel for SuSE
1904
etc_sysconfig_kernel_modify "delete"
1970
1968
# recognize weak modules. These are in $kern/weak-updates but are symlinks to another $kern/extra file.
1972
1970
for installedkern in $(find "$install_tree" -maxdepth 1 -mindepth 1 -type d 2>/dev/null); do
1973
for ko in $(find "$installedkern/weak-updates" -type l 2>/dev/null); do
1974
installedkernver=$(basename $installedkern)
1975
basename_ko=$(basename $ko)
1977
installed_ko="$read_link"
1978
if [ ! -e "$installed_ko" ]; then
1979
# dangling symlink, ouch, but is somebody else's problem so ignore it
1982
# remember, installed_ko is probably a relative path, so $kernelversion isn't present in its link
1983
# is $installed_ko in /var/lib/dkms as installed? Find which module has it
1984
for f in $(find $dkms_tree/$r_mod -maxdepth $depth -mindepth $depth -name kernel-\* -type l 2>/dev/null); do
1985
if [ -z "$r_mod" ]; then
1986
mod=$(find_module_from_ko "$depth" "$ko")
1991
tree_ver=$(echo "$read_link" | awk -F / '{print $1}')
1992
tree_kern=$(echo "$read_link" | awk -F / '{print $2}')
1993
tree_arch=$(echo "$read_link" | awk -F / '{print $3}')
1994
if diff $dkms_tree/$mod/$tree_ver/$tree_kern/$tree_arch/module/$basename_ko \
1995
$installed_ko >/dev/null 2>&1; then
1996
if [ "$r_mod" == "$mod" -o -z "$r_mod" ] && \
1997
[ "$r_ver" == "$tree_ver" -o -z "$r_ver" ] && \
1998
[ "$r_kern" == "$installedkernver" -o -z "$r_kern" ] && \
1999
[ "$r_arch" == "$tree_arch" -o -z "$r_arch" ]; then
2000
add_string_to_array_unique "$mod, $tree_ver, $installedkernver, $tree_arch: installed-weak from $tree_kern"
1971
for ko in $(find "$installedkern/weak-updates" -type l 2>/dev/null); do
1972
installedkernver=$(basename $installedkern)
1973
basename_ko=$(basename $ko)
1975
installed_ko="$read_link"
1976
if [ ! -e "$installed_ko" ]; then
1977
# dangling symlink, ouch, but is somebody else's problem so ignore it
1980
# remember, installed_ko is probably a relative path, so $kernelversion isn't present in its link
1981
# is $installed_ko in /var/lib/dkms as installed? Find which module has it
1982
for f in $(find $dkms_tree/$r_mod -maxdepth $depth -mindepth $depth -name kernel-\* -type l 2>/dev/null); do
1983
if [ -z "$r_mod" ]; then
1984
mod=$(find_module_from_ko "$depth" "$ko")
1989
tree_ver=$(echo "$read_link" | awk -F / '{print $1}')
1990
tree_kern=$(echo "$read_link" | awk -F / '{print $2}')
1991
tree_arch=$(echo "$read_link" | awk -F / '{print $3}')
1992
if diff $dkms_tree/$mod/$tree_ver/$tree_kern/$tree_arch/module/$basename_ko \
1993
$installed_ko >/dev/null 2>&1; then
1994
if [ "$r_mod" == "$mod" -o -z "$r_mod" ] && \
1995
[ "$r_ver" == "$tree_ver" -o -z "$r_ver" ] && \
1996
[ "$r_kern" == "$installedkernver" -o -z "$r_kern" ] && \
1997
[ "$r_arch" == "$tree_arch" -o -z "$r_arch" ]; then
1998
add_string_to_array_unique "$mod, $tree_ver, $installedkernver, $tree_arch: installed-weak from $tree_kern"
2006
2004
print_string_array
2023
2021
[ $tree_depth -eq 4 ] && next="done" && working_dir="$dkms_tree/$mod/$ver/$kern/$arch"
2025
2023
if [ -n "${!next}" ] && [ "$next" != "done" ]; then
2026
do_status "$mod" "$ver" "$kern" "$arch" "$(($tree_depth + 1))"
2024
do_status "$mod" "$ver" "$kern" "$arch" "$(($tree_depth + 1))"
2027
2025
elif [ "$next" != "done" ]; then
2028
local keep_traversing="no"
2029
for directory in `find "$working_dir" -type d -maxdepth 1 -mindepth 1 2>/dev/null`; do
2030
local next_value=`echo $directory | sed "s#$working_dir/##"`
2031
if ! echo "build original_module tarball driver_disk rpm" | grep -q "$next_value\b"; then
2032
keep_traversing="yes"
2033
[ "$next" == "mod" ] && mod=$next_value
2034
[ "$next" == "ver" ] && ver=$next_value
2035
[ "$next" == "kern" ] && kern=$next_value
2036
[ "$next" == "arch" ] && arch=$next_value
2037
do_status "$mod" "$ver" "$kern" "$arch" "$(($tree_depth + 1))"
2026
local keep_traversing="no"
2027
for directory in `find "$working_dir" -type d -maxdepth 1 -mindepth 1 2>/dev/null`; do
2028
local next_value=`echo $directory | sed "s#$working_dir/##"`
2029
if ! echo "build original_module tarball driver_disk rpm" | grep -q "$next_value\b"; then
2030
keep_traversing="yes"
2031
[ "$next" == "mod" ] && mod=$next_value
2032
[ "$next" == "ver" ] && ver=$next_value
2033
[ "$next" == "kern" ] && kern=$next_value
2034
[ "$next" == "arch" ] && arch=$next_value
2035
do_status "$mod" "$ver" "$kern" "$arch" "$(($tree_depth + 1))"
2042
2040
if [ "$keep_traversing" == "no" ] && [ $tree_depth -eq 2 ] && [ -z "$arch" ] || [ "$next" == "done" ]; then
2043
local state="added" && stat_display="$mod, $ver:"
2044
[ -d "$working_dir/module" ] && state="built" && stat_display="$mod, $ver, $kern, $arch:"
2045
if [ -h "$dkms_tree/$mod/kernel-$kern-$arch" ]; then
2046
readlink "$dkms_tree/$mod/kernel-$kern-$arch"
2047
[ "$read_link" == "$ver/$kern/$arch" ] && state="installed"
2050
if [ "$state" == "built" ] || [ "$state" == "installed" ]; then
2051
set_module_suffix "$kern"
2052
local extra_status=""
2053
conf="$dkms_tree/$mod/$ver/source/dkms.conf"
2054
read_conf "$kern" "$arch" "$conf"
2055
[ -d "$dkms_tree/$mod/original_module/$kern/$arch" ] && extra_status="(original_module exists)"
2057
local real_dest_module_location
2058
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2059
tree_mod="$dkms_tree/$mod/$ver/$kern/$arch/module/${dest_module_name[$count]}$module_suffix"
2060
if ! [ -e "$tree_mod" ]; then
2061
extra_status="$extra_status (WARNING! Missing some built modules!)"
2062
elif [ "$state" == "installed" ]; then
2063
real_dest_module_location="$(find_actual_dest_module_location $mod $count $kern $arch)"
2064
if ! diff -q "$tree_mod" "$install_tree/$kern${real_dest_module_location}/${dest_module_name[$count]}$module_suffix" >/dev/null 2>&1; then
2065
extra_status="$extra_status (WARNING! Diff between built and installed module!)"
2072
[ -d "$working_dir" ] && echo "$stat_display $state $extra_status"
2041
local state="added" && stat_display="$mod, $ver:"
2042
[ -d "$working_dir/module" ] && state="built" && stat_display="$mod, $ver, $kern, $arch:"
2043
if [ -h "$dkms_tree/$mod/kernel-$kern-$arch" ]; then
2044
readlink "$dkms_tree/$mod/kernel-$kern-$arch"
2045
[ "$read_link" == "$ver/$kern/$arch" ] && state="installed"
2048
if [ "$state" == "built" ] || [ "$state" == "installed" ]; then
2049
set_module_suffix "$kern"
2050
local extra_status=""
2051
conf="$dkms_tree/$mod/$ver/source/dkms.conf"
2052
read_conf "$kern" "$arch" "$conf"
2053
[ -d "$dkms_tree/$mod/original_module/$kern/$arch" ] && extra_status="(original_module exists)"
2055
local real_dest_module_location
2056
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2057
tree_mod="$dkms_tree/$mod/$ver/$kern/$arch/module/${dest_module_name[$count]}$module_suffix"
2058
if ! [ -e "$tree_mod" ]; then
2059
extra_status="$extra_status (WARNING! Missing some built modules!)"
2060
elif [ "$state" == "installed" ]; then
2061
real_dest_module_location="$(find_actual_dest_module_location $mod $count $kern $arch)"
2062
if ! diff -q "$tree_mod" "$install_tree/$kern${real_dest_module_location}/${dest_module_name[$count]}$module_suffix" >/dev/null 2>&1; then
2063
extra_status="$extra_status (WARNING! Diff between built and installed module!)"
2070
[ -d "$working_dir" ] && echo "$stat_display $state $extra_status"
2147
2145
# Check that the right arguments were passed
2148
2146
if [ -z "$module" ] || [ -z "$module_version" ] || [ -z "$distro" ] || [ -z "${kernelver_array[0]}" ]; then
2150
echo $"Error! Invalid number of parameters passed." >&2
2151
echo $"Usage: mkdriverdisk -d <distro> -m <module> -v <module-version> -k <kernelver> [--media floppy|iso|tar]" >&2
2148
echo $"Error! Invalid number of parameters passed." >&2
2149
echo $"Usage: mkdriverdisk -d <distro> -m <module> -v <module-version> -k <kernelver> [--media floppy|iso|tar]" >&2
2155
2153
# default to floppy media
2156
2154
[ -z "$media" ] && media="floppy"
2158
2156
if [ $? -eq 1 ]; then
2160
echo "$Error! Media $media is invalid." >&2
2161
echo $"Usage: mkdriverdisk -d <distro> -m <module> -v <module-version> -k <kernelver> [--media floppy|iso|tar]" >&2
2158
echo "$Error! Media $media is invalid." >&2
2159
echo $"Usage: mkdriverdisk -d <distro> -m <module> -v <module-version> -k <kernelver> [--media floppy|iso|tar]" >&2
2165
2163
# Check that source symlink works
2166
2164
if ! [ -d "$dkms_tree/$module/$module_version/source" ]; then
2168
echo $"Error! DKMS tree does not contain: $module-$module_version" >&2
2169
echo $"Build cannot continue without the proper tree." >&2
2166
echo $"Error! DKMS tree does not contain: $module-$module_version" >&2
2167
echo $"Build cannot continue without the proper tree." >&2
2173
2171
# Confirm that distro is supported
2174
2172
case "$distro" in
2175
redhat | redhat[12] | suse | UnitedLinux | ubuntu)
2179
echo $"Error! Invalid distro argument. Currently, the distros" >&2
2180
echo $"supported are: redhat, redhat1, redhat2, suse, UnitedLinux" >&2
2173
redhat | redhat[12] | suse | UnitedLinux | ubuntu)
2177
echo $"Error! Invalid distro argument. Currently, the distros" >&2
2178
echo $"supported are: redhat, redhat1, redhat2, suse, UnitedLinux" >&2
2186
2184
# Read the conf file
2187
2185
read_conf "${kernelver_array[0]}" "${arch_array[0]}"
2188
2186
if [ "$?" -ne 0 ]; then
2190
echo $"Error! Bad conf file." >&2
2191
echo $"Your dkms.conf is not valid." >&2
2188
echo $"Error! Bad conf file." >&2
2189
echo $"Your dkms.conf is not valid." >&2
2195
2193
case "$distro" in
2197
make_redhat_driver_disk
2200
make_ubuntu_driver_disk
2203
make_suse_driver_disk
2195
make_redhat_driver_disk
2198
make_ubuntu_driver_disk
2201
make_suse_driver_disk
2291
2289
# kludge to allow redhat1 driver disks with BOOT kernel modules (arch i386)
2292
2290
if [ "$distro" == "redhat1" ] && [ "$multi_arch" == "true" ]; then
2294
local redhat1_okay="true"
2296
while [ $i -lt ${#kernelver_array[@]} ]; do
2297
if [ "${arch_array[$i]}" != "i386" ] && [ "$other_arch" != "${arch_array[$i]}" ] && [ -n "$other_arch" ]; then
2298
redhat1_okay="false"
2299
elif [ "${arch_array[$i]}" != "i386" ] && [ "$other_arch" != "${arch_array[$i]}" ] && [ -z "$other_arch" ]; then
2300
other_arch="${arch_array[$i]}"
2304
if [ "$redhat1_okay" == "false" ]; then
2306
echo $"Error! You have specified a Red Hat version 1 driver disk, but have also" >&2
2307
echo $"specified multiple architectures. Version 1 does not support this." >&2
2308
echo $"Use 'redhat2' instead (only OSes >= RHEL3, FC1 support version 2)." >&2
2292
local redhat1_okay="true"
2294
while [ $i -lt ${#kernelver_array[@]} ]; do
2295
if [ "${arch_array[$i]}" != "i386" ] && [ "$other_arch" != "${arch_array[$i]}" ] && [ -n "$other_arch" ]; then
2296
redhat1_okay="false"
2297
elif [ "${arch_array[$i]}" != "i386" ] && [ "$other_arch" != "${arch_array[$i]}" ] && [ -z "$other_arch" ]; then
2298
other_arch="${arch_array[$i]}"
2302
if [ "$redhat1_okay" == "false" ]; then
2304
echo $"Error! You have specified a Red Hat version 1 driver disk, but have also" >&2
2305
echo $"specified multiple architectures. Version 1 does not support this." >&2
2306
echo $"Use 'redhat2' instead (only OSes >= RHEL3, FC1 support version 2)." >&2
2313
2311
if [ "$distro" == "redhat2" ] || [ "$multi_arch" == "true" ] && [ -z "$redhat1_okay" ]; then
2314
echo $"Creating Red Hat v2 driver disk (arch support)."
2316
local rhdd_filename="rhdd"
2312
echo $"Creating Red Hat v2 driver disk (arch support)."
2314
local rhdd_filename="rhdd"
2318
echo $"Creating Red Hat v1 driver disk."
2320
local rhdd_filename="rhdd-6.1"
2316
echo $"Creating Red Hat v1 driver disk."
2318
local rhdd_filename="rhdd-6.1"
2323
2321
cpioarchive_dir_name=`mktemp -d $tmp_location/dkms.XXXXXX`
2324
2322
if [ -z "$cpioarchive_dir_name" ]; then
2326
echo $"Error: Could not create a temporary directory, failing."
2324
echo $"Error: Could not create a temporary directory, failing."
2331
2329
while [ $i -lt ${#kernelver_array[@]} ]; do
2332
set_module_suffix "${kernelver_array[$i]}"
2335
local dd_prefix="${kernelver_array[$i]}"
2336
[ "$distro" == "redhat2" ] && dd_prefix="${kernelver_array[$i]}/${arch_array[$i]}"
2337
[ "$multi_arch" == "true" ] && [ -z "$redhat1_okay" ] && dd_prefix="${kernelver_array[$i]}/${arch_array[$i]}"
2339
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2340
if ! [ -e "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix" ]; then
2342
echo $"Error! Cannot find module ${dest_module_name[$count]}$module_suffix for kernel ${kernelver_array[$i]} (${arch_array[$i]})." >&2
2343
echo $"Module/version must be in built state before making a driver disk." >&2
2344
rm -rf $cpioarchive_dir_name
2347
# FIXME: add check for KMP binary RPMs to include in the driver disk
2348
if [ -z "$kernel_version_list" ]; then
2349
kernel_version_list="kernel${kernelver_array[$i]}-${arch_array[$i]}"
2351
kernel_version_list="$kernel_version_list-kernel${kernelver_array[$i]}-${arch_array[$i]}"
2353
mkdir -p $cpioarchive_dir_name/$dd_prefix
2354
echo "Marking ${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix..."
2355
cp "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix" "$cpioarchive_dir_name/$dd_prefix/"
2357
modules_cgz_list="$dd_prefix/${dest_module_name[$count]}$module_suffix\n${modules_cgz_list}"
2330
set_module_suffix "${kernelver_array[$i]}"
2333
local dd_prefix="${kernelver_array[$i]}"
2334
[ "$distro" == "redhat2" ] && dd_prefix="${kernelver_array[$i]}/${arch_array[$i]}"
2335
[ "$multi_arch" == "true" ] && [ -z "$redhat1_okay" ] && dd_prefix="${kernelver_array[$i]}/${arch_array[$i]}"
2337
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2338
if ! [ -e "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix" ]; then
2340
echo $"Error! Cannot find module ${dest_module_name[$count]}$module_suffix for kernel ${kernelver_array[$i]} (${arch_array[$i]})." >&2
2341
echo $"Module/version must be in built state before making a driver disk." >&2
2342
rm -rf $cpioarchive_dir_name
2345
# FIXME: add check for KMP binary RPMs to include in the driver disk
2346
if [ -z "$kernel_version_list" ]; then
2347
kernel_version_list="kernel${kernelver_array[$i]}-${arch_array[$i]}"
2349
kernel_version_list="$kernel_version_list-kernel${kernelver_array[$i]}-${arch_array[$i]}"
2351
mkdir -p $cpioarchive_dir_name/$dd_prefix
2352
echo "Marking ${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix..."
2353
cp "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix" "$cpioarchive_dir_name/$dd_prefix/"
2355
modules_cgz_list="$dd_prefix/${dest_module_name[$count]}$module_suffix\n${modules_cgz_list}"
2364
2362
# Create directory and necessary files
2365
2363
driver_disk_dir=`mktemp -d $tmp_location/dkms.XXXXXX`
2366
2364
if [ -z "$driver_disk_dir" ]; then
2368
echo $"Error: Could not create a temporary directory, failing."
2366
echo $"Error: Could not create a temporary directory, failing."
2372
2370
# Copy files for the driver disk (or warn if not present)
2436
2434
find_external_dependencies()
2442
# find all module dependencies
2443
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2445
while [ "$i" -lt "${#kernelver_array[@]}" ]; do
2446
set_module_suffix "${kernelver_array[$i]}"
2447
mod="$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix"
2448
deps=(${deps[@]} $(modinfo "$mod" | sed -n 's/,/ /; s/^depends: *//p'))
2454
# prune internally satisfied dependencies
2456
while [ "$i" -lt "${#deps[@]}" ]; do
2457
for mod in ${dest_module_name[@]}; do
2458
[ "${deps[i]}" == "$mod" ] && deps[i]=
2464
while [ "$i" -lt "${#deps[@]}" ]; do
2440
# find all module dependencies
2441
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2443
while [ "$i" -lt "${#kernelver_array[@]}" ]; do
2444
set_module_suffix "${kernelver_array[$i]}"
2445
mod="$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix"
2446
deps=(${deps[@]} $(modinfo "$mod" | sed -n 's/,/ /; s/^depends: *//p'))
2452
# prune internally satisfied dependencies
2454
while [ "$i" -lt "${#deps[@]}" ]; do
2455
for mod in ${dest_module_name[@]}; do
2456
[ "${deps[i]}" == "$mod" ] && deps[i]=
2462
while [ "$i" -lt "${#deps[@]}" ]; do
2470
2468
make_suse_driver_disk()
2472
if [ -z "$release" ]; then
2474
echo $"Error! Invalid number of parameters passed for suse/UnitedLinux driver disk." >&2
2475
echo $"Usage: mkdriverdisk -d <distro> -m <module> -v <module-version> -k <kernelver>" >&2
2476
echo $" -r <release-number>" >&2
2480
local driver_disk_dir=`mktemp -d $tmp_location/dkms.XXXXXX`
2481
if [ -z "$driver_disk_dir" ]; then
2483
echo $"Error: Could not create a temporary directory, failing."
2486
local suffix="$(driver_disk_suffix)"
2487
local image_dir="$dkms_tree/$module/$module_version/driver_disk"
2488
local image_name="$module-$module_version-$distro-$release-dd.$suffix"
2491
echo $"Creating driver disk:"
2493
local deps="$(find_external_dependencies)"
2496
if [ -n "${deps[*]}" ]; then
2497
# reserve a place for dependencies
2502
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2505
local topdir=`printf "%02d" $(($count+1+offset))`
2506
while [ "$i" -lt "${#kernelver_array[@]}" ]; do
2507
set_module_suffix "${kernelver_array[$i]}"
2509
if ! [ -e "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix" ]; then
2511
echo $"Error! Cannot find module ${dest_module_name[$count]}$module_suffix for kernel ${kernelver_array[$i]} (${arch_array[$i]})." >&2
2512
echo $"Module/version must be in built state before making a driver disk." >&2
2513
rm -rf $temp_dir_name
2470
if [ -z "$release" ]; then
2472
echo $"Error! Invalid number of parameters passed for suse/UnitedLinux driver disk." >&2
2473
echo $"Usage: mkdriverdisk -d <distro> -m <module> -v <module-version> -k <kernelver>" >&2
2474
echo $" -r <release-number>" >&2
2478
local driver_disk_dir=`mktemp -d $tmp_location/dkms.XXXXXX`
2479
if [ -z "$driver_disk_dir" ]; then
2481
echo $"Error: Could not create a temporary directory, failing."
2484
local suffix="$(driver_disk_suffix)"
2485
local image_dir="$dkms_tree/$module/$module_version/driver_disk"
2486
local image_name="$module-$module_version-$distro-$release-dd.$suffix"
2489
echo $"Creating driver disk:"
2491
local deps="$(find_external_dependencies)"
2494
if [ -n "${deps[*]}" ]; then
2495
# reserve a place for dependencies
2500
while [ "$count" -lt "${#dest_module_name[@]}" ]; do
2503
local topdir=`printf "%02d" $(($count+1+offset))`
2504
while [ "$i" -lt "${#kernelver_array[@]}" ]; do
2505
set_module_suffix "${kernelver_array[$i]}"
2507
if ! [ -e "$dkms_tree/$module/$module_version/${kernelver_array[$i]}/${arch_array[$i]}/module/${dest_module_name[$count]}$module_suffix" ]; then
2509
echo $"Error! Cannot find module ${dest_module_name[$count]}$module_suffix for kernel ${kernelver_array[$i]} (${arch_array[$i]})." >&2
2510
echo $"Module/version must be in built state before making a driver disk." >&2
2511
rm -rf $temp_dir_name