Skip to content

Commit

Permalink
Fix lintian errors: prerm-calls-updatemenus, postinst-has-useless-cal…
Browse files Browse the repository at this point in the history
…l-to-update-menus
  • Loading branch information
heatray authored Aug 1, 2024
1 parent 95c4e80 commit 0cf8f92
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 201 deletions.
38 changes: 22 additions & 16 deletions win-linux/package/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,21 @@ DESKTOP_FILES += build/main/usr/share/applications/$(DESKTOPEDITORS_EXEC).deskto
LINUX_DEPS += $(BIN_FILES)
LINUX_DEPS += $(DESKTOP_FILES)
LINUX_DEPS += $(CHANGELOG_RPM)
LINUX_DEPS += $(patsubst $(BRANDING_DIR)/common/icons/%.png, \
build/main/usr/share/icons/hicolor/%/apps/$(DESKTOPEDITORS_EXEC).png, \
$(wildcard $(BRANDING_DIR)/common/icons/*.png))
LINUX_DEPS += build/main/usr/share/licenses/$(PACKAGE_NAME)/LICENSE
LINUX_DEPS += build/main/usr/share/licenses/$(PACKAGE_NAME)/3DPARTYLICENSE
ifneq ($(wildcard $(BRANDING_DIR)/../../../common/package/mimetypes/*.xml),)
LINUX_DEPS += $(patsubst $(BRANDING_DIR)/../../../common/package/mimetypes/%.xml, \
build/main/usr/share/mime/packages/%.xml, \
$(wildcard $(BRANDING_DIR)/../../../common/package/mimetypes/*.xml))
endif

DEB_DEPS += $(CHANGELOG_DEB)
DEB_DEPS += deb/build/debian/compat
DEB_DEPS += deb/build/debian/control
DEB_DEPS += deb/build/debian/postinst
DEB_DEPS += deb/build/debian/postrm
DEB_DEPS += deb/build/debian/prerm
DEB_DEPS += deb/build/debian/rules
DEB_DEPS += deb/build/debian/source/format
DEB_DEPS += deb/build/debian/$(PACKAGE_NAME).dirs
Expand Down Expand Up @@ -141,27 +149,13 @@ build : $(LINUX_DEPS)
cp -rft $@/main/opt/$(DESKTOPEDITORS_PREFIX) $(SOURCE_DIR)/desktopeditors/*
chmod 755 $@/main/opt/$(DESKTOPEDITORS_PREFIX)/DesktopEditors

cp -rf $(BRANDING_DIR)/../../../common/package/license/*.htm \
$@/main/opt/$(DESKTOPEDITORS_PREFIX)/LICENSE.htm
cp -rf $(BRANDING_DIR)/../../../common/package/license/3dparty/3DPARTYLICENSE \
$@/main/opt/$(DESKTOPEDITORS_PREFIX)/

ifneq ($(wildcard $(BRANDING_DIR)/../../../common/package/mimetypes),)
cp -rf $(BRANDING_DIR)/../../../common/package/mimetypes \
$@/main/opt/$(DESKTOPEDITORS_PREFIX)
endif

cd $@; \
for path in main/$(HELP_GLOB); do \
path_new=$$(echo $$path | sed 's|^main/|help/|'); \
mkdir -p $$path_new; \
mv -fT $$path $$path_new; \
done

for path in $(BRANDING_DIR)/common/icons/*.png; do \
cp -f $$path $@/main/opt/$(DESKTOPEDITORS_PREFIX)/asc-de-$${path##*/}; \
done

ifdef MEDIAVIEWER_PREFIX
mkdir -p $@/main/opt/$(MEDIAVIEWER_PREFIX)
cp -rft $@/main/opt/$(MEDIAVIEWER_PREFIX) $(SOURCE_DIR)/mediaviewer/*
Expand All @@ -178,6 +172,18 @@ $(RPM) : build rpm/$(PACKAGE_NAME).spec
$(RPM_PARAMS) \
$(PACKAGE_NAME).spec

build/main/usr/share/icons/hicolor/%/apps/$(DESKTOPEDITORS_EXEC).png : $(BRANDING_DIR)/common/icons/%.png
install -D $< $@

build/main/usr/share/licenses/$(PACKAGE_NAME)/LICENSE : $(BRANDING_DIR)/../../../LICENSE.txt
build/main/usr/share/licenses/$(PACKAGE_NAME)/3DPARTYLICENSE : $(BRANDING_DIR)/../../../common/package/license/3dparty/3DPARTYLICENSE

build/main/usr/share/licenses/% :
install -D $< $@

build/main/usr/share/mime/packages/% : $(BRANDING_DIR)/../../../common/package/mimetypes/%
install -D $< $@

deb/build/debian/% : deb/template/%
mkdir -pv $(@D) && cp -fv $< $@

Expand Down
34 changes: 0 additions & 34 deletions win-linux/package/linux/deb/template/postinst.m4

This file was deleted.

43 changes: 13 additions & 30 deletions win-linux/package/linux/deb/template/postrm.m4
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
#!/bin/sh
#

set -e # fail on any error
set -e

case "$1" in
purge)
ifelse(M4_COMPANY_NAME, ONLYOFFICE,
rm -fr /home/*/.local/share/M4_DESKTOPEDITORS_PREFIX
rm -fr /home/*/.config/onlyoffice/DesktopEditors.conf,
rm -fr /home/*/.local/share/M4_PACKAGE_NAME
if [ -f /etc/astra_version ] && [ -f /etc/X11/trusted ]; then
sed -i '\|/opt/M4_DESKTOPEDITORS_PREFIX/DesktopEditors|d' /etc/X11/trusted
fi)
;;

remove)
ifelse(M4_COMPANY_NAME, ONLYOFFICE,:,
if [ -f /etc/astra_version ] && [ -f /etc/X11/trusted ]; then
sed -i '\|/opt/M4_DESKTOPEDITORS_PREFIX/DesktopEditors|d' /etc/X11/trusted
fi)
;;

upgrade|failed-upgrade|disappear|abort-install|abort-upgrade)
:
;;

*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
purge)
rm -fr /home/*/.local/share/M4_DESKTOPEDITORS_PREFIX
rm -fr /home/*/.config/M4_COMPANY_NAME/DesktopEditors.conf
;;

remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;

*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
34 changes: 0 additions & 34 deletions win-linux/package/linux/deb/template/prerm.m4

This file was deleted.

90 changes: 3 additions & 87 deletions win-linux/package/linux/rpm/common.spec
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ rm -rf "%{buildroot}"
%attr(-, root, root) /opt/*
%attr(-, root, root) %{_datadir}/applications/*
%attr(-, root, root) %{_datadir}/doc/*
%attr(-, root, root) %{_datadir}/icons/*
%attr(-, root, root) %{_datadir}/licenses/*
%attr(-, root, root) %{_datadir}/mime/*
%attr(755, root, root) %{_bindir}/%{_desktopeditors_exec}
%if "%{_company_name}" == "ONLYOFFICE"
%attr(-, root, root) %{_bindir}/desktopeditors
Expand All @@ -73,93 +76,6 @@ rm -rf "%{buildroot}"
/opt/%{_desktopeditors_prefix}/editors/web-apps/apps/*/main/resources/help
%endif

%pre

%post

set -e # fail on any error
set -u # treat unset variable as errors

# 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
exit 1
fi
for icon in "/opt/%{_desktopeditors_prefix}/asc-de-"*.png; do
size="${icon##*/asc-de-}"
if [ $1 == 2 ];then #upgrade (not install)
"$XDG_ICON_RESOURCE" uninstall --size "${size%.png}" "%{_package_name}"
fi
"$XDG_ICON_RESOURCE" install --size "${size%.png}" "$icon" "%{_package_name}"
done

UPDATE_MENUS="`which update-menus 2> /dev/null || true`"
if [ -x "$UPDATE_MENUS" ]; then
update-menus
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

%preun

set -e

action="$1"
if [ "$2" = "in-favour" ]; then
# Treat conflict remove as an upgrade.
action="upgrade"
fi
# Don't clean-up just for an upgrade.`
if [ "$action" = "upgrade" ] ; then
exit 0
fi

# Remove icons from the system icons
if [ $1 == 0 ];then #uninstall (not upgrade)
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
exit 1
fi
for icon in "/opt/%{_desktopeditors_prefix}/asc-de-"*.png; do
size="${icon##*/asc-de-}"
"$XDG_ICON_RESOURCE" uninstall --size "${size%.png}" "%{_package_name}"
done
fi

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

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

%postun

set -e # fail on any error

%posttrans

#for compatibility with old RPMs
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
exit 1
fi
for icon in "/opt/%{_desktopeditors_prefix}/asc-de-"*.png; do
size="${icon##*/asc-de-}"
"$XDG_ICON_RESOURCE" install --size "${size%.png}" "$icon" "%{_package_name}"
done

%changelog

%include ../build/main/usr/share/doc/%{_package_name}/ChangeLog

0 comments on commit 0cf8f92

Please sign in to comment.