File desktop-data-openSUSE.spec of Package desktop-data-openSUSE.import4684

#
# spec file for package desktop-data-openSUSE
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           desktop-data-openSUSE
BuildRequires:  fdupes hicolor-icon-theme perl-RPC-XML update-desktop-files xdg-menu xdg-utils
Version:        11.4
Release:        13.<RELEASE18>
%define wallpaper_version 114
Summary:        Shared Desktop Files for openSUSE
License:        GPLv2+
Group:          System/GUI/Other
Obsoletes:      susewm
Provides:       desktop-data
Obsoletes:      desktop-data-NLD < 11.0
PreReq:         /bin/rm
PreReq:         %fillup_prereq
# some soft Requires: Crystalcursors
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
AutoReqProv:    on
Requires:       hicolor-icon-theme xdg-utils
# This is the default cursor theme we reference in /etc/sysconfig/windowmanager
Requires:       dmz-icon-theme-cursors
Requires(post): update-alternatives
Requires(postun): update-alternatives
Source:         desktop-data.tar.bz2
Source1:        %name.fillup
Source2:        update_rpm
Source3:        desktop-data-openSUSE.xml.in
Source4:        openSUSE-default-static.xml
Patch0:         hidden-fix.diff
BuildArch:      noarch
Provides:       desktop-data-SuSE = 11.0
Obsoletes:      desktop-data-SuSE <= 11.0
Obsoletes:      CheckHardware <= 0.1
Provides:       CheckHardware = 0.1
Obsoletes:      gnome2-SuSE <= 10.3
# BRANDING STUFF
Supplements:    packageand(branding-openSUSE:xorg-x11)
Provides:       desktop-branding = %{version}

%description
This package contains shared desktop files, like the default
applications menu structure and the default wallpaper.

%package extra
License:        GPLv2+
Summary:        Additional wallpapers
Group:          System/GUI/Other
Requires:       desktop-data-openSUSE
Provides:       desktop-data-SuSE-extra = 11.0
Obsoletes:      desktop-data-SuSE-extra <= 11.0
Provides:       desktop-data-SuSE:/usr/share/wallpapers/Bear.jpg
Enhances:       desktop-data-openSUSE

%description extra
This package contains additional wallpapers.

%prep
%setup -q -c
%patch0 -p1

%build
mkdir -p desktop-data/usr/share/gnome-background-properties
sed "s:@VERSION@:%{version}:g" %SOURCE3 > desktop-data/usr/share/gnome-background-properties/desktop-data-openSUSE.xml

# Check that all files mentioned in openSUSE-default.xml actually exist
for file in `sed "s:<[^>]*>::g" %SOURCE4 | grep /usr`; do
    test -f desktop-data/${file} || (echo "${file} is mentioned in %SOURCE4 but does not exist. Please update %SOURCE4, or contact the GNOME team for help."; false )
done

cat >desktop-data/usr/share/gnome-background-properties/desktop-data-openSUSE-extra.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
EOF
for i in desktop-data/usr/share/wallpapers/*.desktop
do
    # Convert KDE style wallpaper desktop files to gnome-wp-list
    case $i in
	# default*.desktop are symlinks for KDE to a real wallpaper.
	desktop-data/usr/share/wallpapers/default*.desktop )
	    GNOMEXML=
	    ;;
	# the default openSUSE wallpaper is handled differently
	desktop-data/usr/share/wallpapers/openSUSE%{wallpaper_version}*.desktop )
	    GNOMEXML=
	    IMG=${i#desktop-data}
	    IMG=${IMG%.desktop}
	    grep -q ${IMG} %SOURCE4 || ( echo "${IMG} not mentioned in %SOURCE4. Please add it there, or contact the GNOME team for help." ; false )
	    ;;
	*.desktop )
	    GNOMEXML=desktop-data/usr/share/gnome-background-properties/desktop-data-openSUSE-extra.xml
	    ;;
    esac
    if test -n "$GNOMEXML" ; then
	IMG=${i#desktop-data}
	IMG=${IMG%.desktop}
	sed -n >>$GNOMEXML <$i '
	    1i \
	<wallpaper deleted="false">
	    $a \
	</wallpaper>
	s@^Name=\(.*\)@		<name>\1</name>@p
	s@^Name\[\([^]]*\)\]=\(.*\)@		<name xml:lang="\1">\2</name>@p
	s@^File=\(.*\)@		<filename>/usr/share/wallpapers/\1</filename>\
		<options>stretched</options>@p
	s@^X-GNOME-WP-Shade-Type=\(.*\)@		<shade_type>\1</shade_type>@p
	s@^X-GNOME-WP-PColor=\(.*\)@		<pcolor>\1</pcolor>@p
	s@^X-GNOME-WP-SColor=\(.*\)@		<scolor>\1</scolor>@p
	'
	# And finally delete X-GNOME-WP-* entries, not needed for KDE style desktop files.
	sed -i '/^X-GNOME-WP-/d' $i
    fi
done
cat >>desktop-data/usr/share/gnome-background-properties/desktop-data-openSUSE-extra.xml <<EOF
</wallpapers>
EOF

%install
cp -a desktop-data/* $RPM_BUILD_ROOT/
install -m 0644 %SOURCE4 $RPM_BUILD_ROOT/usr/share/wallpapers/openSUSE-default-static.xml
touch $RPM_BUILD_ROOT/usr/share/wallpapers/openSUSE-default.xml
mkdir -p $RPM_BUILD_ROOT/etc/xdg/menus/applications-merged
for i in $RPM_BUILD_ROOT/usr/share/desktop-directories/*.directory $RPM_BUILD_ROOT/usr/share/wallpapers/*.desktop
do
    %suse_update_desktop_file "$i"
done
%suse_update_desktop_file package-manager
#
# define default mouse cursor
#
mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates/
install -m 0644 %SOURCE1 \
  $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.windowmanager-%name
#
# is it a valid menu ?
#
export XDG_DATA_DIRS=$RPM_BUILD_ROOT/usr/share/
export XDG_CONFIG_DIRS=$RPM_BUILD_ROOT/etc/xdg/
xdg_menu --die-on-error --format readable
#
# make call-browser executable, symlink
mkdir -p $RPM_BUILD_ROOT/usr/bin
ln -snf xdg-open $RPM_BUILD_ROOT/usr/bin/call-browser
ln -snf xdg-open $RPM_BUILD_ROOT/usr/bin/desktop-launch
#
# fdupes
%fdupes $RPM_BUILD_ROOT/usr/share/icons
%fdupes $RPM_BUILD_ROOT/usr/share/pixmaps

%post
%{fillup_only -an windowmanager}
# clean up old susewm menus
/bin/rm -rf etc/opt/kde3/share/applnk/{Settings,SuSE,work}
update-alternatives --install /usr/share/wallpapers/openSUSE-default.xml openSUSE-default.xml /usr/share/wallpapers/openSUSE-default-static.xml 5

%postun
# Note: we don't use "$1 -eq 0", to avoid issues if the package gets renamed
if [ ! -f /usr/share/wallpapers/openSUSE-default-static.xml ]; then
  update-alternatives --remove openSUSE-default.xml /usr/share/wallpapers/openSUSE-default-static.xml
fi

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%dir /etc/xdg/menus
%dir /etc/xdg/menus/applications-merged
%config(noreplace) /etc/xdg/menus/*.menu
/usr/share/desktop-*
/usr/share/gnome-background-properties/desktop-data-openSUSE.xml
/usr/share/icons/hicolor/*/*/*
%dir /usr/share/icons/oxygen
%dir /usr/share/icons/oxygen/32x32
%dir /usr/share/icons/oxygen/32x32/apps
/usr/share/icons/oxygen/*/*/*
/usr/share/pixmaps/*
/usr/share/applications/package-manager.desktop
# WARNING: If you modify pattern, you must modify also XML generator pattern.
/usr/share/wallpapers/default*
/usr/share/wallpapers/openSUSE%{wallpaper_version}*
%ghost /usr/share/wallpapers/openSUSE-default.xml
/usr/share/wallpapers/openSUSE-default-static.xml
/etc/profile.d/desktop-data.*
/var/adm/fillup-templates/sysconfig.windowmanager-%name
/usr/bin/call-browser
/usr/bin/desktop-launch
/etc/skel/public_html
%dir /etc/kde4
%dir /etc/kde4/kdm
%config /etc/kde4/kdm/backgroundrc
# FIXME: It should be owned by a different package:
%dir /usr/share/gnome-background-properties

%files extra
%defattr(-,root,root)
/usr/share/gnome-background-properties/desktop-data-openSUSE-extra.xml
%exclude /usr/share/wallpapers/default*
%exclude /usr/share/wallpapers/openSUSE%{wallpaper_version}*
%exclude /usr/share/wallpapers/openSUSE-default*.xml
/usr/share/wallpapers
# FIXME: It should be owned by a different package:
%dir /usr/share/gnome-background-properties

%changelog
openSUSE Build Service is sponsored by