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 http://bugs.opensuse.org/
#


%define theme_name openSUSE
%ifarch x86_64 %{ix86}
%define package_gfxboot 1
BuildRequires:  gfxboot-devel
%endif
%ifarch %{arm} aarch64 %{ix86} x86_64 ppc ppc64
%define package_grub2_theme 1
BuildRequires:  grub2
%endif
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
URL:            http://github.com/openSUSE/branding
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
%endif

%description
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).
%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
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}
%{update_bootloader_requires}
%endif

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

%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 %{_datadir}/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=%{_prefix}/sbin:$PATH
make %{?_smp_mflags}
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}%{_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
fi

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"
done
%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
%endif

%check
make %{?_smp_mflags} -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 %{_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
fi

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

%posttrans -n grub2-branding-openSUSE
%{?update_bootloader_posttrans}

%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 openSUSE
     %{?regenerate_initrd_post}
   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 --reset
        %{?regenerate_initrd_post}
    fi
fi

%posttrans -n plymouth-branding-openSUSE
%{?regenerate_initrd_posttrans}

%files
%license COPYING

%{_sysconfdir}/SUSE-brand

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

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

%ghost %{_sysconfdir}/alternatives/openSUSE-default.xml
%{_datadir}/wallpapers/openSUSE-default.xml
%{_datadir}/gnome-background-properties/wallpaper-branding-openSUSE.xml
%{_datadir}/wallpapers/
# 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
%{_datadir}/YaST2/theme/current/wizard

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

%{_datadir}/pixmaps/xfce4-splash-openSUSE.png

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

%files -n plymouth-branding-openSUSE
%{_datadir}/plymouth/themes/openSUSE/

%changelog
openSUSE Build Service is sponsored by