File rpi-ds3231.spec of Package rpi-ds3231

#
# spec file for package rpi-ds3231
#
# Copyright (c) 2020 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#

Name:           rpi-ds3231
Version:        2020.08.22
Release:        0
Summary:        Enable RTC DS3231 for Raspberry Pi
License:        GPL-3.0-or-later
BuildArch:      noarch
Source1:        hwclock-start.service

%define uboot_dir /boot

%description
Activates the DS3231 module with a Device Tree (DT) overlay and creates a systemd service to compare the time.

%prep

%build
mkdir -p %{buildroot}%{uboot_dir}/vc/
cat > %{buildroot}%{uboot_dir}/vc/extraconfig.txt <<-'EOF'
	dtoverlay=i2c-rtc,ds3231
EOF

%install
install -m 644 -D %{SOURCE1} %{buildroot}/%{_unitdir}/hwclock-start.service

%post
if mountpoint -q /boot/efi; then
  if ! [[ "$(readlink -f /boot/efi)" -ef "$(readlink -f %{uboot_dir})" ]]; then
    [ -f %{uboot_dir}/vc/extraconfig.txt ] && cp %{uboot_dir}/vc/extraconfig.txt /boot/efi
  fi
fi
%service_add_post hwclock-start.service

%files
%defattr(-,root,root)
%dir %{uboot_dir}/vc
%{uboot_dir}/vc/extraconfig.txt
%dir %{_unitdir}
%{_unitdir}/hwclock-start.service

%changelog
openSUSE Build Service is sponsored by