Skip to content

Commit

Permalink
RPM: Make /usr/bin/code owned by package
Browse files Browse the repository at this point in the history
Create the `/usr/bin/code` symlink during %install
so that the package owns and manages it.
Also, make it relative (for better relocatability).
  • Loading branch information
ferdnyc committed Feb 12, 2022
1 parent 7e8ca05 commit da1d9d8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions resources/linux/rpm/code.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Visual Studio Code is a new choice of tool that combines the simplicity of a cod
%define _build_id_links none

%install
mkdir -p %{buildroot}/usr/bin
mkdir -p %{buildroot}/usr/share/@@NAME@@
mkdir -p %{buildroot}/usr/share/applications
mkdir -p %{buildroot}/usr/share/pixmaps
Expand All @@ -32,16 +33,14 @@ cp -r usr/share/mime/packages/@@NAME@@-workspace.xml %{buildroot}/usr/share/mime
cp -r usr/share/pixmaps/@@ICON@@.png %{buildroot}/usr/share/pixmaps
cp usr/share/bash-completion/completions/@@NAME@@ %{buildroot}/usr/share/bash-completion/completions/@@NAME@@
cp usr/share/zsh/site-functions/_@@NAME@@ %{buildroot}/usr/share/zsh/site-functions/_@@NAME@@
ln -s ../share/@@NAME@@/bin/@@NAME@@ %{buildroot}/usr/bin/@@NAME@@

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

# Symlink bin command to /usr/bin
ln -sf /usr/share/@@NAME@@/bin/@@NAME@@ %{_bindir}/@@NAME@@

# Register yum repository
# TODO: #229: Enable once the yum repository is signed
#if [ "@@NAME@@" != "code-oss" ]; then
Expand All @@ -56,17 +55,14 @@ ln -sf /usr/share/@@NAME@@/bin/@@NAME@@ %{_bindir}/@@NAME@@
update-mime-database /usr/share/mime &> /dev/null || :

%postun
if [ $1 = 0 ]; then
rm -f /usr/bin/@@NAME@@
fi

# Update mimetype database for removed workspace mimetype
update-mime-database /usr/share/mime &> /dev/null || :

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

/usr/bin/@@NAME@@
/usr/share/@@NAME@@/
/usr/share/applications/@@NAME@@.desktop
/usr/share/applications/@@NAME@@-url-handler.desktop
Expand Down

0 comments on commit da1d9d8

Please sign in to comment.