File branding-openSUSE.spec of Package branding-openSUSE

# spec file for package branding-openSUSE
# Copyright (c) 2018 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

%define theme_name openSUSE
%ifarch x86_64 %{ix86}
%define package_gfxboot 1
BuildRequires:  gfxboot-devel
%ifarch %{arm} aarch64 %{ix86} x86_64 ppc ppc64
%define package_grub2_theme 1
BuildRequires:  grub2
Name:           branding-openSUSE
Version:        13.3
Release:        0
Summary:        openSUSE Brand File
License:        BSD-3-Clause AND CC-BY-SA-3.0 AND GPL-2.0+
Group:          System/Fhs
Source0:        openSUSE.tar.xz
BuildRequires:  fdupes
BuildRequires:  fribidi
BuildRequires:  suse-module-tools
BuildRequires:  update-desktop-files
Conflicts:      branding
Provides:       branding
Obsoletes:      dynamic-wallpaper-branding-openSUSE <= 13.2
BuildArch:      noarch
%if 0%{?suse_version} > 1320
BuildRequires:  update-bootloader-rpm-macros

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

%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)
Conflicts:      gfxboot-branding
Provides:       gfxboot-branding = %{version}
Provides:       gfxboot-theme = %{version}
BuildArch:      noarch

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

%package -n wallpaper-branding-openSUSE
Summary:        openSUSE default wallpapers
License:        BSD-3-Clause
Group:          System/Fhs
Requires(post): update-alternatives
Requires(postun): update-alternatives
Conflicts:      wallpaper-branding
Provides:       wallpaper-branding = %{version}
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
Conflicts:      yast2-qt-branding
Provides:       yast2-qt-branding = %{version}
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
Conflicts:      xfce4-splash-branding
Provides:       xfce4-splash-branding = %{version}
BuildArch:      noarch

%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
# grub2 is required in all cases in order to have /etc/default/grub in place during post.
# Otherwise it may happen that grub2 is installed after the branding packae.
Requires:       grub2
Supplements:    packageand(grub2:branding-openSUSE)
Conflicts:      grub2-branding
Provides:       grub2-branding = %{version}
BuildArch:      noarch
%if 0%{?update_bootloader_requires:1}

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


%package -n plymouth-branding-openSUSE
Summary:        openSUSE branding for Plymouth bootsplash
License:        GPL-2.0-or-later
Group:          System/Fhs
BuildRequires:  plymouth-plugin-two-step
Requires:       plymouth-plugin-two-step
PreReq:         plymouth-plugin-script
PreReq:         plymouth-scripts
Requires(%post): plymouth-plugin-two-step
Supplements:    packageand(plymouth:branding-openSUSE)
Conflicts:      plymouth-branding
Provides:       plymouth-branding = %{version}
BuildArch:      noarch

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

%setup -q -c

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

%if 0%{?package_gfxboot} > 0
mkdir gfx
cp -a %{_datadir}/gfxboot/themes/openSUSE/ gfx
list=`cd openSUSE/gfxboot && find -type f`
for i in $list; do
  cp openSUSE/gfxboot/$i gfx/openSUSE/$i
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=%{_prefix}/sbin:$PATH
make %{?_smp_mflags}

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}%{_sysconfdir}/bootsplash/themes/openSUSE/{bootloader,cdrom}
    cp gfx/openSUSE/bootlogo %{buildroot}%{_sysconfdir}/bootsplash/themes/openSUSE/cdrom
    %{_datadir}/gfxboot/bin/unpack_bootlogo %{buildroot}%{_sysconfdir}/bootsplash/themes/openSUSE/cdrom
    install -m 644 gfx/openSUSE/{message,po/*.tr,help-boot/*.hlp} %{buildroot}%{_sysconfdir}/bootsplash/themes/openSUSE/bootloader
    %{_datadir}/gfxboot/bin/2hl --link --quiet %{buildroot}%{_sysconfdir}/bootsplash/themes/openSUSE/*
    mkdir %{buildroot}/boot
    touch %{buildroot}/boot/message

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

for i in %{buildroot}%{_datadir}/wallpapers/*.desktop; do
    %suse_update_desktop_file "$i"
%suse_update_desktop_file %{buildroot}%{_datadir}/wallpapers/openSUSEdefault/metadata.desktop
# Touch the file handled with update-alternatives
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
ln -s -f %{_sysconfdir}/alternatives/openSUSE-default.xml %{buildroot}%{_datadir}/wallpapers/openSUSE-default.xml

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

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

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

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

%if 0%{?package_gfxboot} > 0
%post -n gfxboot-branding-openSUSE
gfxboot --update-theme openSUSE

%post -n wallpaper-branding-openSUSE
update-alternatives --install %{_datadir}/wallpapers/openSUSE-default.xml openSUSE-default.xml %{_datadir}/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 %{_datadir}/wallpapers/openSUSE-default-static.xml ]; then
  update-alternatives --remove openSUSE-default.xml %{_datadir}/wallpapers/openSUSE-default-static.xml

%if 0%{?package_grub2_theme} > 0
%post -n grub2-branding-openSUSE
%if 0%{?update_bootloader_check_type_refresh_post:1}
%{update_bootloader_check_type_refresh_post grub2 grub2-efi}
if test -e /boot/grub2/grub.cfg ; then
  %{_sbindir}/grub2-mkconfig -o /boot/grub2/grub.cfg || true

%posttrans -n grub2-branding-openSUSE

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

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

%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 --reset

%posttrans -n plymouth-branding-openSUSE

%license COPYING


%if 0%{?package_gfxboot} > 0
%files -n gfxboot-branding-openSUSE
%ghost /boot/message

%files -n wallpaper-branding-openSUSE
%license COPYING

%ghost %{_sysconfdir}/alternatives/openSUSE-default.xml
# File from dynamic-wallpaper-branding-openSUSE:
%exclude %{_datadir}/wallpapers/openSUSE-default-dynamic.xml
# FIXME: It should be owned by a different package:
%dir %{_datadir}/gnome-background-properties/

%files -n yast2-qt-branding-openSUSE
%dir %{_datadir}/YaST2
%dir %{_datadir}/YaST2/theme
%dir %{_datadir}/YaST2/theme/current

%files -n xfce4-splash-branding-openSUSE
%license COPYING


%if 0%{?package_grub2_theme} > 0
%files -n grub2-branding-openSUSE
%dir /boot/grub2
%dir /boot/grub2/themes
%ghost /boot/grub2/themes/openSUSE

%files -n plymouth-branding-openSUSE

openSUSE Build Service is sponsored by