File branding-openSUSE.spec of Package branding-openSUSE

#
# spec file for package branding-openSUSE
#
# Copyright (c) 2016 SUSE LINUX 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/
#


Name:           branding-openSUSE
Version:        13.3
Release:        0
Provides:       branding
Conflicts:      otherproviders(branding)
Url:            http://github.com/openSUSE/branding
Source0:        openSUSE.tar.xz
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%ifarch x86_64 %ix86
%define package_gfxboot 1
BuildRequires:  gfxboot-devel
%endif
%ifarch aarch64 %{ix86} x86_64 ppc ppc64
%define package_grub2_theme 1
BuildRequires:  grub2
%endif
Summary:        openSUSE Brand File
License:        BSD-3-Clause
Group:          System/Fhs
BuildRequires:  fdupes
BuildRequires:  fribidi
BuildRequires:  update-desktop-files
BuildArch:      noarch
Obsoletes:      dynamic-wallpaper-branding-openSUSE <= 13.2

%description
This package contains the file /etc/SUSE-brand, and its name is used as
a trigger for installation of correct vendor brand packages.

%define theme_name openSUSE

%if 0%{?package_gfxboot} > 0

%package        -n gfxboot-branding-openSUSE
Summary:        Graphical bootloader openSUSE theme
License:        BSD-3-Clause
Group:          System/Boot
PreReq:         gfxboot >= 4
Supplements:    packageand(gfxboot:branding-openSUSE)
Provides:       gfxboot-branding = %{version}
Provides:       gfxboot-theme = %{version}
Conflicts:      otherproviders(gfxboot-branding)
BuildArch:      noarch

%description -n gfxboot-branding-openSUSE
openSUSE theme for gfxboot (graphical bootloader for grub).
%endif

%package -n wallpaper-branding-openSUSE
Summary:        openSUSE default wallpapers
License:        BSD-3-Clause
Group:          System/Fhs
Requires(post): update-alternatives
Requires(postun): update-alternatives
Provides:       wallpaper-branding = %{version}
Conflicts:      otherproviders(wallpaper-branding)
BuildArch:      noarch

%description -n wallpaper-branding-openSUSE
openSUSE %{version} defaults wallpapers

%package -n yast2-qt-branding-openSUSE
Summary:        openSUSE branding for yast2-qt
License:        BSD-3-Clause
Group:          System/Fhs
Provides:       yast2-qt-branding = %{version}
Conflicts:      otherproviders(yast2-qt-branding)
BuildArch:      noarch

%description -n yast2-qt-branding-openSUSE
openSUSE %{version} branding and themes for yast2-qt

%package -n xfce4-splash-branding-openSUSE
Summary:        openSUSE branding for XFCE splash
License:        CC-BY-SA-3.0
Group:          System/Fhs
BuildArch:      noarch
Provides:       xfce4-splash-branding = %{version}
Conflicts:      otherproviders(xfce4-splash-branding)

%description -n xfce4-splash-branding-openSUSE
openSUSE %{version} branding for the XFCE splash 

%if 0%{?package_grub2_theme} > 0

%package -n grub2-branding-openSUSE
Summary:        openSUSE branding for GRUB2's graphical console
License:        CC-BY-SA-3.0
Group:          System/Fhs
Requires:       grub2
Provides:       grub2-branding = %{version}
Supplements:    packageand(grub2:branding-openSUSE)
Conflicts:      otherproviders(grub2-branding)
BuildArch:      noarch

%description -n grub2-branding-openSUSE
openSUSE %{version} branding for the GRUB2's graphical console

%endif

%package -n plymouth-branding-openSUSE
Summary:        openSUSE branding for Plymouth bootsplash
License:        GPL-2.0+
Group:          System/Fhs
PreReq:         plymouth-plugin-script
PreReq:         plymouth-scripts
Supplements:    packageand(plymouth:branding-openSUSE)
Provides:       plymouth-branding = %{version}
Conflicts:      otherproviders(plymouth-branding)
BuildArch:      noarch

%description -n plymouth-branding-openSUSE
openSUSE %{version} branding for the plymouth bootsplash

%prep
%setup -q -c
cp -a openSUSE/LICENSE COPYING 

%build
cat >SUSE-brand <<EOF
openSUSE
VERSION = %{version}
EOF

%if 0%{?package_gfxboot} > 0
mkdir gfx
cp -a /usr/share/gfxboot/themes/openSUSE/ gfx
list=`cd openSUSE/gfxboot && find -type f`
for i in $list; do 
  cp openSUSE/gfxboot/$i gfx/openSUSE/$i
done
pushd gfx/openSUSE
sed -i -e "s,product=.*,product=openSUSE Leap %{version}," config
perl -pi -e 's/^(welcome=).*/${1}3/' src/gfxboot.cfg

export PATH=/usr/sbin:$PATH
make
popd
%endif

%install
mkdir -p %{buildroot}%{_sysconfdir}
cp SUSE-brand %{buildroot}%{_sysconfdir}/

# gfxboot themes will soon get a make install - promised by snwint
# gfxboot should use a link /etc/bootsplash/theme -> /usr/share/bootsplash
# like splashy 
if test -f gfx/openSUSE/bootlogo; then
    install -d -m 755 %{buildroot}/etc/bootsplash/themes/openSUSE/{bootloader,cdrom} 
    cp gfx/openSUSE/bootlogo %{buildroot}/etc/bootsplash/themes/openSUSE/cdrom 
    /usr/share/gfxboot/bin/unpack_bootlogo %{buildroot}/etc/bootsplash/themes/openSUSE/cdrom 
    install -m 644 gfx/openSUSE/{message,po/*.tr,help-boot/*.hlp} %{buildroot}/etc/bootsplash/themes/openSUSE/bootloader 
    /usr/share/gfxboot/bin/2hl --link --quiet %{buildroot}/etc/bootsplash/themes/openSUSE/*
    mkdir %{buildroot}/boot 
    touch %{buildroot}/boot/message 
fi

make -C openSUSE install DESTDIR=%{buildroot}
rm -rf %{buildroot}%{_datadir}/kde4/apps
rm -rf %{buildroot}%{_datadir}/gimp

for i in %{buildroot}/usr/share/wallpapers/*.desktop; do
    %suse_update_desktop_file "$i"
done
%suse_update_desktop_file %{buildroot}/usr/share/wallpapers/openSUSEdefault/metadata.desktop
# Touch the file handled with update-alternatives
touch %{buildroot}/usr/share/wallpapers/openSUSE-default.xml

# try how far we get without them
rm -v %{buildroot}/usr/share/wallpapers/openSUSE*desktop %{buildroot}/usr/share/wallpapers/openSUSE*jpg %{buildroot}/usr/share/wallpapers/default*
%fdupes %{buildroot}/usr/share/backgrounds

ln -sf /usr/share/wallpapers/openSUSE-default-static.xml %{buildroot}/usr/share/wallpapers/openSUSE-default-dynamic.xml

# remove 
%if 0%{?package_grub2_theme} < 1
rm -rf %{buildroot}/%{_datadir}/grub2
%endif

%check
make -C openSUSE check DESTDIR=%{buildroot}

%if 0%{?package_gfxboot} > 0

%post -n gfxboot-branding-openSUSE
gfxboot --update-theme openSUSE
%endif

%post -n wallpaper-branding-openSUSE
update-alternatives --install /usr/share/wallpapers/openSUSE-default.xml openSUSE-default.xml /usr/share/wallpapers/openSUSE-default-static.xml 5

%postun -n wallpaper-branding-openSUSE
# 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

%if 0%{?package_grub2_theme} > 0
%post -n grub2-branding-openSUSE
%{_datadir}/grub2/themes/%theme_name/activate-theme
if test -e /boot/grub2/grub.cfg ; then
  /usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg || true
fi

%postun -n grub2-branding-openSUSE
if [ $1 = 0 ] ; then
  rm -rf /boot/grub2/themes/%theme_name
fi
%endif

%post -n plymouth-branding-openSUSE
export LIB=%{_libdir}
OTHEME="$(%{_sbindir}/plymouth-set-default-theme)"
if [ "$OTHEME" == "text" -o "$OTHEME" == "openSUSE" -o "$OTHEME" == "basedonopensuse" ]; then
   if [ ! -e /.buildenv ]; then
     %{_sbindir}/plymouth-set-default-theme -R openSUSE
   else
     %{_sbindir}/plymouth-set-default-theme openSUSE
   fi 
fi

%postun -n plymouth-branding-openSUSE
if [ $1 -eq 0 ]; then
    export LIB=%{_libdir}
    if [ "$(%{_sbindir}/plymouth-set-default-theme)" == "openSUSE" ]; then
        %{_sbindir}/plymouth-set-default-theme -R --reset
    fi
fi

%files
%defattr(-,root,root)
%doc COPYING
%{_sysconfdir}/SUSE-brand

%if 0%{?package_gfxboot} > 0

%files -n gfxboot-branding-openSUSE
%defattr(-,root,root)
%{_sysconfdir}/bootsplash
%ghost /boot/message
%endif

%files -n wallpaper-branding-openSUSE
%defattr(-,root,root)
%doc COPYING
%ghost /usr/share/wallpapers/openSUSE-default.xml
/usr/share/gnome-background-properties/wallpaper-branding-openSUSE.xml
/usr/share/wallpapers/
# File from dynamic-wallpaper-branding-openSUSE:
%exclude /usr/share/wallpapers/openSUSE-default-dynamic.xml
# FIXME: It should be owned by a different package:
%dir /usr/share/gnome-background-properties/

%files -n yast2-qt-branding-openSUSE
%defattr(-,root,root)
%dir /usr/share/YaST2
%dir /usr/share/YaST2/theme
%dir /usr/share/YaST2/theme/current
/usr/share/YaST2/theme/current/wizard

%files -n xfce4-splash-branding-openSUSE
%defattr(-,root,root)
%doc openSUSE/xfce/COPYING
/usr/share/pixmaps/xfce4-splash-openSUSE.png

%if 0%{?package_grub2_theme} > 0
%files -n grub2-branding-openSUSE
%defattr(-,root,root)
%{_datadir}/grub2
%dir /boot/grub2
%dir /boot/grub2/backgrounds
%dir /boot/grub2/themes
%ghost /boot/grub2/backgrounds/openSUSE
%ghost /boot/grub2/themes/openSUSE
%endif

%files -n plymouth-branding-openSUSE
%defattr(-, root, root)
%{_datadir}/plymouth/themes/openSUSE/

%changelog
openSUSE Build Service is sponsored by