diff --git a/suse_update_desktop_file.sh b/suse_update_desktop_file.sh index fb1ac17..f69b96f 100644 --- a/suse_update_desktop_file.sh +++ b/suse_update_desktop_file.sh @@ -22,8 +22,63 @@ COMMENT=no GNAME=no BASEDIR=/no PROJECT= + +function usage() { + local exitcode="$1" + if [ -z "$exitcode" ]; then + exitcode=1 + fi + echo + echo "Usage: $(basename $0) [OPTIONS] [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 " : 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 \"%suse_update_desktop_file \\" + echo " %{buildroot}%{_datadir}/susehelp/meta/%name/%name.desktop\"" + echo " to edit the susehelp desktop entry file instead." + echo " -u|--unimportant : add \"X-SuSE-Unimportant=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 " -t|--trim-i18n : Trim translations (desktops will use gettext to find them)" + echo " otherwise upstream translations are preferred." + 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 : Add \"X-SuSE-DocTeamID=\" to the desktop file." + echo " -D|--docpath : Add \"DocPath=\" to the desktop file - do not guess it" + echo " automatically." + echo " -c|--create : Create a new desktop file in /usr/share/applications/.desktop ." + echo " -C|--comment : Use as \"Comment=\" in desktop file." + echo " -N|--name : Use as \"Name=\" in desktop file." + echo " -G|--genericname : Use as \"GenericName=\" in desktop file." + echo " --basedir : needed only for -t; normally %_srcrpmdir" + echo " --project : set some default values for if any." + echo "" + exit $exitcode +} + + while [ "${1:0:1}" = "-" ]; do case ${1} in + -h|--help) + usage 0 ;; -u|--unimportant) UNIMPORTANT=yes shift @@ -89,7 +144,7 @@ while [ "${1:0:1}" = "-" ]; do continue;; *) echo "UNKNOWN OPTION: $1" - exit 1 ;; + usage 1 ;; esac done @@ -114,9 +169,9 @@ if [ "$CREATE" = "yes" ]; then ICON="$1" shift if [ -z "$NAME" -o -z "$EXEC" ]; then - echo ERROR: after --create you should define - echo DESKTOP_FILE_NAME NAME GENERICNAME EXECUTABLE \[ ICON CATEGORIES... \] - exit 1 + 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 @@ -150,9 +205,9 @@ while [ "$1" ]; do done CATEGORIES="${CATEGORIES#;}" if [ -z "$APPLICATION" ]; then - echo ERROR: suse_update_desktop_file: no application argument given - echo Example: use "qbrew" to edit qbrew.desktop - exit 1 + echo "ERROR: suse_update_desktop_file: no application argument given" >&2 + echo " Example: use "qbrew" to edit qbrew.desktop" >&2 + usage 1 fi # @@ -171,8 +226,8 @@ else FILE_=`find $DIRS -name $APPLICATION.desktop` fi if [ -z "$FILE_" ]; then - echo ERROR: suse_update_desktop_file: unable to find $APPLICATION - exit 1 + echo "ERROR: suse_update_desktop_file: unable to find $APPLICATION" >&2 + usage 1 fi FILE="" for i in $FILE_; do @@ -185,8 +240,8 @@ for i in $FILE_; do sed -e 's/ //' "$i" > "${i}_" && mv "${i}_" "$i" if [ "$FILE" ]; then - echo ERROR: suse_update_desktop_file: $APPLICATION has multiple desktop files - exit 1 + echo "ERROR: suse_update_desktop_file: $APPLICATION has multiple desktop files" >&2 + usage 1 fi FILE=$i done @@ -198,7 +253,7 @@ 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 + 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##*/}" @@ -211,8 +266,8 @@ fi # validate file # if [ ! -r "$FILE" ]; then - echo ERROR: suse_update_desktop_file: unable to read $FILE - exit 1 + echo "ERROR: suse_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}` @@ -242,7 +297,7 @@ for i in $CATIN; do mapCategory $i if [ -z "$ret" ]; then echo "WARNING: Category \"$i\" is unknown \!" - echo WARNING: it is ignored, until you registered a Category at adrian@suse.de . + 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 @@ -303,8 +358,8 @@ if [ -n "$DOCPATH" ] ; then fi if grep -q ^X-SuSE-translate= $FILE; then - echo "ERROR: $FILE contains X-SuSE-translate - called the macro twice?" - exit 1 + echo "ERROR: $FILE contains X-SuSE-translate - called the macro twice?" >&2 + usage 1 fi if [ "$NAME" != "no" ]; then @@ -349,8 +404,8 @@ fi if [ "$I18N" = "yes" ]; then if ! iconv -f utf-8 -t utf-8 $FILE &> /dev/null ; then - echo "ERROR: $FILE is not an UTF-8 file" - exit 1 + echo "ERROR: $FILE is not an UTF-8 file" >&2 + usage 1 fi if [ "$TRIM" = "yes" ]; then diff --git a/update-desktop-files.changes b/update-desktop-files.changes index a726c23..a8839d2 100644 --- a/update-desktop-files.changes +++ b/update-desktop-files.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Jun 8 16:35:32 CEST 2009 - lrupp@suse.de + +- added first usage() +- fix email +- print errors to stderr + ------------------------------------------------------------------- Wed May 20 19:55:00 CEST 2009 - cmorve69o@yahoo.es diff --git a/update-desktop-files.spec b/update-desktop-files.spec index fcad084..8a2abe2 100644 --- a/update-desktop-files.spec +++ b/update-desktop-files.spec @@ -20,7 +20,7 @@ Name: update-desktop-files Version: 11.1 -Release: 2 +Release: 3 Summary: A Build Tool to Update Desktop Files License: GPL v2 or later Group: Development/Tools/Building @@ -64,6 +64,10 @@ rm -rf $RPM_BUILD_ROOT /etc/rpm/* %changelog +* Mon Jun 08 2009 lrupp@suse.de +- added first usage() +- fix email +- print errors to stderr * Wed May 20 2009 cmorve69o@yahoo.es - fix error message when an unknown category is found * Sun Nov 02 2008 coolo@suse.de