Skip to content

Commit 9c3b0bb

Browse files
ferdnycrzhao271
andauthored
RPM: Make /usr/bin/code owned by package (microsoft#142907)
Create the `/usr/bin/code` symlink during %install so that the package owns and manages it. Also, make it relative (for better relocatability). Co-authored-by: Raymond Zhao <[email protected]>
1 parent 3862aa8 commit 9c3b0bb

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

resources/linux/rpm/code.spec.template

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Visual Studio Code is a new choice of tool that combines the simplicity of a cod
2121
%define _build_id_links none
2222

2323
%install
24+
mkdir -p %{buildroot}/usr/bin
2425
mkdir -p %{buildroot}/usr/share/@@NAME@@
2526
mkdir -p %{buildroot}/usr/share/applications
2627
mkdir -p %{buildroot}/usr/share/pixmaps
@@ -34,16 +35,14 @@ cp -r usr/share/mime/packages/@@NAME@@-workspace.xml %{buildroot}/usr/share/mime
3435
cp -r usr/share/pixmaps/@@ICON@@.png %{buildroot}/usr/share/pixmaps
3536
cp usr/share/bash-completion/completions/@@NAME@@ %{buildroot}/usr/share/bash-completion/completions/@@NAME@@
3637
cp usr/share/zsh/site-functions/_@@NAME@@ %{buildroot}/usr/share/zsh/site-functions/_@@NAME@@
38+
ln -s ../share/@@NAME@@/bin/@@NAME@@ %{buildroot}/usr/bin/@@NAME@@
3739

3840
%post
3941
# Remove the legacy bin command if this is the stable build
4042
if [ "@@NAME@@" = "code" ]; then
4143
rm -f /usr/local/bin/code
4244
fi
4345

44-
# Symlink bin command to /usr/bin
45-
ln -sf /usr/share/@@NAME@@/bin/@@NAME@@ %{_bindir}/@@NAME@@
46-
4746
# Register yum repository
4847
# TODO: #229: Enable once the yum repository is signed
4948
#if [ "@@NAME@@" != "code-oss" ]; then
@@ -58,17 +57,14 @@ ln -sf /usr/share/@@NAME@@/bin/@@NAME@@ %{_bindir}/@@NAME@@
5857
update-mime-database /usr/share/mime &> /dev/null || :
5958

6059
%postun
61-
if [ $1 = 0 ]; then
62-
rm -f /usr/bin/@@NAME@@
63-
fi
64-
6560
# Update mimetype database for removed workspace mimetype
6661
update-mime-database /usr/share/mime &> /dev/null || :
6762

6863
%files
6964
%defattr(-,root,root)
7065
%attr(4755, root, root) /usr/share/@@NAME@@/chrome-sandbox
7166

67+
/usr/bin/@@NAME@@
7268
/usr/share/@@NAME@@/
7369
/usr/share/applications/@@NAME@@.desktop
7470
/usr/share/applications/@@NAME@@-url-handler.desktop

0 commit comments

Comments
 (0)