Accepting request 96477 from X11:common: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/96477 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/update-desktop-files?expand=0&rev=81
This commit is contained in:
commit
d2ccf0039b
53
brp-trim-desktop.sh
Normal file
53
brp-trim-desktop.sh
Normal file
@ -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-SuSE-translate= "$FILE"; then
|
||||
echo "DEBUG: $FILE contains X-SuSE-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-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
|
||||
# standard.
|
||||
%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
|
||||
|
@ -13,15 +13,12 @@
|
||||
#
|
||||
INSTALL=no
|
||||
I18N=yes
|
||||
TRIM=no
|
||||
CREATE=no
|
||||
RESET=no
|
||||
UNIMPORTANT=no
|
||||
NAME=no
|
||||
COMMENT=no
|
||||
GNAME=no
|
||||
BASEDIR=/no
|
||||
PROJECT=
|
||||
|
||||
function usage() {
|
||||
local exitcode="$1"
|
||||
@ -49,8 +46,6 @@ function usage() {
|
||||
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"
|
||||
@ -68,8 +63,6 @@ function usage() {
|
||||
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 " --basedir <path> : needed only for -t; normally %_srcrpmdir"
|
||||
echo " --project <string> : set some default values for <string> if any."
|
||||
echo ""
|
||||
exit $exitcode
|
||||
}
|
||||
@ -87,10 +80,6 @@ while [ "${1:0:1}" = "-" ]; do
|
||||
I18N=no
|
||||
shift
|
||||
continue;;
|
||||
-t|--trim-i18n)
|
||||
TRIM=yes
|
||||
shift
|
||||
continue;;
|
||||
-i|--install)
|
||||
INSTALL=yes
|
||||
shift
|
||||
@ -132,31 +121,12 @@ while [ "${1:0:1}" = "-" ]; do
|
||||
GNAME="${1}"
|
||||
shift
|
||||
continue;;
|
||||
--basedir)
|
||||
shift
|
||||
BASEDIR="${1}"
|
||||
shift
|
||||
continue;;
|
||||
--project)
|
||||
shift
|
||||
PROJECT="${1}"
|
||||
shift
|
||||
continue;;
|
||||
*)
|
||||
echo "UNKNOWN OPTION: $1"
|
||||
usage 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "$PROJECT" in
|
||||
SUSE:*|SuSE:*|openSUSE:*)
|
||||
TRIM=yes
|
||||
;;
|
||||
home:coolo:test-desktop-files*)
|
||||
TRIM=yes
|
||||
;;
|
||||
esac
|
||||
|
||||
APPLICATION="$1"
|
||||
shift
|
||||
if [ "$CREATE" = "yes" ]; then
|
||||
@ -406,32 +376,7 @@ if [ "$COMMENT" != "no" ]; then
|
||||
fi
|
||||
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" >&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
|
||||
if [ "$I18N" = "no" ]; then
|
||||
#
|
||||
# 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
|
||||
|
||||
|
@ -15,21 +15,19 @@
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
# norootforbuild
|
||||
|
||||
|
||||
Name: update-desktop-files
|
||||
Version: 12.1
|
||||
Release: 1
|
||||
Release: 0
|
||||
Summary: A Build Tool to Update Desktop Files
|
||||
License: GPL-2.0+
|
||||
Group: Development/Tools/Building
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
AutoReqProv: on
|
||||
Source: suse_update_desktop_file.sh
|
||||
Source1: map-desktop-category.sh
|
||||
Source2: macro
|
||||
Source3: desktop.attr
|
||||
Source4: brp-trim-desktop.sh
|
||||
Source100: mimetypes.prov
|
||||
# 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
|
||||
@ -39,7 +37,13 @@ BuildArch: noarch
|
||||
|
||||
%description
|
||||
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
|
||||
%setup -q -n . -D -T 0
|
||||
@ -53,13 +57,16 @@ mkdir -p $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 %SOURCE3 $RPM_BUILD_ROOT%_rpmconfigdir/fileattrs/desktop.attr
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
install -m0755 -D %SOURCE4 $RPM_BUILD_ROOT/usr/lib/rpm/brp-suse.d/brp-70-trim-desktopfiles
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%_rpmconfigdir/*
|
||||
%exclude %_rpmconfigdir/brp-suse.d
|
||||
/etc/rpm/*
|
||||
|
||||
%files -n brp-trim-desktopfiles
|
||||
%defattr(-,root,root)
|
||||
%_rpmconfigdir/brp-suse.d
|
||||
|
||||
%changelog
|
||||
|
Loading…
Reference in New Issue
Block a user