%global plymouth_initrd_file /boot/initrd-plymouth.img

Name:           plymouth
Version:        0.9.3
Release:        16
License:        GPLv2+
Summary:        Graphical Boot Animation and Logger
URL:            https://www.freedesktop.org/wiki/Software/Plymouth

Source0:        https://freedesktop.org/software/plymouth/releases/%{name}-%{version}.tar.xz
Source2:        charge.plymouth
Source3:        plymouth-update-initrd

# Patches from upstream git for rotated-display support
# https://bugs.freedesktop.org/show_bug.cgi?id=104714
Patch1:         0001-device-manager-drop-superfluous-create_pixel_display.patch
Patch2:         0002-main-Do-not-update-the-display-on-backspace-when-the.patch
Patch3:         0003-pixel-buffer-Add-the-concept-of-device-rotation.patch
Patch4:         0004-drm-Check-for-panel-orientation-connector-property.patch
Patch5:         0005-drm-Reset-primary-plane-rotation-to-DRM_MODE_ROTATE_.patch
Patch6:         0006-pixel-buffer-switch-device-rotation-to-an-enum.patch
Patch7:         0007-terminal-add-include-for-sysmacros.h.patch
Patch8:         0001-device-manager-skip-graphical-renderer-setup-when-de.patch
Patch9:         0001-device-manager-fall-back-to-text-mode-if-graphical-d.patch
# CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER
Patch10:        0001-renderer-support-reactivating-renderer-without-closi.patch
Patch11:        0002-main-move-ply_device_manager_deactivate_renderers-in.patch
Patch12:        0003-main-Only-activate-renderers-if-the-splash-uses-pixe.patch
Patch13:        0004-drm-Remove-unnecessary-reset_scan_out_buffer_if_need.patch
Patch14:        0005-main-Show-details-when-ESC-is-pressed-during-splash_.patch
Patch15:        0006-main-Fix-getting-detailed-logs-from-systemd.patch
Patch16:        0007-main-fix-build.patch
# addressing: https://gitlab.freedesktop.org/plymouth/plymouth/issues/68
Patch17:        0001-main-ensure-tty-is-closed-on-deactivate.patch
Patch18:        0002-libply-Move-kernel-commandline-parsing-functions-to-.patch
Patch19:        0003-drm-Reset-LUT-gamma-table-before-the-first-drmModeSe.patch
Patch20:        0004-drm-Refactor-ply_renderer_connector_get_rotation.patch
Patch21:        0005-drm-Use-preferred-mode-for-outputs-instead-of-curren.patch

Patch6000:      scripts-Use-2-instead-of-dev-stderr.patch
Patch6001:      INSTALL-Fix-a-spelling-error-in-the-command-example.patch
Patch6002:      x11-don-t-call-gdk_display_get_name-before-gtk_init.patch
Patch6003:      client-fix-typo-in-help-text.patch
Patch6004:      docs-fix-some-typos.patch
Patch6005:      systemd-units-Add-ConditionVirtualization-container.patch
Patch6006:      boot-splash-fix-memory-leak-in-error-path.patch
Patch6007:      event-loop-fix-leak-in-error-path.patch
Patch6008:      key-file-ply_key_file_get_value-returns-duplicated-m.patch
Patch6009:      script-fix-various-memory-leaks.patch
Patch6010:      boot-server-free-the-argument-and-triggers.patch
Patch6011:      systemd-units-Also-add-ConditionVirtualization-conta.patch
Patch6012:      ply-device-manager-Fix-race-causing-undesired-creati.patch
Patch6013:      two-step-Fix-animation-not-starting-on-later-added-h.patch
Patch6014:      two-step-Fix-crash-asking-for-password-with-multiple.patch
Patch6015:      ply-pixel-buffer-Fix-fill_with_buffer-fastpath-when-.patch
Patch6016:      keyboard-add-helper-to-get-the-keyboard-s-renderer-i.patch
Patch6017:      device-manager-free-keyboards-when-deactivating-a-re.patch
Patch6018:      libply-Add-ply_strtod-helper.patch
Patch6019:      two-step-Use-plymouth_strtod.patch
Patch6020:      ply-pixel-buffer-Fix-right-and-bottom-edge-rendering.patch

BuildRequires: gcc libdrm-devel systemd-devel kernel-headers libpng-devel libxslt docbook-style-xsl
BuildRequires: gtk3-devel pango-devel cairo-devel git

Requires(post): %{_sbindir}/plymouth-set-default-theme
Requires:       system-logos findutils coreutils gzip cpio dracut

Provides:       %{name}-system-theme %{name}-scripts %{name}-plugin-two-step %{name}-graphics-libs %{name}-core-libs %{name}-plugin-fade-throbber %{name}-plugin-throbgress %{name}-plugin-space-flares %{name}-plugin-script %{name}-theme-script %{name}-plugin-label
Obsoletes:      %{name}-system-theme %{name}-scripts %{name}-plugin-two-step %{name}-graphics-libs %{name}-core-libs %{name}-plugin-fade-throbber %{name}-plugin-throbgress %{name}-plugin-space-flares %{name}-plugin-script %{name}-theme-script %{name}-plugin-label

%description
Plymouth provides an attractive graphical boot animation in
place of the text messages that normally get shown.  Text
messages are instead redirected to a log file for viewing
after boot.

%package        devel
Summary:        Librar  ies and headers for writing Plymouth splash plugins
Requires:       %{name} = %{version}-%{release}
Requires:       pkgconfig

%description    devel
This package contains the libply and libplybootsplash libraries
and headers needed to develop 3rd party splash plugins for Plymouth.

%package        theme-fade-in
Summary:        Plymouth "Fade-In" theme
Requires:       %{name} = %{version}-%{release}

%description 	theme-fade-in
This package contains the "Fade-In" boot splash theme for
Plymouth. It features a centered logo that fades in and out
while stars twinkle around the logo during system boot up.

%package        theme-spinfinity
Summary:        Plymouth "Spinfinity" theme
Requires:       %{name} = %{version}-%{release}

%description    theme-spinfinity
This package contains the "Spinfinity" boot splash theme for
Plymouth. It features a centered logo and animated spinner that
spins in the shape of an infinity sign.

%package        theme-solar
Summary:        Plymouth "Solar" theme
Requires:       %{name} = %{version}-%{release}

%description    theme-solar
This package contains the "Solar" boot splash theme for
Plymouth. It features a blue flamed sun with animated solar flares.

%package        theme-charge
Summary:        Plymouth "Charge" plugin
Requires:       %{name} = %{version}-%{release}

%description    theme-charge
This package contains the "charge" boot splash theme for
Plymouth.

%package        theme-spinner
Summary:        Plymouth "Spinner" theme
Requires:       %{name} = %{version}-%{release}

%description 	theme-spinner
This package contains the "spinner" boot splash theme for
Plymouth. It features a small spinner on a dark background.

%package_help

%prep
%autosetup -n %{name}-%{version} -p1 -S git

sed -i -e 's/spinner/charge/g' src/plymouthd.defaults

%build
%configure --enable-tracing --disable-tests --with-logo=%{_datadir}/pixmaps/system-logo-white.png \
           --with-background-start-color-stop=0x0073B3 --with-background-end-color-stop=0x00457E --with-background-color=0x3391cd                      \
           --disable-gdm-transition --enable-systemd-integration --without-system-root-install                         \
           --without-log-viewer --without-rhgb-compat-link --disable-libkms

make

%install
%make_install

rm -rf $RPM_BUILD_ROOT%{_datadir}/plymouth/glow/
rm -f $RPM_BUILD_ROOT%{_libdir}/plymouth/glow.so

%delete_la_and_a

mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/plymouth
cp -f $RPM_SOURCE_DIR/plymouth-update-initrd $RPM_BUILD_ROOT%{_libexecdir}/plymouth

mkdir -p $RPM_BUILD_ROOT%{_datadir}/plymouth/themes/charge
cp %{SOURCE2} $RPM_BUILD_ROOT%{_datadir}/plymouth/themes/charge
cp $RPM_BUILD_ROOT%{_datadir}/plymouth/themes/glow/{box,bullet,entry,lock}.png $RPM_BUILD_ROOT%{_datadir}/plymouth/themes/charge

%postun
if [ $1 -eq 0 ]; then
    rm -f %{_libdir}/plymouth/default.so
    rm -f /boot/initrd-plymouth.img
fi

%ldconfig_scriptlets

%postun theme-spinfinity
export LIB=%{_lib}
if [ $1 -eq 0 ]; then
    if [ "$(%{_sbindir}/plymouth-set-default-theme)" == "spinfinity" ]; then
        %{_sbindir}/plymouth-set-default-theme text
    fi
fi

%postun theme-fade-in
export LIB=%{_lib}
if [ $1 -eq 0 ]; then
    if [ "$(%{_sbindir}/plymouth-set-default-theme)" == "fade-in" ]; then
        %{_sbindir}/plymouth-set-default-theme --reset
    fi
fi

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

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

%post theme-charge
export LIB=%{_lib}
if [ $1 -eq 1 ]; then
    %{_sbindir}/plymouth-set-default-theme charge
else
    if [ "$(%{_sbindir}/plymouth-set-default-theme)" == "solar" ]; then
        %{_sbindir}/plymouth-set-default-theme charge
    fi
fi

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

%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS
%dir %{_libexecdir}/plymouth
%dir %{_libdir}/plymouth/renderers
%config(noreplace) %{_sysconfdir}/plymouth/plymouthd.conf
%{_bindir}/plymouth
%{_sbindir}/plymouth-set-default-theme
%{_sbindir}/plymouthd
%{_libexecdir}/plymouth/plymouth-*-initrd
%{_libdir}/libply-splash-graphics.so.*
%{_libdir}/plymouth/renderers/drm*
%{_libdir}/plymouth/renderers/frame-buffer*
%{_libdir}/plymouth/*.so
%{_libdir}/libply.so.*
%{_libdir}/libply-splash-core.so.*
%{_libdir}/libply-boot-client.so.*
%{_libdir}/plymouth/two-step.so
%{_datadir}/plymouth/themes/details/details.plymouth
%{_datadir}/plymouth/themes/text/text.plymouth
%{_datadir}/plymouth/themes/tribar/tribar.plymouth
%{_datadir}/plymouth/themes/solar/solar.plymouth
%{_datadir}/plymouth/plymouthd.defaults
%{_datadir}/plymouth/themes/script/script.*
%{_localstatedir}/run/plymouth
%{_localstatedir}/spool/plymouth
%ghost %{_localstatedir}/lib/plymouth/boot-duration
%{_prefix}/lib/systemd/system/*
%exclude %{_libdir}/plymouth/two-step.so
%exclude %{_datadir}/plymouth/themes/glow

%files devel
%defattr(-,root,root)
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc
%{_libdir}/plymouth/renderers/x11*
%{_includedir}/plymouth-1

%files theme-fade-in
%defattr(-,root,root)
%{_datadir}/plymouth/themes/fade-in/fade-in.plymouth

%files theme-spinner
%defattr(-,root,root)
%{_datadir}/plymouth/themes/spinner/spinner.plymouth

%files theme-spinfinity
%defattr(-,root,root)
%{_datadir}/plymouth/themes/spinfinity/spinfinity.plymouth

%files theme-solar
%defattr(-,root,root)
%{_datadir}/plymouth/themes/solar/solar.plymouth

%files theme-charge
%defattr(-,root,root)
%{_datadir}/plymouth/themes/charge/charge.plymouth

%files help
%defattr(-,root,root)
%doc README
%{_datadir}/plymouth/themes/*/*.png
%{_mandir}/man?/*

%changelog
* Fri Dec 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.9.3-16
- description change

* Thu Sep 19 2019 openEuler Buildteam <buildteam@openeuler.org> - 0.9.3-15
- Package init
