[chocolate-doom] 01/02: chocolate-update-menus: search paths

Jonathan Dowland jmtd at moszumanska.debian.org
Mon Jan 23 17:52:58 UTC 2017


This is an automated email from the git hooks/post-receive script.

jmtd pushed a commit to branch chocolate-update-menus
in repository chocolate-doom.

commit b56f0731aae60bd66b103b7d1c0c046f01570312
Author: Jonathan Dowland <jmtd at debian.org>
Date:   Mon Jan 23 16:15:27 2017 +0000

    chocolate-update-menus: search paths
    
    Expand chocolate-update-menus to look in multiple places for IWADs,
    following the upstream search logic (but excluding runtime-specific
    things like $PWD, $DOOMWADPATH etc.)
    
    Check for IWADs case insensitively
    
    Adjustments for if the script is ran as root (to operate system wide)
    or as a user (to search for IWADS and operate on .desktop files within
    ~/.local/share etc.)
---
 debian/chocolate-update-menus | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/debian/chocolate-update-menus b/debian/chocolate-update-menus
index 9c90de6..142fa63 100755
--- a/debian/chocolate-update-menus
+++ b/debian/chocolate-update-menus
@@ -1,24 +1,36 @@
 #!/bin/bash
 set -euo pipefail
+shopt -s nocaseglob
 # chocolate-update-menus: copy/rm application files into/out of place
 # if the corresponding required IWADs are present or absent
 
 # heretic only so far
 
 src=/usr/share/chocolate-doom/applications
-# XXX: if not uid=0 (or not -d/-w), use XDG_.._DIR / ~/.config.. ?
 dst=/usr/share/applications
+# For this purpose we do not inspect $DOOMWADDIR, $DOOMWADPATH or $PWD
+paths=("/usr/local/share/games/doom" "/usr/share/games/doom")
+
+if [[ $EUID -ne 0 ]]; then
+    prefix="${XDG_DATA_HOME-$HOME/.local/share}"
+    dst="$prefix/applications"
+    paths=("$prefix/games/doom" "${paths[@]}")
+fi
 
 name=chocolate-heretic.desktop
 
-# XXX: check all case variations
-# XXX: check other paths according to chocolate-* iwad search logic
-#      (different if UID!=0)
-if [ -f /usr/share/games/doom/heretic.wad ]; then
-    cp "$src/$name" "$dst"
-else
-    # XXX: ensure not locally modified first
-    if [ -f "$dst/$name" ]; then
-        rm "$dst/$name"
-    fi
+for path in "${paths[@]}"; do
+    # glob either expands to any case (heretic.wad, HERETIC.WAD, etc.) or doesn't expand
+    for wad in "$path/heretic.wad"*; do
+        if [ -f "$wad" ]; then
+            mkdir -p "$dst"
+            cp "$src/$name" "$dst"
+            exit 0
+        fi
+        break
+    done
+done
+# XXX: ensure not locally modified first
+if [ -f "$dst/$name" ]; then
+    rm "$dst/$name"
 fi

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/chocolate-doom.git



More information about the Pkg-games-commits mailing list