Skip to content

Commit

Permalink
fix(deb): only execute update-desktop-database and `update-mime-dat…
Browse files Browse the repository at this point in the history
…abase` when exists on the system (#8067)
  • Loading branch information
mmaietta committed Mar 2, 2024
1 parent e6f1beb commit 18340ee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-fishes-impress.md
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix(deb): soft symlink instead of hardlink to handle when /opt is on a separate partition
13 changes: 9 additions & 4 deletions packages/app-builder-lib/templates/linux/after-install.tpl
Expand Up @@ -3,15 +3,20 @@
if type update-alternatives 2>/dev/null >&1; then
# Remove previous link if it doesn't use update-alternatives
if [ -L '/usr/bin/${executable}' -a -e '/usr/bin/${executable}' -a "`readlink '/usr/bin/${executable}'`" != '/etc/alternatives/${executable}' ]; then
rm -f '/usr/bin/${executable}'
rm -f '/usr/bin/${executable}'
fi
update-alternatives --install '/usr/bin/${executable}' '${executable}' '/opt/${sanitizedProductName}/${executable}' 100
update-alternatives --install '/usr/bin/${executable}' '${executable}' '/opt/${sanitizedProductName}/${executable}' 100 || ln -sf '/opt/${sanitizedProductName}/${executable}' '/usr/bin/${executable}'
else
ln -sf '/opt/${sanitizedProductName}/${executable}' '/usr/bin/${executable}'
fi

# SUID chrome-sandbox for Electron 5+
chmod 4755 '/opt/${sanitizedProductName}/chrome-sandbox' || true

update-mime-database /usr/share/mime || true
update-desktop-database /usr/share/applications || true
if hash update-mime-database 2>/dev/null; then
update-mime-database /usr/share/mime || true
fi

if hash update-desktop-database 2>/dev/null; then
update-desktop-database /usr/share/applications || true
fi
13 changes: 9 additions & 4 deletions test/snapshots/linux/debTest.js.snap
Expand Up @@ -541,18 +541,23 @@ exports[`executable path in postinst script 5`] = `
if type update-alternatives 2>/dev/null >&1; then
# Remove previous link if it doesn't use update-alternatives
if [ -L '/usr/bin/Boo' -a -e '/usr/bin/Boo' -a \\"\`readlink '/usr/bin/Boo'\`\\" != '/etc/alternatives/Boo' ]; then
rm -f '/usr/bin/Boo'
rm -f '/usr/bin/Boo'
fi
update-alternatives --install '/usr/bin/Boo' 'Boo' '/opt/foo/Boo' 100
update-alternatives --install '/usr/bin/Boo' 'Boo' '/opt/foo/Boo' 100 || ln -sf '/opt/foo/Boo' '/usr/bin/Boo'
else
ln -sf '/opt/foo/Boo' '/usr/bin/Boo'
fi
# SUID chrome-sandbox for Electron 5+
chmod 4755 '/opt/foo/chrome-sandbox' || true
update-mime-database /usr/share/mime || true
update-desktop-database /usr/share/applications || true"
if hash update-mime-database 2>/dev/null; then
update-mime-database /usr/share/mime || true
fi
if hash update-desktop-database 2>/dev/null; then
update-desktop-database /usr/share/applications || true
fi"
`;

exports[`no quotes for safe exec name 1`] = `
Expand Down

0 comments on commit 18340ee

Please sign in to comment.