[debian-edu-commits] debian-edu/ 139/183: Don't special case UDEdir in update-profile-cache, special case it when filling in the current variables instead (reduces linecount slightly, and makes it easier to read)

Alexander Alemayhu ccscanf-guest at moszumanska.debian.org
Wed Jun 11 16:48:41 UTC 2014


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

ccscanf-guest pushed a commit to branch master
in repository desktop-profiles.

commit f6b401a694bc20ac9e5423bce643b2d1fea302b1
Author: Bart Cornelis <cobaco at linux.be>
Date:   Tue Apr 17 18:16:18 2007 +0000

    Don't special case UDEdir in update-profile-cache, special case it when
    filling in the current variables instead
    (reduces linecount slightly, and makes it easier to read)
---
 20desktop-profiles_activateDesktopProfiles | 18 ++++++-----------
 TODO                                       |  1 -
 update-profile-cache                       | 31 ++++++++++++++++--------------
 3 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/20desktop-profiles_activateDesktopProfiles b/20desktop-profiles_activateDesktopProfiles
index cd3a953..70a8879 100644
--- a/20desktop-profiles_activateDesktopProfiles
+++ b/20desktop-profiles_activateDesktopProfiles
@@ -361,15 +361,12 @@ if (test $INSTALLED = true); then
     ############################################################
     # Actual activation of profiles
     ############################################################
+    # if we have a cache and it's up-to-date -> use it
     if (test -r "$CACHE_FILE") &&
        (test $(ls -t -1 /etc/desktop-profiles/*.listing \
                         /etc/default/desktop-profiles \
                         "$CACHE_FILE" 2> /dev/null | \
 	       head -1) = "$CACHE_FILE"); then
-    # if we have a cache and it's up-to-date -> use it
-      # save UDEdir contents, as we might need it, then unset that var
-      UDEdir_current=$UDEdir; unset UDEdir;
-  
       # export the variable settings in the cache file after replacing 
       # the placeholders for the current variable values with said values 
       # (the location of placeholders is based on the active personalitytype)
@@ -377,17 +374,14 @@ if (test $INSTALLED = true); then
                             -e "s|\\\$XDG_CONFIG_DIRS|$XDG_CONFIG_DIRS|" \
                             -e "s|\\\$XDG_DATA_DIRS|$XDG_DATA_DIRS|" \
                             -e "s|\\\$CHOICESPATH|$CHOICESPATH|" \
-                            -e "s|\\\$GNUSTEP_PATHLIST|$GNUSTEP_PATHLIST|");
+                            -e "s|\\\$GNUSTEP_PATHLIST|$GNUSTEP_PATHLIST|" \
+			    -e "s|\\\$UDEdir|$UDEdir|" );
     
-      # set UDEdir based on cache content, personality type and current value
-      case "$PERSONALITY" in 
-        autocrat) ;; #leave as defined in cache 
-        rude) if(test "$UDEdir"x = x);then export UDEdir="$UDEdir_current";fi ;;
-        polite | *) export UDEdir="$UDEdir_current" ;;
-      esac;  
-    elif (test "$ACTIVE_PROFILE_KINDS"x != "x"); then
+      # UDEdir only holds 1 dir, so drop every dir except the first nonempty one
+      export UDEdir=$(echo $UDEdir | sed 's|^:||' | cut --fields 1 --delimiter ":");
     # else if we have any profile kinds we're interested in, then go 
     # calculate the profile assignments
+    elif (test "$ACTIVE_PROFILE_KINDS"x != "x"); then
       # add trap to ensure we don't leave any tempfiles behind 
       trap general_trap HUP INT TERM;
       # get temp file
diff --git a/TODO b/TODO
index 29923f1..c62ba06 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,2 @@
-- adapt manpage to reflect PERSONALITY setting
 - further improve performance (cache in non-simple case?)
 - build usefull (example) profiles and point to them in docu (for accessibility?)
diff --git a/update-profile-cache b/update-profile-cache
index 4e162c0..76d70de 100755
--- a/update-profile-cache
+++ b/update-profile-cache
@@ -22,9 +22,9 @@
   CACHE_DIR=${CACHE_DIR:-'/var/cache/desktop-profiles'}
   CACHE_FILE="$CACHE_DIR/activated_profiles"
 
-##################  
-# set $CACHE_TYPE  
-##################
+##############################################  
+# Check wether generating a cache makes sense  
+##############################################
   # if is true when there's at least 1 non-deactivated profile with a 
   # group or command requirment
   # (a group or command requirement means at least 1 character in the 
@@ -37,13 +37,13 @@
     CACHE_TYPE=static
   fi;
 
-#######################
-# generate $CACHE_FILE
-#######################
+###########################################
+# generate $CACHE_FILE if that makes sense
+###########################################
   if (test "$CACHE_TYPE" = static); then
     #if:
-    # - cache doesn't exist yet
-    # - last modification time of any metadata file is newer then of the cache
+    # - cache doesn't exist yet or
+    # - last modification time of any metadata file is newer then the cache
     if !(test -e "$CACHE_FILE") ||
        !(test $(ls -t -1 /etc/desktop-profiles/*.listing \
                          /etc/default/desktop-profiles \
@@ -53,10 +53,11 @@
       # delete old cache (otherwise activateDesktopProfiles reuses it)
       rm -f "$CACHE_FILE";
 
-      # regenerate the cache, making sure we only use the metadata files,
-      # adding contents of set variables is done when using the cache 
+      # make sure we only use the metadata files 
       KDEDIRS='';XDG_CONFIG_DIRS='';XDG_DATA_DIRS='';CHOICESPATH='';
       GNUSTEP_PATHLIST='';UDEdir='';
+
+      # generate profile settings
       . /etc/X11/Xsession.d/20desktop-profiles_activateDesktopProfiles;
 
       # move generated path files to cache dir, and set env vars accordingly
@@ -79,11 +80,12 @@
 	DEFAULTS_PATH="$CACHE_DIR/defaults.path";
       fi;	
 
-      # fill $CACHE_FILE
+      # save profile settings to $CACHE_FILE
       mkdir -p "$CACHE_DIR";
       env | grep 'KDEDIRS\|XDG_CONFIG_DIRS\|XDG_DATA_DIRS\|CHOICESPATH\|UDEdir\|GNUSTEP_PATHLIST\|MANDATORY_PATH\|DEFAULTS_PATH' > "$CACHE_FILE";
 
       # Add markers for env variables according to personality type
+      # markers will be filled in at X-start
       case "$PERSONALITY" in 
 	rude) 
 	  sed -i -e 's/^\(KDEDIRS=.*\)$/\1:$KDEDIRS/' \
@@ -91,8 +93,8 @@
 	   -e 's/^\(XDG_DATA_DIRS=.*\)$/\1:$XDG_DATA_DIRS/' \
 	   -e 's/^\(CHOICESPATH=.*\)$/\1:$CHOICESPATH/' \
 	   -e 's/^\(GNUSTEP_PATHLIST=.*\)$/\1:$GNUSTEP_PATHLIST/' \
+	   -e 's/^\(UDEdir=.*\)$/\1:$UDEdir/' \
 	   "$CACHE_FILE";
-	  #UDEdir handled in Xsession.d script as this is a single dir instead of a list
 	;;
 
 	sheep | autocrat) 
@@ -105,11 +107,12 @@
 	   -e 's/^\(XDG_DATA_DIRS=\)\(.*\)$/\1$XDG_DATA_DIRS:\2/' \
 	   -e 's/^\(CHOICESPATH=\)\(.*\)$/\1$CHOICESPATH:\2/' \
 	   -e 's/^\(GNUSTEP_PATHLIST=\)\(.*\)$/\1$GNUSTEP_PATHLIST:\2/' \
+	   -e 's/^\(UDEdir=\)\(.*\)$/\1$UDEdir:\2/' \
 	   "$CACHE_FILE";
-	  #UDEdir handled in Xsession.d script as this is a single dir instead of a list
 	;;	
       esac;	
-    fi;  
+    fi;
+  # end static cache generation  
   else
     # we don't want to use the cache so make sure no old one is left behind  
     rm -f "$CACHE_FILE";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/pkg-team/desktop-profiles.git



More information about the debian-edu-commits mailing list