Blame SPECS/mongo-tools.spec

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