Skip to content

Commit

Permalink
Fix bug 64068 : File mimeapps.list was changed after installation (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
romandemidov authored Sep 27, 2023
1 parent af689bc commit 445e617
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
18 changes: 3 additions & 15 deletions win-linux/package/linux/deb/template/postinst.m4
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,11 @@ if [ -x "$UPDATE_MENUS" ]; then
update-menus
fi

MIMEAPPS_LIST="/usr/share/applications/mimeapps.list"
if [ ! -f "$MIMEAPPS_LIST" ]; then
echo "[Default Applications]" >"$MIMEAPPS_LIST"
fi
if [ $(cat "$MIMEAPPS_LIST" | grep x-scheme-handler/M4_SCHEME_HANDLER | wc -l) -eq "0" ]; then
echo "x-scheme-handler/M4_SCHEME_HANDLER=M4_DESKTOPEDITORS_EXEC.desktop" >>"$MIMEAPPS_LIST"
fi
if [ $(cat "$MIMEAPPS_LIST" | grep text/docxf | wc -l) -eq "0" ]; then
echo "text/docxf=M4_DESKTOPEDITORS_EXEC.desktop" >>"$MIMEAPPS_LIST"
fi
if [ $(cat "$MIMEAPPS_LIST" | grep text/oform | wc -l) -eq "0" ]; then
echo "text/oform=M4_DESKTOPEDITORS_EXEC.desktop" >>"$MIMEAPPS_LIST"
fi

ifelse(M4_COMPANY_NAME, ONLYOFFICE,
xdg-mime install --mode system /opt/M4_DESKTOPEDITORS_PREFIX/mimetypes/onlyoffice-docxf.xml
xdg-mime install --mode system /opt/M4_DESKTOPEDITORS_PREFIX/mimetypes/onlyoffice-oform.xml,
xdg-mime install --mode system /opt/M4_DESKTOPEDITORS_PREFIX/mimetypes/onlyoffice-oform.xml
update-mime-database /usr/share/mime
update-desktop-database /usr/share/applications,
if [ -f /etc/astra_version ] && [ -f /etc/X11/trusted ]; then
sed -i '\|/opt/M4_DESKTOPEDITORS_PREFIX/DesktopEditors|d' /etc/X11/trusted
echo '/opt/M4_DESKTOPEDITORS_PREFIX/DesktopEditors(KBD_R)' >> /etc/X11/trusted
Expand Down
17 changes: 3 additions & 14 deletions win-linux/package/linux/rpm/common.spec
Original file line number Diff line number Diff line change
Expand Up @@ -124,23 +124,12 @@ if [ -x "$UPDATE_MENUS" ]; then
update-menus
fi

MIMEAPPS_LIST="/usr/share/applications/mimeapps.list"
if [ ! -f "$MIMEAPPS_LIST" ]; then
echo "[Default Applications]" >"$MIMEAPPS_LIST"
fi
if [ $(cat "$MIMEAPPS_LIST" | grep x-scheme-handler/%{_scheme_handler} | wc -l) -eq "0" ]; then
echo "x-scheme-handler/%{_scheme_handler}=%{_desktopeditors_exec}.desktop" >>"$MIMEAPPS_LIST"
fi
if [ $(cat "$MIMEAPPS_LIST" | grep text/docxf | wc -l) -eq "0" ]; then
echo "text/docxf=%{_desktopeditors_exec}.desktop" >>"$MIMEAPPS_LIST"
fi
if [ $(cat "$MIMEAPPS_LIST" | grep text/oform | wc -l) -eq "0" ]; then
echo "text/oform=%{_desktopeditors_exec}.desktop" >>"$MIMEAPPS_LIST"
fi

xdg-mime install --mode system /opt/%{_desktopeditors_prefix}/mimetypes/onlyoffice-docxf.xml
xdg-mime install --mode system /opt/%{_desktopeditors_prefix}/mimetypes/onlyoffice-oform.xml

update-mime-database /usr/share/mime
update-desktop-database /usr/share/applications

# Update cache of .desktop file MIME types. Non-fatal since it's just a cache.
#update-desktop-database > /dev/null 2>&1 || true

Expand Down

1 comment on commit 445e617

@sfonteneau
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if use update-desktop-database need desktop-file-utils dependency :

#1069

Please sign in to comment.