RPM packaging: Use standard macros (#153247)

* RPM spec: Use standard macros for paths/name

- Once `@@NAME@@` is replaced into the spec file as the `Name:`,
  it can be referenced with the RPM macro `%{name}`
- The installation directories corresponding to `/usr/bin/` and
  `/usr/share/` are defined in the RPM macros `%{_bindir}` and
  `%{_datadir}`

Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
Co-authored-by: Robo <hop2deep@gmail.com>
This commit is contained in:
Frank Dana
2022-08-03 19:16:33 -04:00
committed by GitHub
parent 1c02bdda63
commit 357d14621c

View File

@@ -11,7 +11,7 @@ Icon: @@NAME@@.xpm
Requires: @@DEPENDENCIES@@ Requires: @@DEPENDENCIES@@
AutoReq: 0 AutoReq: 0
%global __provides_exclude_from ^%{_datadir}/@@NAME@@/.*\\.so.*$ %global __provides_exclude_from ^%{_datadir}/%{name}/.*\\.so.*$
%description %description
Visual Studio Code is a new choice of tool that combines the simplicity of a code editor with what developers need for the core edit-build-debug cycle. See https://code.visualstudio.com/docs/setup/linux for installation instructions and FAQ. Visual Studio Code is a new choice of tool that combines the simplicity of a code editor with what developers need for the core edit-build-debug cycle. See https://code.visualstudio.com/docs/setup/linux for installation instructions and FAQ.
@@ -21,25 +21,29 @@ Visual Studio Code is a new choice of tool that combines the simplicity of a cod
%define _build_id_links none %define _build_id_links none
%install %install
mkdir -p %{buildroot}/usr/bin # Destination directories
mkdir -p %{buildroot}/usr/share/@@NAME@@ mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}/usr/share/applications mkdir -p %{buildroot}%{_datadir}/%{name}
mkdir -p %{buildroot}/usr/share/pixmaps mkdir -p %{buildroot}%{_datadir}/applications
mkdir -p %{buildroot}/usr/share/bash-completion/completions mkdir -p %{buildroot}%{_datadir}/mime/packages
mkdir -p %{buildroot}/usr/share/zsh/site-functions mkdir -p %{buildroot}%{_datadir}/pixmaps
mkdir -p %{buildroot}/usr/share/mime/packages mkdir -p %{buildroot}%{_datadir}/bash-completion/completions
cp -r usr/share/@@NAME@@/* %{buildroot}/usr/share/@@NAME@@ mkdir -p %{buildroot}%{_datadir}/zsh/site-functions
cp -r usr/share/applications/@@NAME@@.desktop %{buildroot}/usr/share/applications # Application
cp -r usr/share/applications/@@NAME@@-url-handler.desktop %{buildroot}/usr/share/applications cp -r usr/share/%{name}/* %{buildroot}%{_datadir}/%{name}
cp -r usr/share/mime/packages/@@NAME@@-workspace.xml %{buildroot}/usr/share/mime/packages/@@NAME@@-workspace.xml ln -s %{_datadir}/%{name}/bin/%{name} %{buildroot}%{_bindir}/%{name}
cp -r usr/share/pixmaps/@@ICON@@.png %{buildroot}/usr/share/pixmaps # Support files
cp usr/share/bash-completion/completions/@@NAME@@ %{buildroot}/usr/share/bash-completion/completions/@@NAME@@ cp -r usr/share/applications/%{name}.desktop %{buildroot}%{_datadir}/applications
cp usr/share/zsh/site-functions/_@@NAME@@ %{buildroot}/usr/share/zsh/site-functions/_@@NAME@@ cp -r usr/share/applications/%{name}-url-handler.desktop %{buildroot}%{_datadir}/applications
ln -s ../share/@@NAME@@/bin/@@NAME@@ %{buildroot}/usr/bin/@@NAME@@ cp -r usr/share/mime/packages/%{name}-workspace.xml %{buildroot}%{_datadir}/mime/packages/%{name}-workspace.xml
cp -r usr/share/pixmaps/@@ICON@@.png %{buildroot}%{_datadir}/pixmaps
# Shell completions
cp usr/share/bash-completion/completions/%{name} %{buildroot}%{_datadir}/bash-completion/completions/%{name}
cp usr/share/zsh/site-functions/_%{name} %{buildroot}%{_datadir}/zsh/site-functions/_%{name}
%post %post
# Remove the legacy bin command if this is the stable build # Remove the legacy bin command if this is the stable build
if [ "@@NAME@@" = "code" ]; then if [ "%{name}" = "code" ]; then
rm -f /usr/local/bin/code rm -f /usr/local/bin/code
fi fi
@@ -54,21 +58,21 @@ fi
#fi #fi
# Update mimetype database to pickup workspace mimetype # Update mimetype database to pickup workspace mimetype
update-mime-database /usr/share/mime &> /dev/null || : update-mime-database %{_datadir}/mime &> /dev/null || :
%postun %postun
# Update mimetype database for removed workspace mimetype # Update mimetype database for removed workspace mimetype
update-mime-database /usr/share/mime &> /dev/null || : update-mime-database %{_datadir}/mime &> /dev/null || :
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%attr(4755, root, root) /usr/share/@@NAME@@/chrome-sandbox %attr(4755, root, root) %{_datadir}/%{name}/chrome-sandbox
/usr/bin/@@NAME@@ %{_bindir}/%{name}
/usr/share/@@NAME@@/ %{_datadir}/%{name}/
/usr/share/applications/@@NAME@@.desktop %{_datadir}/applications/%{name}.desktop
/usr/share/applications/@@NAME@@-url-handler.desktop %{_datadir}/applications/%{name}-url-handler.desktop
/usr/share/mime/packages/@@NAME@@-workspace.xml %{_datadir}/mime/packages/%{name}-workspace.xml
/usr/share/pixmaps/@@ICON@@.png %{_datadir}/pixmaps/@@ICON@@.png
/usr/share/bash-completion/completions/@@NAME@@ %{_datadir}/bash-completion/completions/%{name}
/usr/share/zsh/site-functions/_@@NAME@@ %{_datadir}/zsh/site-functions/_%{name}