|
| 1 | +# Check for missing calls to xdg-utils regen functions |
| 2 | + |
| 3 | +xdg_desktop_database_check() { |
| 4 | + local d f all_files=() missing |
| 5 | + for d in usr/share/applications; do |
| 6 | + [[ -d ${d} ]] || continue |
| 7 | + |
| 8 | + # Look for any .desktop files that have any mime types defined |
| 9 | + while read -r -d $'\0' f; do |
| 10 | + all_files+=( "${f}" ) |
| 11 | + done < <(find "${d}" -name '*.desktop' \ |
| 12 | + -exec grep -lZi '^MimeType=' {} +) |
| 13 | + done |
| 14 | + |
| 15 | + if [[ -z ${all_files[@]} ]]; then |
| 16 | + : |
| 17 | + elif ! has xdg-utils ${INHERITED}; then |
| 18 | + missing='xdg-utils was not inherited' |
| 19 | + elif ! declare -f pkg_postinst | grep -q -E '(xdg_desktop_database_update|(ecm|gnome|java-vm-2|xdg)_pkg_postinst)'; then |
| 20 | + missing='xdg-utils was not used' |
| 21 | + elif ! declare -f pkg_postrm | grep -q -E '(xdg_desktop_database_update|(ecm|gnome|java-vm-2|xdg)_pkg_postrm)'; then |
| 22 | + missing='xdg-utils was not used' |
| 23 | + fi |
| 24 | + |
| 25 | + if [[ ${missing} && ${all_files[@]} ]]; then |
| 26 | + eqawarn "QA Notice: .desktop files with MimeType= were found installed" |
| 27 | + eqawarn "but ${missing}:" |
| 28 | + eqatag -v xdg-utils.desktop "${all_files[@]/#//}" |
| 29 | + eqawarn "Please make sure to call xdg_desktop_database_update()" |
| 30 | + eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs." |
| 31 | + fi |
| 32 | +} |
| 33 | + |
| 34 | +xdg_icon_cache_check() { |
| 35 | + local d f all_files=() missing |
| 36 | + for d in usr/share/icons/*/; do |
| 37 | + local find_args=( |
| 38 | + # gtk-update-icon-cache supports only specific file |
| 39 | + # suffixes; match that to avoid false positives |
| 40 | + '(' -name '*.png' -o -name '*.svg' |
| 41 | + -o -name '*.xpm' -o -name '*.icon' ')' |
| 42 | + ) |
| 43 | + |
| 44 | + # (use -mindepth 2 to easily skip the cache files) |
| 45 | + while read -r -d $'\0' f; do |
| 46 | + all_files+=( "${f}" ) |
| 47 | + done < <(find "${d}" -mindepth 2 -type f "${find_args[@]}" -print0) |
| 48 | + done |
| 49 | + |
| 50 | + if [[ -z ${all_files[@]} ]]; then |
| 51 | + : |
| 52 | + elif ! has xdg-utils ${INHERITED}; then |
| 53 | + missing='xdg-utils was not inherited' |
| 54 | + elif ! declare -f pkg_postinst | grep -q -E '(xdg_icon_cache_update|(ecm|gnome|xdg)_pkg_postinst)'; then |
| 55 | + missing='xdg-utils was not used' |
| 56 | + elif ! declare -f pkg_postrm | grep -q -E '(xdg_icon_cache_update|(ecm|gnome|xdg)_pkg_postrm)'; then |
| 57 | + missing='xdg-utils was not used' |
| 58 | + fi |
| 59 | + |
| 60 | + if [[ ${missing} ]]; then |
| 61 | + eqawarn "QA Notice: new icons were found installed but ${missing}:" |
| 62 | + eqatag -v xdg-utils.icon-cache "${all_files[@]/#//}" |
| 63 | + eqawarn "Please make sure to call xdg_icon_cache_update()" |
| 64 | + eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs." |
| 65 | + fi |
| 66 | +} |
| 67 | + |
| 68 | +xdg_mimeinfo_database_check() { |
| 69 | + local d f all_files=() missing |
| 70 | + for d in usr/share/mime; do |
| 71 | + [[ -d ${d} ]] || continue |
| 72 | + |
| 73 | + while read -r -d $'\0' f; do |
| 74 | + all_files+=( "${f}" ) |
| 75 | + done < <(find "${d}" -name '*.xml' -print0) |
| 76 | + done |
| 77 | + |
| 78 | + if [[ -z ${all_files[@]} ]]; then |
| 79 | + : |
| 80 | + elif ! has xdg-utils ${INHERITED}; then |
| 81 | + missing='xdg-utils was not inherited' |
| 82 | + elif ! declare -f pkg_postinst | grep -q -E '(xdg_mimeinfo_database_update|(ecm|gnome|xdg)_pkg_postinst)'; then |
| 83 | + missing='xdg-utils was not used' |
| 84 | + elif ! declare -f pkg_postrm | grep -q -E '(xdg_mimeinfo_database_update|(ecm|gnome|xdg)_pkg_postrm)'; then |
| 85 | + missing='xdg-utils was not used' |
| 86 | + fi |
| 87 | + |
| 88 | + if [[ ${missing} && ${all_files[@]} ]]; then |
| 89 | + eqawarn "QA Notice: mime-info files were found installed but" |
| 90 | + eqawarn "${missing}:" |
| 91 | + eqatag -v xdg-utils.mime-info "${all_files[@]/#//}" |
| 92 | + eqawarn "Please make sure to call xdg_mimeinfo_database_update()" |
| 93 | + eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs." |
| 94 | + fi |
| 95 | +} |
| 96 | + |
| 97 | +xdg_utils_postinst_check() { |
| 98 | + cd "${D}" || die |
| 99 | + xdg_desktop_database_check |
| 100 | + xdg_icon_cache_check |
| 101 | + xdg_mimeinfo_database_check |
| 102 | +} |
| 103 | + |
| 104 | +xdg_utils_postinst_check |
| 105 | +: # guarantee successful exit |
| 106 | + |
| 107 | +# vim:ft=sh |
0 commit comments