Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deb-package breaks apt/dpkg on dash-shell Linux OS #1227

Open
ChaosNicro opened this issue Dec 28, 2024 · 5 comments
Open

deb-package breaks apt/dpkg on dash-shell Linux OS #1227

ChaosNicro opened this issue Dec 28, 2024 · 5 comments
Assignees
Labels
bug Something isn't working state: Awaiting Reply

Comments

@ChaosNicro
Copy link

What Operating System

Linux (Other)

Debug Code

https://pste.ch/abaligujen

Describe the bug

Installed from ftb-app-1.26.5-amd64.deb.
After installation the app runs, but apt/dpkg will set it as half-installed and continually error when installing or removing packages from that point on.
"dpkg (subprocess): unable to execute installed ftb-app package post-removal script (/var/lib/dpkg/info/ftb-app.postrm): No such file or directory
dpkg: error processing package ftb-app (--remove):
installed ftb-app package post-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
ftb-app
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
"
The package can not be removed or automatically fixed.

The cause of this, is that the postrm-script contains Windows-style line-endings, that mangle the bash commands for removing the app from /usr/bin.
In bash-proper this is ignored, in alternatives like dash, this breaks the script.
I understand that this affects a negligible amount of users, but it may be an easy fix.
The other scripts seem to use Unix line-endings, so I wonder why the postrm-script differs.

Could you please review the build-process and ensure that scripts are formatted for Unix.

Steps to reproduce

  1. Use a dash-shell Linux OS (Tuxedo OS in my case).
  2. Install the app.
  3. Observe that "apt install" now lists the ftb-app as "to be installed".
  4. Attempt to remove the ftb-app.
  5. Observe the error described above.

Expected behaviour

The app can be installed and removed at will, without corrupting the dpkg-state.

Screenshots

No response

Additional information

No response

@ChaosNicro ChaosNicro added the bug Something isn't working label Dec 28, 2024
@MichaelHillcox MichaelHillcox self-assigned this Dec 28, 2024
@nZpUhsX
Copy link

nZpUhsX commented Feb 3, 2025

this doesn't appear to be limited to just dash. i just ran into the same issue with version 1.27.2 on linux mint 21.3 with bash. all i did was install the .deb file, run the program to make sure it worked then tried to purge it.

mint21vm@mint21vm:~$ bash /var/lib/dpkg/info/ftb-app.postrm 
/var/lib/dpkg/info/ftb-app.postrm: line 2: $'\r': command not found
/var/lib/dpkg/info/ftb-app.postrm: line 9: syntax error: unexpected end of file
mint21vm@mint21vm:~$ apt list ftb-app
Listing... Done
ftb-app/now 1.27.2 amd64 [installed,local]
mint21vm@mint21vm:~$ sudo apt purge ftb-app
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
  ftb-app*
0 upgraded, 0 newly installed, 1 to remove and 6 not upgraded.
After this operation, 299 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 674476 files and directories currently installed.)
Removing ftb-app (1.27.2) ...
dpkg (subprocess): unable to execute installed ftb-app package post-removal script (/var/lib/dpkg/info/ftb-app.postrm): No such file or directo
ry
dpkg: error processing package ftb-app (--remove):
 installed ftb-app package post-removal script subprocess returned error exit status 2
dpkg: too many errors, stopping
Errors were encountered while processing:
 ftb-app
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
mint21vm@mint21vm:~$ ls -l /var/lib/dpkg/info/ftb-app.postrm
-rwxr-xr-x 1 root root 202 Feb  1 12:16 /var/lib/dpkg/info/ftb-app.postrm
mint21vm@mint21vm:~$ file /var/lib/dpkg/info/ftb-app.postrm 
/var/lib/dpkg/info/ftb-app.postrm: Bourne-Again shell script, ASCII text executable, with CRLF line terminators

the reason i tested it: https://forums.linuxmint.com/viewtopic.php?t=439536

@rikkathehare
Copy link

Hi there! I'm the person who created the forum topic that user nZpUhsX linked. I'm just gonna copy the solution here just in case someone else sees this bug ticket before the issue is resolved.

I revised ftb-app.postrm located in /var/lib/dpkg/info by changing the line ending option to "Unix/Linux" using the following command:

xed admin:///var/lib/dpkg/info/ftb-app.postrm

After that apt still didn't want to remove the package, but dpkg with the force argument was successful:

my_irl_name:/$ xed admin:///var/lib/dpkg/info/ftb-app.postrm
my_irl_name:/$ sudo apt remove ftb-app
[sudo] password for my_irl_name:          
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: The package ftb-app needs to be reinstalled, but I can't find an archive for it.
my_irl_name:/$ sudo dpkg --remove --force-remove-reinstreq ftb-app
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: package is in a very bad inconsistent state; you should
 reinstall it before attempting a removal
(Reading database ... 606037 files and directories currently installed.)
Removing ftb-app (1.26.5) ...
update-alternatives: warning: alternative /opt/FTB Electron App/ftb-app (part of link group ftb-app) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/ftb-app is dangling; it will be updated with best choice

After that, I cleaned up the config files with:

sudo apt purge ftb-app

And the package is totally gone! Using the following command returns 0 hits:

apt list | grep ftb-app

@MichaelHillcox
Copy link
Member

Hey all! Thanks for bringing this to our attention, we've done some digging, and we think we've found the issue with one of our deps for publishing. We've updated internally and are running some tests. We should have a new version up for tomorrow 👍

@der-eismann
Copy link
Contributor

Might be a bit late if a solution was already found, just wanted to note that the same issue is present with the rpm package:

Running transaction
[1/2] Prepare transaction                                                                                                                                                                             100% |   3.0   B/s |   1.0   B |  00m00s
[2/2] Removing ftb-app-0:1.27.2-1.x86_64                                                                                                                                                              100% | 129.0   B/s | 104.0   B |  00m01s
>>> Running post-uninstall scriptlet: ftb-app-0:1.27.2-1.x86_64
>>> Non-critical error in post-uninstall scriptlet: ftb-app-0:1.27.2-1.x86_64
>>> Scriptlet output:
>>> /var/tmp/rpm-tmp.k9xYLH: line 2: $'\r': command not found
>>> /var/tmp/rpm-tmp.k9xYLH: line 8: syntax error near unexpected token `fi'
>>> /var/tmp/rpm-tmp.k9xYLH: line 8: `fi'
>>> 
>>> [RPM] %postun(ftb-app-1.27.2-1.x86_64) scriptlet failed, exit status 2
Complete!

Luckily this error doesn't break the update/uninstall process. Still looking forward to the fix 🙂

@logwyrm
Copy link

logwyrm commented Feb 16, 2025

Thanks a lot to people investigating this so far. I also ran into this issue. The xed command did not work for me for some reason and I didn't quite understand the issue at first, so here is a quick explanation for anyone who is as confused by this at first as I was:

The issue is that the line endings inside the script named "ftb-app.postrm" are Windows-style line endings, but should instead be Linux-style line endings. The following sed command exchanges the Windows line endings for Linux line endings, which resolved the issue for me and allowed me to uninstall the package - you need to be root for this:

sed -i.bak 's/\r$//' /var/lib/dpkg/info/ftb-app.postrm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working state: Awaiting Reply
Projects
None yet
Development

No branches or pull requests

6 participants