File onlyoffice-desktopeditors.spec of Package onlyoffice-desktopeditors

Name: onlyoffice-desktopeditors
Version: 8.0.1
Release: 0
Url: https://github.com/ONLYOFFICE/DesktopEditors
Summary: ONLYOFFICE Desktop Editors
Group: System/GUI/KDE
BuildRequires: desktop-file-utils
BuildRequires: update-desktop-files
BuildRequires: hicolor-icon-theme
BuildRequires: -post-build-checks
AutoReqProv: no
License: AGPL-3.0
Source0: onlyoffice-desktopeditors_amd64.deb
BuildRoot: %{_tmppath}/%{name}-%{version}-build

%description
ONLYOFFICE Desktop Editors is a free office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit documents stored on your Windows/Linux PC or Mac without an Internet connection. It is fully compatible with Office Open XML formats: .docx, .xlsx, .pptx.

%build
ar -x %{SOURCE0}

%install
mkdir -p %{buildroot}/opt/onlyoffice/
cp -f data.tar.xz %{buildroot}/opt/onlyoffice/data.tar.xz

%post
if test -e /opt/onlyoffice/data.tar.xz ; then
	tar xf /opt/onlyoffice/data.tar.xz -C /
fi

# Add icons to the system icons
XDG_ICON_RESOURCE="$(which xdg-icon-resource 2> /dev/null || true)"
if [ ! -x "$XDG_ICON_RESOURCE" ]; then
  echo "Error: Could not find xdg-icon-resource" >&2
fi
for icon in "/opt/onlyoffice/desktopeditors/asc-de-"*.png; do
  size="${icon##*/asc-de-}"
  "$XDG_ICON_RESOURCE" install --size "${size%.png}" "$icon" "onlyoffice-desktopeditors"
done

UPDATE_MENUS="$(which update-menus 2> /dev/null || true)"
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/oo-office | wc -l) -eq "0" ]; then
  echo "x-scheme-handler/oo-office=onlyoffice-desktopeditors.desktop" >>"$MIMEAPPS_LIST"
fi

# Create .desktop file
rm -f %{_datadir}/applications/%{name}.desktop
cat > %{_datadir}/applications/%{name}.desktop << EOM
[Desktop Entry]
Version=1.0
Name=ONLYOFFICE Desktop Editors
GenericName=Document Editor
GenericName[ru]=Редактор документов
GenericName[pt_BR]=Editar documentos de escritório
Comment=Edit office documents
Comment[ru]=Редактировать офисные документы
Comment[pt_BR]=Editar documentos de escritório
Type=Application
Exec=/usr/bin/onlyoffice-desktopeditors %U
Terminal=false
Icon=onlyoffice-desktopeditors
Keywords=Text;Document;OpenDocument Text;Microsoft Word;Microsoft Works;odt;doc;docx;rtf;
Categories=Office;WordProcessor;Spreadsheet;Presentation;
MimeType=application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.text-template;application/vnd.oasis.opendocument.text-web;application/vnd.oasis.opendocument.text-master;application/vnd.sun.xml.writer;application/vnd.sun.xml.writer.template;application/vnd.sun.xml.writer.global;application/msword;application/vnd.ms-word;application/x-doc;application/rtf;text/rtf;application/vnd.wordperfect;application/wordperfect;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-word.document.macroenabled.12;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/vnd.ms-word.template.macroenabled.12;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/msexcel;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel.sheet.macroenabled.12;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-excel.template.macroenabled.12;application/vnd.ms-excel.sheet.binary.macroenabled.12;text/csv;text/spreadsheet;application/csv;application/excel;application/x-excel;application/x-msexcel;application/x-ms-excel;text/comma-separated-values;text/tab-separated-values;text/x-comma-separated-values;text/x-csv;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocument.presentation-template;application/vnd.sun.xml.impress;application/vnd.sun.xml.impress.template;application/mspowerpoint;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.ms-powerpoint.presentation.macroenabled.12;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.ms-powerpoint.template.macroenabled.12;application/vnd.openxmlformats-officedocument.presentationml.slide;application/vnd.openxmlformats-officedocument.presentationml.slideshow;application/vnd.ms-powerpoint.slideshow.macroEnabled.12;x-scheme-handler/oo-office;text/docxf;text/oform;
Actions=NewDocument;NewSpreadsheet;NewPresentation;NewForm;

[Desktop Action NewDocument]
Name=New Document
Name[de]=Neues Dokument
Name[fr]=Nouveau document
Name[es]=Documento nuevo
Name[ru]=Создать документ
Name[pt_BR]=Novo documento
Exec=/usr/bin/onlyoffice-desktopeditors --new:word

[Desktop Action NewSpreadsheet]
Name=New Spreadsheet
Name[de]=Neues Tabellendokument
Name[fr]=Nouveau classeur
Name[es]=Hoja de cálculo nueva
Name[ru]=Создать эл.таблицу
Name[pt_BR]=Nova planilha
Exec=/usr/bin/onlyoffice-desktopeditors --new:cell

[Desktop Action NewPresentation]
Name=New Presentation
Name[de]=Neue Präsentation
Name[fr]=Nouvelle présentation
Name[es]=Presentación nueva
Name[ru]=Создать презентацию
Name[pt_BR]=Nova apresentação
Exec=/usr/bin/onlyoffice-desktopeditors --new:slide

[Desktop Action NewForm]
Name=New form template
Name[de]=Neue Formularvorlage
Name[fr]=Nouveau modèle de formulaire
Name[es]=Nueva plantilla de formulario
Name[ru]=Создать шаблон формы
Name[pt_BR]=Novo modelo de formulário
Exec=/usr/bin/onlyoffice-desktopeditors --new:form
EOM

# Fix onlyoffice icon
if test ! -e "/usr/share/pixmaps/onlyoffice-desktopeditors.png"; then
  cp -f /opt/onlyoffice/desktopeditors/asc-de-128.png \
  /usr/share/pixmaps/onlyoffice-desktopeditors.png
fi

%desktop_database_post
%icon_theme_cache_post
%mime_database_post

update-desktop-database
gtk-update-icon-cache

%preun
if [ "$1" = 0 ]; then
  # Remove files
  rm -rf "/opt/onlyoffice"
  rm -f "/usr/bin/desktopeditors"
  rm -f "/usr/bin/onlyoffice-desktopeditors"
  rm -f "%{_datadir}/applications/onlyoffice-desktopeditors.desktop"

  # Remove icons from the system icons
  XDG_ICON_RESOURCE="$(which xdg-icon-resource 2> /dev/null || true)"
  if [ ! -x "$XDG_ICON_RESOURCE" ]; then
    echo "Error: Could not find xdg-icon-resource" >&2
  fi
  for icon in "/opt/onlyoffice/desktopeditors/asc-de-"*.png; do
    size="${icon##*/asc-de-}"
    "$XDG_ICON_RESOURCE" uninstall --size "${size%.png}" "onlyoffice-desktopeditors"
  done

  UPDATE_MENUS="$(which update-menus 2> /dev/null || true)"
  if [ -x "$UPDATE_MENUS" ]; then
    update-menus
  fi

  %desktop_database_post
  %icon_theme_cache_post
  %mime_database_post

  update-desktop-database
  gtk-update-icon-cache
fi

%clean

%files
%defattr(-,root,root)
/opt/onlyoffice/data.tar.xz

%changelog
openSUSE Build Service is sponsored by