Preserve user-managed /usr/local/bin/code in RPM %post scriptlet#310054
Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Open
Preserve user-managed /usr/local/bin/code in RPM %post scriptlet#310054yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
Conversation
The RPM %post scriptlet unconditionally removed /usr/local/bin/code, which deleted user-installed wrapper scripts or symlinks that happened to live at that path. The path is not owned by the package and is a common location for users to drop wrapper scripts (for example to add flags like --ozone-platform=wayland system-wide). Only remove /usr/local/bin/code when it is a symlink pointing at the location previously installed by this package, so that user-managed files at that path are preserved. Fixes microsoft#236132
50d7aeb to
f9aa01d
Compare
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @rzhao271Matched files:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
The RPM
%postscriptlet currently removes/usr/local/bin/codeunconditionally on every install/upgrade of the stablecodepackage:/usr/local/bin/codeis not a path owned by this package, and it's a common place for users to drop a wrapper script (for example, to launch/usr/bin/codewith extra flags like--ozone-platform=waylandsystem-wide). Deleting it on every RPM upgrade silently destroys user-managed files.This PR keeps the legacy cleanup, but only when the file is a symlink pointing at the target the package itself used to install (
/usr/share/code/bin/code/%{_datadir}/%{name}/bin/%{name}). Regular files (user wrapper scripts) and symlinks to other targets are left untouched.Behavior change
rm -f /usr/local/bin/coderan on every%post, removing whatever was at that path./usr/local/bin/codeis a symlink whose target is the legacy package-installed location.This preserves the original intent (cleaning up the legacy symlink from very old packages) without trampling files the user owns.
Testing notes
This affects RPM packaging only and is exercised at install time. Manual verification scenarios:
/usr/local/bin/code(e.g. a wrapper shell script) -> preserved across RPM upgrade./usr/local/bin/code->/some/user/path/code-> preserved across RPM upgrade./usr/local/bin/code->/usr/share/code/bin/code(legacy package layout) -> removed, matching previous cleanup behavior./usr/local/bin/code-> no-op.Fixes #236132