File mongodb.spec of Package mongodb
%define bname mongodb
Name: %bname
%define dname mongod
%define sname mongos
Version: 2.6.12
Release: 2
Summary: High-performance, schema-free document-oriented database system
Group: Productivity/Databases/Servers
License: AGPL-3.0 and Apache-2.0
# util/md5 is under the zlib license
# manpages and bson are under Apache-2.0
# everything else is AGPL-3.0
URL: http://www.%bname.org
Source00: http://fastdl.%bname.org/src/%bname-src-r%version.tar.gz
Source01: %name-tmpfile
Source02: %dname.logrotate
Source03: %dname.conf
Source04: %sname.sysconf
Source05: %dname.service
Source06: %dname.sysconf
Source07: %sname.conf
Source08: %sname.service
Source09: %name-rpmlintrc
Source10: README.test
Patch0: %name-%version-git.patch
Patch1: 0001-post-2.6.12.patch
Patch2: %name-2.6.7-swap.patch
Requires: %dname = %version-%release
Requires: %sname = %version-%release
Requires: %name-shell = %version-%release
Requires: %name-tools = %version-%release
%ifarch %arm
BuildRequires: gcc-c++ >= 4.7
%else
BuildRequires: gcc-c++
%endif
BuildRequires: scons pkgconfig
%if 0%{?fedora_version}
BuildRequires: v8-devel >= 1:3.12
BuildConflicts: v8-devel >= 1:4
%else
BuildRequires: libv8-devel >= 3.12
BuildConflicts: v8-devel >= 4
%endif
BuildRequires: pkgconfig(libpcre) pkgconfig(yaml-cpp)
BuildRequires: boost-devel >= 1.44
# Provides tcmalloc
BuildRequires: gperftools-devel
BuildRequires: libstemmer-devel snappy-devel
BuildRequires: openssl-devel libpcap-devel
BuildRequires: python-pymongo
%define _homedir %_localstatedir/lib/%bname
%define _user %bname
%define _group %bname
%def_disable lto
#if_enabled lto
%define _smp_ncpus_max 2
%if 0%(echo "%{?_smp_mflags}" | sed 's/^-j//') > %_smp_ncpus_max
%define _smp_mflags -j%_smp_ncpus_max
%endif
#endif
%description
MongoDB is built for scalability, performance and high availability, scaling from
single server deployments to large, complex multi-site architectures.
By leveraging in-memory computing, MongoDB provides high performance for both
reads and writes. MongoDB’s native replication and automated failover enable
enterprise-grade reliability and operational flexibility.
MongoDB is an open-source database used by companies of all sizes, across all
industries and for a wide variety of applications. It is an agile database that
allows schemas to change quickly as applications evolve, while still providing
the functionality developers expect from traditional databases, such as secondary
indexes, a full query language and strict consistency.
MongoDB has a rich client ecosystem including hadoop integration, officially
supported drivers for 10 programming languages and environments, as well as 40
drivers supported by the user community.
MongoDB features:
- JSON Data Model with Dynamic Schemas
- Auto-Sharding for Horizontal Scalability
- Built-In Replication for High Availability
- Rich Secondary Indexes, including geospatial
- TTL indexes
- Text Search
- Aggregation Framework & Native MapReduce
This metapackage will install the mongo shell, import/export tools, other client
utilities, server software, default configuration, and init scripts.
%package server
Summary: MongoDB database server
Group: Productivity/Databases/Servers
Provides: %dname = %version-%release
Requires: logrotate
Requires(pre): shadow
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%description server
MongoDB is built for scalability, performance and high availability, scaling from
single server deployments to large, complex multi-site architectures.
By leveraging in-memory computing, MongoDB provides high performance for both
reads and writes. MongoDB’s native replication and automated failover enable
enterprise-grade reliability and operational flexibility.
MongoDB is an open-source database used by companies of all sizes, across all
industries and for a wide variety of applications. It is an agile database that
allows schemas to change quickly as applications evolve, while still providing
the functionality developers expect from traditional databases, such as secondary
indexes, a full query language and strict consistency.
MongoDB has a rich client ecosystem including hadoop integration, officially
supported drivers for 10 programming languages and environments, as well as 40
drivers supported by the user community.
MongoDB features:
- JSON Data Model with Dynamic Schemas
- Auto-Sharding for Horizontal Scalability
- Built-In Replication for High Availability
- Rich Secondary Indexes, including geospatial
- TTL indexes
- Text Search
- Aggregation Framework & Native MapReduce
This package contains the MongoDB server software, default configuration files,
and init scripts.
%package -n %sname
Summary: MongoDB sharded cluster query router
Group: Productivity/Databases/Servers
Requires(pre): shadow
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%description -n %sname
MongoDB is built for scalability, performance and high availability, scaling from
single server deployments to large, complex multi-site architectures.
By leveraging in-memory computing, MongoDB provides high performance for both
reads and writes. MongoDB’s native replication and automated failover enable
enterprise-grade reliability and operational flexibility.
MongoDB is an open-source database used by companies of all sizes, across all
industries and for a wide variety of applications. It is an agile database that
allows schemas to change quickly as applications evolve, while still providing
the functionality developers expect from traditional databases, such as secondary
indexes, a full query language and strict consistency.
MongoDB has a rich client ecosystem including hadoop integration, officially
supported drivers for 10 programming languages and environments, as well as 40
drivers supported by the user community.
MongoDB features:
- JSON Data Model with Dynamic Schemas
- Auto-Sharding for Horizontal Scalability
- Built-In Replication for High Availability
- Rich Secondary Indexes, including geospatial
- TTL indexes
- Text Search
- Aggregation Framework & Native MapReduce
This package contains mongos, the MongoDB sharded cluster query router.
%package shell
Summary: MongoDB Shell
Group: Productivity/Databases/Servers
Provides: mongo = %version-%release
%description shell
mongo is an interactive JavaScript shell interface to MongoDB, which provides a
powerful interface for systems administrators as well as a way for developers to
test queries and operations directly with the database. mongo also provides a
fully functional JavaScript environment for use with a MongoDB.
%package tools
Summary: MongoDB tools
Group: Productivity/Databases/Servers
Requires(pre): shadow
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%description tools
MongoDB is built for scalability, performance and high availability, scaling from
single server deployments to large, complex multi-site architectures.
By leveraging in-memory computing, MongoDB provides high performance for both
reads and writes. MongoDB’s native replication and automated failover enable
enterprise-grade reliability and operational flexibility.
MongoDB is an open-source database used by companies of all sizes, across all
industries and for a wide variety of applications. It is an agile database that
allows schemas to change quickly as applications evolve, while still providing
the functionality developers expect from traditional databases, such as secondary
indexes, a full query language and strict consistency.
MongoDB has a rich client ecosystem including hadoop integration, officially
supported drivers for 10 programming languages and environments, as well as 40
drivers supported by the user community.
MongoDB features:
- JSON Data Model with Dynamic Schemas
- Auto-Sharding for Horizontal Scalability
- Built-In Replication for High Availability
- Rich Secondary Indexes, including geospatial
- TTL indexes
- Text Search
- Aggregation Framework & Native MapReduce
This package contains standard utilities for interacting with MongoDB.
%package test
Summary: MongoDB test suite
Group: Productivity/Databases/Servers
Requires: %name = %version-%release
Requires: %name-server = %version-%release
Requires: python-pymongo
%description test
This package contains the regression test suite distributed with the MongoDB
sources.
%prep
%setup -q -n %bname-src-r%version
%patch0 -p1
%patch1 -p1 -R
%patch2 -p1
sed -i 's/\r$//' README jstests/{core/useindexonobjgtlt,dur/{a_quick,dur1{,_tool},oplog}}.js
chmod 0644 jstests/*/*.js
# Fixed in upstream - version 2.7.3
sed -i '/conf\.FindSysLibDep/s/\["yaml"\]/["yaml-cpp"]/' SConstruct
# Use optflags and __global_ldflags, disable -fPIC
sed -i -r \
-e '/LINKFLAGS=\[/s/"-fPIC",/"-Wl,--no-keep-memory", "-Wl,--reduce-memory-overheads",/' \
-e '/CCFLAGS=\[/s/"-fPIC"/"'"$(echo "%optflags" | sed -r 's/[[:blank:]]+/", "/g')"'"/' \
SConstruct
# disable propagation of $TERM env var into the Scons build system
sed -i "/for key in/s/,[[:blank:]]*'TERM'//" SConstruct
# disable run test and perftest programs
sed -i -r "s/^([[:space:]]*)((|el)if suite == '(test|perf)':)/&\n\1 continue/" buildscripts/smoke.py
# by default use system mongod, mongos and mongo binaries
sed -i -e "/default=os\.path\.join(\|os\.path\.join(mongo_repo, program)/s|mongo_repo|'%_bindir'|" buildscripts/smoke.py
# set default data prefix
sed -i -r -e "s/(smoke_db_prefix = ')'/\1var'/" \
-e "s|^([[:blank:]]*)(set_globals\(options, tests\))$|\1\2\n\1global failfile\n\1failfile = os.path.join\(os.path.join\(mongo_repo, smoke_db_prefix\), 'failfile.smoke'\)|" \
buildscripts/smoke.py
sed -i "/LINKFLAGS=/s/-flto/&%{?_smp_ncpus_max:=%_smp_ncpus_max} -fwhole-program/" SConstruct
%build
# see add_option() calls in SConstruct for options
scons \
%{?_smp_mflags} \
--prefix=%buildroot%_prefix \
--variant-dir=build \
%if %(rpm -q --qf '%%{version}' boost-devel | cut -d. -f2) <= 57
--use-system-boost \
%endif
--use-system-stemmer \
--use-system-tcmalloc \
--use-system-pcre \
%if %(rpm -q --qf '%%{version}' snappy-devel | grep -q '^1\.1\.[012]' && echo 1 || echo 0)
--use-system-snappy \
%endif
%if "%(pkg-config --modversion yaml-cpp)" == "0.5.1"
--use-system-yaml \
%endif
--use-system-v8 \
--nostrip \
--ssl \
%{?_enable_lto:--lto} \
--disable-warnings-as-errors \
all
%install
# NOTE: If install flags are not EXACTLY the same as in %%build,
# mongodb will be built twice!
scons \
%{?_smp_mflags} \
--prefix=%buildroot%_prefix \
--variant-dir=build \
%if %(rpm -q --qf '%%{version}' boost-devel | cut -d. -f2) <= 57
--use-system-boost \
%endif
--use-system-stemmer \
--use-system-tcmalloc \
--use-system-pcre \
%if %(rpm -q --qf '%%{version}' snappy-devel | grep -q '^1\.1\.[012]' && echo 1 || echo 0)
--use-system-snappy \
%endif
%if "%(pkg-config --modversion yaml-cpp)" == "0.5.1"
--use-system-yaml \
%endif
--use-system-v8 \
--nostrip \
--ssl \
%{?_enable_lto:--lto} \
--disable-warnings-as-errors \
install
install -d -m 0755 %buildroot%_localstatedir/log/%name
install -pD -m 0644 %{S:1} %buildroot%_tmpfilesdir/%name.conf
install -pD -m 0644 %{S:2} %buildroot%_sysconfdir/logrotate.d/%dname
install -pD -m 0644 %{S:4} %buildroot%_sysconfdir/sysconfig/%sname
install -p -m 0644 %{S:6} %buildroot%_sysconfdir/sysconfig/%dname
install -p -m 0644 %{S:3} %buildroot%_sysconfdir/%dname.conf
install -p -m 0644 %{S:7} %buildroot%_sysconfdir/%sname.conf
install -pD -m 0644 %{S:5} %buildroot%_unitdir/%dname.service
install -p -m 0644 %{S:8} %buildroot%_unitdir/%sname.service
install -d -m 0755 %buildroot%_sbindir
mv %buildroot%_bindir/{%dname,%sname} %buildroot%_sbindir/
ln -sf service %buildroot%_sbindir/rc%dname
ln -sf service %buildroot%_sbindir/rc%sname
install -d -m 0755 %buildroot%_mandir/man1
install -p -m 0644 debian/*.1 %buildroot%_mandir/man1/
install -d -m 0755 %buildroot%_datadir/%name-test/var
install -p -m 0555 buildscripts/smoke.py %buildroot%_datadir/%name-test/
install -p -m 0444 buildscripts/{cleanbb,utils}.py %buildroot%_datadir/%name-test/
cp -a jstests %buildroot%_datadir/%name-test/
install -p -m 0644 %{S:10} %buildroot%_datadir/%name-test/README
%ifnarch %ix86
%check
# More info about testing:
# http://www.mongodb.org/about/contributors/tutorial/test-the-mongodb-server/
# Run new-style unit tests (*_test files)
while read i; do
./$i || exit 1
done < ./build/unittests.txt
%if 0
# Run JavaScript integration tests
install -d -m 0755 ./var
buildscripts/smoke.py --smoke-db-prefix ./var --continue-on-failure --mongo=%buildroot%_bindir/mongo --mongod=%buildroot%_sbindir/%dname --nopreallocj jsCore
rm -rf ./var
%endif
%endif
%pre server
groupadd -r %_group >/dev/null 2>&1 ||:
useradd -r -g %_group -c "MongoDB database admin" -s /bin/false -d %_homedir %_user 2>/dev/null ||:
usermod -g %_group -s /bin/false %_user ||:
%service_add_pre %dname.service
%post server
%service_add_post %dname.service
%preun server
%service_del_preun %dname.service
%postun server
%service_del_postun %dname.service
%pre -n %sname
groupadd -r %_group >/dev/null 2>&1 ||:
useradd -r -g %_group -c "MongoDB database admin" -s /bin/false -d %_homedir %_user 2>/dev/null ||:
usermod -g %_group -s /bin/false %_user ||:
%service_add_pre %sname.service
%post -n %sname
%service_add_post %sname.service
%preun -n %sname
%service_del_preun %sname.service
%postun -n %sname
%service_del_postun %sname.service
%files
%defattr(-,root,root)
%files server
%defattr(-,root,root)
%dir %attr(0750, %name, root) %_localstatedir/log/*
%config(noreplace) %_sysconfdir/logrotate.d/%dname
%config(noreplace) %_sysconfdir/%dname.conf
%config(noreplace) %_sysconfdir/sysconfig/%dname
%_sbindir/%dname
%_mandir/man1/%dname.*
%_tmpfilesdir/*
%_unitdir/%dname.*
%_sbindir/rc%dname
%files -n %sname
%defattr(-,root,root)
%config(noreplace) %_sysconfdir/%sname.conf
%config(noreplace) %_sysconfdir/sysconfig/%sname
%_sbindir/%sname
%_mandir/man1/%sname.*
%_unitdir/%sname.*
%_sbindir/rc%sname
%files shell
%defattr(-,root,root)
%_bindir/mongo
%_mandir/man1/mongo.*
%files tools
%defattr(-,root,root)
%_bindir/*
%_mandir/man1/*
%exclude %_bindir/mongo
%exclude %_mandir/man1/mongo.*
%exclude %_mandir/man1/%dname.*
%exclude %_mandir/man1/%sname.*
%files test
%defattr(-,root,root)
%doc %_datadir/%name-test/README
%dir %attr(0755, %name, root) %_datadir/%name-test
%dir %attr(0755, %name, root) %_datadir/%name-test/jstests
%_datadir/%name-test/*.py*
%_datadir/%name-test/jstests/*
%changelog