rebuild_dkms_packages.sh script fails

Report Bugs, Issues and non- package Requests
Message
Author
User avatar
dolphin_oracle
Developer
Posts: 22657
Joined: Sun Dec 16, 2007 12:17 pm

Re: rebuild_dkms_packages.sh script fails

#21 Post by dolphin_oracle »

tony37 wrote: Mon Nov 09, 2020 2:49 pm "dpkg-query --status" also gives output for packages with remaining configuration files:

Code: Select all

Status: deinstall ok config-files
do kernels have left over conf files (that's a real question)?
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

tony37
Posts: 1306
Joined: Sat Jul 18, 2020 12:34 pm

Re: rebuild_dkms_packages.sh script fails

#22 Post by tony37 »

Of course, I have linux-image-4.19.0-11-amd64 there
(easy command to search for such packages: aptitude search '~c')

User avatar
dolphin_oracle
Developer
Posts: 22657
Joined: Sun Dec 16, 2007 12:17 pm

Re: rebuild_dkms_packages.sh script fails

#23 Post by dolphin_oracle »

ok, then we will go full on fool-proof

Code: Select all

#!/bin/bash

#force rebuild of dkms packages (virtualbox, nvidia, fglrx, broadcom, ndiswrapper)
#part of mx-packageinstaller

kernel="$1"

# if parameter passed, then check to see if package is installed, exit if not
if [ -n "$kernel" ]; then
	[[ ! $(LANG=C dpkg-query --status $1 |grep "install ok installed"  ) ]] || exit 0
fi	

#if no kernel parameter given, assume current kernel
if [ -z "$kernel" ]; then
	kernel="$(uname -r)"
fi

kernel=${kernel#"linux-image-"}
kernel=${kernel%-unsigned}

echo "update dkms modules for kernel: " $kernel |tee /var/log/rebuild-dkms.log
echo "see log at /var/log/rebuild-dkms.log"

/usr/lib/dkms/dkms_autoinstaller start $kernel |tee -a /var/log/rebuild-dkms.log

exit 0
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

tony37
Posts: 1306
Joined: Sat Jul 18, 2020 12:34 pm

Re: rebuild_dkms_packages.sh script fails

#24 Post by tony37 »

Maybe still a mistake, I think it exits if the package is installed and not the reverse

If you leave out the ! it works better:

Code: Select all

[[ $(LANG=C dpkg-query --status $1 |grep "install ok installed"  ) ]] || exit 0
But with a package not installed and also with no config files remaining, I get this message:

Code: Select all

dpkg-query: package 'linux-image-4.19.0-10-amd64' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.
edit: The right solution is of course combining the two conditions:

Code: Select all

#!/bin/bash

#force rebuild of dkms packages (virtualbox, nvidia, fglrx, broadcom, ndiswrapper)
#part of mx-packageinstaller

kernel="$1"

# if parameter passed, then check to see if package is installed, exit if not
if [ -n "$kernel" ]; then
	[[ $(dpkg-query --status $1 2>/dev/null ) ]] || exit 0
	[[ $(LANG=C dpkg-query --status $1 |grep "install ok installed"  ) ]] || exit 0
fi	

#if no kernel parameter given, assume current kernel
if [ -z "$kernel" ]; then
	kernel="$(uname -r)"
fi

kernel=${kernel#"linux-image-"}
kernel=${kernel%-unsigned}

echo "update dkms modules for kernel: " $kernel |tee /var/log/rebuild-dkms.log
echo "see log at /var/log/rebuild-dkms.log"

/usr/lib/dkms/dkms_autoinstaller start $kernel |tee -a /var/log/rebuild-dkms.log

exit 0
Last edited by tony37 on Mon Nov 09, 2020 4:02 pm, edited 1 time in total.

tony37
Posts: 1306
Joined: Sat Jul 18, 2020 12:34 pm

Re: rebuild_dkms_packages.sh script fails

#25 Post by tony37 »

in case you can still use this, an easy way to find the dependency of the installed linux-image-amd64 package:

Code: Select all

dpkg-query -W -f='${Depends}\n' linux-image-amd64

User avatar
dolphin_oracle
Developer
Posts: 22657
Joined: Sun Dec 16, 2007 12:17 pm

Re: rebuild_dkms_packages.sh script fails

#26 Post by dolphin_oracle »

tony37 wrote: Mon Nov 09, 2020 3:41 pm in case you can still use this, an easy way to find the dependency of the installed linux-image-amd64 package:

Code: Select all

dpkg-query -W -f='${Depends}\n' linux-image-amd64
I used similar in the kernel pm files.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

User avatar
dolphin_oracle
Developer
Posts: 22657
Joined: Sun Dec 16, 2007 12:17 pm

Re: rebuild_dkms_packages.sh script fails

#27 Post by dolphin_oracle »

I don't want it it exit if the package is installed. I want it to exit if the package is NOT installed, so that nothing happens if the build fails.

I'll make sure to test it when I'm back at my linux box.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

tony37
Posts: 1306
Joined: Sat Jul 18, 2020 12:34 pm

Re: rebuild_dkms_packages.sh script fails

#28 Post by tony37 »

this works to check if the package is installed or not:

Code: Select all

if [ -n "$kernel" ]; then
    [[ $(grep -A1 $1 /var/lib/dpkg/status | grep 'install ok installed'  ) ]] || exit 0
fi	

User avatar
dolphin_oracle
Developer
Posts: 22657
Joined: Sun Dec 16, 2007 12:17 pm

Re: rebuild_dkms_packages.sh script fails

#29 Post by dolphin_oracle »

used your test, and got rid of hte !

Code: Select all

#!/bin/bash

#force rebuild of dkms packages (virtualbox, nvidia, fglrx, broadcom, ndiswrapper)
#part of mx-packageinstaller

kernel="$1"

# if parameter passed, then check to see if package is installed, exit if not
if [ -n "$kernel" ]; then
    [[ -n $(grep -A1 $kernel /var/lib/dpkg/status | grep 'install ok installed'  ) ]] || exit 0
fi	

#if no kernel parameter given, assume current kernel
if [ -z "$kernel" ]; then
	kernel="$(uname -r)"
fi

kernel=${kernel#"linux-image-"}
kernel=${kernel%-unsigned}

echo "update dkms modules for kernel: " $kernel |tee /var/log/rebuild-dkms.log
echo "see log at /var/log/rebuild-dkms.log"

#/usr/lib/dkms/dkms_autoinstaller start $kernel |tee -a /var/log/rebuild-dkms.log

exit 0
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Live system help document: https://mxlinux.org/wiki/help-antix-live-usb-system/

tony37
Posts: 1306
Joined: Sat Jul 18, 2020 12:34 pm

Re: rebuild_dkms_packages.sh script fails

#30 Post by tony37 »

I'm sorry to say, but you have

Code: Select all

file=$(apt-cache show linux-image-amd64=4.19 |grep -m1 Depends)
in kernel_debian_64.pm (and similar in kernel_debian_32.pm) and it should have been

Code: Select all

file=$(apt-cache show linux-image-amd64=4.19* |grep -m1 Depends)
:lipsrsealed:

edit: the deb file also has a folder /share/mx-packageinstaller-pkglist (without /usr)...

Post Reply

Return to “Bugs and Non-Package Requests Forum”