/usr/bin/update-profile-cache is in desktop-profiles 1.4.20.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | #!/bin/sh
#
# This script checks whether generating a cache of the wanted profile
# assignment makes sense, and if so (re)generate the cache if it's out of date
#
# Supported CACHE_TYPES:
# - static: used when profiles are either activated machine-wide or not at all
# - none: used when we either don't want or don't support a cache
# TODO: caching in the non-static case
###############################################################################
#################
# initialization
#################
# get user preferences
if (test -r /etc/default/desktop-profiles); then
. /etc/default/desktop-profiles;
fi;
#failsave in case default file is deleted
LISTINGS_DIRS=${LISTINGS_DIRS:-'/etc/desktop-profiles'}
CACHE_DIR=${CACHE_DIR:-'/var/cache/desktop-profiles'}
CACHE_FILE="$CACHE_DIR/activated_profiles"
##############################################
# 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
# requirement that's neither whitespace nor '!')
if( test $(list-desktop-profiles -e '$REQUIREMENTS' -r '[^[:space:]!]' | \
grep -v '^![[:space:]]\|[[:space:]]!$\|[[:space:]]![[:space:]]\|^!$' | \
wc -l) -ne 0); then
CACHE_TYPE=none;
else
CACHE_TYPE=static
fi;
###########################################
# generate $CACHE_FILE if that makes sense
###########################################
if (test "$CACHE_TYPE" = static); then
#if:
# - 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 \
"$CACHE_FILE" 2> /dev/null | \
head -1) = "$CACHE_FILE"); then
# delete old cache (otherwise activateDesktopProfiles reuses it)
rm -f "$CACHE_FILE";
# 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
if (test -e "$MANDATORY_PATH" ); then
# sanity check
mkdir -p "$CACHE_DIR";
#do it with cat+rm instead of mv to ensure correct permissions
cat "$MANDATORY_PATH" > "$CACHE_DIR/mandatory_path";
rm -f "$MANDATORY_PATH";
MANDATORY_PATH="$CACHE_DIR/mandatory_path";
fi;
if (test -e "$DEFAULTS_PATH" ); then
#sanity check
mkdir -p "$CACHE_DIR";
#do it with cat+rm instead of mv to ensure correct permissions
cat "$DEFAULTS_PATH" > "$CACHE_DIR/defaults.path";
rm -f "$DEFAULTS_PATH";
DEFAULTS_PATH="$CACHE_DIR/defaults.path";
fi;
# 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/' \
-e 's/^\(XDG_CONFIG_DIRS=.*\)$/\1:$XDG_CONFIG_DIRS/' \
-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";
;;
sheep | autocrat)
#no markers to add
;;
polite | *)
sed -i -e 's/^\(KDEDIRS=\)\(.*\)$/\1$KDEDIRS:\2/' \
-e 's/^\(XDG_CONFIG_DIRS=\)\(.*\)$/\1$XDG_CONFIG_DIRS:\2/' \
-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";
;;
esac;
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";
fi;
|