aboutsummaryrefslogtreecommitdiff
path: root/sbopkglint.d/35-desktop.t.sh
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2022-04-04 14:07:14 -0400
committerB. Watson <yalhcru@gmail.com>2022-04-04 14:07:14 -0400
commit533599f74e56dc42bdac215e2d152f9769b6b56e (patch)
tree9a8d349d138937a7c2880589ae16078b68f4009e /sbopkglint.d/35-desktop.t.sh
downloadsbo-maintainer-tools-533599f74e56dc42bdac215e2d152f9769b6b56e.tar.gz
initial commit
Diffstat (limited to 'sbopkglint.d/35-desktop.t.sh')
-rw-r--r--sbopkglint.d/35-desktop.t.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/sbopkglint.d/35-desktop.t.sh b/sbopkglint.d/35-desktop.t.sh
new file mode 100644
index 0000000..9650ef4
--- /dev/null
+++ b/sbopkglint.d/35-desktop.t.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# sbopkglint test, must be sourced by sbopkglint (not run standalone).
+
+# PKG, PRGNAM, VERSION, ARCH are set by sbopkglint. also the current
+# directory is the root of the installed package tree.
+
+#######################################################################
+# if the package contains any files in /usr/share/applications/, they
+# must be named *.desktop, must pass desktop-file-validate, and must
+# be mode 644, owner root:root.
+
+BADPERMS=""
+BADDESKTOP=""
+NONDESKTOP=""
+if [ -d usr/share/applications ]; then
+ # doinst.sh creates this, don't check here now that we have a doinst test.
+ #[ -e "usr/share/applications/mimeinfo.cache" ] || warn "doinst.sh is missing update-desktop-database"
+
+ for f in usr/share/applications/*; do
+ [ -e "$f" ] || continue
+
+ [ "$f" = "usr/share/applications/mimeinfo.cache" ] && continue
+
+ [ "$( stat -Lc '%a %U %G' "$f" )" = "644 root root" ] || BADPERMS+="$f "
+ case "$f" in
+ *.desktop) desktop-file-validate "$f" || BADDESKTOP+="$f " ;;
+ *) NONDESKTOP+="$f " ;;
+ esac
+ done
+
+ [ -n "$BADPERMS" ] && warn "bad permissions/owner on .desktop files (should be 0644 root:root):" && ls -ld $BADPERMS
+ [ -n "$BADDESKTOP" ] && warn ".desktop files fail to validate:" && ls -ld $BADDESKTOP
+ [ -n "$NONDESKTOP" ] && warn "unknown file (not .desktop) in desktop dir:" && ls -ld $NONDESKTOP
+fi