diff --git a/bin/install-qa-check.d/50xdg-utils b/bin/install-qa-check.d/50xdg-utils new file mode 100644 index 0000000000..3e0537f35a --- /dev/null +++ b/bin/install-qa-check.d/50xdg-utils @@ -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 diff --git a/bin/postinst-qa-check.d/50xdg-utils b/bin/postinst-qa-check.d/50xdg-utils deleted file mode 100644 index 2951ae05c6..0000000000 --- a/bin/postinst-qa-check.d/50xdg-utils +++ /dev/null @@ -1,156 +0,0 @@ -# Check for missing calls to xdg-utils regen functions - -xdg_desktop_database_check() { - type -P update-desktop-database &>/dev/null || return - - local d f all_files=() missing - for d in usr/share/applications; do - [[ -d ${d} ]] || continue - - local files=() find_args=() - # If the cache does not exist at all, we complain for any file - # otherwise, we look for files newer than the cache - [[ -f ${d}/mimeinfo.cache ]] && - find_args+=( -newercm "${d}"/mimeinfo.cache ) || missing=1 - - # Look for any .desktop files that are newer than the cache - # and that have any mime types defined - while read -r -d $'\0' f; do - files+=( "${f}" ) - done < <(find "${d}" -name '*.desktop' "${find_args[@]}" \ - -exec grep -lZi '^MimeType=' {} +) - - # If any files were found, update the db to avoid repeating - # the warning for subsequent packages - if [[ ${files[@]} ]]; then - all_files+=("${files[@]}") - addwrite "${d}" - update-desktop-database "${d}" - fi - done - - # Preinst initializes the baseline state for the posinst check - [[ ${PORTAGE_QA_PHASE} == preinst ]] && return - - # Parallel-install makes it impossible to blame a specific package - has parallel-install ${FEATURES} && return - - # The eqatag call is prohibitively expensive if the cache is - # missing and there are a large number of files. - if [[ -z ${missing} && ${all_files[@]} ]]; then - eqawarn "QA Notice: .desktop files with MimeType= were found installed" - eqawarn "but desktop mimeinfo cache has not been updated:" - 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() { - type -P gtk-update-icon-cache &>/dev/null || return - - local d f all_files=() missing - for d in usr/share/icons/*/; do - # xdg_icon_cache_update updates only themes with an index - [[ -f ${d}/index.theme ]] || continue - - local files=() 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' ')' - ) - - # If the cache does not exist at all, we complain for any file - # otherwise, we look for files newer than the cache - [[ -f ${d}/icon-theme.cache ]] && - find_args+=( -newercm "${d}"/icon-theme.cache ) || missing=1 - - # (use -mindepth 2 to easily skip the cache files) - while read -r -d $'\0' f; do - files+=( "${f}" ) - done < <(find "${d}" -mindepth 2 -type f "${find_args[@]}" -print0) - - # If any files were found, update the db to avoid repeating - # the warning for subsequent packages - if [[ ${files[@]} ]]; then - all_files+=("${files[@]}") - addwrite "${d}" - gtk-update-icon-cache -qf "${d}" - fi - done - - # preinst initializes the baseline state for the posinst check - [[ ${PORTAGE_QA_PHASE} == preinst ]] && return - - # parallel-install makes it impossible to blame a specific package - has parallel-install ${FEATURES} && return - - # Avoid false-positives on first install (bug #649464) - [[ ${PN} == gtk-update-icon-cache ]] && return - - # The eqatag call is prohibitively expensive if the cache is - # missing and there are a large number of files. - if [[ -z ${missing} && ${all_files[@]} ]]; then - eqawarn "QA Notice: new icons were found installed but icon cache" - eqawarn "has not been updated:" - 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() { - type -P update-mime-database &>/dev/null || return - - local d f all_files=() missing - for d in usr/share/mime; do - [[ -d ${d} ]] || continue - - local files=() find_args=() - # If the cache does not exist at all, we complain for any file - # otherwise, we look for files newer than the cache - [[ -f ${d}/mime.cache ]] && - find_args+=( -newercm "${d}"/mime.cache ) || missing=1 - - while read -r -d $'\0' f; do - files+=( "${f}" ) - done < <(find "${d}" -name '*.xml' "${find_args[@]}" -print0) - - # if any files were found, update the db to avoid repeating - # the warning for subsequent packages - if [[ ${files[@]} ]]; then - all_files+=("${files[@]}") - addwrite "${d}" - update-mime-database "${d}" - fi - done - - # preinst initializes the baseline state for the posinst check - [[ ${PORTAGE_QA_PHASE} == preinst ]] && return - - # parallel-install makes it impossible to blame a specific package - has parallel-install ${FEATURES} && return - - # The eqatag call is prohibitively expensive if the cache is - # missing and there are a large number of files. - if [[ -z ${missing} && ${all_files[@]} ]]; then - eqawarn "QA Notice: mime-info files were found installed but mime-info" - eqawarn "cache has not been updated:" - 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 "${EROOT:-/}" || die - xdg_desktop_database_check - xdg_icon_cache_check - xdg_mimeinfo_database_check -} - -xdg_utils_postinst_check -: # guarantee successful exit - -# vim:ft=sh diff --git a/bin/preinst-qa-check.d/50xdg-utils b/bin/preinst-qa-check.d/50xdg-utils deleted file mode 120000 index 16f68a471d..0000000000 --- a/bin/preinst-qa-check.d/50xdg-utils +++ /dev/null @@ -1 +0,0 @@ -../postinst-qa-check.d/50xdg-utils \ No newline at end of file