[debian-edu-commits] debian-edu/ 25/183: Added list-desktop-profiles script, allows the admin to easily see what profiles are present/applicable (without needing to look in all .listing files) e.g. 'list-desktop-profiles -k KDE -u <some-user> -s precedence` -> returns all KDE profiles that will be activated for <some-user> in order of precedence

Alexander Alemayhu ccscanf-guest at moszumanska.debian.org
Wed Jun 11 16:48:30 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 d677a1df9a31c0695c805a1821c0310f238783b6
Author: Bart Cornelis <cobaco at linux.be>
Date:   Thu Nov 4 20:37:50 2004 +0000

    Added list-desktop-profiles script, allows the admin to easily see what
    profiles are present/applicable (without needing to look in all .listing
    files)
      e.g.
      'list-desktop-profiles -k KDE -u <some-user> -s precedence`
      -> returns all KDE profiles that will be activated for <some-user> in
         order of precedence
    
    Split out some utility functions in a shell library so both the new script
    and the xsession.d script can use them
    
    Still need to do a manpage for the new script
---
 20desktop-profiles_activateDesktopProfiles | 158 ++++++-----------------------
 TODO                                       |  16 ++-
 debian/changelog                           |   9 +-
 debian/rules                               |   2 +
 default.listing                            |   5 +-
 5 files changed, 55 insertions(+), 135 deletions(-)

diff --git a/20desktop-profiles_activateDesktopProfiles b/20desktop-profiles_activateDesktopProfiles
index e817b75..594e587 100644
--- a/20desktop-profiles_activateDesktopProfiles
+++ b/20desktop-profiles_activateDesktopProfiles
@@ -10,138 +10,35 @@
 ###############################################################################
 
 # Where do we look for .listing files
-PROFILE_DIR="/etc/desktop-profiles";
+LISTINGS_DIR="/etc/desktop-profiles";
 
 # Where do we place the generated path file for gnome (if any)
 PROFILE_PATH_FILES_DIR="/var/cache/desktop-profiles/"
 
-######################################################################
-# $1 = requirement
-# requirement = <group>  	-> $USER is a member of <group>
-#             = !<group> 	-> $USER must not be member of group
-#             = !		-> never activate this profile
-#             = $(command)	-> command exits succesfully
-#
-# returns succesfully ($?=0) if requirement is met
-# returns 1 otherwise
-######################################################################
-test_requirement(){
-  #######################
-  # negative requirement
-  #######################
-  if (echo "$1" | grep '^!' > /dev/null) ; then
-    GROUP=`echo "$1" | sed 's/^!//'`;
-    
-    ###########################
-    # ! -> deactivated profile
-    ###########################
-    if (test "$GROUP"x = x); then
-      exit 1;
-    fi;  
-    
-    ###############################################
-    # !<group> -> $USER is not a member of <group>
-    ###############################################
-    if (groups | grep -v $GROUP > /dev/null); then
-      exit;# success
-    fi;
-
-  ######################
-  # Command requirement
-  ######################
-  elif (echo "$1" | grep '^\$(.*)' > /dev/null); then
-    COMMAND="`echo "$1" | sed -e 's/^\$(//' -e 's/)$//'`";
-    
-    sh -c "$COMMAND" > /dev/null;
-    exit $?;    
-  ####################
-  # group requirement
-  ####################
-  else
-    if (groups | grep $1 > /dev/null); then
-      exit;# success
-    fi;
-  fi;  
-
-  #########################
-  # not met if we get here
-  #########################
-  exit 1;# failure
-}
-
-##########################################################
-# filter the profiles listed in the given files $@
-# -> output only those for which the requirements are met
-##########################################################
-get_profiles_with_fulfilled_requirements () {
-  #####################
-  #for each profile do
-  #####################
-  cat $@ | grep -v ^# | while read PROFILE; do
-    PROFILE_REQUIREMENTS="`echo $PROFILE | cut --fields 4 --delimiter ";"`";
-
-    #########################################################
-    # if there are no requirements, activate the profile
-    ########################################################
-    if (test "$PROFILE_REQUIREMENTS"x = x); then
-      echo $PROFILE;
-      continue;
-    fi;
-    
-    ############################################
-    # iterate over requirements and check them 
-    ############################################
-    while (test "$PROFILE_REQUIREMENTS"x != x); do
-      #########################
-      # get first REQUIREMENT 
-      ######################### 
-      declare -i C=1;
-      REQUIREMENT=`echo $PROFILE_REQUIREMENTS | cut --fields 1 --delimiter " "`;
-
-      # if command make sure we have the whole command (with params)
-      if (echo "$REQUIREMENT" | grep "^\$(" > /dev/null); then 
-        while (echo "$REQUIREMENT" | grep -v ')$' > /dev/null); do
-	  C=C+1;
-          REQUIREMENT=`echo $PROFILE_REQUIREMENTS | cut --fields -$C --delimiter " "`;
-	done;	
-
-        # prepare loop for next iteration 
-	C=C+1;
-        PROFILE_REQUIREMENTS=`echo $PROFILE_REQUIREMENTS | cut --fields $C- --delimiter " " `;
-      else
-        # prepare loop for next iteration 
-        PROFILE_REQUIREMENTS=`echo $PROFILE_REQUIREMENTS | sed -e "s/^$REQUIREMENT//" -e "s/^ *//"`;
-      fi;
-      
-      ############################
-      # test current requirement 
-      ############################
-      if !(test_requirement "$REQUIREMENT"); then
-        continue 2;# requirment not fulfilled -> goto next profile
-      fi
-    done;
-    
-    #####################################################
-    # all requirements are met (or we wouldn't get here)
-    # so keep this profile
-    #####################################################
-    echo $PROFILE;      
-  done;
-}
+# get utility functions for working with .listing files
+LIB=/usr/share/desktop-profiles/listingmodule;
+if (test -r $LIB); then
+  . $LIB;
+else
+  echo "Shell library $LIB is missing! Aborting.";
+  exit 1;
+fi;
 
 #################################################
 # $1 = Profile-kind 
 #      (KDE, ROX, GCONF, XDG_DATA or XDG_CONFIG)
 #################################################
 get_profiles() {
-  #################
-  # order profiles
-  #################
-  get_profiles_with_fulfilled_requirements `ls $PROFILE_DIR/*.listing` | sort --reverse --general-numeric-sort --field-separator=";" --key 3 | \
+  (# get profiles that are have fulfilled requirements
+     cat `ls $LISTINGS_DIR/*.listing` | grep -v "^#" | while read PROFILE; do
+      if (test_profile_requirements "$PROFILE"); then
+        echo $PROFILE;      
+      fi;  
+    done;
+   #and sort them by preference
+  ) | sort --reverse --general-numeric-sort --field-separator=";" --key 3 | \
   while read PROFILE; do
-    ############################################################
     # output the profile-root if this is the right profile kind
-    ############################################################
     if echo -n `echo "$PROFILE" | cut --fields 5 --delimiter ";"` | grep $1 > /dev/null; then
       if (test "$1" != "GCONF"); then
         echo -n "`echo "$PROFILE" | cut --fields 2 --delimiter ";"` ";
@@ -152,34 +49,37 @@ get_profiles() {
   done;  
 }
 
-###############
-# Script Entry
-###############
+###########################################################################
+# Activate Profiles
+# -> not setting variables if they would be empty or equal to the default
+# -> not generating gconf path files if they won't be included
+###########################################################################
 #if variable empty or = default -> no need to set it
 KDEDIRS=`get_profiles KDE | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`
 if (test "$KDEDIRS"x != x) &&
-   (test "$KDEDIRS" != "`cat $PROFILE_DIR/default.listing | grep "^kde-prefix" | cut --fields 2 --delimiter ";"`"); then
+   (test "$KDEDIRS" != "`cat $LISTINGS_DIR/default.listing | grep "^kde-prefix" | cut --fields 2 --delimiter ";"`"); then
   KDEDIRS=$(sh -c "echo $KDEDIRS");# FORCE expansion of variables in KDEDIRS if any
   export KDEDIRS;
 fi;
 
 XDG_CONFIG_DIRS=`get_profiles XDG_CONFIG | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`
 if (test "$XDG_CONFIG_DIRS"x != x) &&
-   (test "$XDG_CONFIG_DIRS" != "`cat $PROFILE_DIR/default.listing | grep "^default-xdg_config_dirs" | cut --fields 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`"); then
+   (test "$XDG_CONFIG_DIRS" != "`cat $LISTINGS_DIR/default.listing | grep "^default-xdg_config_dirs" | cut --fields 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`"); then
   XDG_CONFIG_DIRS=$(sh -c "echo $XDG_CONFIG_DIRS");# FORCE expansion of variables in XDG_CONFIG_DIRS if any
   export XDG_CONFIG_DIRS;
 fi;
 
+
 XDG_DATA_DIRS=`get_profiles XDG_DATA | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`
 if (test "$XDG_DATA_DIRS"x != x) &&
-   (test "$XDG_DATA_DIRS" != "`cat $PROFILE_DIR/default.listing | grep "^default-xdg_data_dirs" | cut --fields 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`"); then
+   (test "$XDG_DATA_DIRS" != "`cat $LISTINGS_DIR/default.listing | grep "^default-xdg_data_dirs" | cut --fields 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`"); then
   XDG_DATA_DIRS=$(sh -c "echo $XDG_DATA_DIRS");# FORCE expansion of variables in XDG_DATA_DIRS if any
   export XDG_DATA_DIRS;
 fi;
 
 CHOICESPATH=`get_profiles ROX | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"`
-DEFAULT_CHOICES=$(cat $PROFILE_DIR/default.listing | grep '^default-rox-system;' | cut --field 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g")
-DEFAULT_CHOICES="$(cat $PROFILE_DIR/default.listing | grep '^default-rox-user;' | cut --field 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"):$DEFAULT_CHOICES"
+DEFAULT_CHOICES=$(cat $LISTINGS_DIR/default.listing | grep '^default-rox-system;' | cut --field 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g")
+DEFAULT_CHOICES="$(cat $LISTINGS_DIR/default.listing | grep '^default-rox-user;' | cut --field 2 --delimiter ";" | sed -e "s/^ *//" -e "s/ *$//" -e "s/ /:/g"):$DEFAULT_CHOICES"
 if (test "$CHOICESPATH"x != x) &&
    (test "$CHOICESPATH" != "$DEFAULT_CHOICES"); then
   CHOICESPATH=$(sh -c "echo $CHOICESPATH");# FORCE expansion of variables in CHOICESPATH if any
@@ -189,7 +89,7 @@ fi;
 # don't s/ /:g/ in next line, UDE doesn't currently support combining profile dirs
 UDEDIRS=`get_profiles UDE | sed -e "s/^ *//" -e "s/ *$//"`
 if (test "$UDEDIRS"x != x) &&
-   (test "$UDEDIRS" != "`cat $PROFILE_DIR/default.listing | grep "^ude-install-dir" | cut --fields 2 --delimiter ";"`"); then
+   (test "$UDEDIRS" != "`cat $LISTINGS_DIR/default.listing | grep "^ude-install-dir" | cut --fields 2 --delimiter ";"`"); then
   # Take first dir and break, as UDE currently only supports one dir
   for dir in $UDEDIRS; do 
     UDEdir=$dir;
diff --git a/TODO b/TODO
index 382ff75..820bdc6 100644
--- a/TODO
+++ b/TODO
@@ -14,8 +14,16 @@
 - Are there any docs on the kiosk system of XFCE 4.2 available anywhere we can
   point to?
 
-- Create (debconf?) Tools to help maintain/build/add profiles, profile-precedence, and
-profile requirements.
-  - change priority
-  - change requirements (deactivate, addgroup, excludegroup, commandtest)
+- Create Tools to :
+      - add/change/remove requirement (activate/deactivate)
+      - change precedence
+      - change description (if only one/ location the same)
+      - rename profile
+  move-profile 
+  -> location & kind are fixed
+
+- Tools to build (cross-desktop) profiles? (if at all possible)
+  - background
+  - add something to desktop/panel/bookmarks/menu
+  
 - Debhelper script for installing profiles? 
diff --git a/debian/changelog b/debian/changelog
index 4252051..861d66f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,11 @@
-desktop-profiles (1.0-2) UNRELEASED; urgency=low
+desktop-profiles (1.0-3) UNRELEASED; urgency=low
+
+  * Add script for listing profiles (that answer to certain criteria), so
+    the admin doesn't need to search through all the .listing files himself
+
+ -- Bart Cornelis (cobaco) <cobaco at linux.be>  Thu,  4 Nov 2004 21:22:14 +0100
+
+desktop-profiles (1.0-2) unstable; urgency=low
 
   * GNOME doesn't always like it if user write source is in secondary include
     , so change it around
diff --git a/debian/rules b/debian/rules
index 60bece6..ae344fb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -33,6 +33,8 @@ binary-indep: build install
 	dh_installdocs
 	dh_installexamples path
 	dh_installman desktop-profiles.7
+	dh_install listingmodule usr/share/desktop-profiles/
+	dh_install list-desktop-profiles usr/bin/
 	dh_install 20desktop-profiles_activateDesktopProfiles etc/X11/Xsession.d/
 	dh_install default.listing etc/desktop-profiles/
 	dh_installdebconf
diff --git a/default.listing b/default.listing
index 2e6b2eb..cc9ba8d 100644
--- a/default.listing
+++ b/default.listing
@@ -16,10 +16,13 @@
 # file, and how it will be used
 ################################################################################
 kde-prefix;/usr;;;KDE;System-wide kde stuff on Debian (stuff in PREFIX)
+
 default-xdg_config_dirs;/etc/xdg;;;XDG_CONFIG;Default config location defined by XDG Base Directory Specification
 default-xdg_data_dirs;/usr/local/share /usr/share;;;XDG_DATA;Default data locations defined by XDG Base Directory Specification
+
 default-rox-system;/usr/local/share/Choices /usr/share/rox/Choices;;;ROX;Default locations for non-user settings of ROX programs on Debian
-default-rox-user;${HOME}/.rox_choices;1000;;ROX;ROX user settings on Debian (should normally take precedence over everything else)
+default-rox-user;${HOME}/.rox_choices;999999999999999999;;ROX;ROX user settings on Debian (should normally take precedence over everything else)
+
 ude-install-dir;/usr/share/ude;;;UDE;Default location of system-wide UDE stuff
 
 gconf-mandatory;xml:readonly:/etc/gconf/gconf.xml.mandatory;101;;GCONF;Configuration source with the mandatory system-wide settings

-- 
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