Skip to content

Commit

Permalink
postinst-qa-check.d: fix [[ ${files[@]} ]] logic in for loops
Browse files Browse the repository at this point in the history
Use a separate all_files array to accumulate the results
from all loops, so that [[ ${files[@]} ]] only checks for
files found during the current loop.
  • Loading branch information
zmedico committed Sep 19, 2017
1 parent 1f10eb7 commit 4677a3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 5 additions & 4 deletions bin/postinst-qa-check.d/50gnome2-utils
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# check for missing calls to gnome2-utils regen functions

gnome2_icon_cache_check() {
local d f files=() find_args
local d f all_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=(
local files=() find_args=(
# gtk-update-icon-cache supports only specific file
# suffixes; match that to avoid false positives
'(' -name '*.png' -o -name '*.svg'
Expand All @@ -27,15 +27,16 @@ gnome2_icon_cache_check() {
# (note: yes, it will eagerly repeat the update for next dirs
# but that's a minor issue)
if [[ ${files[@]} ]]; then
all_files+=("${files[@]}")
addwrite "${d}"
gtk-update-icon-cache -qf "${d}"
fi
done

if [[ ${files[@]} ]]; then
if [[ ${all_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[@]/#//}"
eqatag -v gnome2-utils.icon-cache "${all_files[@]/#//}"
eqawarn "Please make sure to call gnome2_icon_cache_update()"
eqawarn "in pkg_postinst() and pkg_postrm() phases of appropriate pkgs."
fi
Expand Down
14 changes: 8 additions & 6 deletions bin/postinst-qa-check.d/50xdg-utils
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ xdg_desktop_database_check() {
for d in usr/share/applications; do
[[ -d ${d} ]] || continue

find_args=()
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 ]] &&
Expand All @@ -23,15 +23,16 @@ xdg_desktop_database_check() {
# (note: yes, it will eagerly repeat the update for next dirs
# but it's a minor issue and we have only one dir anyway)
if [[ ${files[@]} ]]; then
all_files+=("${files[@]}")
addwrite "${d}"
update-desktop-database "${d}"
fi
done

if [[ ${files[@]} ]]; then
if [[ ${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 "${files[@]/#//}"
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
Expand All @@ -42,7 +43,7 @@ xdg_mimeinfo_database_check() {
for d in usr/share/mime; do
[[ -d ${d} ]] || continue

find_args=()
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 ]] &&
Expand All @@ -57,15 +58,16 @@ xdg_mimeinfo_database_check() {
# (note: yes, it will eagerly repeat the update for next dirs
# but it's a minor issue and we have only one dir anyway)
if [[ ${files[@]} ]]; then
all_files+=("${files[@]}")
addwrite "${d}"
update-mime-database "${d}"
fi
done

if [[ ${files[@]} ]]; then
if [[ ${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 "${files[@]/#//}"
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
Expand Down

0 comments on commit 4677a3b

Please sign in to comment.