LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-09-2023, 06:10 PM   #1
bobIsHere244
Member
 
Registered: Dec 2018
Posts: 37

Rep: Reputation: Disabled
I broke my package system on linux mint 20


I was building a script to automate something with apt, and to put it shortly, I ended up interrupting the script, which stopped apt mid-way through an operation.

The package system is now broken due to a single broke package, so now every time I try to run any command with apt or dpkg, it tries to fix it or something, resulting in a massive trainwreck of errors every time i try to use the package system.

The package was bluez, but I don't think it matters exactly which one.

I've tried a whole bunch of ways to remove or reinstall the damaged package.
Code:
sudo dpkg --remove --force-remove-reinstreq bluez
sudo apt-get -f install
sudo apt-get update
sudo apt-get autoremove
sudo dpkg --configure -a
sudo apt-get clean
sudo apt purge bluez
sudo apt remove bluez
tried to fix it from apt
tried to fix it from apt-get
tried to fix it from dpkg
tried to fix it from synaptic
a whole bunch more...
Nothing worked.

Here's the errors:
Code:
user@User-Box:~$ sudo dpkg --remove bluez
[sudo] password for user:
(Reading database ... 331226 files and directories currently installed.)
Removing bluez (5.53-0ubuntu3.6) ...
/usr/sbin/invoke-rc.d: 1: /sbin/runlevel: Exec format error
/usr/sbin/invoke-rc.d: 290: systemctl: Exec format error
invoke-rc.d: could not determine current runlevel
/usr/sbin/invoke-rc.d: 491: systemctl: Exec format error
/usr/sbin/invoke-rc.d: 512: systemctl: Exec format error
/usr/sbin/invoke-rc.d: 521: systemctl: Exec format error
invoke-rc.d: initscript bluetooth, action "stop" failed.
dpkg: error processing package bluez (--remove):
 installed bluez package pre-removal script subprocess returned error exit status 1
/usr/bin/systemctl: 3: Syntax error: EOF in backquote substitution
/usr/sbin/invoke-rc.d: 1: /sbin/runlevel: Exec format error
/usr/sbin/invoke-rc.d: 290: systemctl: Exec format error
invoke-rc.d: could not determine current runlevel
/usr/sbin/invoke-rc.d: 491: systemctl: Exec format error
/usr/sbin/invoke-rc.d: 512: systemctl: Exec format error
/usr/sbin/invoke-rc.d: 518: systemctl: Exec format error
invoke-rc.d: initscript bluetooth, action "start" failed.
/usr/sbin/invoke-rc.d: 563: systemctl: Exec format error
dpkg: error while cleaning up:
 installed bluez package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 bluez
Which as far as I can tell, happens exactly the same way every time I try to do anything with any package manager, it doesn't stop me from editing other packages, but it does slow everything down because while trying to do something else, it tries to fix bluez every time as well.
 
Old 02-09-2023, 07:56 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,330
Blog Entries: 28

Rep: Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144
Please provide more detail.

When you say that you "tried to fix if from Synaptic" and the other package management tools, what exactly did you do?
 
Old 02-09-2023, 09:59 PM   #3
bobIsHere244
Member
 
Registered: Dec 2018
Posts: 37

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by frankbell View Post
Please provide more detail.

When you say that you "tried to fix if from Synaptic" and the other package management tools, what exactly did you do?
that is irrelevant at this point, i simply want to know what the error messages mean and how to fix them, also how to finally remove this broken package.
 
Old 02-10-2023, 03:33 AM   #4
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,813
Blog Entries: 1

Rep: Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068
/usr/sbin/invoke-rc.d is a script. The numbers look like line numbers in the script where calls are causing the exec format errors from trying to read missing or corrupt file(s). This could be caused by the incomplete installation of bluez and its relationship with other packages with startup scripts in /etc/init.d/. I would look for a bluez and/or bluetooth or other files there with (a) timestamp(s) of when the problem began instead of timestamps of files in the .debs they came from, which would indicate incomplete or corrupt file. I would have expected dpkg -r bluez (aka --remove) or apt-get remove -f bluez to have removed bluez.
 
Old 02-10-2023, 07:37 AM   #5
bobIsHere244
Member
 
Registered: Dec 2018
Posts: 37

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mrmazda View Post
/usr/sbin/invoke-rc.d is a script. The numbers look like line numbers in the script where calls are causing the exec format errors from trying to read missing or corrupt file(s). This could be caused by the incomplete installation of bluez and its relationship with other packages with startup scripts in /etc/init.d/. I would look for a bluez and/or bluetooth or other files there with (a) timestamp(s) of when the problem began instead of timestamps of files in the .debs they came from, which would indicate incomplete or corrupt file. I would have expected dpkg -r bluez (aka --remove) or apt-get remove -f bluez to have removed bluez.
No luck!
This happened in 2023, as you can see, the dates end at 2021.
Attached Thumbnails
Click image for larger version

Name:	inspected folder.png
Views:	12
Size:	50.0 KB
ID:	40447  
 
Old 02-10-2023, 07:58 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,879

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
Quote:
Originally Posted by bobIsHere244 View Post
that is irrelevant at this point, i simply want to know what the error messages mean and how to fix them, also how to finally remove this broken package.
I don't think so. If you give us more details we can better help you to solve this issue. But anyway:
exec format error means you wanted to execute a file but the format of the file is invalid, incorrect, corrupted or just incompatible with the current environment. Probably this helps: https://ostechnix.com/fix-exec-forma...parts-command/
 
Old 02-10-2023, 11:51 AM   #7
bobIsHere244
Member
 
Registered: Dec 2018
Posts: 37

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I don't think so. If you give us more details we can better help you to solve this issue. But anyway:
exec format error means you wanted to execute a file but the format of the file is invalid, incorrect, corrupted or just incompatible with the current environment. Probably this helps: https://ostechnix.com/fix-exec-forma...parts-command/
The details are just trying commands to remove the package, and fix apt by cleaning or something, pretty much everything I wrote already.

Synaptic says bluez is installed, but trying to remove it from various package managers command line and gui-based, all results in it not being apparently removed.

Is there a way i can remove bluez manually or force an overwriting reinstallation of some kind?

Last edited by bobIsHere244; 02-10-2023 at 11:58 AM.
 
Old 02-14-2023, 10:35 AM   #8
bobIsHere244
Member
 
Registered: Dec 2018
Posts: 37

Original Poster
Rep: Reputation: Disabled
update: i managed to remove the broken package, and when i restarted my system a bunch of other things are now broken, yay, and now the problem spread to another package, and now dpkg is completely crippled and does not even work anymore.

Code:
user@User-Box:~/Desktop$ sudo dpkg --configure -a
[sudo] password for user:
Setting up initramfs-tools (0.136ubuntu6.7) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.7) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-91-generic
/usr/sbin/mkinitramfs: 75: modprobe: Exec format error
/usr/sbin/mkinitramfs: 76: modprobe: Exec format error
/usr/sbin/mkinitramfs: 75: modprobe: Exec format error
/usr/sbin/mkinitramfs: 76: modprobe: Exec format error
^Cdpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess was interrupted
Errors were encountered while processing:
 initramfs-tools
is there a rebuild-everything-and-replace-corrupted-files command?

Last edited by bobIsHere244; 02-14-2023 at 10:39 AM.
 
Old 02-14-2023, 11:20 AM   #9
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,879

Rep: Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317Reputation: 7317
Quote:
Originally Posted by bobIsHere244 View Post
update: i managed to remove the broken package, and when i restarted my system a bunch of other things are now broken, yay, and now the problem spread to another package, and now dpkg is completely crippled and does not even work anymore.

Code:
user@User-Box:~/Desktop$ sudo dpkg --configure -a
[sudo] password for user:
Setting up initramfs-tools (0.136ubuntu6.7) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.7) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-91-generic
/usr/sbin/mkinitramfs: 75: modprobe: Exec format error
/usr/sbin/mkinitramfs: 76: modprobe: Exec format error
/usr/sbin/mkinitramfs: 75: modprobe: Exec format error
/usr/sbin/mkinitramfs: 76: modprobe: Exec format error
^Cdpkg: error processing package initramfs-tools (--configure):
 installed initramfs-tools package post-installation script subprocess was interrupted
Errors were encountered while processing:
 initramfs-tools
is there a rebuild-everything-and-replace-corrupted-files command?
Yes, it is: rebuild-everything-and-replace-corrupted-files-especially-for-you
The easy way is to reinstall the system, but I'm afraid you will corrupt your system just the same way. So would be better to tell us how did you manage to reach this situation.
Probably you installed some incompatible packages. Or ?
Exec format error means your system tried to execute some binaries, but failed because the format of the executable is incompatible (with the current system).
Yes, you can restore the original files, if you know what did you make, what do you need to restore and you have a backup. (this is not a problem with the package manager itself, but you have some useless/corrupted executable files somewhere which are used by modprobe, systemctl and probably other tools too). And probably you destroyed some other files, not only binaries (but config files).
 
Old 02-14-2023, 12:13 PM   #10
bobIsHere244
Member
 
Registered: Dec 2018
Posts: 37

Original Poster
Rep: Reputation: Disabled
https://www.linuxquestions.org/quest...94#post6411294
is more of the story, which was initially a separate problem, as i thought i was done with the package system being broken, and that the device issues were just a remaining side effect of the battle i had with apt, and that they could be fixed separately and it would all be over.

but then that wasnt fixed so easily, and it became clear the 2 problems were actually just the same one getting worse.

this all happened because i interrupted a python script designed to take a list of packages and install them, because i just went from linux mint 18, to linux mint 20, i had to install new because i wanted to move my os to an ssd instead of hdd.

i saved the list of packages to be installed by the script, so that i can get back up to speed on the new os.

the script got interrupted, not sure why i did that, but it interrupted a "sudo apt install ___" somewhere in the middle of some operation, and then the package bluez got corrupted.

every time i used apt after that, every operation was slowed down by apt trying to fix bluez at the same time.

i tried to remove bluez by force in various ways, and removed and probably purged some other packages that used it, to try and free it from being depended on, these other packages appeared to be other bluetooth systems, i dont even have bluetooth on this machine so i didnt need them anyway.

eventually i found https://unix.stackexchange.com/quest...-with-apt-dpkg and chose to use
Quote:
Edit /var/lib/dpkg/info/srvadmin-hapi.prerm, and insert set -x as the second line (i.e. immediately after the #! line). Editing this script will need to be done as root.
and opted for
Quote:
just insert exit 0 as the second line of the .prerm script.
and it appeared to allow apt to continue past the screwed up point, and it did infact remove the package or atleast appeared to do so.

then i restarted the computer and now theres no sound, mouse and keyboard dont work unless i plug them out and back in, so device management is damaged too, its possible something else was unintentionally removed or damaged, and so now its quite unfixed.

at this point i concluded that something was uninstalled, and i found a list of default packages for linux mint 20, and set the script to install those, so i could undo the damage. it did get stuck on bluez again, so i stopped it, fixed that AGAIN, and continued, then apt got stuck on a diff package, and when i tried to deal with this, i ended up having dpkg get completely stuck on a loop every time i try to use it.

so i think it doesnt help that i dont even know what got damaged or corrupted when apt was interrupted in the first place, and also that even after searching i cant find any kind of debug or verbose mode so dpkg or apt really tells me what its doing in a useful way.

i just wanted to reinstall my old packages, go ahead and laugh at me lmfao.

Last edited by bobIsHere244; 02-14-2023 at 01:28 PM.
 
Old 02-18-2023, 04:28 PM   #11
bobIsHere244
Member
 
Registered: Dec 2018
Posts: 37

Original Poster
Rep: Reputation: Disabled
reinstall operating system
 
Old 02-18-2023, 05:25 PM   #12
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,813
Blog Entries: 1

Rep: Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068Reputation: 2068
Quote:
Originally Posted by bobIsHere244 View Post
reinstall operating system
Cryptic. Question? Report? Something else?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] No package 'x11' found No package 'xext' found No package 'xdamage' found No package 'xfixes' found No package 'x11-xcb' found Jigsaw Linux From Scratch 14 02-23-2021 08:35 PM
Is it my system or computer / HDD broke? What can I do about this? (Linux Mint) CapableFactor Linux - Newbie 5 05-19-2019 09:51 AM
I broke my package manager / broken package blocks installs [Debian Wheezy] arthoc Linux - Software 4 06-20-2014 03:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration