Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 815118 - dev-util/android-studio-2020.3.1.24 file collisions on upgrade due to symlink replacement
Summary: dev-util/android-studio-2020.3.1.24 file collisions on upgrade due to symlink...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jason A. Donenfeld
URL:
Whiteboard:
Keywords:
Depends on: 834600
Blocks:
  Show dependency tree
 
Reported: 2021-09-27 09:32 UTC by Kobboi
Modified: 2022-03-05 08:05 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kobboi 2021-09-27 09:32:48 UTC
* Detected file collision(s):
 * 
 * 	/opt/android-studio/jre/release
 * 	/opt/android-studio/jre/lib/jexec
 * 	/opt/android-studio/jre/bin/pack200
 * 	/opt/android-studio/jre/bin/jjs
 * 	/opt/android-studio/jre/bin/rmiregistry
 * 	/opt/android-studio/jre/bin/jrunscript
 * 	/opt/android-studio/jre/bin/unpack200
 * 	/opt/android-studio/jre/bin/jdeps
 * 	/opt/android-studio/jre/bin/jarsigner
 * 	/opt/android-studio/jre/bin/jfr
 * 	/opt/android-studio/jre/bin/javap
 * 	/opt/android-studio/jre/bin/keytool
 * 	/opt/android-studio/jre/bin/serialver
 * 	/opt/android-studio/jre/bin/java
 * 	/opt/android-studio/jre/bin/jar
 * 	/opt/android-studio/jre/bin/jdb
 * 	/opt/android-studio/jre/bin/javadoc
 * 	/opt/android-studio/jre/bin/javac
 * 	/opt/android-studio/jre/bin/rmid
 * 
 * Searching all installed packages for file collisions...
 * 
 * Press Ctrl-C to Stop
 * 
 * dev-java/icedtea-3.19.0:8::gentoo
 * 	/usr/lib64/icedtea8/bin/jar
 * 	/usr/lib64/icedtea8/bin/jarsigner
 * 	/usr/lib64/icedtea8/bin/java
 * 	/usr/lib64/icedtea8/bin/javac
 * 	/usr/lib64/icedtea8/bin/javadoc
 * 	/usr/lib64/icedtea8/bin/javap
 * 	/usr/lib64/icedtea8/bin/jdb
 * 	/usr/lib64/icedtea8/bin/jdeps
 * 	/usr/lib64/icedtea8/bin/jfr
 * 	/usr/lib64/icedtea8/bin/jjs
 * 	/usr/lib64/icedtea8/bin/jrunscript
 * 	/usr/lib64/icedtea8/bin/keytool
 * 	/usr/lib64/icedtea8/bin/pack200
 * 	/usr/lib64/icedtea8/bin/rmid
 * 	/usr/lib64/icedtea8/bin/rmiregistry
 * 	/usr/lib64/icedtea8/bin/serialver
 * 	/usr/lib64/icedtea8/bin/unpack200
 * 	/usr/lib64/icedtea8/lib/jexec
 * 	/usr/lib64/icedtea8/release


Reproducible: Always
Comment 1 Kobboi 2021-09-27 09:34:07 UTC
I think some symlinking stuff is going wrong during the install 

This is my filesystem:

$ ls /opt/android-studio/ -rtl
total 56
drwxr-xr-x 52 root root  4096  9 mrt  2021 plugins
-rw-r--r--  1 root root   396 26 sep 04:49 NOTICE.txt
-rw-r--r--  1 root root 11352 26 sep 04:49 LICENSE.txt
-rw-r--r--  1 root root  1840 26 sep 04:49 Install-Linux-tar.txt
-rw-r--r--  1 root root    25 26 sep 04:49 build.txt
-rw-r--r--  1 root root   383 26 sep 04:49 product-info.json
lrwxrwxrwx  1 root root    41 26 sep 04:49 jre -> ../../etc/java-config-2/current-system-vm
drwxr-xr-x  4 root root  4096 26 sep 04:51 bin
drwxr-xr-x  5 root root 16384 26 sep 04:51 lib
drwxr-xr-x  2 root root  4096 26 sep 04:51 license

$ ls -rtl /etc/java-config-2/current-system-vm
lrwxrwxrwx 1 root root 23 11 mrt  2021 /etc/java-config-2/current-system-vm -> /usr/lib/jvm//icedtea-8
Comment 2 Jouni Kosonen 2021-09-27 13:00:52 UTC
Same with dev-java/icedtea-3.18.0.

Commit e0f8ffe7b switches to using the bundled OpenJDK Runtime Environment 11.0.10 unconditionally but that doesn't clobber the /opt/android-studio/jre symlink from an earlier install.
Comment 3 Jason A. Donenfeld gentoo-dev 2021-09-27 15:46:11 UTC
This seems to be a bug in portage's merging algorithm, so I'll give ownership of this to the portage folks.

In the meantime you can fix this by:

    # emerge -C android-studio
    # rm -f /opt/android-studio/jre
    # emerge android-studio

The problem is that the old package makes /opt/android-studio/jre a symlink to elsewhere on the system, while the new package populates /opt/android-studio/jre/ as a folder with actual package-owned content. In this case, portage currently follows the symlink which overwrites files from another package. What it should do is sense that in the new package, /opt/android-studio/jre is a real directory rather than a symlink, and then remove the target symlink before copying files in. It's possible this is a matter of simply using `lstat` instead of `stat`.
Comment 4 Jason A. Donenfeld gentoo-dev 2021-09-27 15:47:24 UTC
Appending old bug title so it's easier to find.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-09-27 15:58:36 UTC
It's intentional behavior.  I don't necessarily agree with it but this is what we have now, it's permitted by the PMS (specifically to allow the historical Portage behavior) and even if we changed Portage, you'd still have to solve it in ebuild for compatibility with old versions.

Now, technically we could try to detect this specific case (i.e. overwriting a symlink owned by the same package).  However, in general we need to respect symlinks to directories, as otherwise random packages would overwrite symlinks installed by other packages or the sysadmin.
Comment 6 Jason A. Donenfeld gentoo-dev 2021-09-27 17:28:31 UTC
I disagree with that interpretation of the PMS. It's one thing to follow symlinks so that folks can redirect packages as they wish on their file system. It's quite another for portage's file replacement algorithm to trip on its own shoes. It *knows* that it used to own a symlink and that now that same filepath is going to be a real directory instead. This should be handled. It's natural for packages to change their directory structure over time, and symlink things or unsymlink thins as is. This is something portage should handle.
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2021-09-27 17:54:57 UTC
Feel free to work on a patch.  With this attitude, don't expect anything from me.

That said, the ebuild is broken as of behavior today and this breakage affects users.  Ignoring the bug and reassigning it to Portage team doesn't solve the problem today.
Comment 8 Mike Gilbert gentoo-dev 2021-09-27 18:01:13 UTC
I think the only workable solution today would be to add a hard blocker on old versions. Something like:

RDEPEND="!!<dev-util/android-studio-2020.3.1.24"
Comment 9 Mike Gilbert gentoo-dev 2021-09-27 18:03:17 UTC
Regarding the Portage behavior, I would suggest filing a separate bug and describing how you think it should work.
Comment 10 Kobboi 2021-09-27 18:09:20 UTC
(In reply to Mike Gilbert from comment #8)
> I think the only workable solution today would be to add a hard blocker on
> old versions. Something like:
> 
> RDEPEND="!!<dev-util/android-studio-2020.3.1.24"

Unfortunately, old versions have already been stripped from the tree. Quite prematurely IMHO.
Comment 11 Jason A. Donenfeld gentoo-dev 2021-09-27 18:11:16 UTC
> Feel free to work on a patch.  With this attitude, don't expect anything from me.

I didn't mean to have an "attitude"... It just seems squarely like a portage bug rather than a package bug. I have only meant to express my technical opinion about the matter. That evidently differs from your opinion. But that's okay, isn't it?

> RDEPEND="!!<dev-util/android-studio-2020.3.1.24"

Thanks for the tip. I'll do this.

Now you guys are aware of the portage issue and you can do something about it if you wish.
Comment 12 Larry the Git Cow gentoo-dev 2021-09-27 18:13:52 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f95c0916c985476d63c85fb3e794130594be084b

commit f95c0916c985476d63c85fb3e794130594be084b
Author:     Jason A. Donenfeld <zx2c4@gentoo.org>
AuthorDate: 2021-09-27 18:13:22 +0000
Commit:     Jason A. Donenfeld <zx2c4@gentoo.org>
CommitDate: 2021-09-27 18:13:36 +0000

    dev-util/android-studio: hack around portage deficiency with hard blocker
    
    Portage should handle unlinking symlinks it owns before clashing with
    directories it is about to install, but it doesn't, so hack around it
    with this.
    
    Closes: https://bugs.gentoo.org/815118
    Package-Manager: Portage-3.0.23, Repoman-3.0.3
    Signed-off-by: Jason A. Donenfeld <zx2c4@gentoo.org>

 dev-util/android-studio/android-studio-2020.3.1.24.ebuild | 1 +
 1 file changed, 1 insertion(+)
Comment 13 Mike Gilbert gentoo-dev 2021-09-27 18:21:37 UTC
(In reply to Kobboi from comment #10)
> Unfortunately, old versions have already been stripped from the tree. Quite
> prematurely IMHO.

That doesn't prevent a blocker from being added to the remaining ebuild.
Comment 14 PF4Public 2021-10-09 11:45:44 UTC
With this block in place portage seems to be unable to update android-studio. Am I doing something wrong?

# emerge -v1 android-studio

These are the packages that would be merged, in order:

Calculating dependencies  . ... done!
[ebuild     U ~] dev-util/android-studio-2020.3.1.24::gentoo [4.1.3.0.201.7199119::gentoo] USE="(-selinux) (-custom-jdk%)" 957,649 KiB
[blocks B      ] <dev-util/android-studio-2020.3.1.24 ("<dev-util/android-studio-2020.3.1.24" is hard blocking dev-util/android-studio-2020.3.1.24)

Total: 1 package (1 upgrade), Size of downloads: 957,649 KiB
Conflict: 1 block (1 unsatisfied)

 * Error: The above package list contains packages which cannot be
 * installed at the same time on the same system.

  (dev-util/android-studio-2020.3.1.24:0/0::gentoo, ebuild scheduled for merge) pulled in by
    dev-util/android-studio required by @my-set 
    android-studio

# emerge -v1 =dev-util/android-studio-2020.3.1.24

These are the packages that would be merged, in order:

Calculating dependencies  .... done!
[ebuild     U ~] dev-util/android-studio-2020.3.1.24::gentoo [4.1.3.0.201.7199119::gentoo] USE="(-selinux) (-custom-jdk%)" 957,649 KiB
[blocks B      ] <dev-util/android-studio-2020.3.1.24 ("<dev-util/android-studio-2020.3.1.24" is hard blocking dev-util/android-studio-2020.3.1.24)

Total: 1 package (1 upgrade), Size of downloads: 957,649 KiB
Conflict: 1 block (1 unsatisfied)

 * Error: The above package list contains packages which cannot be
 * installed at the same time on the same system.

  (dev-util/android-studio-2020.3.1.24:0/0::gentoo, ebuild scheduled for merge) pulled in by
    =dev-util/android-studio-2020.3.1.24
    dev-util/android-studio required by @my-set
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-10-09 23:03:21 UTC
(In reply to PF4Public from comment #14)
> With this block in place portage seems to be unable to update
> android-studio. Am I doing something wrong?

I think you need to actually unmerge it here, which is rather exceptional (no point in deselecting and depcleaning given you still want it...)