-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install-qa-check.d: migrate xdg-utils checks over from preinst/postin…
…st to ${D} It's practically criminal to run these at merge time instead of src_install time. It disproportionately affects binpkg consumers, because it applies to the entirety of ROOT. We actually don't want to do... basically any of this. It's not even accurate because we are heavily reliant on mtime of installed files to check whether the commands were actually run. What we actually want to do is significantly simpler: every package that installs specific files to ${D} has to also inherit an eclass and run a function in pkg_postinst. We can check for inherits quite trivially, and warn about those. We can also slightly less efficiently check the contents of pkg_* functions to see if they make certain calls; bash can print the function contents and we can grep for that. It doesn't catch cases where a custom eclass runs the xdg functions, but we manually include those in our matching.
- Loading branch information
1 parent
a28a0fd
commit 659dc0e
Showing
3 changed files
with
107 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.