Accepting request 96425 from home:coolo:branches:openSUSE:Factory
- split brp-trim-desktopfiles that installs a brp script to trim all .desktop files without need of an extra macro OBS-URL: https://build.opensuse.org/request/show/96425 OBS-URL: https://build.opensuse.org/package/show/X11:common:Factory/update-desktop-files?expand=0&rev=29
This commit is contained in:
parent
a733f33e7b
commit
7e61e8d818
46
brp-trim-desktop.sh
Normal file
46
brp-trim-desktop.sh
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#! /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 -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-SuSE-translate= "$FILE"; then
|
||||||
|
echo "DEBUG: $FILE contains X-SuSE-translate - skipping" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# save for backup
|
||||||
|
if test -w $BASEDIR && test -f /.buildenv; then
|
||||||
|
echo "<<$FILE>>" >> $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles
|
||||||
|
cat $FILE >> $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles
|
||||||
|
echo "created $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles"
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# Trim translations (desktops will use gettext to find them)
|
||||||
|
#
|
||||||
|
grep -v -E '^Name\[|^GenericName\[|^Comment\[' $FILE > ${FILE}_
|
||||||
|
sed -i -e '/^\[Desktop Entry\]/a \
|
||||||
|
X-SuSE-translate=true' ${FILE}_
|
||||||
|
mv ${FILE}_ $FILE
|
||||||
|
|
||||||
|
done
|
||||||
|
|
2
macro
2
macro
@ -2,5 +2,5 @@
|
|||||||
# Used to add easily a category to .desktop files according to XDG
|
# Used to add easily a category to .desktop files according to XDG
|
||||||
# standard.
|
# standard.
|
||||||
%suse_update_desktop_file(cinrud:D:N:C:G:) \
|
%suse_update_desktop_file(cinrud:D:N:C:G:) \
|
||||||
/usr/lib/rpm/suse_update_desktop_file.sh %{?distribution:--project "%distribution"} %{?_project:--project "%_project"} --basedir %_srcrpmdir %{**} || exit 1 \
|
/usr/lib/rpm/suse_update_desktop_file.sh %{**} || exit 1 \
|
||||||
%nil
|
%nil
|
||||||
|
@ -13,15 +13,12 @@
|
|||||||
#
|
#
|
||||||
INSTALL=no
|
INSTALL=no
|
||||||
I18N=yes
|
I18N=yes
|
||||||
TRIM=no
|
|
||||||
CREATE=no
|
CREATE=no
|
||||||
RESET=no
|
RESET=no
|
||||||
UNIMPORTANT=no
|
UNIMPORTANT=no
|
||||||
NAME=no
|
NAME=no
|
||||||
COMMENT=no
|
COMMENT=no
|
||||||
GNAME=no
|
GNAME=no
|
||||||
BASEDIR=/no
|
|
||||||
PROJECT=
|
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
local exitcode="$1"
|
local exitcode="$1"
|
||||||
@ -49,8 +46,6 @@ function usage() {
|
|||||||
echo " file."
|
echo " file."
|
||||||
echo " -n|--no-i18n : Do not prepare the desktop file for translators (obsoletes -t)."
|
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 " (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 " -i|--install : Install an existing desktop file in /usr/share/applications/"
|
||||||
echo " The to be installed desktop file can be located in:"
|
echo " The to be installed desktop file can be located in:"
|
||||||
echo " - RPM_SOURCE_DIR or"
|
echo " - RPM_SOURCE_DIR or"
|
||||||
@ -68,8 +63,6 @@ function usage() {
|
|||||||
echo " -C|--comment <string> : Use <string> as \"Comment=<string>\" in desktop file."
|
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 " -N|--name <string> : Use <string> as \"Name=<string>\" in desktop file."
|
||||||
echo " -G|--genericname <string> : Use <string> as \"GenericName=<string>\" in desktop file."
|
echo " -G|--genericname <string> : Use <string> as \"GenericName=<string>\" in desktop file."
|
||||||
echo " --basedir <path> : needed only for -t; normally %_srcrpmdir"
|
|
||||||
echo " --project <string> : set some default values for <string> if any."
|
|
||||||
echo ""
|
echo ""
|
||||||
exit $exitcode
|
exit $exitcode
|
||||||
}
|
}
|
||||||
@ -87,10 +80,6 @@ while [ "${1:0:1}" = "-" ]; do
|
|||||||
I18N=no
|
I18N=no
|
||||||
shift
|
shift
|
||||||
continue;;
|
continue;;
|
||||||
-t|--trim-i18n)
|
|
||||||
TRIM=yes
|
|
||||||
shift
|
|
||||||
continue;;
|
|
||||||
-i|--install)
|
-i|--install)
|
||||||
INSTALL=yes
|
INSTALL=yes
|
||||||
shift
|
shift
|
||||||
@ -132,31 +121,12 @@ while [ "${1:0:1}" = "-" ]; do
|
|||||||
GNAME="${1}"
|
GNAME="${1}"
|
||||||
shift
|
shift
|
||||||
continue;;
|
continue;;
|
||||||
--basedir)
|
|
||||||
shift
|
|
||||||
BASEDIR="${1}"
|
|
||||||
shift
|
|
||||||
continue;;
|
|
||||||
--project)
|
|
||||||
shift
|
|
||||||
PROJECT="${1}"
|
|
||||||
shift
|
|
||||||
continue;;
|
|
||||||
*)
|
*)
|
||||||
echo "UNKNOWN OPTION: $1"
|
echo "UNKNOWN OPTION: $1"
|
||||||
usage 1 ;;
|
usage 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
case "$PROJECT" in
|
|
||||||
SUSE:*|SuSE:*|openSUSE:*)
|
|
||||||
TRIM=yes
|
|
||||||
;;
|
|
||||||
home:coolo:test-desktop-files*)
|
|
||||||
TRIM=yes
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
APPLICATION="$1"
|
APPLICATION="$1"
|
||||||
shift
|
shift
|
||||||
if [ "$CREATE" = "yes" ]; then
|
if [ "$CREATE" = "yes" ]; then
|
||||||
@ -406,32 +376,7 @@ if [ "$COMMENT" != "no" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$I18N" = "yes" ]; then
|
if [ "$I18N" = "no" ]; then
|
||||||
|
|
||||||
if ! iconv -f utf-8 -t utf-8 $FILE &> /dev/null ; then
|
|
||||||
echo "ERROR: $FILE is not an UTF-8 file" >&2
|
|
||||||
usage 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$TRIM" = "yes" ]; then
|
|
||||||
# save for backup
|
|
||||||
if test -w $BASEDIR && test -f /.buildenv; then
|
|
||||||
echo "<<$FILE>>" >> $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles
|
|
||||||
cat $FILE >> $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles
|
|
||||||
echo "created $BASEDIR/$RPM_PACKAGE_NAME.desktopfiles"
|
|
||||||
fi
|
|
||||||
#
|
|
||||||
# Trim translations (desktops will use gettext to find them)
|
|
||||||
#
|
|
||||||
grep -v -E '^Name\[|^GenericName\[|^Comment\[' $FILE > ${FILE}_
|
|
||||||
sed -i -e '/^\[Desktop Entry\]/a \
|
|
||||||
X-SuSE-translate=true' ${FILE}_
|
|
||||||
mv ${FILE}_ $FILE
|
|
||||||
else # silently do nothing - upstream translations preferred
|
|
||||||
sed -e '/^\[Desktop Entry\]/a \
|
|
||||||
X-SuSE-translate=true' $FILE > ${FILE}_ && mv ${FILE}_ $FILE
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
#
|
#
|
||||||
# this file will not get translated
|
# this file will not get translated
|
||||||
#
|
#
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Dec 9 14:26:41 UTC 2011 - coolo@suse.com
|
||||||
|
|
||||||
|
- split brp-trim-desktopfiles that installs a brp script to trim all
|
||||||
|
.desktop files without need of an extra macro
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Thu Sep 29 14:58:16 UTC 2011 - vuntz@opensuse.org
|
Thu Sep 29 14:58:16 UTC 2011 - vuntz@opensuse.org
|
||||||
|
|
||||||
|
@ -15,21 +15,18 @@
|
|||||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||||
#
|
#
|
||||||
|
|
||||||
# norootforbuild
|
|
||||||
|
|
||||||
|
|
||||||
Name: update-desktop-files
|
Name: update-desktop-files
|
||||||
Version: 12.1
|
Version: 12.1
|
||||||
Release: 1
|
Release: 0
|
||||||
Summary: A Build Tool to Update Desktop Files
|
Summary: A Build Tool to Update Desktop Files
|
||||||
License: GPLv2+
|
License: GPL-2.0+
|
||||||
Group: Development/Tools/Building
|
Group: Development/Tools/Building
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
AutoReqProv: on
|
|
||||||
Source: suse_update_desktop_file.sh
|
Source: suse_update_desktop_file.sh
|
||||||
Source1: map-desktop-category.sh
|
Source1: map-desktop-category.sh
|
||||||
Source2: macro
|
Source2: macro
|
||||||
Source3: desktop.attr
|
Source3: desktop.attr
|
||||||
|
Source4: brp-trim-desktop.sh
|
||||||
Source100: mimetypes.prov
|
Source100: mimetypes.prov
|
||||||
# This is not true technically, but we do that to make the rpm macros from
|
# 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
|
# desktop-file-utils available to most packages that ship a .desktop file
|
||||||
@ -39,7 +36,13 @@ BuildArch: noarch
|
|||||||
|
|
||||||
%description
|
%description
|
||||||
This package provides further translations and a shell script to update
|
This package provides further translations and a shell script to update
|
||||||
desktop files. It is used by the %suse_update_desktop_file rpm macro.
|
desktop files. It is used by the %%suse_update_desktop_file rpm macro.
|
||||||
|
|
||||||
|
%package -n brp-trim-desktopfiles
|
||||||
|
Summary: Trim translations from .deskop files
|
||||||
|
|
||||||
|
%description -n brp-trim-desktopfiles
|
||||||
|
Trim translations from all .deskop files found in build root
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n . -D -T 0
|
%setup -q -n . -D -T 0
|
||||||
@ -53,13 +56,16 @@ mkdir -p $RPM_BUILD_ROOT%_rpmconfigdir
|
|||||||
install -m0755 %SOURCE0 %SOURCE1 %SOURCE100 $RPM_BUILD_ROOT%_rpmconfigdir
|
install -m0755 %SOURCE0 %SOURCE1 %SOURCE100 $RPM_BUILD_ROOT%_rpmconfigdir
|
||||||
install -m0644 -D %SOURCE2 $RPM_BUILD_ROOT/etc/rpm/macros.%name
|
install -m0644 -D %SOURCE2 $RPM_BUILD_ROOT/etc/rpm/macros.%name
|
||||||
install -m0644 -D %SOURCE3 $RPM_BUILD_ROOT%_rpmconfigdir/fileattrs/desktop.attr
|
install -m0644 -D %SOURCE3 $RPM_BUILD_ROOT%_rpmconfigdir/fileattrs/desktop.attr
|
||||||
|
install -m0755 -D %SOURCE4 $RPM_BUILD_ROOT/usr/lib/rpm/brp-suse.d/brp-70-trim-desktopfiles
|
||||||
%clean
|
|
||||||
rm -rf $RPM_BUILD_ROOT
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
%_rpmconfigdir/*
|
%_rpmconfigdir/*
|
||||||
|
%exclude %_rpmconfigdir/brp-suse.d
|
||||||
/etc/rpm/*
|
/etc/rpm/*
|
||||||
|
|
||||||
|
%files -n brp-trim-desktopfiles
|
||||||
|
%defattr(-,root,root)
|
||||||
|
%_rpmconfigdir/brp-suse.d
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
Loading…
Reference in New Issue
Block a user