Blame SPECS/mongo-tools.spec

7fe184
%{?scl:%scl_package mongo-tools}
7fe184
7fe184
%global with_devel 1
7fe184
%global with_bundled 1
7fe184
%global with_debug 1
7fe184
%global with_check 1
7fe184
%global with_unit_test 1
7fe184
7fe184
%if 0%{?with_debug}
7fe184
# https://bugzilla.redhat.com/show_bug.cgi?id=995136#c12
7fe184
%global _dwz_low_mem_die_limit 0
7fe184
%else
7fe184
%global debug_package   %{nil}
7fe184
%endif
7fe184
7fe184
%global provider        github
7fe184
%global provider_tld    com
7fe184
%global project         mongodb
7fe184
%global repo            mongo-tools
7fe184
# https://github.com/mongodb/mongo-tools
7fe184
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
7fe184
%global import_path     %{provider_prefix}
7fe184
%global commit          2b10d8492e1185039be4d5f2242a5b11ea102303
7fe184
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
7fe184
7fe184
# Git hash in https://github.com/mongodb/mongo which corresponds to Version
7fe184
%global mongohash 9586e557d54ef70f9ca4b43c26892cd55257e1a5
7fe184
7fe184
%global gopath %{_datadir}/gocode
7fe184
7fe184
%global golangscl go-toolset-7
7fe184
%global golangprefix %{golangscl}-
7fe184
%global buildscls %{golangscl} %{?scl}
7fe184
7fe184
Name:           %{?scl_prefix}%{repo}
7fe184
Version:        3.6.3
7fe184
Release:        1%{?dist}
7fe184
Summary:        MongoDB Tools
7fe184
License:        ASL 2.0
7fe184
URL:            https://%{provider_prefix}
7fe184
Source0:	https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
7fe184
# Mongo-tools does not contain man files yet
7fe184
# - see https://groups.google.com/forum/#!topic/mongodb-dev/t6Sd2Bki12I
7fe184
Source1:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/bsondump.1
7fe184
Source2:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongodump.1
7fe184
Source3:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongoexport.1
7fe184
Source4:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongofiles.1
7fe184
Source5:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongoimport.1
7fe184
Source6:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongooplog.1
7fe184
Source7:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongorestore.1
7fe184
Source8:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongostat.1
7fe184
Source9:        https://github.com/mongodb/mongo/raw/%{mongohash}/debian/mongotop.1
7fe184
Source10:       https://github.com/mongodb/mongo/raw/%{mongohash}/APACHE-2.0.txt
7fe184
7fe184
Patch0:         change-import-path.patch
7fe184
#Patch1:         use-dup3-on-linux.patch - fixed in 3.4.7
7fe184
7fe184
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
7fe184
ExclusiveArch:  %{ix86} x86_64 %{arm} aarch64 ppc64le s390x
7fe184
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
7fe184
BuildRequires:  %{?golangprefix}golang
7fe184
7fe184
BuildRequires:  openssl-devel
7fe184
BuildRequires:  libpcap-devel
7fe184
7fe184
%if ! 0%{?with_bundled}
7fe184
BuildRequires:  %{?scl_prefix}golang(github.com/howeyc/gopass)
7fe184
BuildRequires:  %{?scl_prefix}golang(github.com/jessevdk/go-flags)
7fe184
BuildRequires:  %{?scl_prefix}golang(github.com/smartystreets/goconvey/convey)
7fe184
BuildRequires:  %{?scl_prefix}golang(github.com/10gen/openssl)
7fe184
BuildRequires:  %{?scl_prefix}golang(golang.org/x/crypto/ssh/terminal)
7fe184
BuildRequires:  %{?scl_prefix}golang(gopkg.in/mgo.v2)
7fe184
BuildRequires:  %{?scl_prefix}golang(gopkg.in/mgo.v2/bson)
7fe184
BuildRequires:  %{?scl_prefix}golang(gopkg.in/tomb.v2)
7fe184
%endif
7fe184
7fe184
%{?scl:Requires:%scl_runtime}
7fe184
7fe184
#Conflicts:      mongodb < 3.0.0
7fe184
7fe184
%description
7fe184
The MongoDB tools provides import, export, and diagnostic capabilities.
7fe184
7fe184
%if 0%{?with_devel}
7fe184
%package devel
7fe184
Summary:       %{summary}
7fe184
BuildArch:     noarch
7fe184
7fe184
%if ! 0%{?with_bundled}
7fe184
%if 0%{?with_check}
7fe184
BuildRequires: %{?scl_prefix}golang(github.com/howeyc/gopass)
7fe184
BuildRequires: %{?scl_prefix}golang(github.com/jessevdk/go-flags)
7fe184
BuildRequires: %{?scl_prefix}golang(github.com/smartystreets/goconvey/convey)
7fe184
BuildRequires: %{?scl_prefix}golang(github.com/10gen/openssl)
7fe184
BuildRequires: %{?scl_prefix}golang(golang.org/x/crypto/ssh/terminal)
7fe184
BuildRequires: %{?scl_prefix}golang(gopkg.in/mgo.v2)
7fe184
BuildRequires: %{?scl_prefix}golang(gopkg.in/mgo.v2/bson)
7fe184
BuildRequires: %{?scl_prefix}golang(gopkg.in/tomb.v2)
7fe184
%endif
7fe184
7fe184
Requires:      %{?scl_prefix}golang(github.com/howeyc/gopass)
7fe184
Requires:      %{?scl_prefix}golang(github.com/jessevdk/go-flags)
7fe184
Requires:      %{?scl_prefix}golang(github.com/smartystreets/goconvey/convey)
7fe184
Requires:      %{?scl_prefix}golang(github.com/10gen/openssl)
7fe184
Requires:      %{?scl_prefix}golang(golang.org/x/crypto/ssh/terminal)
7fe184
Requires:      %{?scl_prefix}golang(gopkg.in/mgo.v2)
7fe184
Requires:      %{?scl_prefix}golang(gopkg.in/mgo.v2/bson)
7fe184
Requires:      %{?scl_prefix}golang(gopkg.in/tomb.v2)
7fe184
%endif
7fe184
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/bsondump) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/archive) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/auth) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/bsonutil) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/db) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/db/kerberos) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/db/openssl) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/failpoint) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/intents) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/json) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/log) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/options) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/password) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/progress) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/signals) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/testutil) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/text) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/common/util) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongodump) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongoexport) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongofiles) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongoimport) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongoimport/csv) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongorestore) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongostat) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongotop) = %{version}-%{release}
7fe184
Provides:      %{?scl_prefix}golang(%{import_path}/mongoreplay) = %{version}-%{release}
7fe184
7fe184
%{?scl:Requires:%scl_runtime}
7fe184
7fe184
%description devel
7fe184
This package contains library source intended for
7fe184
building other packages which use %{project}/%{repo}.
7fe184
%endif
7fe184
7fe184
%if 0%{?with_unit_test} && 0%{?with_devel}
7fe184
%package unit-test
7fe184
Summary:         Unit tests for %{name} package
7fe184
BuildRequires:  %{?golangprefix}golang
7fe184
7fe184
%if 0%{?with_check}
7fe184
#Here comes all BuildRequires: PACKAGE the unit tests
7fe184
#in %%check section need for running
7fe184
%endif
7fe184
7fe184
# test subpackage tests code from devel subpackage
7fe184
Requires:        %{name}-devel = %{version}-%{release}
7fe184
7fe184
%description unit-test
7fe184
%{summary}
7fe184
7fe184
This package contains unit tests for project
7fe184
providing packages with %{import_path} prefix.
7fe184
%endif
7fe184
7fe184
# syspath subpackages
7fe184
%if 0%{?scl:1}
7fe184
%scl_syspaths_package -d
7fe184
%endif
7fe184
7fe184
%prep
7fe184
%setup -q -n %{repo}-%{commit}
7fe184
%if ! 0%{?with_bundled}
7fe184
%patch0 -p1
7fe184
%endif
7fe184
7fe184
%build
7fe184
%{?scl:scl enable %{buildscls} - << "SCLEOF"}
7fe184
set -ex
7fe184
# Make link for etcd itself
7fe184
mkdir -p src/github.com/mongodb
7fe184
ln -s ../../../  src/github.com/mongodb/mongo-tools
7fe184
7fe184
%if 0%{?with_bundled}
7fe184
export GOPATH=$(pwd):$(pwd)/vendor:%{gopath}
7fe184
%else
7fe184
export GOPATH=$(pwd):%{gopath}
7fe184
%endif
7fe184
7fe184
%if ! 0%{?gobuild:1}
7fe184
%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; 
7fe184
%endif
7fe184
7fe184
mkdir bin
7fe184
binaries=(bsondump mongodump mongoexport mongofiles mongoimport mongoreplay mongorestore mongostat mongotop )
7fe184
for bin in "${binaries[@]}"; do
7fe184
  %gobuild -o bin/${bin} \-tags ssl ${bin}/main/${bin}.go
7fe184
done
7fe184
7fe184
# Copy Apache license
7fe184
cp %{SOURCE10} $(basename %{SOURCE10})
7fe184
7fe184
%{?scl:SCLEOF}
7fe184
%install
7fe184
%{?scl:scl enable %{buildscls} - << "SCLEOF"}
7fe184
set -ex
7fe184
# main package binary
7fe184
install -d -p %{buildroot}%{_bindir}
7fe184
install -p -m 0755 bin/* %{buildroot}%{_bindir}
7fe184
7fe184
install -d -m 755            %{buildroot}%{_mandir}/man1
7fe184
install -p -m 644 %{SOURCE1} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE2} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE3} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE4} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE5} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE6} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE7} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE8} %{buildroot}%{_mandir}/man1/
7fe184
install -p -m 644 %{SOURCE9} %{buildroot}%{_mandir}/man1/
7fe184
7fe184
%if 0%{?with_devel}
7fe184
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
7fe184
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
7fe184
# find all *.go but no *_test.go files and generate devel.file-list
7fe184
for file in $(find . -iname "*.go" \! -iname "*_test.go") ; do
7fe184
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
7fe184
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
7fe184
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
7fe184
done
7fe184
%endif
7fe184
7fe184
# testing files for this project
7fe184
%if 0%{?with_unit_test} && 0%{?with_devel}
7fe184
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
7fe184
# find all *_test.go files and generate unit-test.file-list
7fe184
for file in $(find . -iname "*_test.go"); do
7fe184
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file)
7fe184
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
7fe184
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list
7fe184
done
7fe184
cp -r mongorestore/testdata %{buildroot}/%{gopath}/src/%{import_path}/mongorestore/testdata
7fe184
echo "%%{gopath}/src/%%{import_path}/mongorestore/testdata" >> unit-test.file-list
7fe184
cp -r mongostat/test_data %{buildroot}/%{gopath}/src/%{import_path}/mongostat/test_data
7fe184
echo "%%{gopath}/src/%%{import_path}/mongostat/test_data" >> unit-test.file-list
7fe184
%endif
7fe184
7fe184
%if 0%{?with_devel}
7fe184
olddir=$(pwd)
7fe184
pushd %{buildroot}/%{gopath}/src/%{import_path}
7fe184
for file in $(find . -type d) ; do
7fe184
    echo "%%dir %%{gopath}/src/%%{import_path}/$file" >> ${olddir}/devel.file-list
7fe184
done
7fe184
popd
7fe184
echo "%%dir %%{gopath}/src/%{provider}.%{provider_tld}/%{project}" >> devel.file-list
7fe184
echo "%%dir %%{gopath}/src/%{provider}.%{provider_tld}" >> devel.file-list
7fe184
7fe184
sort -u -o devel.file-list devel.file-list
7fe184
%endif
7fe184
7fe184
# syspath subpackages
7fe184
%if 0%{?scl:1}
7fe184
binaries='bsondump mongostat mongofiles mongoexport mongoimport mongorestore mongodump mongotop mongooplog'
7fe184
binaries_no_man='mongoreplay'
7fe184
mans= ; for bin in $binaries; do mans+="${sep}man1/$bin.1.gz" ; sep=' '; done
7fe184
%scl_syspaths_install_wrappers -n %{pkg_name} -m script -p bin $binaries
7fe184
%scl_syspaths_install_wrappers -n %{pkg_name} -m link -p man $mans
7fe184
%scl_syspaths_install_wrappers -n %{pkg_name} -m script -p bin $binaries_no_man
7fe184
%endif
7fe184
%{?scl:SCLEOF}
7fe184
7fe184
%check
7fe184
%{?scl:scl enable %{buildscls} - << "SCLEOF"}
7fe184
set -ex
7fe184
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
7fe184
%if ! 0%{?with_bundled}
7fe184
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
7fe184
%else
7fe184
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
7fe184
%endif
7fe184
7fe184
%if ! 0%{?gotest:1}
7fe184
%global gotest go test
7fe184
%endif
7fe184
7fe184
%gotest %{import_path}/common/bsonutil
7fe184
# import cycle not allowed in test
7fe184
#gotest %{import_path}/common/db
7fe184
# upstream bug, removed field from Intents struct
7fe184
#%%gotest %{import_path}/common/intents
7fe184
# redeclaration of C
7fe184
#gotest {import_path}/common/json
7fe184
# import cycle not allowed in test
7fe184
#gotest {import_path}/common/log
7fe184
%gotest %{import_path}/common/progress
7fe184
%gotest %{import_path}/common/text
7fe184
#%gotest %{import_path}/common/util
7fe184
%gotest %{import_path}/mongodump
7fe184
%gotest %{import_path}/mongoexport
7fe184
%gotest %{import_path}/mongofiles
7fe184
#gotest {import_path}/mongoimport
7fe184
%gotest %{import_path}/mongorestore
7fe184
%gotest %{import_path}/mongostat
7fe184
#%gotest %{import_path}/mongoreplay
7fe184
%endif
7fe184
%{?scl:SCLEOF}
7fe184
7fe184
#define license tag if not already defined
7fe184
%{!?_licensedir:%global license %doc}
7fe184
7fe184
%files
7fe184
%license LICENSE.md APACHE-2.0.txt
7fe184
%doc Godeps README.md CONTRIBUTING.md THIRD-PARTY-NOTICES
7fe184
%{_bindir}/*
7fe184
%{_mandir}/man1/*
7fe184
7fe184
%if 0%{?with_devel}
7fe184
%files devel -f devel.file-list
7fe184
%license LICENSE.md
7fe184
%doc Godeps README.md CONTRIBUTING.md THIRD-PARTY-NOTICES
7fe184
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
7fe184
%endif
7fe184
7fe184
%if 0%{?with_unit_test} && 0%{?with_devel}
7fe184
%files unit-test -f unit-test.file-list
7fe184
%license LICENSE.md
7fe184
%doc Godeps README.md CONTRIBUTING.md THIRD-PARTY-NOTICES
7fe184
%endif
7fe184
7fe184
# syspath subpackages
7fe184
%if 0%{?scl:1}
7fe184
%scl_syspaths_files
7fe184
%endif
7fe184
7fe184
%changelog
7fe184
* Wed Feb 28 2018 Marek Skalický <mskalick@redhat.com> - 3.6.3-1
7fe184
- Rebase to latest upstream release
7fe184
7fe184
* Mon Aug 28 2017 Marek Skalický <mskalick@redhat.com> - 3.4.7-1
7fe184
- Update to latest minor release
7fe184
7fe184
* Mon Jul 24 2017 Marek Skalický <mskalick@redhat.com> - 3.4.6-0.1.git29b8883
7fe184
- Update to latest minor version 3.4.6
7fe184
  Resolves: RHBZ#1474253
7fe184
7fe184
* Mon Jul 03 2017 Marek Skalický <mskalick@redhat.com> - 3.4.5-0.5.git4d4d965
7fe184
- Use go-toolset-7 for building
7fe184
7fe184
* Mon Jun 26 2017 Marek Skalický <mskalick@redhat.com> - 3.4.5-0.4.git4d4d965
7fe184
- Use golang from rh-mongodb32 for building
7fe184
7fe184
* Fri Jun 23 2017 Marek Skalický <mskalick@redhat.com> - 3.4.5-0.3.git4d4d965
7fe184
- Add -syspath subpackage
7fe184
7fe184
* Thu Jun 22 2017 Marek Skalický <mskalick@redhat.com> - 3.4.5-0.2.git4d4d965
7fe184
- Build also mongoreplay
7fe184
- patch vendored dependency github.com/spacemonkeygo/spacelog to use syscall.Dup3
7fe184
7fe184
* Thu Jun 22 2017 Marek Skalický <mskalick@redhat.com> - 3.4.5-0.1.git4d4d965
7fe184
- Update to 3.4.5
7fe184
7fe184
* Wed Jun 21 2017 Marek Skalický <mskalick@redhat.com> - 3.2.1-0.7.git17a5573
7fe184
- Use bundled dependencies
7fe184
- Use go-toolset-7 for building
7fe184
7fe184
* Tue Sep 27 2016 Marek Skalický <mskalick@redhat.com> - 3.2.1-0.6.git17a5573
7fe184
- Fix dependency on -runtime
7fe184
   Resolves: RHBZ#1379295
7fe184
7fe184
* Wed Jul 27 2016 Marek Skalický <mskalick@redhat.com> - 3.2.1-0.5.git17a5573
7fe184
- Rebuild for new golang version
7fe184
7fe184
* Fri Jul 22 2016 Marek Skalický <mskalick@redhat.com> - 3.2.1-0.4.git17a5573
7fe184
- Use golang from SCL
7fe184
7fe184
* Fri Feb 12 2016 Marek Skalicky <mskalick@redhat.com> - 3.1.1-0.3.git17a5573
7fe184
- Removed conflict with old versions of mongodb
7fe184
7fe184
* Wed Feb 3 2016 Marek Skalicky <mskalick@redhat.com> - 3.1.1-0.2.git17a5573
7fe184
- Fixed directory ownership
7fe184
7fe184
* Wed Jan 27 2016 jchaloup <jchaloup@redhat.com> - 3.1.1-0.1.git17a5573
7fe184
- Update to 3.2.1
7fe184
  resolves: #1282650
7fe184
7fe184
* Mon Nov 09 2015 jchaloup <jchaloup@redhat.com> - 3.0.4-0.2.gitefe71bf
7fe184
- Update to spec-2.1
7fe184
  resolves: #1279140
7fe184
7fe184
* Mon Jun 22 2015 Marek Skalicky <mskalick@redhat.com> - 3.0.4-1
7fe184
- Repacked by using gofed tool (thanks to jchaloup@redhat.com)
7fe184
7fe184
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 3.0.3-2
7fe184
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
7fe184
7fe184
* Mon May 11 2015 Marek Skalicky <mskalick@redhat.com> - 3.0.3-1
7fe184
- Upgrade to version 3.0.3
7fe184
- Add Apache license
7fe184
7fe184
* Mon May 4 2015 Marek Skalicky <mskalick@redhat.com> - 3.0.2-1
7fe184
- Initial packaging