import 12.1 accepted/tizen/20130503.230725 accepted/tizen/20130520.094421 accepted/trunk/20130325.213620 submit/tizen/20130503.233255 submit/tizen/20130509.184634 submit/tizen/20130517.024306 submit/trunk/20130325.083851
authorAnas Nashif <anas.nashif@intel.com>
Fri, 9 Nov 2012 14:28:45 +0000 (06:28 -0800)
committerAnas Nashif <anas.nashif@intel.com>
Fri, 9 Nov 2012 14:28:45 +0000 (06:28 -0800)
packaging/brp-trim-desktop.sh [new file with mode: 0644]
packaging/macro [new file with mode: 0644]
packaging/map-desktop-category.sh [new file with mode: 0644]
packaging/tizen_update_desktop_file.sh [new file with mode: 0644]
packaging/update-desktop-files.spec [new file with mode: 0644]

diff --git a/packaging/brp-trim-desktop.sh b/packaging/brp-trim-desktop.sh
new file mode 100644 (file)
index 0000000..8e56850
--- /dev/null
@@ -0,0 +1,53 @@
+#! /bin/sh
+
+# macro: suse_update_desktop_file
+#
+#     Used to add easily a category to .desktop files according to XDG
+#     standard.
+#
+
+#
+# find file
+#
+BASEDIR=`dirname $RPM_SOURCE_DIR`/OTHER
+
+if ! test -f /.buildenv; then
+   # this looks fishy, skip it
+   echo "WARNING: I better not trim without a /.buildenv around"
+   exit 0
+fi
+
+if ! test -w $BASEDIR; then
+   echo "WARNING: Can't write to $BASEDIR, skipping"
+   exit 0
+fi
+
+find /$RPM_BUILD_ROOT/opt/kde3/share/applications/kde/ \
+  /$RPM_BUILD_ROOT/opt/kde3/share/applnk/ \
+  /$RPM_BUILD_ROOT/usr/share/xsessions/ \
+  /$RPM_BUILD_ROOT/usr/share/applications/ \
+  /$RPM_BUILD_ROOT/usr/share/mimelnk/ \
+  /$RPM_BUILD_ROOT/usr/share/gnome/apps/ \
+  /$RPM_BUILD_ROOT/etc/xdg/autostart/ -name *.desktop -o -name .directory 2>/dev/null | while read FILE; do
+
+       if grep -q ^X-TIZEN-translate= "$FILE"; then
+          echo "DEBUG: $FILE contains X-TIZEN-translate - skipping" >&2
+          continue
+       fi
+
+       # save for backup 
+       NFILE=${FILE#$RPM_BUILD_ROOT}
+       echo "<<$NFILE>>" >> $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles
+       cat $FILE >> $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles
+       echo "trimmed output to $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles"
+
+       #
+       # Trim translations (desktops will use gettext to find them)
+       #
+       grep -v -E '^Name\[|^GenericName\[|^Comment\[' $FILE > ${FILE}_ 
+       sed -i -e '/^\[Desktop Entry\]/a \
+X-TIZEN-translate=true' ${FILE}_
+       mv ${FILE}_ $FILE
+
+done
+
diff --git a/packaging/macro b/packaging/macro
new file mode 100644 (file)
index 0000000..88e8c36
--- /dev/null
@@ -0,0 +1,6 @@
+# macro: %suse_update_desktop_file
+#     Used to add easily a category to .desktop files according to XDG
+#     standard.
+%tizen_update_desktop_file(cinrud:D:N:C:G:) \
+   /usr/lib/rpm/tizen_update_desktop_file.sh %{**} || exit 1 \
+  %nil
diff --git a/packaging/map-desktop-category.sh b/packaging/map-desktop-category.sh
new file mode 100644 (file)
index 0000000..610a2f1
--- /dev/null
@@ -0,0 +1,139 @@
+#! /bin/sh
+
+function mapCategory() {
+  ret=""
+  local in="${1#X-TIZEN-}"
+  case $in in
+#old 9.0 Categories
+    AddressBook)
+       ret="ContactManagement"
+       echo WARNING: AddressBook is an outdated Category, mapping it to ContactManagement
+       ;;
+    Camera)
+       ret="Photography"
+       echo WARNING: Camera is an outdated Category, mapping it to Photography
+       ;;
+    NewsReader)
+       ret="News"
+       echo WARNING: NewsReader is an outdated Category, mapping it to News
+       ;;
+    DialUp)
+       ret="Dialup"
+       echo WARNING: DialUp is an outdated Category, mapping it to Dialup
+       ;;
+    Telephone)
+       ret="Telephony"
+       echo WARNING: Telephone is an outdated Category, mapping it to Telephony
+       ;;
+    MidiPlayer)
+       ret="Midi"
+       echo WARNING: MidiPlayer is an outdated Category, mapping it to Midi
+       ;;
+    AudioMixer)
+       ret="Mixer"
+       echo WARNING: AudioMixer is an outdated Category, mapping it to Mixer
+       ;;
+    SimulationGame)
+       ret="Simulation"
+       echo WARNING: SimulationGame is an outdated Category, mapping it to Simulation
+       ;;
+    RolePlayingGame)
+       ret="RolePlaying"
+       echo WARNING: RolePlayingGame is an outdated Category, mapping it to RolePlaying
+       ;;
+    School)
+       ret="Teaching"
+       echo WARNING: School is an outdated Category, mapping it to Teaching
+       ;;
+
+
+#special cases
+    Internet)
+       ret="Network"
+       echo WARNING: Internet is an illegal Category, mapping it to Network
+       ;;
+    DevelopmentWWW)
+       ret="X-TIZEN-WebDevelopment"
+       echo WARNING: DevelopmentWWW is an illegal Category, mapping it to WebDevelopment
+       ;;
+    Language)
+       ret="Languages"
+       echo WARNING: Language is an illegal Category, mapping it to Languages
+       ;;
+    Burning)
+       ret="DiscBurning"
+       echo WARNING: Burning is an illegal Category, mapping it to DiscBurning
+       ;;
+    AudioVideoRecorder)
+       ret="Recorder"
+       echo WARNING: AudioVideoRecorder is an illegal Category, mapping it to Recorder
+       ;;
+    AudioVideoPlayer)
+       ret="Player"
+       echo WARNING: AudioVideoPlayer is an illegal Category, mapping it to Player
+       ;;
+    Photograph)
+       ret="Photography"
+       echo WARNING: Photograph is a mistyped Category, mapping it to Photography
+       ;;
+#Office Menu:
+    Calendar|WordProcessor|Spreadsheet|ProjectManagement|Presentation| \
+    Database|Dictionary|Finance|FlowChart|ContactManagement|PDFViewer) ret=$in ;;
+    Warehouse|Addressbook)
+       ret="X-TIZEN-$in";;
+#Internet/Network Menu:
+    P2P|HamRadio|Email|News|Dialup|IRCClient|FileTransfer|InstantMessaging|WebBrowser|WebDevelopment) ret=$in ;;
+    RSS-News)
+       ret="X-TIZEN-$in";;
+#Development Menu:
+    GUIDesigner|RevisionControl|IDE|Building|Debugger|Profiling|Translation) ret=$in ;;
+    Design)
+       ret="X-TIZEN-$in";;
+#Graphics Menu:
+    3DGraphics|Photography|Scanning|OCR|VectorGraphics|RasterGraphics|2DGraphics) ret=$in ;;
+#Education Menu:
+    Teaching|Science|Math|Chemistry|Astronomy|Art|Construction|Languages| \
+    Engineering|Geography) ret=$in ;;
+#Multimedia Menu:
+    AudioVideoEditing|Music|DiscBurning|Mixer|Player|Midi|Sequencer| \
+    TV|Tuner|Recorder|Video) ret=$in ;;
+    CD|CDReader|Jukebox)
+       ret="X-TIZEN-$in";;
+#System Menu:
+    Applet|Emulator|Monitor|Screensaver|TerminalEmulator|SystemSetup| \
+    FileManager|Filesystem|Archiving|PackageManager|TrayIcon| \
+    Security|RemoteAccess) ret=$in ;;
+    ServiceConfiguration| \
+    Backup|YaST|YaST-Hardware|YaST-Misc|YaST-Network|YaST-Virtualization|YaST-Support| \
+    Feedback|YaST-Net_advanced|YaST-Security|YaST-Software|YaST-System|YaST-AppArmor)
+       ret="X-TIZEN-$in" ;;
+#Utility Menu:
+    Telephony|Accessibility|TextEditor|PDA|Calculator|Clock) ret=$in ;;
+    DesktopUtility|SyncUtility|PrintingUtility|TimeUtility|WebUtility|Editor)
+       ret="X-TIZEN-$in" ;;
+#Game Menu:
+    3DGame|Amusement|ArcadeGame|CardGame|FirstPersonGame|BoardGame|\
+    PlatformGame|PuzzleGame|SportsGame|StrategyGame|BlocksGame| \
+    ActionGame|AdventureGame|KidsGame|LogicGame|Simulation|RolePlaying)
+       ret=$in ;;
+#Control Center Categories:
+    ControlCenter-Personal|ControlCenter-Hardware|ControlCenter-LookAndFeel|ControlCenter-System)
+       ret="X-TIZEN-$in" ;;
+#XFCE Private Categories:
+    X-Xfce*|X-XFCE*)
+       ret="$in" ;;
+#special tags:
+    Application|Qt|KDE|GTK|GNOME|XFCE|Motif|ConsoleOnly|Shell|X-Red-*| \
+    X-Ximian-*|X-GNOME-*|X-KDE-*|Settings|DesktopSettings|HardwareSettings| \
+    Office|Network|Game|Graphics|Education|Documentation|Development| \
+    Viewer|System|Utility|AudioVideo|AdvancedSettings|More) ret=$in ;;
+    Core-Edutainment|Core-Game|Core-Graphics|Core-Internet| \
+    Core-Multimedia|Core-Office|Core-Settings|Core-Utility|Core-System| \
+    Core-Configuration|Core-Development|core)
+       ret="X-TIZEN-$in" ;;
+    Core)
+       ret="$in" ;;
+    *) ret="" ;;
+  esac
+}
+
diff --git a/packaging/tizen_update_desktop_file.sh b/packaging/tizen_update_desktop_file.sh
new file mode 100644 (file)
index 0000000..9b9584d
--- /dev/null
@@ -0,0 +1,393 @@
+#! /bin/sh
+
+# macro: tizen_update_desktop_file
+#
+#     Used to add easily a category to .desktop files according to XDG
+#     standard.
+#
+
+. /usr/lib/rpm/map-desktop-category.sh
+
+#
+# parse arguments
+#
+INSTALL=no
+I18N=yes
+CREATE=no
+RESET=no
+UNIMPORTANT=no
+NAME=no
+COMMENT=no
+GNAME=no
+
+function usage() {
+       local exitcode="$1"
+       if [ -z "$exitcode" ]; then
+               exitcode=1
+       fi
+       echo
+       echo "Usage: $(basename $0) [OPTIONS] <APPLICATION> [CATEGORIES]"
+       echo
+       echo " Summary:"
+       echo "       Used to add easily a category to .desktop files according to XDG"
+       echo "       standard. More information is available on"
+       echo "       http://en.opensuse.org/SUSE_Package_Conventions/RPM_Macros"
+       echo "       If you have any questions, please use our mailinglist: "
+       echo "       opensuse-packaging@opensuse.org"
+       echo " Options:"
+       echo "       <APPLICATION>             : The name of the desktop file."
+       echo "                                   Example: use \"qbrew\" to edit qbrew.desktop"
+       echo "                                   If APPLICATION has multiple desktop files, try the exact path"
+       echo "                                   to the desktop file."
+       echo "                                   Example: use \"%tizen_update_desktop_file \\"
+       echo "                                   %{buildroot}%{_datadir}/susehelp/meta/%name/%name.desktop\""
+       echo "                                   to edit the susehelp desktop entry file instead."
+       echo "       -u|--unimportant          : add \"NoDisplay=true\" to the resulting desktop"
+       echo "                                   file."
+       echo "       -n|--no-i18n              : Do not prepare the desktop file for translators (obsoletes -t)."
+       echo "                                   (adds X-SuSE-translate=false to the desktop file)"
+       echo "       -i|--install              : Install an existing desktop file in /usr/share/applications/"
+       echo "                                   The to be installed desktop file can be located in:"
+       echo "                                   - RPM_SOURCE_DIR or"
+       echo "                                   - RPM_BUILD_DIR"
+       echo "                                   A referenced icon file (ending *.png; *.xpm) is installed in"
+       echo "                                   /usr/share/pixmaps/ automatically if it is located in one of the " 
+       echo "                                   directories mentioned above (-maxdepth 1)."
+       echo "       -r|--reset                : Reset the \"Categories\" line in an existing desktop file."
+       echo "                                   Normally, categories mentioned in an existing desktop file will be"
+       echo "                                   obtained. Additional categories from commandline are added."
+       echo "       -d|--docid <string>       : Add \"X-SuSE-DocTeamID=<string>\" to the desktop file."
+       echo "       -D|--docpath <path>       : Add \"DocPath=<path>\" to the desktop file - do not guess it"
+       echo "                                   automatically."
+       echo "       -c|--create <name>        : Create a new desktop file in /usr/share/applications/<name>.desktop ."
+       echo "       -C|--comment <string>     : Use <string> as \"Comment=<string>\" in desktop file."
+       echo "       -N|--name <string>        : Use <string> as \"Name=<string>\" in desktop file."
+       echo "       -G|--genericname <string> : Use <string> as \"GenericName=<string>\" in desktop file."
+       echo ""
+       exit $exitcode
+}
+
+
+while [ "${1:0:1}" = "-" ]; do
+  case ${1} in
+    -h|--help)
+       usage 0 ;;
+    -u|--unimportant)
+       UNIMPORTANT=yes
+       shift
+       continue;;
+    -n|--no-i18n)
+       I18N=no
+       shift
+       continue;;
+    -i|--install)
+       INSTALL=yes
+       shift
+       continue;;
+    -r|--reset)
+       RESET=yes
+       shift
+       continue;;
+    -d|--docid)
+       shift
+       DOCID="${1}"
+       shift
+       continue;;
+    -D|--docpath)
+       shift
+       DOCPATH="${1}"
+       if ! [ -r "$RPM_BUILD_ROOT/opt/kde3/share/doc/HTML/en/$DOCPATH/index.docbook" -o -r $RPM_BUILD_ROOT/usr/share/gnome/help/$DOCPATH/C/$DOCPATH.xml -o -r $RPM_BUILD_ROOT/usr/share/gnome/help/${DOCPATH/\///C/} ] ; then 
+         echo WARNING:tizen_update_desktop_file: DocPath target $DOCPATH for $FILE does not exist
+       fi
+       shift
+       continue;;
+    -c|--create)
+       CREATE=yes
+       INSTALL=yes
+       shift
+       continue;;
+    -C|--comment)
+       shift
+       COMMENT="${1}"
+       shift
+       continue;;
+    -N|--name)
+       shift
+       NAME="${1}"
+       shift
+       continue;;
+    -G|--genericname)
+       shift
+       GNAME="${1}"
+       shift
+       continue;;
+    --basedir)
+       echo "WARNING: basedir is no longer supported"
+       shift
+       shift
+       continue;;
+    --project)
+       echo "WARNING: project is no longer supported"
+       shift
+       shift
+       continue;;
+   *)
+       echo "UNKNOWN OPTION: $1"
+       usage 1 ;;
+  esac
+done
+
+APPLICATION="$1"
+shift
+if [ "$CREATE" = "yes" ]; then
+  NAME="$1"
+  shift
+  GNAME="$1"
+  shift
+  EXEC="$1"
+  shift
+  ICON="$1"
+  shift
+  if [ -z "$NAME" -o -z "$EXEC" ]; then
+     echo "ERROR: after --create you should define" >&2
+     echo "       DESKTOP_FILE_NAME NAME GENERICNAME EXECUTABLE \[ ICON CATEGORIES... \]" >&2
+     usage 1
+  fi
+  mkdir -p $RPM_BUILD_ROOT/usr/share/applications/
+  cat > $RPM_SOURCE_DIR/$APPLICATION.desktop << EOF
+[Desktop Entry]
+Encoding=UTF-8
+Name=$NAME
+GenericName=$GNAME
+Type=Application
+Exec=$EXEC
+Icon=$ICON
+EOF
+NAME=no
+GNAME=no
+fi
+if [ "$INSTALL" = "yes" ]; then
+  mkdir -p $RPM_BUILD_ROOT/usr/share/applications/
+  FILE=`find $RPM_SOURCE_DIR $RPM_BUILD_DIR . -name $APPLICATION.desktop| sort -r | head -n 1`
+  if [ -s "$FILE" ]; then
+    cp -v "$FILE" $RPM_BUILD_ROOT/usr/share/applications/
+    icon_file=`sed -n '/^\[Desktop Entry\]/,/(\[.*|$)/ s,Icon=\(.*\),\1,p' "$FILE"`
+    icon_file=`find $RPM_SOURCE_DIR $RPM_BUILD_DIR -maxdepth 1 -name ${icon_file}.png -o -name ${icon_file}.xpm -o -name $icon_file | sort -r | head -n 1`
+    if [ -s "$icon_file" ]; then
+      mkdir -p $RPM_BUILD_ROOT/usr/share/pixmaps/
+      cp -v "$icon_file" $RPM_BUILD_ROOT/usr/share/pixmaps/
+    fi
+  fi
+fi
+while [ "$1" ]; do
+  CATEGORIES="$CATEGORIES;$1"
+  shift
+done
+CATEGORIES="${CATEGORIES#;}"
+if [ -z "$APPLICATION" ]; then
+  echo "ERROR: tize_update_desktop_file: no application argument given" >&2
+  echo "                                 Example: use "qbrew" to edit qbrew.desktop" >&2
+  usage 1
+fi
+
+#
+# find file
+#
+for i in /$RPM_BUILD_ROOT/opt/kde3/share/applications/kde/ \
+  /$RPM_BUILD_ROOT/opt/kde3/share/applnk \
+  /$RPM_BUILD_ROOT/usr/share/applications/ \
+  /$RPM_BUILD_ROOT/usr/share/gnome/apps/ \
+  /$RPM_BUILD_ROOT/etc/xdg/autostart/ ; do
+    [ -e "$i" ] && DIRS="$DIRS $i" 
+done 
+if [ "${APPLICATION:0:1}" == "/" -a -e "$APPLICATION" ]; then
+  FILE_="$APPLICATION"
+else
+  FILE_=`find $DIRS -name $APPLICATION.desktop` 
+fi
+if [ -z "$FILE_" ]; then 
+   echo "ERROR: tizen_update_desktop_file: unable to find $APPLICATION" >&2
+   usage 1 
+fi 
+FILE=""
+for i in $FILE_; do
+  #
+  # fix old files
+  #
+  sed -e 's/\[KDE Desktop Entry\]/[Desktop Entry]/' "$i" > "${i}_" && mv "${i}_" "$i"
+
+  # dos2unix for the poor
+  sed -e 's/\r//' "$i" > "${i}_" && mv "${i}_" "$i"
+
+  if [ "$FILE" ]; then
+    echo "ERROR: tizen_update_desktop_file: $APPLICATION has multiple desktop files" >&2
+    usage 1
+  fi
+  FILE=$i
+done
+
+#
+# move KDE legacy files to XDG path
+#
+if echo $FILE | grep -q /opt/kde3/share/applnk/ ; then
+ if ! echo $FILE | grep -q /opt/kde3/share/applnk/.hidden/ ; then
+  if ! echo $FILE | grep -q /opt/kde3/share/applnk/Settings/ ; then
+   if ! echo $FILE | grep -q /opt/kde3/share/applnk/System/ScreenSavers/ ; then
+     echo "WARNING: file is in old KDE legacy path, moving it to XDG path"
+     mkdir -p $RPM_BUILD_ROOT/opt/kde3/share/applications/kde/
+     mv "$FILE" $RPM_BUILD_ROOT/opt/kde3/share/applications/kde/
+     FILE="$RPM_BUILD_ROOT/opt/kde3/share/applications/kde/${FILE##*/}"
+   fi
+  fi
+ fi
+fi
+
+#
+# validate file
+#
+if [ ! -r "$FILE" ]; then 
+   echo "ERROR: _update_desktop_file: unable to read $FILE" >&2
+   usage 1 
+fi 
+# esp. for susehelp
+FILE_DOCPATH=`sed -n -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,;, ,g' -e 's,^DocPath=\\(.*\\),\\1,p' ${FILE}` 
+if [ -n "$FILE_DOCPATH" ] ; then
+  if [ ! -r "$RPM_BUILD_ROOT/opt/kde3/share/doc/HTML/en/$FILE_DOCPATH/index.docbook" ] && [ ! -r "$RPM_BUILD_ROOT/usr/share/gnome/help/$FILE_DOCPATH/C/$FILE_DOCPATH.xml" ] && [ ! -r $RPM_BUILD_ROOT/usr/share/gnome/help/${DOCPATH/\///C/} ] ; then 
+     echo WARNING: tizen_update_desktop_file: DocPath target $FILE_DOCPATH for $FILE does not exist
+  fi
+fi
+
+#
+# update Categories
+#
+if [ "$RESET" = "no" ]; then
+  CATIN=`sed -n -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,;, ,g' -e 's,^Categories=\\(.*\\),\\1,p' ${FILE}` 
+fi
+CATIN="$CATIN ${CATEGORIES//;/ }"
+if [ -z "$CATIN" ]; then 
+  case "${FILE%/*}" in
+   */opt/kde3/*) CATIN="Qt KDE" ;;
+   */usr/share/gnome*) CATIN="GTK" ;;
+  esac
+fi
+unset CAT
+unset DCAT
+for i in $CATIN; do
+  ret=""
+  mapCategory $i
+  if [ -z "$ret" ]; then 
+    echo "WARNING: Category \"$i\" is unknown \!"
+    echo WARNING: it is ignored, until you registered a Category at opensuse-packaging@opensuse.org .
+  else
+    echo "$CAT" | grep -q "[=;]$i;" || CAT="$CAT$ret;"
+  fi
+done
+echo "" >> "${FILE}" 
+CAT="${CAT#;}"
+if grep -q ^Categories= $FILE; then 
+  sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Categories=.*,Categories='${CAT}',' "$FILE"
+else 
+  if [ -n "${CAT%;}" ]; then
+    sed -i -e '/^\[Desktop Entry\]/a \
+'"Categories=${CAT%;};" $FILE
+  fi
+fi
+if [ "$UNIMPORTANT" = "yes" ]; then
+  if grep -q ^NoDisplay= $FILE; then
+    sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^NoDisplay=.*,NoDisplay=true,' "$FILE" 
+  else
+    sed -i -e '/^\[Desktop Entry\]/a \
+NoDisplay=true' $FILE 
+  fi
+fi
+if [ "$DOCID" ]; then
+  sed -i -e '/^\[Desktop Entry\]/a \
+'"X-SuSE-DocTeamID=$DOCID" $FILE
+fi
+
+#
+# check or set DocPath
+#
+DOCPATH_IS_GUESS=false
+if [ -z "$DOCPATH" ] ; then
+  if [ -f $RPM_BUILD_ROOT/usr/share/gnome/help/$APPLICATION/C/$APPLICATION.xml ] ; then
+    DOCPATH=$APPLICATION
+    DOCPATH_IS_GUESS=true
+  fi
+  if [ -f $RPM_BUILD_ROOT/opt/kde3/share/doc/HTML/en/$APPLICATION/index.docbook ] ; then
+    DOCPATH=$APPLICATION
+    DOCPATH_IS_GUESS=true
+  fi
+  # NOTE: Here we can add guess for application/file.xml
+fi
+if [ -n "$DOCPATH" ] ; then
+  if [ -n "$FILE_DOCPATH" ] ; then 
+    # DocPath already exists. Update it only from command line, not from guess.
+    if $DOCPATH_IS_GUESS ; then
+      if [ "$DOCPATH" != "$FILE_DOCPATH" ] ; then
+        echo WARNING: tizen_update_desktop_file: DocPath target $FILE_DOCPATH differs from guess $DOCPATH for $FILE
+      fi
+    else
+      sed -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^DocPath=.*,DocPath='${DOCPATH}',' "$FILE" > "${FILE}.new" &&
+      mv "${FILE}.new" "${FILE}"
+    fi
+  else 
+    sed -i -e '/^\[Desktop Entry\]/a \
+'"DocPath=${DOCPATH}" $FILE 
+    if $DOCPATH_IS_GUESS ; then
+      echo NOTE: tizen_update_desktop_file: Guessing DocPath=$DOCPATH in $FILE
+    fi
+  fi
+fi
+
+if grep -q ^X-SuSE-translate= $FILE; then
+   echo "ERROR: $FILE contains X-SuSE-translate - called the macro twice?" >&2
+   usage 1
+fi
+
+if [ "$NAME" != "no" ]; then
+    sed -i -e '/^Name\[/d' $FILE 
+    if [ -n "$NAME" ]; then
+       if ! grep -q ^Name= ${FILE}; then
+         sed -i -e '/^\[Desktop Entry\]/a '"Name=${NAME//,/\,}" ${FILE}
+       else
+         sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Name=.*,Name='"${NAME//,/\,}"',' ${FILE}
+       fi
+    else
+      sed -i -e '/^Name=/d' $FILE
+    fi
+fi
+
+if [ "$GNAME" != "no" ]; then
+    sed -i -e '/^GenericName\[/d' $FILE
+    if [ -n "$GNAME" ]; then
+       if ! grep -q ^GenericName= ${FILE}_; then
+        sed -i -e '/^\[Desktop Entry\]/a '"GenericName=${GNAME//,/\,}" ${FILE}
+       else
+         sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^GenericName=.*,GenericName='"${GNAME//,/\,}"',' ${FILE}
+       fi
+    else
+      sed -i -e '/^GenericName=/d' $FILE
+    fi
+fi
+
+if [ "$COMMENT" != "no" ]; then
+    sed -i -e '/^Comment\[/d' $FILE 
+    if [ -n "$COMMENT" ]; then
+       if ! grep -q ^Comment= ${FILE}; then
+          sed -i -e '/^\[Desktop Entry\]/a '"Comment=${COMMENT//,/\,}" ${FILE}
+       else
+          sed -i -e '/^\[Desktop Entry\]/,/(\[.*|$)/ s,^Comment=.*,Comment='"${COMMENT//,/\,}"',' ${FILE}
+       fi
+    else
+      sed -i -e '/^Comment=/d' $FILE
+    fi
+fi
+
+if [ "$I18N" = "no" ]; then
+  #
+  # this file will not get translated
+  #
+  sed -i -e '/^\[Desktop Entry\]/a \
+X-SuSE-translate=false' $FILE
+fi
diff --git a/packaging/update-desktop-files.spec b/packaging/update-desktop-files.spec
new file mode 100644 (file)
index 0000000..ed17844
--- /dev/null
@@ -0,0 +1,52 @@
+Name:           update-desktop-files
+Version:        12.1
+Release:        0
+Summary:        A Build Tool to Update Desktop Files
+License:        GPL-2.0+
+Group:          Development/Tools/Building
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+Source:         tizen_update_desktop_file.sh
+Source1:        map-desktop-category.sh
+Source2:        macro
+Source4:        brp-trim-desktop.sh
+# This is not true technically, but we do that to make the rpm macros from
+# desktop-file-utils available to most packages that ship a .desktop file
+# (since they already have a update-desktop-files BuildRequires).
+Requires:       desktop-file-utils
+BuildArch:      noarch
+
+%description
+This package provides further translations and a shell script to update
+desktop files. It is used by the %%tizen_update_desktop_file rpm macro.
+
+%package -n brp-trim-desktopfiles
+Summary:        Trim translations from .deskop files
+Group:          Development/Tools/Building
+
+%description -n brp-trim-desktopfiles
+Trim translations from all .deskop files found in build root
+
+%prep
+%setup -q -n . -D -T 0
+mkdir %name
+cd %name
+
+%build
+
+%install
+mkdir -p $RPM_BUILD_ROOT%_rpmconfigdir
+install -m0755 %SOURCE0 %SOURCE1 $RPM_BUILD_ROOT%_rpmconfigdir
+install -m0644 -D %SOURCE2 $RPM_BUILD_ROOT/etc/rpm/macros.%name
+install -m0755 -D %SOURCE4 $RPM_BUILD_ROOT/usr/lib/rpm/brp-tizen.d/brp-70-trim-desktopfiles
+
+%files
+%defattr(-,root,root)
+%_rpmconfigdir/*
+%exclude %_rpmconfigdir/brp-tizen.d
+/etc/rpm/*
+
+%files -n brp-trim-desktopfiles
+%defattr(-,root,root)
+%_rpmconfigdir/brp-tizen.d
+
+%changelog