rendered paste bodyfunction _setupDesktopFile() {
local adjust_path="$1"
local F="$2"
local categories_value category category_add
if $adjust_path; then
trace Adjusting path for $F...
local bindir=$( escapeValue "$PREFIX/bin/" )
grep -q '^TryExec=/' "$F" || safeSed "$F" "s/^TryExec=/TryExec=$bindir/"
grep -q '^Exec=/' "$F" || safeSed "$F" "s/^Exec=/Exec=$bindir/"
fi
# ensure there is an ending ';' in the 'Categories' values from Desktop Entry section - if not rewrite the entry
local desktop_entry_section=$( getSection "$F" "Desktop Entry" )
local cat_count=$( echo "$desktop_entry_section" | grep -c '^Categories' )
if (( cat_count == 1 )); then
categories_value=`echo "$desktop_entry_section" | grep '^Categories=' | awk 'BEGIN{FS="="}; { print $2 }' -`
trace categories_value is $categories_value
local i=${#categories_value}
(( i-- ))
if [[ ${categories_value:$i} != ";" ]]; then
trace adding ';' to Desktop Entry Categories values in $F
addSectionLine "$F" "Desktop Entry" "Categories=${categories_value};" "^Categories="
# reload categories_value
desktop_entry_section=$( getSection "$F" "Desktop Entry" )
categories_value=`echo "$desktop_entry_section" | grep '^Categories=' | awk 'BEGIN{FS="="}; { print $2 }' -`
fi
if ! echo "$categories_value" | grep -qF "X-Red-Hat-Base;"; then
trace adding X-Red-Hat-Base to $F...
addSectionLine "$F" "Desktop Entry" "Categories=${categories_value}X-Red-Hat-Base;" "^Categories="
fi
# mandriva category mangling area - compatibility till full implementation of xdg
if [[ "$AUTOPACKAGE_DISTRIBUTION_ID" == "mandriva" ]]; then
for category in `echo $categories_value | sed 's/\;/ /g'`; do
case $category in
Audio ) category_add="X-MandrivaLinux-Multimedia-Sound";;
AudioVideo ) category_add="X-MandrivaLinux-Multimedia";;
Audio ) category_add="X-MandrivaLinux-Multimedia-Sound";;
Video ) category_add="X-MandrivaLinux-Multimedia-Video";;
Development ) category_add="X-MandrivaLinux-MoreApplications-Development";;
Education ) category_add="X-MandrivaLinux-MoreApplications-Education";;
Game ) category_add="X-MandrivaLinux-MoreApplications-Games";;
Graphics ) category_add="X-MandrivaLinux-Multimedia-Graphics";;
Network ) category_add="X-MandrivaLinux-Internet";;
Office ) category_add="X-MandrivaLinux-Office";;
Settings ) category_add="X-MandrivaLinux-System-Configuration";;
System ) category_add="X-MandrivaLinux-System";;
Utility ) category_add="X-MandrivaLinux-Office-Accessories";;
esac
[ -n "$category_add" ] && addSectionLine "$F" "Desktop Entry" "Categories=${categories_value}${category_add};" "^Categories="
done
fi
elif (( cat_count > 1 )); then
err "installMenuItem: desktop file $F has more than 1 'Categories' keys in the Desktop Entry section."
fi
# check if we need to update MIME database
if grep -q '^MimeType=' "$F"; then
# register update-mime-database trigger
_registerTrigger mime
else
warn no MimeType line for $F
fi
addSectionLine "$F" "Desktop Entry" "X-Autopackage=${ROOTNAME}" "^X-Autopackage="
# add action menu text to .desktop file and add short name
#outn "$DESKTOP_ACTION_UPDATE" "$SHORTNAME" >> "$F";
outn "$DESKTOP_ACTION_VERIFY" "$SHORTNAME" >> "$F";
outn "$DESKTOP_ACTION_REMOVE" "$SHORTNAME" >> "$F";
safeSed "$F" "s/Short_Name/${SHORTNAME}/"
# gather previous 'Actions' values from Desktop Entry section and prepend new action values
action_value=`getSection "$F" "Desktop Entry" | grep '^Actions=' | awk 'BEGIN{FS="="}; { print $2 }' -`
#addSectionLine "$F" "Desktop Entry" "Actions=Apkg-Update;Apkg-Verify;Apkg-Remove;$action_value" "^Actions="
addSectionLine "$F" "Desktop Entry" "Actions=Apkg-Verify;Apkg-Remove;$action_value" "^Actions="
}
##