From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 43CF51396D0 for ; Tue, 15 Aug 2017 10:32:19 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 303AFE0E98; Tue, 15 Aug 2017 10:32:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EF1D9E0E92 for ; Tue, 15 Aug 2017 10:32:13 +0000 (UTC) Received: from localhost.localdomain (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 63FFC341772; Tue, 15 Aug 2017 10:32:12 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-portage-dev] [PATCH 2/2] Add post-postinst checks for a few missed cache updates Date: Tue, 15 Aug 2017 12:32:00 +0200 Message-Id: <20170815103200.15680-2-mgorny@gentoo.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170815103200.15680-1-mgorny@gentoo.org> References: <20170815103200.15680-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 4ba0fbe3-0e7f-4980-aef6-96619a0a25b6 X-Archives-Hash: af1beb768eeef43334fadb0704d59c13 Add postinst-qa-check.d checks for missed desktop, mime-info and GTK+ icon cache updates. In all of the cases the checks simply look for any installed files that are newer than the cache. This check has some limitations: it assumes that mtime is not preserved when copying files to D, it can't distinguish whether the files were installed by the current package (it reports all new files since the last cache update) and it can't distinguish between the update on postinst and postrm. However, it's certainly a step forward and will help find a few bugs. --- bin/postinst-qa-check.d/50gnome2-utils | 38 ++++++++++++++++++++ bin/postinst-qa-check.d/50xdg-utils | 65 ++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 bin/postinst-qa-check.d/50gnome2-utils create mode 100644 bin/postinst-qa-check.d/50xdg-utils diff --git a/bin/postinst-qa-check.d/50gnome2-utils b/bin/postinst-qa-check.d/50gnome2-utils new file mode 100644 index 000000000..68e21cb74 --- /dev/null +++ b/bin/postinst-qa-check.d/50gnome2-utils @@ -0,0 +1,38 @@ +# check for missing calls to gnome2-utils regen functions + +gnome2_icon_cache_check() { + local d f files=() find_args + for d in usr/share/icons/*/; do + # gnome2_icon_cache_update updates only themes with an index + [[ -f ${d}/index.theme ]] || continue + + 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}/icon-theme.cache ]] && + find_args+=( -newer "${d}"/icon-theme.cache ) + + # (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) + done + + if [[ ${files[@]} ]]; then + eqawarn "QA Notice: new icons were found installed but GTK+ icon cache" + eqawarn "has not been updated:" + eqatag -v gnome2-utils.icon-cache "${files[@]/#//}" + eqawarn "Please make sure to call gnome2_icon_cache_update()" + eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs." + fi +} + +gnome2_utils_postinst_check() { + cd "${EROOT}" || die + gnome2_icon_cache_check +} + +gnome2_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 new file mode 100644 index 000000000..4bc7bee9a --- /dev/null +++ b/bin/postinst-qa-check.d/50xdg-utils @@ -0,0 +1,65 @@ +# check for missing calls to xdg-utils regen functions + +xdg_desktop_database_check() { + local d f files=() + for d in usr/share/applications; do + [[ -d ${d} ]] || continue + + 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+=( -newer "${d}"/mimeinfo.cache ) + + # 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=' {} +) + done + + if [[ ${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 "${files[@]/#//}" + eqawarn "Please make sure to call xdg_desktop_database_update()" + eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs." + fi +} + +xdg_mimeinfo_database_check() { + local d f files=() + for d in usr/share/mime; do + [[ -d ${d} ]] || continue + + 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+=( -newer "${d}"/mime.cache ) + + while read -r -d $'\0' f; do + files+=( "${f}" ) + done < <(find "${d}" -name '*.xml' "${find_args[@]}" -print0) + done + + if [[ ${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 "${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_mimeinfo_database_check +} + +xdg_utils_postinst_check +: # guarantee successful exit + +# vim:ft=sh -- 2.14.1