[debian-edu-commits] debian-edu/ 71/183: Finish conversion script (still needs a man-page): - don't generate metadata for desktop-profiles hooks - change path file - make sure user configuration source always has precedence 0, wich makes all sources with defaults have negative precedence, and all sources with mandatory values have positive precedence, - fill in help message
Alexander Alemayhu
ccscanf-guest at moszumanska.debian.org
Wed Jun 11 16:48:34 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 25d5175ea0d15431fa6f8ab5c00af6dcec58bfc4
Author: Bart Cornelis <cobaco at linux.be>
Date: Thu Jun 2 17:46:18 2005 +0000
Finish conversion script (still needs a man-page):
- don't generate metadata for desktop-profiles hooks
- change path file
- make sure user configuration source always has precedence 0,
wich makes all sources with defaults have negative precedence,
and all sources with mandatory values have positive precedence,
- fill in help message
Document conversion script in README
Have debconf note point user to conversion script, don't provide a hook
to this (as this is considered policy violation)
---
README | 10 +-
debian/po/nl.po | 32 +++-
debian/po/templates.pot | 24 +--
debian/postinst | 39 ++---
debian/templates | 22 +--
path2desktop-profiles-metadata | 345 +++++++++++++++++++++++++++++------------
6 files changed, 311 insertions(+), 161 deletions(-)
diff --git a/README b/README
index 986c988..b23af1d 100644
--- a/README
+++ b/README
@@ -37,12 +37,10 @@ The easiest way to get there is to use the conversion script
(/usr/sbin/path2desktop-profiles-metadata). That script will generate metadata
for all your currently activated configuration sources, and will replace the
global path file with /usr/share/desktop-profiles/path.
-Running the script should not produce any user-visible changes. All it does is
-make it so the admin can manage all configuration sources through
-desktop-profiles.
-A backup of the current path file will be made with the name
-/etc/gconf/2/path.pre-converion, restoring that will revert to the pre-desktop
-profiles situation.
+Running the script should not produce any user-visible changes, only make it so that
+you as admin can manage all configuration sources through desktop-profiles.
+The script will create a backup of all files it messes with, so you can always go
+back to the previous situation (by restoring the global path file in /etc/gconf/2/)
NOTE FOR DEBIAN-EDU USERS
=-=-=-=-=-=-=-=-=-=-=-=-=
diff --git a/debian/po/nl.po b/debian/po/nl.po
index e373f47..eba8033 100644
--- a/debian/po/nl.po
+++ b/debian/po/nl.po
@@ -15,8 +15,8 @@ msgid ""
msgstr ""
"Project-Id-Version: desktop-profiles\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-05-29 15:04+0200\n"
-"PO-Revision-Date: 2005-05-29 15:21+0100\n"
+"POT-Creation-Date: 2005-06-02 19:07+0200\n"
+"PO-Revision-Date: 2005-06-02 19:13+0100\n"
"Last-Translator: Bart Cornelis <cobaco at linux.be>\n"
"Language-Team: debian-l10n-dutch <debian-l10n-dutch at lists.debian.org>\n"
"MIME-Version: 1.0\n"
@@ -27,14 +27,14 @@ msgstr ""
#. Type: note
#. Description
#: ../templates:3
-msgid "gconf profiles won't work by default"
-msgstr "gconf-profielen werken standaard niet"
+msgid "Global gconf path file needs to be changed!"
+msgstr "Het systeemwijde gconf 'path'-bestand dient aangepast te worden!"
#. Type: note
#. Description
#: ../templates:3
-msgid "The default gconf (i.e. GNOME) setup doesn't facilitate the use of profiles for certain groups only. This package provides an alternative way to manage gconf configuration sources that does. In order to activate this alternative way of managing your configuration sources the system-wide gconf 'path' file (/etc/gconf/<gconf-version>/path) needs to be adapted."
-msgstr "De standaard manier waarmee gconf (en dus GNOME) configuratiebronnen beheert biedt geen ondersteunen voor het conditioneel activeren van bronnen. Dit pakket voorziet een alternatieve aanpak die dit wel ondersteund. Om ervoor te zorgen dat gconf de aanpak van dit pakket gebruikt dient het systeemwijde 'path'-bestand (/etc/gconf.<gconf-version>/path) aangepast te worden."
+msgid "Your current gconf (i.e. GNOME) setup doesn't facilitate the use of configuration sources managed by desktop-profiles (either because you haven't made the necessary changes yet, or because you had a version previous to 1.4.6 of this package installed which used a different path-file). In order to rectify this situation your global gconf 'path' file (/etc/gconf/<gconf-version>/path) needs to be adapted, and the metadata needed by desktop-profiles for your current configuration sou [...]
+msgstr "Uw huidige gconf (en dus Gnome) instellingen ondersteunen geen door desktop-profiles beheerde configuratiebronnen. (of omdat u de nodige aanpassingen nog niet gedaan heeft; of omdat u een versie van dit pakket eerder dan 1.4.6 geinstalleerd had, deze gebruikte een ander 'path'-bestand). Om gebruik van door desktop-profiles beheerde configuratiebronnen mogelijk te maken dient enerzijds uw systeemwijde gconf 'path'-bestand aangepast te worden, en anderzijds de door desktop-profiles [...]
#. Type: note
#. Description
@@ -45,8 +45,8 @@ msgstr "Dit pakket bevat een conversie-script. Het script (/usr/sbin/path2deskto
#. Type: note
#. Description
#: ../templates:3
-msgid "Running this script shouldn't create any user-visible differences. But will allow the admin to manage all configuration sources through desktop-profiles. A backup of the old path file will be made with the name /etc/gconf/2/path.pre-conversion, you can always go back to managing configuration sources directly by putting that back."
-msgstr "Het uitvoeren van dit script geeft geen voor gebruikers zichtbare veranderingen, maar laat de beheerder wel toe om alle configuratiebronnen te beherenvia desktop-profiles. Een reservekopie van het huidige globale 'path'-bestand wordt gemaakt met de naam /etc/gconf/2/path.pre-conversion. U kunt altijdterugkeren naar de oude situatie zonder door desktop-profiles beheerde configuratiebronnen door deze reservekopie terug te plaatsen."
+msgid "Running this script shouldn't create any user-visible differences. But will allow you to manage all configuration sources through desktop-profiles. The script will make backup copies of all files it touches, so you can always go back to the previous situation."
+msgstr "Het uitvoeren van dit script geeft geen voor gebruikers zichtbare veranderingen, maar laat u toe om alle configuratiebronnen te beheren via desktop-profiles. Dit script maakt een reservekopie van alle bestanden waar het veranderingen in aanbrengt, u kunt dus altijd terug naar de vorige situatie."
#. Type: note
#. Description
@@ -54,6 +54,22 @@ msgstr "Het uitvoeren van dit script geeft geen voor gebruikers zichtbare verand
msgid "If you want to do the conversion manually this is off course possible, see /usr/share/doc/desktop-profiles/README for more information."
msgstr "Deze conversie handmatig uitvoeren is natuurlijk ook mogelijk, zie /usr/share/doc/desktop-profiles/README voor meer informatie."
+#~ msgid "gconf profiles won't work by default"
+#~ msgstr "gconf-profielen werken standaard niet"
+#~ msgid ""
+#~ "The default gconf (i.e. GNOME) setup doesn't facilitate the use of "
+#~ "profiles for certain groups only. This package provides an alternative "
+#~ "way to manage gconf configuration sources that does. In order to activate "
+#~ "this alternative way of managing your configuration sources the system-"
+#~ "wide gconf 'path' file (/etc/gconf/<gconf-version>/path) needs to be "
+#~ "adapted."
+#~ msgstr ""
+#~ "De standaard manier waarmee gconf (en dus GNOME) configuratiebronnen "
+#~ "beheert biedt geen ondersteunen voor het conditioneel activeren van "
+#~ "bronnen. Dit pakket voorziet een alternatieve aanpak die dit wel "
+#~ "ondersteund. Om ervoor te zorgen dat gconf de aanpak van dit pakket "
+#~ "gebruikt dient het systeemwijde 'path'-bestand (/etc/gconf.<gconf-"
+#~ "version>/path) aangepast te worden."
#~ msgid "Replace the default system-wide 'path' file?"
#~ msgstr "Systeemwijd 'path'-bestand vervangen?"
#~ msgid ""
diff --git a/debian/po/templates.pot b/debian/po/templates.pot
index 9aadaa3..b057a80 100644
--- a/debian/po/templates.pot
+++ b/debian/po/templates.pot
@@ -16,7 +16,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-05-29 15:04+0200\n"
+"POT-Creation-Date: 2005-06-02 19:07+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <LL at li.org>\n"
@@ -27,18 +27,21 @@ msgstr ""
#. Type: note
#. Description
#: ../templates:3
-msgid "gconf profiles won't work by default"
+msgid "Global gconf path file needs to be changed!"
msgstr ""
#. Type: note
#. Description
#: ../templates:3
msgid ""
-"The default gconf (i.e. GNOME) setup doesn't facilitate the use of profiles "
-"for certain groups only. This package provides an alternative way to manage "
-"gconf configuration sources that does. In order to activate this "
-"alternative way of managing your configuration sources the system-wide "
-"gconf 'path' file (/etc/gconf/<gconf-version>/path) needs to be adapted."
+"Your current gconf (i.e. GNOME) setup doesn't facilitate the use of "
+"configuration sources managed by desktop-profiles (either because you "
+"haven't made the necessary changes yet, or because you had a version "
+"previous to 1.4.6 of this package installed which used a different path-"
+"file). In order to rectify this situation your global gconf 'path' file (/"
+"etc/gconf/<gconf-version>/path) needs to be adapted, and the metadata needed "
+"by desktop-profiles for your current configuration sources needs to be "
+"available."
msgstr ""
#. Type: note
@@ -57,10 +60,9 @@ msgstr ""
#: ../templates:3
msgid ""
"Running this script shouldn't create any user-visible differences. But will "
-"allow the admin to manage all configuration sources through desktop-"
-"profiles. A backup of the old path file will be made with the name /etc/"
-"gconf/2/path.pre-conversion, you can always go back to managing "
-"configuration sources directly by putting that back."
+"allow you to manage all configuration sources through desktop-profiles. The "
+"script will make backup copies of all files it touches, so you can always go "
+"back to the previous situation."
msgstr ""
#. Type: note
diff --git a/debian/postinst b/debian/postinst
index b044b1b..8e22da6 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -3,29 +3,20 @@
# source debconf library
. /usr/share/debconf/confmodule
-#############################################################
-# Change default gconf path file so it uses desktop-profiles
-# IF (and only if) the user explicitly agreed to this
-#############################################################
-db_get desktop-profiles/replace-gconf-system-wide-path-file || true
-if (test "$RET" = true); then
- # if gconf 2 path file is present and doesn't include the generated path file
- # then replace path file
- if (test -e /etc/gconf/2/path) ; then
- if ! ( (grep 'include *\$(ENV_MANDATORY_PATH)' /etc/gconf/2/path 2>&1 > /dev/null ) ||
- (grep 'include *\$(ENV_DEFAULTS_PATH)' /etc/gconf/2/path 2>&1 > /dev/null ) ); then
- mv /etc/gconf/2/path /etc/gconf/2/path.pre-desktop-profiles;
- cp /usr/share/desktop-profiles/path /etc/gconf/2/path;
- fi;
- # if gconf 1 path file is present and doesn't include the generated path file
- # then replace path file
- elif (test -e /etc/gconf/1/path) ; then
- if ! ( (grep 'include *\$(ENV_MANDATORY_PATH)' /etc/gconf/1/path 2>&1 > /dev/null ) ||
- (grep 'include *\$(ENV_DEFAULTS_PATH)' /etc/gconf/1/path 2>&1 > /dev/null ) ); then
- mv /etc/gconf/1/path /etc/gconf/1/path.pre-desktop-profiles;
- cp -f /usr/share/desktop-profiles/path /etc/gconf/1/path;
- fi;
- fi;
-fi;
+##############################################################################
+# Popup note about need to change default global gconf path file so it allows
+# use of desktop-profiles, when current global path file doesn't
+##############################################################################
+if (test -e /etc/gconf/2/path) ; then
+ if ! ( (grep 'include *\$(ENV_MANDATORY_PATH)' /etc/gconf/2/path 2>&1 > /dev/null ) ||
+ (grep 'include *\$(ENV_DEFAULTS_PATH)' /etc/gconf/2/path 2>&1 > /dev/null ) ); then
+ db_get desktop-profiles/replace-gconf-system-wide-path-file || true
+ fi;
+elif (test -e /etc/gconf/1/path) ; then
+ if ! ( (grep 'include *\$(ENV_MANDATORY_PATH)' /etc/gconf/1/path 2>&1 > /dev/null ) ||
+ (grep 'include *\$(ENV_DEFAULTS_PATH)' /etc/gconf/1/path 2>&1 > /dev/null ) ); then
+ db_get desktop-profiles/replace-gconf-system-wide-path-file || true
+ fi;
+fi;
#DEBHELPER#
diff --git a/debian/templates b/debian/templates
index 1566aaf..610b2c7 100644
--- a/debian/templates
+++ b/debian/templates
@@ -1,11 +1,14 @@
Template: desktop-profiles/replace-gconf-system-wide-path-file
Type: note
-_Description: gconf profiles won't work by default
- The default gconf (i.e. GNOME) setup doesn't facilitate the use of
- profiles for certain groups only. This package provides an alternative way to
- manage gconf configuration sources that does. In order to activate this
- alternative way of managing your configuration sources the system-wide
- gconf 'path' file (/etc/gconf/<gconf-version>/path) needs to be adapted.
+_Description: Global gconf path file needs to be changed!
+ Your current gconf (i.e. GNOME) setup doesn't facilitate the use of
+ configuration sources managed by desktop-profiles (either because
+ you haven't made the necessary changes yet, or because you had a version
+ previous to 1.4.6 of this package installed which used a different path-file).
+ In order to rectify this situation your global gconf 'path' file
+ (/etc/gconf/<gconf-version>/path) needs to be adapted, and the metadata
+ needed by desktop-profiles for your current configuration sources needs to be
+ available.
.
This package includes a conversion script that wil create the necessary
metadata to have all your configuration sources managed by desktop-profiles
@@ -14,10 +17,9 @@ _Description: gconf profiles won't work by default
desktop-profiles.
.
Running this script shouldn't create any user-visible differences. But will
- allow the admin to manage all configuration sources through desktop-profiles.
- A backup of the old path file will be made with the name
- /etc/gconf/2/path.pre-conversion, you can always go back to managing
- configuration sources directly by putting that back.
+ allow you to manage all configuration sources through desktop-profiles.
+ The script will make backup copies of all files it touches, so you can always
+ go back to the previous situation.
.
If you want to do the conversion manually this is off course possible, see
/usr/share/doc/desktop-profiles/README for more information.
diff --git a/path2desktop-profiles-metadata b/path2desktop-profiles-metadata
index 0a99e6d..7d59826 100644
--- a/path2desktop-profiles-metadata
+++ b/path2desktop-profiles-metadata
@@ -2,25 +2,58 @@
# This script is ment to allow you to setup gconf to manage confiuration
# sources through desktop-profiles.
#
-# It will read your current gconf configuration and will:
-# - check wether it will use the configuration sources managed by
+# It will read your a path file (the global gconf one by default) and will:
+# - generate the necessary metadata to manage all profiles through
# desktop-profiles
-# - offer to generate the necessary metadata to manage all profiles
-# (that aren't already) through desktop-profiles
-# - offer to adapt the global path file accordingly
+# - adapt the global path file to manage all configuration sources with
+# desktop-profiles (unless told not to)
#
# (c) 2005 Bart Cornelis <cobaco AT skolelinux no>
#########################################################################
+ROOT_PATH_FILE=/etc/gconf/2/path
+CUSTOM_LISTINGS=/etc/desktop-profiles/path2desktop-profiles-metadata_generated.listing
+DEFAULT_LISTINGS=/etc/desktop-profiles/desktop-profiles.listing
+
+# default distance to leave between 2 successive priority sources
+# we're leaving some distance to allow the easy insertion of later profiles
+SOURCE_DISTANCE=50;
+
print_help () {
cat <<EOF
-FIXME
+Usage: path2desktop-profiles-metadata [OPTIONS]
+ This script facilitates the conversion from managing gconf configuration
+ sources directly through path files, to managing them with desktop-profiles.
+ As such it will generally be run only ones, directly after installing the
+ desktop-profiles package.
+
+ It will generate the metadata needed by desktop-profiles to manage the
+ configuration sources that are activated directly or indirectly (i.e. through
+ included path files) by the path file it is run on.
+ After the generation of the metadata the converted path file will be
+ replaced by one assuming that desktop-profiles manages activation of
+ configuration sources.
+
+Options:
+ -d, --distance : precedence distance between different configuration
+ sources (defaults to $SOURCE_DISTANCE),
+ The idea is to leave some space between precedences so you
+ can easily insert other configuration sources later on.
+ -f, --file : path file to start conversion from
+ (defaults to $ROOT_PATH_FILE)
+ -o, --output-file: file to put the generated metadata in (defaults to
+ $CUSTOM_LISTINGS)
+ --no-replace-file: don't replace path file from which we start the conversion
+ with one that manages everything through desktop-profiles
+ -h, --help : display this helpmessage
EOF
}
# $1 is the path file to look at
# output is the reverse-priority ordered list of configuration sources that $1
-# contains (directly, or indirectly through nested include directives).
+# contains (directly, or indirectly through nested include directives). The
+# output will ignore the hooks for desktop-profiles if present (as we don't
+# need to generate any metadata for them).
#
# Note: not recursing down includes referring to environment variables as we
# can't be sure they'll resolve the same way when converting, and when
@@ -31,11 +64,17 @@ EOF
list_sources_in_path_file () {
# if it's an existing file, process it, otherwise ignore it
if (test -r "$1"); then
- # strip out comments and empty lines, leaving only config sources and includes
+ # strip out comments & empty lines, leave only config sources and includes
tac "$1" | sed -e "s/^[[:space:]]*//g" -e "s/[[:space:]]*$//g" | \
grep -v "^#.*\|^$" | while read CONFIG_SOURCE; do
- # if nested path file
- if (echo "$CONFIG_SOURCE" | grep "^include[[:space:]]*" > /dev/null); then
+ # ignore desktop-profiles hooks (new and old) as they don't need metadata
+ if ( (test "$CONFIG_SOURCE" = 'include $(ENV_MANDATORY_PATH)') ||
+ (test "$CONFIG_SOURCE" = 'include *\$(ENV_DEFAULTS_PATH)') ||
+ (test "$CONFIG_SOURCE" = 'include /var/cache/desktop-profiles/\$(USER)_mandatory.path') ||
+ (test "$CONFIG_SOURCE" = 'include /var/cache/desktop-profiles/\$(USER)_defaults.path') ); then
+ true;
+ # process nested path files
+ elif (echo "$CONFIG_SOURCE" | grep "^include[[:space:]]*" > /dev/null); then
# check if recursing makes sense (don't recurse when user-controlled or
# dependend on current environment (which might be influenced by user)
if (echo "$CONFIG_SOURCE" | grep -e "\$(HOME)" -e "\$(USER)" -e "\$(ENV_.*)" > /dev/null); then
@@ -43,7 +82,8 @@ list_sources_in_path_file () {
else
list_sources_in_path_file $(echo "$CONFIG_SOURCE" | sed "s/^include[[:space:]]*//");
fi;
- else #regular config source, just output
+ # process regular config sources
+ else
echo $CONFIG_SOURCE;
fi;
done;
@@ -54,14 +94,30 @@ list_sources_in_path_file () {
# $2 is the precedence value
# $3 is the file where it should be added into
add_as_profile () {
- echo "source-$2;GCONF;$1;$2;;" >> "$3";
+ if (test -r "$3"); then
+ declare -i mandatory_number="$(cat "$3" | grep '^mandatory' | wc -l) + 1";
+ declare -i default_number="$(cat "$3" | grep '^default' | wc -l) + 1";
+ else
+ declare -i mandatory_number=1;
+ declare -i default_number=1;
+ fi;
+
+ if (test 0 -lt $2 ); then
+ echo "mandatory_$mandatory_number;GCONF;$1;$2;;" >> "$3";
+ else
+ echo "default_$default_number;GCONF;$1;$2;;" >> "$3";
+ fi;
}
# $1 is the configuration source whose metadata we want to update
# $2 is the new precedence value
# $3 is the file where the configuration sources' metadata is to be found
update_precedence () {
- sed -i "s|\(.*\);GCONF;$1;.*;\(.*\);\(.*\)|\1;GCONF;$1;$2;\2;\3|" "$3";
+ if (test -w "$3"); then
+ sed -i "s|\(.*\);GCONF;$1;.*;\(.*\);\(.*\)|\1;GCONF;$1;$2;\2;\3|" "$3";
+ else
+ echo "Don't have sufficient permissions to adapt the precedence of $1 in $3 to $2";
+ fi;
}
# $1 is the configuration source of the profile we want to deactivate
@@ -69,122 +125,207 @@ update_precedence () {
set_inactive () {
sed -i "s|\(.*\);GCONF;$1;\(.*\);\(.*\);\(.*\)|\1;GCONF;$1;\2;! \3;\4|" "$2";
}
-############################
-# Start of script execution
-############################
-ROOT_PATH_FILE=/etc/gconf/2/path
-CUSTOM_LISTINGS=/etc/desktop-profiles/path2desktop-profiles_generated.listing
-DEFAULT_LISTINGS=/etc/desktop-profiles/desktop-profiles.listing
+# $1 is the file to backup
+# $2 is the reason
+make_backup_of () {
+ if (test -e "$1"); then
+ # tell user what we're doing
+ echo "$1 already exists, and this script wil $2 it."
+ echo "-> a backup of named $1.$(date --iso-8601=seconds) will be created."
+ echo ;
-# default distance to leave between 2 successive priority sources
-# we're leaving some distance to allow the easy insertion of later profiles
-SOURCE_DISTANCE=50;
+ # make backup of current version
+ mv "$1" "$1.$(date --iso-8601=seconds)";
+ fi;
+}
+
+# we're processing the global path file by default
+# -> so unless asked not to we'll want to replace it
+GLOBAL_PATH_FILE=true;
+REPLACE_PATH_FILE=true;
+#####################
# Parse command line
+#####################
while test $# -ge 1; do
case $1 in
- -d| --distance)
+ -d | --distance)
# takes positive integer as distance (between configuration sources)
- if (test $# -lt 2) || !(echo $2 | grep -E '^[0-9]+$' > /dev/null); then
- print_help;exit;
+ if (test $# -lt 2) || !(echo "$2" | grep -E '^[0-9]+$' > /dev/null); then
+ print_help;
+ exit;
else # valid distance -> set it
- SOURCE_DISTANCE=$2;
+ SOURCE_DISTANCE="$2";
fi;
+ shift 2;
;;
# takes path file to be converted as argument
- -f| --file)
+ -f | --file)
#validate argument, should be a readable path file
if (test $# -lt 2) || !(test -r $2); then
- print_help;exit;
+ print_help;
+ exit;
else #valid filename -> add to list of files to convert
ROOT_PATH_FILE="$2";
+ if (test "$ROOT_PATH_FILE" != /etc/gconf/2/path) || \
+ (test "$ROOT_PATH_FILE" != /etc/gconf/1/path); then
+ GLOBAL_PATH_FILE=false;
+ fi;
fi;
+ shift 2;
;;
- -h| --help)
- print_help;exit;
- ;;
-
- # listing-file to put converted sources in
- -o|--output-file)
- #validate argument
+ # takes name of file that will contain the metada for the
+ # converted configuration sources
+ -o | --output-file)
+ #check for argument
if (test $# -lt 2); then
- print_help;exit;
- else #valid filename -> add to list of files to convert
+ print_help;
+ exit;
+ else #Change name of metadata file accordingly
CUSTOM_LISTINGS="$2";
- echo;
fi;
+ shift 2;
+ ;;
+
+ # takes boolean value
+ --no-replace-file)
+ REPLACE_PATH_FILE=false;
+ shift;
;;
- *)
- print_help;exit;
+ -h| --help | *)
+ print_help;
+ exit;
;;
esac;
-
- # All options take an argument so we should always shift twice
- # (except --help, but then we don't get here)
- shift 2;
done;
-# flags indicating wether we've encountered the default sources yet puth in
-# tempfile, as we need to change them from within a pipe, which means subshell,
-# which means setting a variable doesn't carry outside of loop
-TMP=$(tempfile);
-echo SEEN_GCONF_MANDATORY="false" >> "$TMP";
-echo SEEN_GCONF_DEFAULTS="false" >> "$TMP";
-echo SEEN_GCONF_USER_PATH="false" >> "$TMP";
-echo SEEN_GCONF_USER="false" >> "$TMP";
-
-# make backup-copy of current files to be touched
-if (test -e "$CUSTOM_LISTINGS"); then
- mv "$CUSTOM_LISTINGS" "$CUSTOM_LISTINGS.$(date --iso-8601=seconds).conversion";
-fi;
+######################################
+# Check if we need to do anything,
+# and communicate that with the admin
+######################################
+ # Check if ROOT_PATH_FILE is same as path file we want
+ if (diff $ROOT_PATH_FILE /usr/share/desktop-profiles/path 2>&1 > /dev/null); then
+ #same -> nothing to do
+ echo "$ROOT_PATH_FILE file is already converted to desktop-profiles:";
+ echo " -> nothing to do";
+ echo " -> exiting";
+ exit;
+ # check for precense of current desktop-profiles hooks
+ # if so warn that the precedence might not be correct
+ # they're different -> so we need to convert
+ elif
+ (grep 'include *\$(ENV_MANDATORY_PATH)' "$ROOT_PATH_FILE" 2>&1 > /dev/null) ||
+ (grep 'include *\$(ENV_DEFAULTS_PATH)' "$ROOT_PATH_FILE" 2>&1 > /dev/null); then
+ true;#FIXME;
+ # check for precense of old desktop-profiles hooks
+ # if so warn that the precedence might not be correct
+ # they're different -> so we need to convert
+ elif
+ (grep 'include /var/cache/desktop-profiles/\$(USER)_mandatory.path' "$ROOT_PATH_FILE" 2>&1 > /dev/null) ||
+ (grep 'include /var/cache/desktop-profiles/\$(USER)_defaults.path' "$ROOT_PATH_FILE" 2>&1 > /dev/null); then
+ true;#FIXME;
+ else
+ echo "Metadata for all configuration sources contained in $ROOT_PATH_FILE";
+ echo "(wether contained directly, or indirectly through includes) will be"
+ echo "generated and put in $CUSTOM_LISTINGS."
+ echo;
+ fi;
+
+################################
+# Deal with generating metadata
+################################
+ USER_SOURCE_RANK=$(list_sources_in_path_file $ROOT_PATH_FILE | nl | \
+ grep 'xml:readwrite:\$(HOME)/.gconf' | sed "s/^[[:space:]]*//g" | cut --fields 1);
+
+ # flags indicating wether we've encountered the default sources yet puth in
+ # tempfile, as we need to change them from within a pipe, which means subshell,
+ # which means setting a variable doesn't carry outside of loop
+ export AID_TMP=$(tempfile);
+ echo SEEN_GCONF_MANDATORY="false" >> "$AID_TMP";
+ echo SEEN_GCONF_DEFAULTS="false" >> "$AID_TMP";
+ echo SEEN_GCONF_USER_PATH="false" >> "$AID_TMP";
+ echo SEEN_GCONF_USER="false" >> "$AID_TMP";
+
+ # check if file, we'll be messing with already exists, if so create backup
+ make_backup_of "$CUSTOM_LISTINGS" regenerate
-# iterate over all confguration sources, listed directly or indirectly by the
-# $ROOT_PATH_FILE (by default = /etc/gconf/2/path)
-list_sources_in_path_file $ROOT_PATH_FILE | nl | sed "s/^[[:space:]]*//g" | \
-while read ITEM; do
- # the '- 2 * SOURCE_DISTANCE' at the end is to get the user-source with
- # priority 0 in the default situation
- declare -i PRECEDENCE="$(echo "$ITEM" | cut --fields 1) * $SOURCE_DISTANCE - 2 * $SOURCE_DISTANCE";
- CONFIG_SOURCE="$(echo "$ITEM" | cut --fields 2)";
-
- # If one of the default source -> update precedence
- # else add a profile-metadata entry for this configuration source
- if (test "$CONFIG_SOURCE" = "xml:readonly:/etc/gconf/gconf.xml.mandatory") ; then
- echo 'SEEN_GCONF_MANDATORY="true"' >> "$TMP";
- update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
- elif (test "$CONFIG_SOURCE" = 'include "$(HOME)/.gconf.path"'); then
- echo 'SEEN_GCONF_USER_PATH="true"' >> "$TMP";
- update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
- elif (test "$CONFIG_SOURCE" = 'xml:readwrite:$(HOME)/.gconf'); then
- echo 'SEEN_GCONF_USER="true"' >> "$TMP";
- update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
- elif (test "$CONFIG_SOURCE" = "xml:readonly:/etc/gconf/gconf.xml.defaults"); then
- echo 'SEEN_GCONF_DEFAULTS="true"' >> "$TMP";
- update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
- else #split in default and my-gconf listings
- add_as_profile "$CONFIG_SOURCE" "$PRECEDENCE" "$CUSTOM_LISTINGS";
+ # iterate over all confguration sources, listed directly or indirectly by the
+ # $ROOT_PATH_FILE (by default = /etc/gconf/2/path)
+ list_sources_in_path_file $ROOT_PATH_FILE | nl | sed "s/^[[:space:]]*//g" | \
+ while read ITEM; do
+ # the '- USER_SOURCE_RANK * SOURCE_DISTANCE' at the end is to ensure that
+ # the user-source ends up with precedence 0, yielding all mandatory sources
+ # with a positive precedence, and all default sources with a negative one
+ declare -i PRECEDENCE="$(echo "$ITEM" | cut --fields 1) * $SOURCE_DISTANCE - $USER_SOURCE_RANK * $SOURCE_DISTANCE";
+ CONFIG_SOURCE="$(echo "$ITEM" | cut --fields 2)";
+
+ # If one of the default source -> update precedence
+ # else add a profile-metadata entry for this configuration source
+ if (test "$CONFIG_SOURCE" = "xml:readonly:/etc/gconf/gconf.xml.mandatory") ; then
+ echo 'SEEN_GCONF_MANDATORY="true"' >> "$AID_TMP";
+ update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
+ elif (test "$CONFIG_SOURCE" = 'include "$(HOME)/.gconf.path"'); then
+ echo 'SEEN_GCONF_USER_PATH="true"' >> "$AID_TMP";
+ update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
+ elif (test "$CONFIG_SOURCE" = 'xml:readwrite:$(HOME)/.gconf'); then
+ echo 'SEEN_GCONF_USER="true"' >> "$AID_TMP";
+ update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
+ elif (test "$CONFIG_SOURCE" = "xml:readonly:/etc/gconf/gconf.xml.defaults"); then
+ echo 'SEEN_GCONF_DEFAULTS="true"' >> "$AID_TMP";
+ update_precedence "$CONFIG_SOURCE" "$PRECEDENCE" "$DEFAULT_LISTINGS";
+ else
+ add_as_profile "$CONFIG_SOURCE" "$PRECEDENCE" "$CUSTOM_LISTINGS";
+ fi;
+ done;
+
+ # Activate/Deactivate default sources as requiered
+ # If and only if, we're processing the global path file
+ if (test "$GLOBAL_PATH_FILE" = true); then
+ # deactivate any of the default configuration sources we didn't encounter
+ . "$AID_TMP";#get seen flags
+ if (test "$SEEN_GCONF_MANDATORY" = false) || (test "$SEEN_GCONF_USER_PATH" = false) ||
+ (test "$SEEN_GCONF_USER" = false) || (test "$SEEN_GCONF_DEFAULTS" = false); then
+ make_backup_of "$DEFAULT_LISTING" "make changes to"
+ fi;
+
+ if (test "$SEEN_GCONF_MANDATORY" = false); then
+ set_inactive "xml:readonly:/etc/gconf/gconf.xml.mandatory" "$DEFAULT_LISTINGS";
+ fi;
+ if (test "$SEEN_GCONF_USER_PATH" = false); then
+ set_inactive 'include "$(HOME)/.gconf.path"' "$DEFAULT_LISTINGS";
+ fi;
+ if (test "$SEEN_GCONF_USER" = false); then
+ set_inactive 'xml:readwrite:$(HOME)/.gconf' "$DEFAULT_LISTINGS";
+ fi;
+ if (test "$SEEN_GCONF_DEFAULTS" = false); then
+ set_inactive "xml:readonly:/etc/gconf/gconf.xml.defaults" "$DEFAULT_LISTINGS";
+ fi;
fi;
-done;
-
-# deactivate any of the default configuration sources we didn't encounter
-. "$TMP";#get seen flags
-if (test "$SEEN_GCONF_MANDATORY" = false); then
- set_inactive "xml:readonly:/etc/gconf/gconf.xml.mandatory" "$DEFAULT_LISTINGS";
-fi;
-if (test "$SEEN_GCONF_USER_PATH" = false); then
- set_inactive 'include "$(HOME)/.gconf.path"' "$DEFAULT_LISTINGS";
-fi;
-if (test "$SEEN_GCONF_USER" = false); then
- set_inactive 'xml:readwrite:$(HOME)/.gconf' "$DEFAULT_LISTINGS";
-fi;
-if (test "$SEEN_GCONF_DEFAULTS" = false); then
- set_inactive "xml:readonly:/etc/gconf/gconf.xml.defaults" "$DEFAULT_LISTINGS";
-fi;
-rm "$TMP";#cleanup
-
-#FIXME: take our global path file in the place of the global path file
-#cp $DEFAULT_LISTINGS $DEFAULT_LISTINGS.pre-conversion
+
+ # cleanup
+ rm "$AID_TMP";
+ unset AID_TMP;
+
+######################################
+# Deal with changing global path file
+######################################
+if (test $REPLACE_PATH_FILE = true); then
+ # make backup-copy of $ROOT_PATH_FILE, before changing it
+ if (test -e "$ROOT_PATH_FILE"); then
+ # tell user what we're doing
+ echo "The global path file will now be replaced with one assuming all "
+ echo "configuration sources are managed by desktop-profiles."
+ echo "-> a backup named $ROOT_PATH_FILE.$(date --iso-8601=seconds) will be created."
+ echo ;
+
+ # make backup of current version
+ mv "$ROOT_PATH_FILE" "$ROOT_PATH_FILE.$(date --iso-8601=seconds)";
+ fi;
+
+ # actually replace global path file
+ cp /usr/share/desktop-profiles/path "$ROOT_PATH_FILE";
+fi;
--
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