teams-for-linux icon indicating copy to clipboard operation
teams-for-linux copied to clipboard

rpm %postun scriptlet fails

Open utoddl opened this issue 1 year ago • 8 comments

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 avatar Sep 20 '23 12:09 utoddl

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.

utoddl avatar Sep 20 '23 13:09 utoddl

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

IsmaelMartinez avatar Oct 06 '23 19:10 IsmaelMartinez

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 <[email protected]>
Vendor      : Ismael Martinez <[email protected]>
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.

storm9c1 avatar Feb 13 '24 07:02 storm9c1

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!

IsmaelMartinez avatar Mar 21 '24 10:03 IsmaelMartinez

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.

storm9c1 avatar Mar 21 '24 15:03 storm9c1

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 https://github.com/electron-userland/electron-builder/issues/7326 that might just be the issue behind this?

IsmaelMartinez avatar Mar 21 '24 18:03 IsmaelMartinez

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.

storm9c1 avatar Mar 24 '24 00:03 storm9c1

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

IsmaelMartinez avatar Jun 11 '24 05:06 IsmaelMartinez