Bug 1831562 - Upgrading from Fedora 30/31 to 32/33: failed to link /usr/bin/hg -> /etc/alternatives/hg: /usr/bin/hg exists and it is not a symlink [NEEDINFO]
Summary: Upgrading from Fedora 30/31 to 32/33: failed to link /usr/bin/hg -> /etc/alte...
Keywords:
Status: ON_QA
Alias: None
Product: Fedora
Classification: Fedora
Component: mercurial
Version: 32
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Petr Stodulka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-05-05 09:43 UTC by Miro Hrončok
Modified: 2020-09-25 16:47 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
mhroncok: needinfo? (ndbecker2)


Attachments (Terms of Use)

Description Miro Hrončok 2020-05-05 09:43:56 UTC
When upgrading Fedora with mercurial installed, the snippet to upgrade the alternatives fails.

Steps to reproduce:

$ podman run -ti fedora:31 /usr/bin/bash
# dnf install mercurial file
# file /usr/bin/hg
/usr/bin/hg: Python script, ASCII text executable
# rpm -q mercurial
mercurial-4.9-2.fc31.x86_64
# dnf --releasever=32 upgrade mercurial
...

Installing:
 mercurial-py2
     replacing  mercurial.x86_64 4.9-2.fc31

Running transaction
  Preparing        :                                      1/1 
  Installing       : mercurial-lang-5.2-4.fc32.x86_64     1/3 
  Installing       : mercurial-py2-5.2-4.fc32.x86_64      2/3 
  Running scriptlet: mercurial-py2-5.2-4.fc32.x86_64      2/3 
failed to link /usr/bin/hg -> /etc/alternatives/hg: /usr/bin/hg exists and it is not a symlink
failed to link /usr/bin/hg-ssh -> /etc/alternatives/hg-ssh: /usr/bin/hg-ssh exists and it is not a symlink

  Obsoleting       : mercurial-4.9-2.fc31.x86_64          3/3 
  Running scriptlet: mercurial-4.9-2.fc31.x86_64          3/3 
  Verifying        : mercurial-lang-5.2-4.fc32.x86_64     1/3 
  Verifying        : mercurial-py2-5.2-4.fc32.x86_64      2/3 
  Verifying        : mercurial-4.9-2.fc31.x86_64          3/3 

# head /usr/bin/hg
#!/usr/bin/python2
...

This leads to a broken setup:

# dnf --releasever 32 swap mercurial-py2 mercurial-py3
...
  Running scriptlet: mercurial-py3-5.2-4.fc32.x86_64          30/55 
failed to link /usr/bin/hg -> /etc/alternatives/hg: /usr/bin/hg exists and it is not a symlink
failed to link /usr/bin/hg-ssh -> /etc/alternatives/hg-ssh: /usr/bin/hg-ssh exists and it is not a symlink

  Cleanup          : yum-4.2.18-1.fc31.noarch                 31/55 
  Running scriptlet: mercurial-py2-5.2-4.fc32.x86_64          32/55 
failed to link /usr/bin/hg -> /etc/alternatives/hg: /usr/bin/hg exists and it is not a symlink
failed to link /usr/bin/hg-ssh -> /etc/alternatives/hg-ssh: /usr/bin/hg-ssh exists and it is not a symlink

  Erasing          : mercurial-py2-5.2-4.fc32.x86_64          32/55 
...

# head /usr/bin/hg
#!/usr/bin/python2
...

# rpm -q mercurial-py2
package mercurial-py2 is not installed

# rpm -q mercurial-py3
mercurial-py3-5.2-4.fc32.x86_64

Comment 1 Miro Hrončok 2020-05-05 09:55:59 UTC
I think a fix is to use %posttrans instead of %post, but I've asked in:

https://lists.fedoraproject.org/archives/list/packaging@lists.fedoraproject.org/message/7NI7RHMG76BZT6J56OP6T6SAMNNFAW2L/

Comment 2 Miro Hrončok 2020-06-11 12:37:36 UTC
What do you think?

Comment 3 Mads Kiilerich 2020-06-11 13:33:20 UTC
Independent from the problems with the introduction of alternatives in f32 and what it is feasible to change there:
There should not be any need for mercurial-py2 or alternatives in f33. Many of the f32 changes should be dropped again.

Comment 4 Petr Stodulka 2020-06-11 15:23:08 UTC
I am voting for drop of mercurial-py2 completely and going just with Py3 only. Some related apps stopped working already anyway and I think now it's the best time to drop it, when there is enough time till the release of F33. It could happen that some apps will never be ported to Py3. If some appliacations are worthy, these will be ported. If not, probably no problem to drop them too.

Comment 5 Miro Hrončok 2020-06-11 16:02:44 UTC
I am in favor of that, but this particular problem still needs to be solved in Fedora 32.

Comment 6 Miro Hrončok 2020-07-24 12:02:20 UTC
What do you think about the proposed fix, may I do it?

Comment 7 Petr Stodulka 2020-07-27 09:40:20 UTC
I will have some free nights for Fedora Thu-Sat.

Comment 8 Miro Hrončok 2020-08-10 15:58:04 UTC
I'd like to see this fixed. How can I move it forward?

Comment 9 Petr Stodulka 2020-08-10 18:30:02 UTC
Hi Miro. Sorry for taking it so long. I tried to resolve it in posttrans but it's not fixing the problem. It seems the problem is that the /usr/bin/{hg,hg-ssh} files are listed in both packages but in the new one as ghost files, so the files are not updated/removed and then we are not able to create the symlinks as the orig files exists. 

So we need to remove these two files first, in case they are not symlinks. When they are symlinks, we do not have to do anything so far as I understand. I don't know how to resolve this better to be honest. Any idea?

I am keeping the scriptlet in %post, as it seems more correct to me - as some scriptlets from other rpms could use hg in example. I have opened PR with the fix:
  https://src.fedoraproject.org/rpms/mercurial/pull-request/10

Could look at it Miro and give me feedback?

Comment 10 Miro Hrončok 2020-08-14 09:15:48 UTC
Feedback provided. Let's ship this?

Comment 11 Fedora Update System 2020-08-25 12:22:08 UTC
FEDORA-2020-1950731493 has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-1950731493

Comment 12 Fedora Update System 2020-08-26 14:34:00 UTC
FEDORA-2020-1950731493 has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-1950731493`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-1950731493

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 13 Petr Stodulka 2020-08-31 16:50:59 UTC
Just to not miss that, the current fix is available for testing just for F32. Changes are applied for F33+ as well, but new builds are not available as the current mercurial is not possible to build with Python 3.9 right now. See bug 1871992 for detail. Once I am able to create builds on F33+, I will create them.

Comment 14 Petr Viktorin 2020-09-02 09:18:11 UTC
Here's a patch that could either be a workaround or a proper fix for the FTBFS on Python 3.9: https://src.fedoraproject.org/rpms/mercurial/pull-request/12

Comment 15 Fedora Update System 2020-09-03 16:38:55 UTC
FEDORA-2020-1950731493 has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 16 Fedora Update System 2020-09-04 22:17:10 UTC
FEDORA-2020-bc1902e34e has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-bc1902e34e

Comment 17 Fedora Update System 2020-09-05 21:39:36 UTC
FEDORA-2020-bc1902e34e has been pushed to the Fedora 33 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-bc1902e34e`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-bc1902e34e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Fedora Update System 2020-09-25 16:47:52 UTC
FEDORA-2020-bc1902e34e has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.