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

rpm %postun scriptlet fails #958

Closed
utoddl opened this issue Sep 20, 2023 · 11 comments
Closed

rpm %postun scriptlet fails #958

utoddl opened this issue Sep 20, 2023 · 11 comments
Labels
blocked This issue depends on external projects bug Something isn't working hacktoberfest Community support is welcome

Comments

@utoddl
Copy link

utoddl commented Sep 20, 2023

Describe the bug
Upgrading or re-installing the rpm produces the following messages:

Running transaction
  Preparing        :                                                                       1/1 
  Reinstalling     : teams-for-linux-1.3.11-1.x86_64                                       1/2 
  Running scriptlet: teams-for-linux-1.3.11-1.x86_64                                       1/2 
update-alternatives is /sbin/update-alternatives

  Cleanup          : teams-for-linux-1.3.11-1.x86_64                                       2/2 
  Running scriptlet: teams-for-linux-1.3.11-1.x86_64                                       2/2 
/usr/bin/teams-for-linux has not been configured as an alternative for teams-for-linux
warning: %postun(teams-for-linux-1.3.11-1.x86_64) scriptlet failed, exit status 2

Error in POSTUN scriptlet in rpm package teams-for-linux
  Verifying        : teams-for-linux-1.3.11-1.x86_64                                       1/2 
  Verifying        : teams-for-linux-1.3.11-1.x86_64                                       2/2 

Reinstalled:
  teams-for-linux-1.3.11-1.x86_64

To Reproduce
Steps to reproduce the behavior:

  1. update or re-install teams-for-linux via rpm

Expected behavior
It's expected that routine rpm updates would not produce errors

Desktop (please complete the following information):

  • OS: Fedora release 38 (Thirty Eight)
  • Installation package: rpm
  • Version: 3.1.11

Additional context
The postuninstall scriptlet is

#!/bin/bash

# Delete the link to the binary
if type update-alternatives >/dev/null 2>&1; then
    update-alternatives --remove 'teams-for-linux' '/usr/bin/teams-for-linux'
else
    rm -f '/usr/bin/teams-for-linux'
fi

and the problem is in the update-alternatives command. The last parameter should be the path to the binary (/opt/teams-for-linux/teams-for-linux) rather than the path to the alternatives link (/usr/bin/teams-for-linux). That is, the command should be:

   update-alternatives --remove 'teams-for-linux' '/opt/teams-for-linux/teams-for-linux'

But this seems problematic, as it runs after the install. It should include a check to see that /usr/bin/teams-for-linux doesn't resolve to an executable ([ -e /usr/bin/teams-for-linux ]). Otherwise it will remove the perfectly valid, just-installed link.

Finally, in the course of writing this up, I'm starting to wonder if this is a problem with Electron rather than something in teams-for-linux itself. If nothing else, at least this documents it.

@utoddl
Copy link
Author

utoddl commented Sep 20, 2023

Mildly interesting related side note: The releases folders do not contain the *.src.rpm from which the individual binary rpms a built. Apparently it's treated as a build artifact and discarded, which is okay, but that leave no place from which to extract the teams-for-linux.spec file, so it's impossible to say what rpmbuild macros are used, or how exactly to address this issue with a flawed %postuninstall script.

@IsmaelMartinez
Copy link
Owner

Thanks for reporting. Really not sure where to look at. I will leave it open and see if someone has any info

@IsmaelMartinez IsmaelMartinez added the hacktoberfest Community support is welcome label Oct 7, 2023
@storm9c1
Copy link

storm9c1 commented Feb 13, 2024

I'm late to the party with this bug, but if anybody could tell me where to get the SRPM, I'd be glad to help test the RPM and fix the spec file. I've only built a few thousand RPMs over the years. :-)

I can see the Source RPM in the metadata but no way to get to it. Perhaps it would be helpful if the spec file were included in the GIT code repo somewhere.

$ rpm -qpi teams-for-linux-1.4.10.x86_64.rpm 
Name        : teams-for-linux
Version     : 1.4.10
Release     : 1
Architecture: x86_64
Install Date: (not installed)
Group       : net
Size        : 269689428
License     : GPL-3.0-or-later
Signature   : (none)
Source RPM  : teams-for-linux-1.4.10-1.src.rpm
Build Date  : Sun Feb  4 03:40:55 2024
Build Host  : fv-az841-72.g11ey1dcctbuhkhojwlj3kcpwe.dx.internal.cloudapp.net
Relocations : / 
Packager    : Ismael Martinez <ismaelmartinez@gmail.com>
Vendor      : Ismael Martinez <ismaelmartinez@gmail.com>
URL         : https://github.com/IsmaelMartinez/teams-for-linux
Summary     : Teams for Linux
Description :
Unofficial Microsoft Teams client for Linux using Electron. It uses the Web App and wraps it as a standalone application using Electron.

@IsmaelMartinez
Copy link
Owner

Hi @storm9c1 , apologies for the delay.

Here some info. We use electron-builder to generate our packages.

Here info on how it works and what configuration allows:
https://www.electron.build/configuration/linux
https://www.electron.build/configuration/configuration.html

Here is the command used https://github.com/IsmaelMartinez/teams-for-linux/blob/develop/package.json#L30

and the only options I can see we apply are in here https://github.com/IsmaelMartinez/teams-for-linux/blob/develop/package.json#L96

image

In theory it supports all fpm client options... but I have no experience with it. https://fpm.readthedocs.io/en/latest/cli-reference.html

Does this help? Hopefully is just a wee option missing in there. Thanks a lot in advance and do reach out if you got any questions and/or if you find anything. We extremely appreciate any help we can get!

@storm9c1
Copy link

Hi @IsmaelMartinez,

I'm old school, I still design all RPMs by hand, I know, that's sooooo 2010. So I am not very familiar with fpm. I'll try to learn it (in my copious amounts of free time). It definitely seems like an interesting tool to learn for some of my upcoming work.

Let me dig through the doc links you provided first. Normally RPM needs little or no command line options to do its build work. The rpm .spec file and macros essentially control everything.

.
.
.

OK, I've skimmed the docs, right now it's not clear to me where electron builder is getting it's "afterInstall" string. Which I assume generates the %post install portion of the RPM?

Do we maintain that post install script in the repo or is the electron builder fully providing this? If so, then this may be entirely an electron builder issue.

@IsmaelMartinez
Copy link
Owner

it might be worth looking at the issues in there https://github.com/electron-userland/electron-builder/issues surely someone had this issue before us.

I can see this open issue electron-userland/electron-builder#7326 that might just be the issue behind this?

@storm9c1
Copy link

Yeah, I think you are on to something. The Electron bug does talk about scriptlet ordering between DEB and RPM. That's definitely a thing. I've solved this a few different ways. I'll try and see if I can dig deeper and contribute if I can.

@IsmaelMartinez IsmaelMartinez added bug Something isn't working blocked This issue depends on external projects labels Mar 29, 2024
@IsmaelMartinez
Copy link
Owner

Did you manage to look into this @storm9c1 / anyone?

@utoddl
Copy link
Author

utoddl commented Aug 28, 2024

OP here. I didn't notice when it changed, but at least as of teams-for-linux-1.9.2-1 the behavior on install wrt /etc/alternatives is correct. Behold:

$ alternatives --display teams-for-linux
teams-for-linux - status is auto.
 link currently points to /opt/teams-for-linux/teams-for-linux
/opt/teams-for-linux/teams-for-linux - priority 100
Current `best' version is /opt/teams-for-linux/teams-for-linux.

@IsmaelMartinez
Copy link
Owner

I assume then this is fixed. It would have been a electron-build update that probably brought the fix. Thanks for reporting and checking!

@utoddl
Copy link
Author

utoddl commented Sep 9, 2024

I am so sorry. Apparently I didn't read far enough in the logs. Package upgrades do set alternatives correctly, but the cleanup script for the prior version still throws the same errors.

Downloading Packages:
teams-for-linux-1.10.1.x86_64.rpm               5.0 MB/s |  84 MB     00:16    
--------------------------------------------------------------------------------
Total                                           5.0 MB/s |  84 MB     00:16     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Upgrading        : teams-for-linux-1.10.1-1.x86_64                        1/2 
  Running scriptlet: teams-for-linux-1.10.1-1.x86_64                        1/2 
update-alternatives is /sbin/update-alternatives

  Cleanup          : teams-for-linux-1.10.0-1.x86_64                        2/2 
  Running scriptlet: teams-for-linux-1.10.0-1.x86_64                        2/2 
/usr/bin/teams-for-linux has not been configured as an alternative for teams-for-linux
warning: %postun(teams-for-linux-1.10.0-1.x86_64) scriptlet failed, exit status 2

Error in POSTUN scriptlet in rpm package teams-for-linux

Upgraded:
  teams-for-linux-1.10.1-1.x86_64

As noted earlier, this is an issue with Electron. Sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked This issue depends on external projects bug Something isn't working hacktoberfest Community support is welcome
Projects
None yet
Development

No branches or pull requests

3 participants