## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by go2rpm 1.6.0
%bcond_without check
%bcond_with bootstrap
%global debug_package %{nil}

%if %{with bootstrap}
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(.*\\)$
%endif
# Windows only
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(github.com/Microsoft/hcsshim/.*\\)$

# https://github.com/moby/moby
%global goipath         github.com/docker/docker
%global forgeurl        https://github.com/moby/moby
Version:                23.0.5

%gometa -f

%global goaltipaths     github.com/moby/moby

%global common_description %{expand:
Moby is an open-source project created by Docker to enable and accelerate
software containerization.

It provides a "Lego set" of toolkit components, the framework for assembling
them into custom container-based systems, and a place for all container
enthusiasts and professionals to experiment and exchange ideas. Components
include container build tools, a container registry, orchestration tools, a
runtime and more, and these can be used as building blocks in conjunction with
other tools and projects.}

%global golicenses      LICENSE NOTICE
%global godocs          docs AUTHORS CHANGELOG.md CONTRIBUTING.md README.md\\\
                        ROADMAP.md SECURITY.md TESTING.md VENDORING.md

Name:           %{goname}
Release:        %autorelease
Summary:        Collaborative project for the container ecosystem

# Upstream license specification: MIT and Apache-2.0
License:        MIT AND Apache-2.0
URL:            %{gourl}
Source0:        %{gosource}
# For compatibility with current Swarmkit
# https://github.com/moby/swarmkit/issues/3081
Patch0:         0001-Revert-backend-add-StopOptions-to-ContainerRestart-a.patch
Patch1:         0002-Revert-client-ContainerStop-ContainerRestart-support.patch
Patch2:         0003-Revert-api-types-time-remove-DurationToSecondsString.patch
# Fix build for btrfs-progs-6.1
Patch3:         44707.patch

BuildRequires:  git-core
BuildRequires:  pkgconfig(libseccomp)
BuildRequires:  pkgconfig(devmapper)
%if %{without bootstrap}
BuildRequires:  golang(github.com/agext/levenshtein)
BuildRequires:  golang(github.com/gofrs/flock)
BuildRequires:  golang(github.com/google/shlex)
BuildRequires:  golang(github.com/mitchellh/hashstructure)
BuildRequires:  golang(github.com/moby/buildkit/source/types)
BuildRequires:  golang(github.com/moby/buildkit/util/buildinfo/types)
BuildRequires:  golang(github.com/moby/buildkit/util/resolver/config)
BuildRequires:  golang(github.com/tonistiigi/units)
%endif

%description
%{common_description}

%gopkg

%prep
%goprep
#patch0 -p1
#patch1 -p1
#patch2 -p1
#patch3 -p1
find . -iname "*_windows.go" -type f -exec rm -rfv '{}' \+;
rm -rfv pkg/archive/changes_test.go libnetwork/drivers/windows/ daemon/graphdriver/windows/
sed -i "s|github.com/docker/distribution|github.com/distribution/distribution/v3|" $(find . -iname "*.go" -type f)
sed -i "s|MountTypeCSI|MountTypeCluster|" $(find . -iname "*.go" -type f)

%if %{without bootstrap}
%generate_buildrequires
%go_generate_buildrequires
%endif

%build
for cmd in cmd/* ; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done

%install
%gopkginstall
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/

%if %{without bootstrap}
%if %{with check}
%check
for test in "TestCheckoutGit" \
            "TestSCTP4Proxy" \
            "TestBtrfsSetup" \
            "TestBtrfsCreateEmpty" \
            "TestBtrfsCreateBase" \
            "TestBtrfsCreateSnap" \
            "TestBtrfsSubvolDelete" \
            "TestGetSourceMount" \
            "TestIfaceAddrs" \
; do
awk -i inplace '/^func.*'"$test"'\(/ { print; print "\tt.Skip(\"disabled failing test\")"; next}1' $(grep -rl $test)
done
%gocheck -t cmd -t daemon/graphdriver -d integration/network -t libnetwork -d pkg/archive
%endif
%endif

%files
%license LICENSE NOTICE
%doc docs AUTHORS CONTRIBUTING.md README.md ROADMAP.md SECURITY.md
%doc TESTING.md VENDORING.md api/README.md
%{_bindir}/*

%gopkgfiles

%changelog
* Sat May 06 2023 Sérgio M. Basto <sergio@serjux.com> - 23.0.5-1
- 23.0.5

* Sun Apr 23 2023 Sérgio M. Basto <sergio@serjux.com> - 23.0.4-1
- moby-23.0.4

* Sun Jan 01 2023 Sérgio M. Basto <sergio@serjux.com> 22.06.0~beta.0-6
- add 44707.patch

* Sun Jan 01 2023 Sérgio M. Basto <sergio@serjux.com> 22.06.0~beta.0-5
- Fix build for btrfs-progs-6.1

* Sun Oct 30 2022 Robert-André Mauchin <zebob.m@gmail.com> 22.06.0~beta.0-4
- Disable some flaky tests

* Thu Oct 27 2022 Robert-André Mauchin <zebob.m@gmail.com> 22.06.0~beta.0-3
- Fix patch

* Wed Oct 26 2022 Robert-André Mauchin <zebob.m@gmail.com> 22.06.0~beta.0-2
- Update to 22.06.0~beta.0

* Sat Oct 22 2022 Robert-André Mauchin <zebob.m@gmail.com> 22.06.0~beta.0-1
- Update to 22.06.0~beta.0

* Wed Aug 10 2022 Maxwell G <gotmax@e.email> 20.10.12-4
- Rebuild to fix FTBFS

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> 20.10.12-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> 20.10.12-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Mon Dec 20 2021 Maxwell G <gotmax@e.email> 20.10.12-1
- Update to 20.10.12

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 20.10.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Tue Apr 20 2021 Olivier Lemasle <o.lemasle@gmail.com> - 20.10.6-1
- Update to 20.10.6

* Sun Mar 07 2021 Olivier Lemasle <o.lemasle@gmail.com> - 20.10.5-1
- Update to 20.10.5

* Sun Jan 31 2021 Olivier Lemasle <o.lemasle@gmail.com> - 20.10.2-3
- Fix license (ASL 2.0 only)

* Fri Jan 29 2021 Olivier Lemasle <o.lemasle@gmail.com> - 20.10.2-2
- Unbootstrap

* Thu Jan 28 2021 Olivier Lemasle <o.lemasle@gmail.com> - 20.10.2-1
- Update to 20.10.2 - Bootstrap

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 19.03.13-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sun Aug 23 02:25:48 CEST 2020 Robert-André Mauchin <zebob.m@gmail.com> - 19.03.13-1
- Update to 19.03.13

* Sun Aug 23 02:25:48 CEST 2020 Robert-André Mauchin <zebob.m@gmail.com> - 19.03.12-3
- Fix FTBFS

* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 19.03.12-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Sat Jul 25 22:11:51 CEST 2020 Robert-André Mauchin <zebob.m@gmail.com> - 19.03.12-1
- Update to 19.03.12

* Wed Apr 01 2020 Olivier Lemasle <o.lemasle@gmail.com> - 19.03.5-4
- Unbootstrap

* Wed Apr 01 2020 Olivier Lemasle <o.lemasle@gmail.com> - 19.03.5-3
- Make it compatible with Go 1.14

* Wed Apr 01 2020 Olivier Lemasle <o.lemasle@gmail.com> - 19.03.5-2
- Bootstrap

* Thu Jan 30 00:42:22 CET 2020 Robert-André Mauchin <zebob.m@gmail.com> - 19.03.5-1
- Update to 19.03.5
- Patch test to work with Go 1.14

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 19.03.0-2.rc3.2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 19.03.0-2.rc3.1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Sat Jul 06 15:03:03 CEST 2019 Robert-André Mauchin <zebob.m@gmail.com> - 19.03.0-2.rc3
- Remove Windows only dependency

* Sat Jul 06 13:58:06 CEST 2019 Robert-André Mauchin <zebob.m@gmail.com> - 19.03.0-1.rc3
- Release 19.03.0-rc3

* Thu Jul 04 19:22:49 CEST 2019 Robert-André Mauchin <zebob.m@gmail.com> - 18.09.7-1
- Release 18.09.7

* Sat May 04 20:50:08 CEST 2019 Robert-André Mauchin <zebob.m@gmail.com> - 17.03.2-1.ce.20190504git619df5a
- Initial package