Hadoop RPM Spec file

This spec file was done to create a simple RPM package that could be installed on CentOS 6.


 

%global hadoop_uid 560
%global hadoop_user hadoop
%global hadoop_gid 560
%global hadoop_group hadoop
%global _prefix /opt
%global _tmppath /tmp

%define __os_install_post /usr/lib/rpm/redhat/brp-compress %{!?__debug_package:/usr/lib/rpm/redhat/brp-strip %{__strip}} /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} /usr/lib/rpm/brp-python-bytecompile /usr/lib/rpm/redhat/brp-python-hardlink %{nil}

 

Summary: Apache Hadoop
Name: hadoop
Version: 2.2.0
Release: 1%{?dist}
License: ASL 2.0
Vendor: None
Packager: Martin Charette <iam@cinq.com>
Group: System Environment/Daemons
Summary: Hadoop is a distributed data computing platform
URL: http://hadoop.apache.org/
Source0: http://mirror.its.dal.ca/apache/hadoop/common/stable/%{name}-%{version}.tar.gz
#Source0: http://www.us.apache.org/dist/hadoop/common/stable/%{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
Requires: sh-utils, /usr/sbin/useradd, /usr/sbin/usermod
AutoReqProv: no
Provides: hadoop
%define homedir %{_prefix}/%{name}
%define libdir %{homedir}/lib
%define confdir %{homedir}/etc/hadoop
%description
The Apache™ Hadoop® project develops open-source software for reliable, scalable, distributed computing.

The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage. Rather than rely on hardware to deliver high-availability, the library itself is designed to detect and handle failures at the application layer, so delivering a highly-available service on top of a cluster of computers, each of which may be prone to failures.
%prep

#This command changes to the build directory, typically /usr/src/redhat/BUILD, and then extracts the source files.
#The -n is used if the top-level directory did not match the package name

%setup -q -n %{name}-%{version}

%build

%install
rm -rf %{buildroot}
%{__install} –directory %{buildroot}
%{__install} –directory %{buildroot}%{libdir}
%{__install} –directory %{buildroot}%{homedir}/bin
%{__install} –directory %{buildroot}%{homedir}/sbin
%{__install} –directory %{buildroot}%{homedir}/libexec
%{__install} –directory %{buildroot}%{confdir}
%{__install} –directory %{buildroot}%{homedir}/include
%{__install} –directory %{buildroot}%{homedir}/share
# Copy all files
cp *.txt %{buildroot}%{homedir}
cp -r lib/* %{buildroot}%{libdir}
cp -r bin/* %{buildroot}%{homedir}/bin
cp -r sbin/* %{buildroot}%{homedir}/sbin
cp -r libexec/* %{buildroot}%{homedir}/libexec
cp -r etc/hadoop/* %{buildroot}%{confdir}
cp -r include/* %{buildroot}%{homedir}/include
cp -r share/* %{buildroot}%{homedir}/share
%pre
# create hadoop group
if ! getent group %{hadoop_group} >/dev/null; then
groupadd -g %{hadoop_gid} -r %{hadoop_group}
fi

# create hadoop user
if ! getent passwd %{hadoop_user} >/dev/null; then
useradd -d %{homedir} -s /bin/bash -c “Apache Hadoop” -g %{hadoop_group} -m -r -u %{hadoop_uid} %{hadoop_user}
fi
%post
%preun
%postun

%clean
rm -rf $RPM_BUILD_ROOT

 

%files
%defattr(-,%{hadoop_user},%{hadoop_group})
%{homedir}
#%docdir %{docsdir}
#%{docsdir}
#%{libdir}
#%{confdir}
#%attr(775,%{hadoop_user},%{hadoop_group}) %dir %{_localstatedir}/log/%{name}
#%attr(775,%{hadoop_user},%{hadoop_group}) %dir %{_localstatedir}/run/%{name}
#%config(noreplace) %{confdir}/*.xml
%changelog
* Tue Jun 17 2014 Martin Charette <iam@cinq.com> – 2.2.0-1
– Creation of Hadoop 2.2.0 x86_64 RPM

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s