%bcond_with systemd
%bcond_with build_nosrc

%if !%{with build_nosrc}
%global _disable_source_fetch 0
%endif

Name: docker-ce
Summary: The open-source application container engine
Version: 24.0.2
Release: 1%{?_dist_release}%{?with_systemd:.systemd}
Group: system,virtualization
Vendor: Project Vine
Distribution: Vine Linux
Packager: tomop

License: ASL 2.0
URL: https://www.docker.com
Source0: https://download.docker.com/linux/static/stable/x86_64/docker-%{version}.tgz
Source1: https://raw.githubusercontent.com/docker/cli/v%{version}/README.md
Source2: https://raw.githubusercontent.com/docker/cli/v%{version}/LICENSE

Source10: docker.init
Source11: docker.sysconfig
Source12: docker.conf
Source100: docker.service
Source101: docker.socket
Source102: containerd.service

%if %{with build_nosrc}
NoSource: 0
NoSource: 1
NoSource: 2
%endif

# required packages on install
Requires: /bin/sh
Requires: libcgroup
Requires: docker-ce-cli = %{version}-%{release}
%if %{with systemd}
%{?systemd_requires}
%endif

Conflicts: docker-ee
Conflicts: docker-ee-cli

%description
Docker is is a product for you to build, ship and run any application as a
lightweight container.

Docker containers are both hardware-agnostic and platform-agnostic. This means
they can run anywhere, from your laptop to the largest cloud compute instance and
everything in between - and they don't require you to use a particular
language, framework or packaging system. That makes them great building blocks
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.


%package cli
Summary: clients for Docker
Group: admin-tools,virtualization

%description cli
Docker is is a product for you to build, ship and run any application as a
lightweight container.

Docker containers are both hardware-agnostic and platform-agnostic. This means
they can run anywhere, from your laptop to the largest cloud compute instance and
everything in between - and they don't require you to use a particular
language, framework or packaging system. That makes them great building blocks
for deploying and scaling web apps, databases, and backend services without
depending on a particular stack or provider.


%prep
%setup -q -c -n docker


%build


# %check
# cli/build/docker -v


%install
# install binary
install -d %{buildroot}%{_bindir}
install -d %{buildroot}%{_localstatedir}/lib/docker

for f in docker/*; do
  install -p -m 755 $f %{buildroot}%{_bindir}/
done

%if %{with systemd}
install -D -p -m 644 %{SOURCE100} %{buildroot}%{_unitdir}/docker.service
install -D -p -m 755 %{SOURCE101} %{buildroot}%{_unitdir}/docker.socket
install -D -p -m 644 %{SOURCE102} %{buildroot}%{_unitdir}/containerd.service
%else
install -d %{buildroot}%{_localstatedir}/run/docker
install -D -p -m 755 %{SOURCE10} %{buildroot}%{_initdir}/docker
install -D -p -m 644 %{SOURCE11} %{buildroot}%{_sysconfdir}/sysconfig/docker
install -D -p -m 644 %{SOURCE12} %{buildroot}%{_sysconfdir}/rsyslog.d/docker
%endif

install -p -m 644 %{SOURCE1} ./
install -p -m 644 %{SOURCE2} ./


%clean
rm -rf %{buildroot}

%pre
if ! getent group docker > /dev/null; then
    groupadd --system docker
fi

%post
%if %{with systemd}
%systemd_post containerd.service docker.service
%else
if [ $1 -eq 1 ]; then
  /sbin/chkconfig --add docker
fi
%endif

%preun
%if %{with systemd}
%systemd_preun containerd.service docker.service
%else
if [ $1 -eq 0 -o -x /bin/systemctl ]; then
  /sbin/chkconfig docker off
  /sbin/chkconfig --del docker
fi
%endif

%if %{with systemd}
%postun
%systemd_postun_with_restart containerd.service docker.service
%endif


# list files owned by the package here
%files
%defattr(-,root,root,-)
%license LICENSE
%doc README.md
%{_bindir}/containerd
%{_bindir}/containerd-shim*
%{_bindir}/ctr
%{_bindir}/docker-init
%{_bindir}/docker-proxy
%{_bindir}/dockerd
%{_bindir}/runc
%dir %{_localstatedir}/lib/docker
%if %{with systemd}
%{_unitdir}/docker.service
%{_unitdir}/docker.socket
%{_unitdir}/containerd.service
%else
%{_initdir}/docker
%dir %{_localstatedir}/run/docker
%config(noreplace) %{_sysconfdir}/sysconfig/docker
%config(noreplace) %{_sysconfdir}/rsyslog.d/docker
%endif

%files cli
%defattr(-,root,root,-)
%license LICENSE
%doc README.md
%{_bindir}/docker


%changelog
* Thu Jun 08 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 24.0.2-1
- new upstream release.

* Mon Feb 13 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.10.23-1
- new upstream release.

* Mon Sep 12 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.10.18-1
- new upstream release.

* Tue Dec 28 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.10.12-1
- new upstream release.

* Wed Dec 01 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.10.9-1
- new upstream release.

* Wed May 12 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.10.6-1
- new upstream release.

* Thu Feb 11 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.10.3-1
- new upstream release.

* Thu Dec 17 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 19.03.14-1
- new upstream release.

* Sun Jul 26 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 19.03.09-1
- new upstream release.
- added systemd support (disabled as default).

* Thu Mar 19 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 19.03.08-1
- new upstream release.

* Thu Oct 10 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 19.03.03-1
- new upstream release.

* Tue Aug 27 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 19.03.1-2
- updated initscript: added syslog support.

* Sun Aug 11 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 19.03.1-1
- initial build for Vine Linux.
