diff options
Diffstat (limited to 'r14-xdg-update')
-rw-r--r-- | r14-xdg-update | 188 |
1 files changed, 103 insertions, 85 deletions
diff --git a/r14-xdg-update b/r14-xdg-update index 93dc9bbd4..0a9c5ba7e 100644 --- a/r14-xdg-update +++ b/r14-xdg-update @@ -3,6 +3,8 @@ # A script to perform R14.0.0 XDG compliance updates. # This script should be needed to run only once. +SCRIPT_NAME="`basename \`readlink -f $0\``" + # TODO: Do we need to trap whether the user is running this script while # in a Trinity session? Most files can be updated "live" but some can't, # such as kdeglobals. @@ -18,11 +20,29 @@ fi # We presume $HOME/.trinity, but should provide a way to pass a command line # parameter to change that location. PROFILE_DIR="$HOME/.trinity" +CACHE_DIR="$PROFILE_DIR/cache-`uname -n`" # TODO: How to handle environments where files/directories are locked # administratively and can't be updated. The nominal validation checks # in this script provide some notice but no direct remedy. +# The binaries for TDE are located in the same place as this script. +# To determine that location use the following method rather than presuming +# the existence of $TDEDIR. That environment variable might not be +# defined or defined to point to KDE4 binaries. +BIN_DIR="`dirname \`readlink -f $0\``" +if [ -x $BIN_DIR/tde-config ]; then + TDEDIR=${BIN_DIR%/bin} +else + echo "[r14-xdg-update] Unable to determine TDE base directory." + echo "[r14-xdg-update] This script should be installed in the same directory." + echo "[r14-xdg-update] Exiting." + exit 1 +fi +unset BIN_DIR + +unset KDEGLOBALS_KEY_VALUE + Wait_For_Response () { unset response # -r Backslash does not act as an escape character. @@ -62,6 +82,15 @@ if [ "$DISPLAY" != "" ]; then fi } +Validation_Failure () { +Display_Message "$MESSAGE" +if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then + KDEGLOBALS_KEY_VALUE="$TEST_NUM" +else + KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;$TEST_NUM" +fi +} + # Do not update when $TDEHOME is a sym link to another profile directory. Trinity should have # full reign within its own profile directory (limited to administrative locking), but the error # check is a conservative approach. @@ -73,9 +102,9 @@ if [ "$TDEHOME_LINK" != "" ]; then # Are we in X? Display an X dialog explaining breakage. if [ "$DISPLAY" != "" ]; then echo "[r14-xdg-update] Warning! The profile directory $PROFILE_DIR is a" 1>&2 - echo "[r14-xdg-update] sym link to $TDEHOME_LINK!" 1>&2 - echo "[r14-xdg-update] R14 updates will not be performed because Trinity needs its own separate profile directory." 1>&2 - echo "[r14-xdg-update] Without R14 updates some Trinity apps will fail to function correctly." 1>&2 + echo " sym link to $TDEHOME_LINK!" 1>&2 + echo " R14 updates will not be performed because Trinity needs its own separate profile directory." 1>&2 + echo " Without R14 updates some Trinity apps will fail to function correctly." 1>&2 fi MESSAGE="Oops! The profile directory $PROFILE_DIR is a sym link to $TDEHOME_LINK.\n\nTrinity R14 XDG compliance updates will not be performed because\nTrinity needs its own separate profile directory.\n\nWithout R14 XDG compliance updates, some Trinity apps will fail to\nfunction properly.\n\nFailures include the following:\n\n* Many left-side icon lists will not populate,\n such as the Panel and Konqueror configuration dialogs.\n\n* User-defined keyboard shortcuts fail (khotkeysrc).\n System defined shortcuts remain functional.\n\n* User-defined app preferences fail (profilerc).\n\n* Konqueror navigation/sidebar panel won't open.\n\n* User-defined konqueror service menus, kicker customization,\n konqueror sidebar, Recent Documents list fail.\n\nPossible remedies:\n\n* If necessary contact your system administrator.\n\n* Break the sym link to allow Trinity to create a fresh Trinity profile.\n\n* Use the migratekde3 script to migrate a KDE3 profile to Trinity." # Are we in X? Display an X dialog explaining breakage. @@ -110,9 +139,9 @@ R14_UPDATED="`$TDEDIR/bin/kreadconfig --file kdeglobals --group "R14 XDG Updates if [ "$R14_UPDATED" != "true" ] || [ "$FORCE" = "true" ]; then if [ "$R14_UPDATED" != "true" ] && [ "$R14_UPDATED" != "false" ] && [ "$R14_UPDATED" != "" ]; then Message_Prefix - echo -e "The r14-xdg-update script has been run at least once." + echo "The r14-xdg-update script has been run at least once." Message_Prefix - echo -e "The error code is $R14_UPDATED." + echo "The error code is $R14_UPDATED." MESSAGE="The r14-xdg-update script has been run at least once.\n\nThe script is not successfully updating.\n\nThe script will run with each login until corrected.\n\nPlease contact an administrator or take appropriate\nadmininstrative action to correct the problem.\n\nThe error code is $R14_UPDATED." # Are we in X? Display an X dialog explaining breakage. if [ "$DISPLAY" != "" ]; then @@ -127,28 +156,28 @@ if [ "$R14_UPDATED" != "true" ] || [ "$FORCE" = "true" ]; then fi fi Message_Prefix - echo -e "Performing a profile update for Trinity release R14 XDG compliance." + echo "Performing a profile update for Trinity release R14 XDG compliance." Message_Prefix - echo -e "Updating *.desktop files." + echo "Updating *.desktop files." find "$PROFILE_DIR" -name "*.desktop" -exec sed -i 's|X-KDE-|X-TDE-|g' {} \; 2>/dev/null find "$PROFILE_DIR" -name "*.desktop" -exec sed -i 's|KDE\;|TDE\;|g' {} \; 2>/dev/null find "$HOME/.local" -name "*.desktop" -exec sed -i 's|X-KDE-|X-TDE-|g' {} \; 2>/dev/null find "$HOME/.local" -name "*.desktop" -exec sed -i 's|KDE\;|TDE\;|g' {} \; 2>/dev/null Message_Prefix - echo -e "Updating references of $TDEDIR/share/applications/kde to share/applications/tde." + echo "Updating references of $TDEDIR/share/applications/kde to share/applications/tde." # Exclude KMail mail files --- we don't want to touch those files. find "$PROFILE_DIR" -path "$PROFILE_DIR/share/apps/kmail/mail" -prune -o -type f -exec sed -i "s|$TDEDIR/share/applications/kde|$TDEDIR/share/applications/tde|g" {} \; 2>/dev/null # Preserve keyboard shortcuts and input actions. Message_Prefix - echo -e "Updating user-defined keyboard shortcuts in khotkeysrc." + echo "Updating user-defined keyboard shortcuts in khotkeysrc." sed -i 's|CommandURL=kde-|CommandURL=tde-|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null sed -i 's|K Menu - kde-|TDE Menu - tde-|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null sed -i 's|Name=K Menu|Name=TDE Menu|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null sed -i 's|in KDE stands|in TDE stands|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null sed -i 's| use KDE| use TDE|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null Message_Prefix - echo -e "Updating some text strings in khotkeysrc." + echo "Updating some text strings in khotkeysrc." sed -i 's|Go to KDE Website|Go to TDE Website|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null sed -i 's|www\.kde\.org|www\.trinitydesktop\.org|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null sed -i 's|KDE3\.1|TDE|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null @@ -156,19 +185,19 @@ if [ "$R14_UPDATED" != "true" ] || [ "$FORCE" = "true" ]; then sed -i 's|kde321|trinity21|g' "$PROFILE_DIR/share/config/khotkeysrc" 2>/dev/null # Fix the some of the same text strings in kglobalshortcutsrc. Message_Prefix - echo -e "Updating some text strings in kglobalshortcutsrc." + echo "Updating some text strings in kglobalshortcutsrc." sed -i 's|Go to KDE Website|Go to TDE Website|g' "$PROFILE_DIR/share/config/kglobalshortcutsrc" 2>/dev/null sed -i 's|www\.kde\.org|www\.trinitydesktop\.org|g' "$PROFILE_DIR/share/config/kglobalshortcutsrc" 2>/dev/null sed -i 's|KDE3\.1|TDE|g' "$PROFILE_DIR/share/config/kglobalshortcutsrc" 2>/dev/null # Preserve app preferences. Message_Prefix - echo -e "Updating user-defined app preferences in profilerc." + echo "Updating user-defined app preferences in profilerc." sed -i 's|Application=kde-|Application=tde-|g' "$PROFILE_DIR/share/config/profilerc" 2>/dev/null # Preserve kicker/panel icons. Message_Prefix - echo -e "Updating kicker/panel customizations in kickerrc." + echo "Updating kicker/panel customizations in kickerrc." sed -i 's|StorageId\[\$e\]=kde-|StorageId\[\$e\]=tde-|g' "$PROFILE_DIR/share/config/kickerrc" 2>/dev/null # Preserve Quick Launch icons. @@ -177,7 +206,7 @@ if [ "$R14_UPDATED" != "true" ] || [ "$FORCE" = "true" ]; then QUICK_LAUNCH_CONFIG="`grep launcher_panelapplet $PROFILE_DIR/share/config/kickerrc | awk -F = '{print $2}'`" if [ "$QUICK_LAUNCH_CONFIG" != "" ]; then Message_Prefix - echo -e "Updating Quick Launch applet." + echo "Updating Quick Launch applet." sed -i 's|,kde-|,tde-|g' "$PROFILE_DIR/share/config/$QUICK_LAUNCH_CONFIG" 2>/dev/null fi @@ -197,6 +226,7 @@ if [ "$R14_UPDATED" != "true" ] || [ "$FORCE" = "true" ]; then if [ "$?" != "0" ]; then Message_Prefix echo "There was an error with creating a new sym link for $LINK." 1>&2 + KDEGLOBALS_KEY_VALUE="autostart" fi done ) @@ -206,97 +236,83 @@ if [ "$R14_UPDATED" != "true" ] || [ "$FORCE" = "true" ]; then sed -i 's|<Filename>kde-|<Filename>tde-|g' $HOME/.config/menus/applications-kmenuedit.menu fi - unset KDEGLOBALS_KEY_VALUE # Perform some nominal update validations. - # This test includes *.desktop files in the profile Autostart directory. - R14_UPDATE_TEST1="`find \"$PROFILE_DIR\" -name \"*.desktop\" -exec grep \"X-KDE\" {} \; 2>/dev/null`" + # First clean house from any previous failures. + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test*.txt + # This first test includes *.desktop files in the profile Autostart directory. + TEST_NUM="1" + R14_UPDATE_TEST1="`find \"$PROFILE_DIR\" -name \"*.desktop\" -exec grep \"X-KDE\" {} \; &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST1" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check *.desktop files for 'X-KDE'.)" - Display_Message "$MESSAGE" - KDEGLOBALS_KEY_VALUE="1" + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check *.desktop files for 'X-KDE' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi - R14_UPDATE_TEST2="`find \"$PROFILE_DIR\" -name \"*.desktop\" -exec grep -q \"KDE;\" {} \; 2>/dev/null`" + TEST_NUM="2" + R14_UPDATE_TEST2="`find \"$PROFILE_DIR\" -name \"*.desktop\" -exec grep -q \"KDE;\" {} \; &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST2" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check *.desktop files for 'KDE;'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="2" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;2" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check *.desktop files for 'KDE;' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi - R14_UPDATE_TEST3="`find \"$PROFILE_DIR\" \"$PROFILE_DIR/share/apps/kmail/mail\" -prune -o -type f -exec grep -q \"$TDEDIR/share/applications/kde\" {} \; 2>/dev/null`" + TEST_NUM="3" + R14_UPDATE_TEST3="`find \"$PROFILE_DIR\" \"$PROFILE_DIR/share/apps/kmail/mail\" -prune -o -type f -exec grep -q \"$TDEDIR/share/applications/kde\" {} \; &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST3" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check files for '$TDEDIR/share/applications/kde'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="3" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;3" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check files for '$TDEDIR/share/applications/kde' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi - R14_UPDATE_TEST4="`grep -q \"CommandURL=kde-\" \"$PROFILE_DIR/share/config/khotkeysrc\" 2>/dev/null`" + TEST_NUM="4" + R14_UPDATE_TEST4="`grep -q \"CommandURL=kde-\" \"$PROFILE_DIR/share/config/khotkeysrc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST4" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check khotkeysrc for 'CommandURL=kde-'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="4" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;4" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check khotkeysrc for 'CommandURL=kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi - R14_UPDATE_TEST5="`grep -q \"K Menu - kde-\" \"$PROFILE_DIR/share/config/khotkeysrc\" 2>/dev/null`" + TEST_NUM="5" + R14_UPDATE_TEST5="`grep -q \"K Menu - kde-\" \"$PROFILE_DIR/share/config/khotkeysrc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST5" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check khotkeysrc for 'K Menu - kde-'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="5" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;5" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check khotkeysrc for 'K Menu - kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi - R14_UPDATE_TEST6="`grep -q \"Application=kde-\" \"$PROFILE_DIR/share/config/profilerc\" 2>/dev/null`" + TEST_NUM="6" + R14_UPDATE_TEST6="`grep -q \"Application=kde-\" \"$PROFILE_DIR/share/config/profilerc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST6" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check profilerc for 'Application=kde-'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="6" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;6" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check profilerc for 'Application=kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi - R14_UPDATE_TEST7="`grep -q \"StorageId\[\$e\]=kde-\" \"$PROFILE_DIR/share/config/kickerrc\" 2>/dev/null`" + TEST_NUM="7" + R14_UPDATE_TEST7="`grep -q \"StorageId\[\$e\]=kde-\" \"$PROFILE_DIR/share/config/kickerrc\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST7" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check kickerrc for 'StorageId[$e]=kde-'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="7" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;7" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check kickerrc for 'StorageId[$e]=kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi if [ "$QUICK_LAUNCH_CONFIG" != "" ]; then - R14_UPDATE_TEST8="`grep -q \"kde-\" \"$PROFILE_DIR/share/config/$QUICK_LAUNCH_CONFIG\" 2>/dev/null`" + TEST_NUM="8" + R14_UPDATE_TEST8="`grep -q \"kde-\" \"$PROFILE_DIR/share/config/$QUICK_LAUNCH_CONFIG\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST8" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check $QUICK_LAUNCH_CONFIG for 'kde-'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="8" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;8" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check $QUICK_LAUNCH_CONFIG for 'kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi fi if [ -r $HOME/.config/menus/applications-kmenuedit.menu ]; then - R14_UPDATE_TEST9="`grep -q \"<Filename>kde-\" \"$HOME/.config/menus/applications-kmenuedit.menu\" 2>/dev/null`" + TEST_NUM="9" + R14_UPDATE_TEST9="`grep -q \"<Filename>kde-\" \"$HOME/.config/menus/applications-kmenuedit.menu\" &>${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt`" if [ "$R14_UPDATE_TEST9" != "" ]; then - MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check applications-kmenuedit.menu for '<Filename>kde-'.)" - Display_Message "$MESSAGE" - if [ "$KDEGLOBALS_KEY_VALUE" = "" ]; then - KDEGLOBALS_KEY_VALUE="9" - else - KDEGLOBALS_KEY_VALUE="$KDEGLOBALS_KEY_VALUE;9" - fi + MESSAGE="Some Trinity profile R14 XDG compliance updates failed.\n\n(Check applications-kmenuedit.menu for '<Filename>kde-' in\n${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt.)" + Validation_Failure + else + rm -f ${CACHE_DIR}/${SCRIPT_NAME}-test${TEST_NUM}.txt fi fi if [ "$R14_UPDATE_TEST1" = "" ] && [ "$R14_UPDATE_TEST2" = "" ] && [ "$R14_UPDATE_TEST3" = "" ] \ @@ -304,7 +320,8 @@ if [ "$R14_UPDATED" != "true" ] || [ "$FORCE" = "true" ]; then && [ "$R14_UPDATE_TEST7" = "" ] && [ "$R14_UPDATE_TEST8" = "" ] && [ "$R14_UPDATE_TEST9" = "" ]; then $TDEDIR/bin/kwriteconfig --file kdeglobals --group "R14 XDG Updates" --key Updated --type bool "true" else - $TDEDIR/bin/kwriteconfig --file kdeglobals --group "R14 XDG Updates" --key Updated --type bool "$KDEGLOBALS_KEY_VALUE" + # Don't use the --type parameter here because the value no longer is boolean. + $TDEDIR/bin/kwriteconfig --file kdeglobals --group "R14 XDG Updates" --key Updated "$KDEGLOBALS_KEY_VALUE" fi else echo "This script has been run at least once previously. To run manually pass the 'force' parameter." @@ -320,4 +337,5 @@ unset R14_UPDATE_TEST4 unset R14_UPDATE_TEST5 unset R14_UPDATE_TEST6 unset KDEGLOBALS_KEY_VALUE +unset TEST_NUM exit 0 |