Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install-qa-check.d: migrate xdg-utils checks over from preinst/postinst to ${D} #1362

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions bin/install-qa-check.d/50xdg-utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Check for missing calls to xdg-utils regen functions

xdg_desktop_database_check() {
local d f all_files=() missing
for d in usr/share/applications; do
[[ -d ${d} ]] || continue

# Look for any .desktop files that have any mime types defined
while read -r -d $'\0' f; do
all_files+=( "${f}" )
done < <(find "${d}" -name '*.desktop' \
-exec grep -lZi '^MimeType=' {} +)
done

if [[ -z ${all_files[@]} ]]; then
:
elif ! has xdg-utils ${INHERITED}; then
missing='xdg-utils was not inherited'
elif ! declare -f pkg_postinst | grep -q -E '(xdg_desktop_database_update|(ecm|gnome|java-vm-2|xdg)_pkg_postinst)'; then
missing='xdg-utils was not used'
elif ! declare -f pkg_postrm | grep -q -E '(xdg_desktop_database_update|(ecm|gnome|java-vm-2|xdg)_pkg_postrm)'; then
missing='xdg-utils was not used'
fi

if [[ ${missing} && ${all_files[@]} ]]; then
eqawarn "QA Notice: .desktop files with MimeType= were found installed"
eqawarn "but ${missing}:"
eqatag -v xdg-utils.desktop "${all_files[@]/#//}"
eqawarn "Please make sure to call xdg_desktop_database_update()"
eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs."
fi
}

xdg_icon_cache_check() {
local d f all_files=() missing
for d in usr/share/icons/*/; do
local find_args=(
# gtk-update-icon-cache supports only specific file
# suffixes; match that to avoid false positives
'(' -name '*.png' -o -name '*.svg'
-o -name '*.xpm' -o -name '*.icon' ')'
)

# (use -mindepth 2 to easily skip the cache files)
while read -r -d $'\0' f; do
all_files+=( "${f}" )
done < <(find "${d}" -mindepth 2 -type f "${find_args[@]}" -print0)
done

if [[ -z ${all_files[@]} ]]; then
:
elif ! has xdg-utils ${INHERITED}; then
missing='xdg-utils was not inherited'
elif ! declare -f pkg_postinst | grep -q -E '(xdg_icon_cache_update|(ecm|gnome|xdg)_pkg_postinst)'; then
missing='xdg-utils was not used'
elif ! declare -f pkg_postrm | grep -q -E '(xdg_icon_cache_update|(ecm|gnome|xdg)_pkg_postrm)'; then
missing='xdg-utils was not used'
fi

if [[ ${missing} ]]; then
eqawarn "QA Notice: new icons were found installed but ${missing}:"
eqatag -v xdg-utils.icon-cache "${all_files[@]/#//}"
eqawarn "Please make sure to call xdg_icon_cache_update()"
eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs."
fi
}

xdg_mimeinfo_database_check() {
local d f all_files=() missing
for d in usr/share/mime; do
[[ -d ${d} ]] || continue

while read -r -d $'\0' f; do
all_files+=( "${f}" )
done < <(find "${d}" -name '*.xml' -print0)
done

if [[ -z ${all_files[@]} ]]; then
:
elif ! has xdg-utils ${INHERITED}; then
missing='xdg-utils was not inherited'
elif ! declare -f pkg_postinst | grep -q -E '(xdg_mimeinfo_database_update|(ecm|gnome|xdg)_pkg_postinst)'; then
missing='xdg-utils was not used'
elif ! declare -f pkg_postrm | grep -q -E '(xdg_mimeinfo_database_update|(ecm|gnome|xdg)_pkg_postrm)'; then
missing='xdg-utils was not used'
fi

if [[ ${missing} && ${all_files[@]} ]]; then
eqawarn "QA Notice: mime-info files were found installed but"
eqawarn "${missing}:"
eqatag -v xdg-utils.mime-info "${all_files[@]/#//}"
eqawarn "Please make sure to call xdg_mimeinfo_database_update()"
eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs."
fi
}

xdg_utils_postinst_check() {
cd "${D}" || die
xdg_desktop_database_check
xdg_icon_cache_check
xdg_mimeinfo_database_check
}

xdg_utils_postinst_check
: # guarantee successful exit

# vim:ft=sh
156 changes: 0 additions & 156 deletions bin/postinst-qa-check.d/50xdg-utils

This file was deleted.

1 change: 0 additions & 1 deletion bin/preinst-qa-check.d/50xdg-utils

This file was deleted.